Skip to content

Commit

Permalink
Add protocol dto classes #5
Browse files Browse the repository at this point in the history
- schema POC
  • Loading branch information
Kindrat committed Nov 15, 2015
1 parent 6ec8056 commit caec6c3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.nginate.kafka.protocol.messages.request;

import com.github.nginate.kafka.protocol.messages.Request;
import com.github.nginate.kafka.protocol.types.Type;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static com.github.nginate.kafka.protocol.types.TypeName.STRING;

@Data
@EqualsAndHashCode(callSuper = true)
public class TopicMetadataRequest extends Request {
/**
* The topics to produce metadata for. If empty the request will yield metadata for all topics.
*/
@Type(STRING)
private String[] topic;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.github.nginate.kafka.protocol.messages.response;

import com.github.nginate.kafka.protocol.messages.Response;
import com.github.nginate.kafka.protocol.types.Type;
import lombok.Data;
import lombok.EqualsAndHashCode;

import static com.github.nginate.kafka.protocol.types.TypeName.*;

@Data
@EqualsAndHashCode(callSuper = true)
public class MetadataResponse extends Response {
@Type(WRAPPER)
private Broker[] brokers;
@Type(WRAPPER)
private TopicMetadata[] topicMetadata;

@Data
public static class Broker {
@Type(INT32)
private int nodeId;
@Type(STRING)
private String host;
@Type(INT32)
private int port;
}

@Data
public static class TopicMetadata {
@Type(INT16)
private int topicErrorCode;
@Type(STRING)
private String topicName;
@Type(WRAPPER)
private PartitionMetadata[] partitionMetadata;

@Data
public static class PartitionMetadata {
@Type(INT16)
private int partitionErrorCode;
@Type(INT32)
private int partitionId;
/**
* The node id for the kafka broker currently acting as leader for this partition. If no leader exists
* because we are in the middle of a leader election this id will be -1.
*/
@Type(INT32)
private int leader;
/**
* The set of alive nodes that currently acts as slaves for the leader for this partition.
*/
@Type(INT32)
private int[] replicas;
/**
* The set subset of the replicas that are "caught up" to the leader
*/
@Type(INT32)
private int[] isr;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
@Documented
public @interface Type {
TypeName value();
boolean repeatable() default false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ public enum TypeName {
/**
* Consist of a signed int32 giving a length N followed by N bytes of content. A length of -1 indicates null.
*/
BYTES
BYTES,
/**
* Used to mark utility objects, wrapping actual binary data for protocol
*/
WRAPPER
}

0 comments on commit caec6c3

Please sign in to comment.