org.apache.kafka.common.protocol.types.Schema Java Examples
The following examples show how to use
org.apache.kafka.common.protocol.types.Schema.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestJGroupMetadataManager.java From kafka-eagle with Apache License 2.0 | 5 votes |
private static Schema schemaForOffsetValue(int version) { if (OFFSET_VALUE_SCHEMAS.containsKey(version)) { return OFFSET_VALUE_SCHEMAS.get(version); } else { LOG.error("Unknown offset schema version " + version); return null; } }
Example #2
Source File: KafkaOffsetGetter.java From Kafka-Insight with Apache License 2.0 | 5 votes |
/** Analysis of struct data structure in metadata in Kafka. */ private static MessageValueStructAndVersionInfo readMessageValueStruct(ByteBuffer buffer) { MessageValueStructAndVersionInfo mvs = new MessageValueStructAndVersionInfo(); if (buffer == null) { mvs.setValue(null); mvs.setVersion(Short.valueOf("-1")); } else { short version = buffer.getShort(); Schema valueSchema = schemaFor(version).getValueSchema(); Struct value = (Struct) valueSchema.read(buffer); mvs.setValue(value); mvs.setVersion(version); } return mvs; }
Example #3
Source File: KafkaOffsetGetter.java From Kafka-Insight with Apache License 2.0 | 5 votes |
/** Analysis of Kafka data in topic in buffer. */ private static GroupTopicPartition readMessageKey(ByteBuffer buffer) { short version = buffer.getShort(); Schema keySchema = schemaFor(version).getKeySchema(); Struct key = (Struct) keySchema.read(buffer); String group = key.getString(KEY_GROUP_FIELD); String topic = key.getString(KEY_TOPIC_FIELD); int partition = key.getInt(KEY_PARTITION_FIELD); return new GroupTopicPartition(group, new TopicPartition(topic, partition)); }
Example #4
Source File: TestKafkaOffsetGetter.java From kafka-eagle with Apache License 2.0 | 5 votes |
/** Analysis of struct data structure in metadata in Kafka. */ private static MessageValueStructAndVersionInfo readMessageValueStruct(ByteBuffer buffer) { MessageValueStructAndVersionInfo mvs = new MessageValueStructAndVersionInfo(); if (buffer == null) { mvs.setValue(null); mvs.setVersion(Short.valueOf("-1")); } else { short version = buffer.getShort(); Schema valueSchema = schemaFor(version).getValueSchema(); Struct value = (Struct) valueSchema.read(buffer); mvs.setValue(value); mvs.setVersion(version); } return mvs; }
Example #5
Source File: TestBrokerAdminClient.java From kafka-eagle with Apache License 2.0 | 5 votes |
/** Analysis of struct data structure in metadata in Kafka. */ private static MessageValueStructAndVersionInfo readMessageValueStruct(ByteBuffer buffer) { MessageValueStructAndVersionInfo mvs = new MessageValueStructAndVersionInfo(); if (buffer == null) { mvs.setValue(null); mvs.setVersion(Short.valueOf("-1")); } else { short version = buffer.getShort(); Schema valueSchema = schemaFor(version).getValueSchema(); Struct value = (Struct) valueSchema.read(buffer); mvs.setValue(value); mvs.setVersion(version); } return mvs; }
Example #6
Source File: TestJGroupMetadataManager.java From kafka-eagle with Apache License 2.0 | 5 votes |
private static Schema schemaForGroupValue(int version) { if (GROUP_VALUE_SCHEMAS.containsKey(version)) { return GROUP_VALUE_SCHEMAS.get(version); } else { LOG.error("Unknown group metadata version " + version); return null; } }
Example #7
Source File: GroupMetadataConstants.java From kop with Apache License 2.0 | 5 votes |
private static Schema schemaForKey(int version) { Schema schema = MESSAGE_TYPE_SCHEMAS.get(version); if (null == schema) { throw new KafkaException("Unknown offset schema version " + version); } return schema; }
Example #8
Source File: TestJGroupMetadataManager.java From kafka-eagle with Apache License 2.0 | 5 votes |
private static Schema schemaForKey(int version) { if (MESSAGE_TYPE_SCHEMAS.containsKey(version)) { return MESSAGE_TYPE_SCHEMAS.get(version); } else { LOG.error("Unknown message key schema version " + version); return null; } }
Example #9
Source File: GroupMetadataConstants.java From kop with Apache License 2.0 | 5 votes |
private static Schema schemaForGroup(int version) { Schema schema = GROUP_VALUE_SCHEMAS.get(version); if (null == schema) { throw new KafkaException("Unknown group metadata version " + version); } return schema; }
Example #10
Source File: GroupMetadataConstants.java From kop with Apache License 2.0 | 5 votes |
private static Schema schemaForOffset(int version) { Schema schema = OFFSET_VALUE_SCHEMAS.get(version); if (null == schema) { throw new KafkaException("Unknown offset schema version " + version); } return schema; }
Example #11
Source File: KeyAndValueSchemasInfo.java From kafka-eagle with Apache License 2.0 | 4 votes |
public void setValueSchema(Schema valueSchema) { this.valueSchema = valueSchema; }
Example #12
Source File: KeyAndValueSchemasInfo.java From kafka-eagle with Apache License 2.0 | 4 votes |
public Schema getValueSchema() { return valueSchema; }
Example #13
Source File: KeyAndValueSchemasInfo.java From kafka-eagle with Apache License 2.0 | 4 votes |
public void setKeySchema(Schema keySchema) { this.keySchema = keySchema; }
Example #14
Source File: KeyAndValueSchemasInfo.java From kafka-eagle with Apache License 2.0 | 4 votes |
public Schema getKeySchema() { return keySchema; }
Example #15
Source File: GroupMetadataConstants.java From kop with Apache License 2.0 | 4 votes |
static GroupMetadata readGroupMessageValue(String groupId, ByteBuffer buffer) { if (null == buffer) { // tombstone return null; } short version = buffer.getShort(); Schema valueSchema = schemaForGroup(version); Struct value = valueSchema.read(buffer); if (version == 0 || version == 1) { int generationId = value.getInt(GENERATION_KEY); String protocolType = value.getString(PROTOCOL_TYPE_KEY); String protocol = value.getString(PROTOCOL_KEY); String leaderId = value.getString(LEADER_KEY); Object[] memberMetadataArray = value.getArray(MEMBERS_KEY); GroupState initialState; if (memberMetadataArray.length == 0) { initialState = GroupState.Empty; } else { initialState = GroupState.Stable; } List<MemberMetadata> members = Lists.newArrayList(memberMetadataArray) .stream() .map(memberMetadataObj -> { Struct memberMetadata = (Struct) memberMetadataObj; String memberId = memberMetadata.getString(MEMBER_ID_KEY); String clientId = memberMetadata.getString(CLIENT_ID_KEY); String clientHost = memberMetadata.getString(CLIENT_HOST_KEY); int sessionTimeout = memberMetadata.getInt(SESSION_TIMEOUT_KEY); int rebalanceTimeout; if (version == 0) { rebalanceTimeout = sessionTimeout; } else { rebalanceTimeout = memberMetadata.getInt(REBALANCE_TIMEOUT_KEY); } ByteBuffer subscription = memberMetadata.getBytes(SUBSCRIPTION_KEY); byte[] subscriptionData = new byte[subscription.remaining()]; subscription.get(subscriptionData); Map<String, byte[]> protocols = new HashMap<>(); protocols.put(protocol, subscriptionData); return new MemberMetadata( memberId, groupId, clientId, clientHost, rebalanceTimeout, sessionTimeout, protocolType, protocols ); }).collect(Collectors.toList()); return GroupMetadata.loadGroup( groupId, initialState, generationId, protocolType, protocol, leaderId, members ); } else { throw new IllegalStateException("Unknown group metadata message version"); } }
Example #16
Source File: KeyAndValueSchemasInfo.java From Kafka-Insight with Apache License 2.0 | 4 votes |
public Schema getKeySchema() { return keySchema; }
Example #17
Source File: KeyAndValueSchemasInfo.java From Kafka-Insight with Apache License 2.0 | 4 votes |
public void setKeySchema(Schema keySchema) { this.keySchema = keySchema; }
Example #18
Source File: KeyAndValueSchemasInfo.java From Kafka-Insight with Apache License 2.0 | 4 votes |
public Schema getValueSchema() { return valueSchema; }
Example #19
Source File: KeyAndValueSchemasInfo.java From Kafka-Insight with Apache License 2.0 | 4 votes |
public void setValueSchema(Schema valueSchema) { this.valueSchema = valueSchema; }