keyMeta.put(kv.getKey(), kv.getValue()); });
MessageImpl(String topic, BatchMessageIdImpl batchMessageIdImpl, MessageMetadata msgMetadata, PulsarApi.SingleMessageMetadata singleMessageMetadata, ByteBuf payload, Optional<EncryptionContext> encryptionCtx, ClientCnx cnx, Schema<T> schema, int redeliveryCount) { this.msgMetadataBuilder = MessageMetadata.newBuilder(msgMetadata); this.messageId = batchMessageIdImpl; this.topic = topic; this.cnx = cnx; this.redeliveryCount = redeliveryCount; this.payload = Unpooled.copiedBuffer(payload); this.encryptionCtx = encryptionCtx; if (singleMessageMetadata.getPropertiesCount() > 0) { Map<String, String> properties = Maps.newTreeMap(); for (KeyValue entry : singleMessageMetadata.getPropertiesList()) { properties.put(entry.getKey(), entry.getValue()); } this.properties = Collections.unmodifiableMap(properties); } else { properties = Collections.emptyMap(); } if (singleMessageMetadata.hasPartitionKey()) { msgMetadataBuilder.setPartitionKeyB64Encoded(singleMessageMetadata.getPartitionKeyB64Encoded()); msgMetadataBuilder.setPartitionKey(singleMessageMetadata.getPartitionKey()); } if (singleMessageMetadata.hasEventTime()) { msgMetadataBuilder.setEventTime(singleMessageMetadata.getEventTime()); } this.schema = schema; }
public static SchemaInfo newSchemaInfo(Schema schema) { SchemaInfo si = new SchemaInfo(); si.setName(schema.getName()); si.setSchema(schema.getSchemaData().toByteArray()); si.setType(Commands.getSchemaType(schema.getType())); if (schema.getPropertiesCount() == 0) { si.setProperties(Collections.emptyMap()); } else { si.setProperties(new TreeMap<>()); for (int i = 0; i < schema.getPropertiesCount(); i++) { PulsarApi.KeyValue kv = schema.getProperties(i); si.getProperties().put(kv.getKey(), kv.getValue()); } } return si; }
responseBuilder.header("X-Pulsar-Message-ID", pos.toString()); for (KeyValue keyValue : metadata.getPropertiesList()) { responseBuilder.header("X-Pulsar-PROPERTY-" + keyValue.getKey(), keyValue.getValue());
keyMeta.put(kv.getKey(), kv.getValue()); });
private List<Message<byte[]>> getIndividualMsgsFromBatch(String topic, String msgId, byte[] data, Map<String, String> properties) { List<Message<byte[]>> ret = new ArrayList<>(); int batchSize = Integer.parseInt(properties.get(BATCH_HEADER)); for (int i = 0; i < batchSize; i++) { String batchMsgId = msgId + ":" + i; PulsarApi.SingleMessageMetadata.Builder singleMessageMetadataBuilder = PulsarApi.SingleMessageMetadata .newBuilder(); ByteBuf buf = Unpooled.wrappedBuffer(data); try { ByteBuf singleMessagePayload = Commands.deSerializeSingleMessageInBatch(buf, singleMessageMetadataBuilder, i, batchSize); SingleMessageMetadata singleMessageMetadata = singleMessageMetadataBuilder.build(); if (singleMessageMetadata.getPropertiesCount() > 0) { for (KeyValue entry : singleMessageMetadata.getPropertiesList()) { properties.put(entry.getKey(), entry.getValue()); } } ret.add(new MessageImpl<>(topic, batchMsgId, properties, singleMessagePayload, Schema.BYTES)); } catch (Exception ex) { log.error("Exception occured while trying to get BatchMsgId: {}", batchMsgId, ex); } buf.release(); singleMessageMetadataBuilder.recycle(); } return ret; }
MessageImpl(String topic, BatchMessageIdImpl batchMessageIdImpl, MessageMetadata msgMetadata, PulsarApi.SingleMessageMetadata singleMessageMetadata, ByteBuf payload, Optional<EncryptionContext> encryptionCtx, ClientCnx cnx, Schema<T> schema) { this.msgMetadataBuilder = MessageMetadata.newBuilder(msgMetadata); this.messageId = batchMessageIdImpl; this.topic = topic; this.cnx = cnx; this.payload = Unpooled.copiedBuffer(payload); this.encryptionCtx = encryptionCtx; if (singleMessageMetadata.getPropertiesCount() > 0) { Map<String, String> properties = Maps.newTreeMap(); for (KeyValue entry : singleMessageMetadata.getPropertiesList()) { properties.put(entry.getKey(), entry.getValue()); } this.properties = Collections.unmodifiableMap(properties); } else { properties = Collections.emptyMap(); } if (singleMessageMetadata.hasPartitionKey()) { msgMetadataBuilder.setPartitionKeyB64Encoded(singleMessageMetadata.getPartitionKeyB64Encoded()); msgMetadataBuilder.setPartitionKey(singleMessageMetadata.getPartitionKey()); } if (singleMessageMetadata.hasEventTime()) { msgMetadataBuilder.setEventTime(singleMessageMetadata.getEventTime()); } this.schema = schema; }
public SchemaInfo(Schema schema) { this.name = schema.getName(); this.schema = schema.getSchemaData().toByteArray(); this.type = Commands.getSchemaType(schema.getType()); if (schema.getPropertiesCount() == 0) { this.properties = Collections.emptyMap(); } else { this.properties = new TreeMap<>(); for (int i =0 ; i < schema.getPropertiesCount();i ++ ) { KeyValue kv = schema.getProperties(i); properties.put(kv.getKey(), kv.getValue()); } } }
public Builder clearKey() { bitField0_ = (bitField0_ & ~0x00000001); key_ = getDefaultInstance().getKey(); return this; } void setKey(org.apache.pulsar.shaded.com.google.protobuf.v241.ByteString value) {
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.KeyValue other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.getDefaultInstance()) return this; if (other.hasKey()) { setKey(other.getKey()); } if (other.hasValue()) { setValue(other.getValue()); } return this; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.KeyValue other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.getDefaultInstance()) return this; if (other.hasKey()) { setKey(other.getKey()); } if (other.hasValue()) { setValue(other.getValue()); } return this; }
public Builder clearKey() { bitField0_ = (bitField0_ & ~0x00000001); key_ = getDefaultInstance().getKey(); return this; } void setKey(org.apache.pulsar.shaded.com.google.protobuf.v241.ByteString value) {