List<KeyValue> kvList = new ArrayList<KeyValue>(); keyInfo.getMetadata().forEach((key, value) -> { kvList.add(KeyValue.newBuilder().setKey(key).setValue(value).build()); }); msgMetadata.addEncryptionKeys(EncryptionKeys.newBuilder().setKey(keyName)
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addMetadata(subBuilder.buildPartial());
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addProperties(subBuilder.buildPartial());
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addMetadata(subBuilder.buildPartial());
List<KeyValue> kvList = new ArrayList<KeyValue>(); keyInfo.getMetadata().forEach((key, value) -> { kvList.add(KeyValue.newBuilder().setKey(key).setValue(value).build()); }); msgMetadata.addEncryptionKeys(EncryptionKeys.newBuilder().setKey(keyName)
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addProperties(subBuilder.buildPartial());
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addProperties(subBuilder.buildPartial());
org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.Builder subBuilder = org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.newBuilder(); input.readMessage(subBuilder, extensionRegistry); addMetadata(subBuilder.buildPartial());
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; }
private static PulsarApi.Schema getSchema(SchemaInfo schemaInfo) { PulsarApi.Schema.Builder builder = PulsarApi.Schema.newBuilder() .setName(schemaInfo.getName()) .setSchemaData(copyFrom(schemaInfo.getSchema())) .setType(getSchemaType(schemaInfo.getType())) .addAllProperties( schemaInfo.getProperties().entrySet().stream().map(entry -> PulsarApi.KeyValue.newBuilder() .setKey(entry.getKey()) .setValue(entry.getValue()) .build() ).collect(Collectors.toList()) ); PulsarApi.Schema schema = builder.build(); builder.recycle(); return schema; }
public Builder toBuilder() { return newBuilder(this); }
public int getSerializedSize() { int size = memoizedSerializedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += org.apache.pulsar.shaded.com.google.protobuf.v241.CodedOutputStream .computeBytesSize(1, getKeyBytes()); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += org.apache.pulsar.shaded.com.google.protobuf.v241.CodedOutputStream .computeBytesSize(2, getValueBytes()); } memoizedSerializedSize = size; return size; }
public org.apache.pulsar.common.api.proto.PulsarApi.KeyValue getDefaultInstanceForType() { return org.apache.pulsar.common.api.proto.PulsarApi.KeyValue.getDefaultInstance(); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.pulsar.common.api.proto.PulsarApi.KeyValue prototype) {
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 static Builder newBuilder(org.apache.pulsar.common.api.proto.PulsarApi.KeyValue prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }