use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandPartitionedTopicMetadata in project pulsar by yahoo.
the class Commands method newPartitionMetadataRequest.
public static ByteBuf newPartitionMetadataRequest(String topic, long requestId) {
CommandPartitionedTopicMetadata.Builder partitionMetadataBuilder = CommandPartitionedTopicMetadata.newBuilder();
partitionMetadataBuilder.setTopic(topic);
partitionMetadataBuilder.setRequestId(requestId);
CommandPartitionedTopicMetadata partitionMetadata = partitionMetadataBuilder.build();
ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.PARTITIONED_METADATA).setPartitionMetadata(partitionMetadata));
partitionMetadataBuilder.recycle();
partitionMetadata.recycle();
return res;
}
use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandPartitionedTopicMetadata in project pulsar by yahoo.
the class ServerConnection method sendPartitionMetadataResponse.
private void sendPartitionMetadataResponse(CommandPartitionedTopicMetadata partitionMetadata) {
final long requestId = partitionMetadata.getRequestId();
DestinationName dn = DestinationName.get(partitionMetadata.getTopic());
service.getDiscoveryProvider().getPartitionedTopicMetadata(service, dn, authRole).thenAccept(metadata -> {
if (LOG.isDebugEnabled()) {
LOG.debug("[{}] Total number of partitions for topic {} is {}", authRole, dn, metadata.partitions);
}
ctx.writeAndFlush(Commands.newPartitionMetadataResponse(metadata.partitions, requestId));
}).exceptionally(ex -> {
LOG.warn("[{}] Failed to get partitioned metadata for topic {} {}", remoteAddress, dn, ex.getMessage(), ex);
ctx.writeAndFlush(Commands.newPartitionMetadataResponse(ServerError.ServiceNotReady, ex.getMessage(), requestId));
return null;
});
}
Aggregations