Interface ProtocolHandler
- All Superinterfaces:
AutoCloseable
The protocol handler interface for support additional protocols on Pulsar brokers.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanVerify if the protocol can speak the given protocol.voidclose()Retrieve the protocol related data to advertise as part ofLocalBrokerData.voidinitialize(org.apache.pulsar.broker.ServiceConfiguration conf) Initialize the protocol handler when the protocol is constructed from reflection.Map<InetSocketAddress,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> Create the list of channel initializers for the ports that this protocol handler will listen on.Returns the unique protocol name.voidstart(BrokerService service) Start the protocol handler with the provided broker service.
-
Method Details
-
protocolName
String protocolName()Returns the unique protocol name. For example, `kafka-v2` for protocol handler for Kafka v2 protocol. -
accept
Verify if the protocol can speak the given protocol.- Parameters:
protocol- the protocol to verify- Returns:
- true if the protocol handler can handle the given protocol, otherwise false.
-
initialize
Initialize the protocol handler when the protocol is constructed from reflection.The initialize should initialize all the resources required for serving the protocol handler but don't start those resources until
start(BrokerService)is called.- Parameters:
conf- broker service configuration- Throws:
Exception- when fail to initialize the protocol handler.
-
getProtocolDataToAdvertise
String getProtocolDataToAdvertise()Retrieve the protocol related data to advertise as part ofLocalBrokerData.For example, when implementing a Kafka protocol handler, you need to advertise corresponding Kafka listeners so that Pulsar brokers understand how to give back the listener information when handling metadata requests.
NOTE: this method is called after
initialize(ServiceConfiguration)and beforestart(BrokerService).- Returns:
- the protocol related data to be advertised as part of LocalBrokerData.
-
start
Start the protocol handler with the provided broker service.The broker service provides the accesses to the Pulsar components such as load manager, namespace service, managed ledger and etc.
- Parameters:
service- the broker service to start with.
-
newChannelInitializers
Map<InetSocketAddress,io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> newChannelInitializers()Create the list of channel initializers for the ports that this protocol handler will listen on.NOTE: this method is called after
start(BrokerService).- Returns:
- the list of channel initializers for the ports that this protocol handler listens on.
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-