Class QUICBabelChannelBuilder
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.AbstractBabelChannelBuilder<QUICBabelChannelBuilder>
pt.unl.fct.di.novasys.babel2.channels.AbstractIPBabelChannelBuilder<QUICBabelChannelBuilder>
pt.unl.fct.di.novasys.babel2.channels.quic.QUICBabelChannelBuilder
- All Implemented Interfaces:
BabelChannelBuilder
Builder for
QUICBabelChannel instances.
Configures channel parameters such as the local binding address, event loop group, number of streams, TLS trust manager, and identity keys prior to building the channel via the Babel runtime. Example usage:
QUICBabelChannelBuilder builder = QUICBabelChannel.builder()
.setBindingAddress(new InetSocketAddress("0.0.0.0", 7000))
.setNumberOfStreams(4)
.setNumberOfConnections(100)
.setTrustManagerFactory(new PeerIdentityTrustManagerFactory());
When registered with Babel via
Babel.builder().registerProtocol(protocol, holderFactory, builder),
build(Babel, NodeStore, BabelNode, BabelProtocol) is invoked for
each registering protocol.
The underlying QUICBabelChannel is created on the first invocation
and shared,
returning a dedicated QUICBabelChannelProtocolWrapper for each
registering protocol.
-
Field Summary
Fields inherited from class AbstractIPBabelChannelBuilder
DEFAULT_CONNECTION_UP_DELAY, DEFAULT_CONNECTION_UP_DELAY_UNITModifier and TypeFieldDescriptionstatic final longDefault delay in milliseconds before dispatching connection-up notifications.static final TimeUnitDefault time unit forAbstractIPBabelChannelBuilder.DEFAULT_CONNECTION_UP_DELAY.Fields inherited from class AbstractBabelChannelBuilder
DEFAULT_NUMBER_OF_CONNECTIONS, DEFAULT_NUMBER_OF_MESSAGESModifier and TypeFieldDescriptionstatic final intDefault number of connections to expect when initializing the channel.static final intDefault number of message types expected by this channel. -
Method Summary
Modifier and TypeMethodDescriptionbuild(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol) Builds the channel or returns a protocol-specific wrapper if the underlying channel has already been constructed.setComparator(Comparator<? extends BabelNode> comparator) Sets the comparator used to resolve simultaneous-connection conflicts.setKeyMaterial(CertGenerator.KeyMaterial keyMaterial) Sets pre-generatedCertGenerator.KeyMaterialcontaining the ephemeral key and certificate.setNumberOfStreams(int numberOfStreams) Sets the maximum number of concurrent unidirectional streams per connection.setTrustManager(TrustManager trustManager) Sets theTrustManagerused to validate peer TLS certificates during the QUIC handshake.setTrustManagerFactory(TrustManagerFactory trustManager) Sets theTrustManagerFactoryused to validate peer TLS certificates during the QUIC handshake.Methods inherited from class AbstractIPBabelChannelBuilder
getBindingAddress, getConnectionUpDelay, getConnectionUpDelayUnit, getEventLoopGroup, setBindingAddress, setConnectionUpDelay, setConnectionUpDelay, setEventLoopGroupModifier and TypeMethodDescriptionprotected final InetSocketAddressReturns the currently configured binding address.protected final longReturns the configured connection up delay value.protected final TimeUnitReturns the time unit of the connection up delay.protected final io.netty.channel.EventLoopGroupReturns the configured event loop group, initializing a default one viaBabelIpUtils.createLoopGroup()if none has been set.final QUICBabelChannelBuildersetBindingAddress(InetSocketAddress bindingAddress) Sets the local IP socket address to which the channel should bind.final QUICBabelChannelBuildersetConnectionUpDelay(long delayMillis) Sets the delay in milliseconds before notifying the runtime that a connection is fully up.final QUICBabelChannelBuildersetConnectionUpDelay(long delay, TimeUnit unit) Sets the delay and unit before notifying the runtime that a connection is fully up.final QUICBabelChannelBuildersetEventLoopGroup(io.netty.channel.EventLoopGroup eventLoopGroup) Configures the NettyEventLoopGroupused for network I/O.Methods inherited from class AbstractBabelChannelBuilder
getChannel, getNumberOfConnections, getNumberOfMessages, setChannel, setNumberOfConnections, setNumberOfMessages, validateStateOrThrowModifier and TypeMethodDescriptionprotected final @Nullable BabelChannelReturns the channel instance created by this builder, ornullif not yet built.protected final intGets the expected number of connections set in this builder.protected final intGets the expected number of messages set in this builder.protected final voidsetChannel(BabelChannel channel) Sets the constructed channel instance created by this builder.final QUICBabelChannelBuildersetNumberOfConnections(int numberOfConnections) Sets the default number of connections expected.final QUICBabelChannelBuildersetNumberOfMessages(int numberOfMessages) Sets the expected number of distinct message types handled by this channel.protected final voidValidates that this builder has not yet built its channel instance.
-
Method Details
-
setNumberOfStreams
Sets the maximum number of concurrent unidirectional streams per connection. Also ensures the trust manager is initialized toInsecureTrustManagerFactory.INSTANCEif not already customized.- Parameters:
numberOfStreams- the number of unidirectional streams to configure- Returns:
- this builder instance for method chaining
-
setTrustManagerFactory
Sets theTrustManagerFactoryused to validate peer TLS certificates during the QUIC handshake.- Parameters:
trustManager- the trust manager factory to use- Returns:
- this builder instance for method chaining
-
setTrustManager
Sets theTrustManagerused to validate peer TLS certificates during the QUIC handshake.- Parameters:
trustManager- the trust manager to use- Returns:
- this builder instance for method chaining
-
setKeyMaterial
Sets pre-generatedCertGenerator.KeyMaterialcontaining the ephemeral key and certificate.- Parameters:
keyMaterial- the key material to use- Returns:
- this builder instance for method chaining
-
setComparator
Sets the comparator used to resolve simultaneous-connection conflicts.- Parameters:
comparator- the comparator to use for tie-breaking- Returns:
- this builder instance for method chaining
-
build
public BabelChannel build(Babel runtime, NodeStore store, BabelNode identity, BabelProtocol protocol) Builds the channel or returns a protocol-specific wrapper if the underlying channel has already been constructed.- Parameters:
runtime- the Babel runtime instancestore- the node store containing peer componentsidentity- the local node's identityprotocol- the Babel protocol registering with the channel- Returns:
- a
BabelChannelwrapper bound to the registering protocol - Throws:
IllegalArgumentException- ifnumberOfStreamshas not been set (equals 0)
-