Search in sources :

Example 1 with CommandPartitionedTopicMetadata

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;
}
Also used : UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf) CommandPartitionedTopicMetadata(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandPartitionedTopicMetadata)

Example 2 with CommandPartitionedTopicMetadata

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;
    });
}
Also used : AuthenticationDataCommand(com.yahoo.pulsar.broker.authentication.AuthenticationDataCommand) ServerError(com.yahoo.pulsar.common.api.proto.PulsarApi.ServerError) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Redirect(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse.LookupType.Redirect) PulsarHandler(com.yahoo.pulsar.common.api.PulsarHandler) AuthenticationException(javax.naming.AuthenticationException) TimeUnit(java.util.concurrent.TimeUnit) CommandPartitionedTopicMetadata(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandPartitionedTopicMetadata) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) SSLSession(javax.net.ssl.SSLSession) LoadReport(com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport) SslHandler(io.netty.handler.ssl.SslHandler) CommandConnect(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect) CommandLookupTopic(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandLookupTopic) ChannelHandler(io.netty.channel.ChannelHandler) Commands(com.yahoo.pulsar.common.api.Commands) DestinationName(com.yahoo.pulsar.common.naming.DestinationName) DestinationName(com.yahoo.pulsar.common.naming.DestinationName)

Aggregations

CommandPartitionedTopicMetadata (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandPartitionedTopicMetadata)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 AuthenticationDataCommand (com.yahoo.pulsar.broker.authentication.AuthenticationDataCommand)1 Commands (com.yahoo.pulsar.common.api.Commands)1 PulsarHandler (com.yahoo.pulsar.common.api.PulsarHandler)1 CommandConnect (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandConnect)1 CommandLookupTopic (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandLookupTopic)1 Redirect (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandLookupTopicResponse.LookupType.Redirect)1 ServerError (com.yahoo.pulsar.common.api.proto.PulsarApi.ServerError)1 DestinationName (com.yahoo.pulsar.common.naming.DestinationName)1 LoadReport (com.yahoo.pulsar.common.policies.data.loadbalancer.LoadReport)1 ByteBuf (io.netty.buffer.ByteBuf)1 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)1 UnpooledHeapByteBuf (io.netty.buffer.UnpooledHeapByteBuf)1 ChannelHandler (io.netty.channel.ChannelHandler)1 SslHandler (io.netty.handler.ssl.SslHandler)1 TimeUnit (java.util.concurrent.TimeUnit)1 AuthenticationException (javax.naming.AuthenticationException)1 SSLSession (javax.net.ssl.SSLSession)1 Logger (org.slf4j.Logger)1