Class AtomixClusterBuilder
- All Implemented Interfaces:
Builder<AtomixCluster>
AtomixCluster instance.
This builder is used to configure an AtomixCluster instance programmatically. To
create a new builder, use one of the AtomixCluster.builder(MeterRegistry) static methods.
AtomixClusterBuilder builder = AtomixCluster.builder();
The instance is configured by calling the with* methods on this builder. Once the
instance has been configured, call build() to build the instance:
AtomixCluster cluster = AtomixCluster.builder()
.withMemberId("member-1")
.withAddress("localhost", 5000)
.build();
Backing the builder is an ClusterConfig which is loaded when the builder is initially
constructed. To load a configuration from a file, use AtomixCluster.builder(MeterRegistry).-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAtomixClusterBuilder(ClusterConfig config, io.micrometer.core.instrument.MeterRegistry meterRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbuild()withAddress(Address address) Sets the member address.withClusterId(String clusterId) Sets the cluster identifier.Sets the member host.withMemberId(MemberId localMemberId) Sets the local member identifier.withMemberId(String localMemberId) Sets the local member identifier.Sets the cluster membership protocol.withMembershipProvider(NodeDiscoveryProvider locationProvider) Sets the cluster membership provider.withMessageCompression(MessagingConfig.CompressionAlgorithm messageCompression) withMessagingInterface(String iface) Sets the interface to which to bind the instance.withMessagingInterfaces(Collection<String> ifaces) Sets the interface(s) to which to bind the instance.withMessagingPort(int bindPort) Sets the local port to which to bind the node.withPort(int port) Sets the member port.withProperties(Properties properties) Sets the member properties.withSecurity(File certificateChain, File privateKey) Enables TLS encryption of the messaging service.
-
Field Details
-
config
-
-
Constructor Details
-
AtomixClusterBuilder
public AtomixClusterBuilder(ClusterConfig config, io.micrometer.core.instrument.MeterRegistry meterRegistry)
-
-
Method Details
-
withClusterId
Sets the cluster identifier.The cluster identifier is used to verify intra-cluster communication is taking place between nodes that are intended to be part of the same cluster, e.g. if multicast discovery is used. It only needs to be configured if multiple Atomix clusters are running within the same network.
- Parameters:
clusterId- the cluster identifier- Returns:
- the cluster builder
-
withMemberId
Sets the local member identifier.The member identifier is an optional attribute that can be used to identify and send messages directly to this node. If no member identifier is provided, a
UUIDbased identifier will be generated.- Parameters:
localMemberId- the local member identifier- Returns:
- the cluster builder
-
withMemberId
Sets the local member identifier.The member identifier is an optional attribute that can be used to identify and send messages directly to this node. If no member identifier is provided, a
UUIDbased identifier will be generated.- Parameters:
localMemberId- the local member identifier- Returns:
- the cluster builder
-
withHost
Sets the member host.- Parameters:
host- the member host- Returns:
- the cluster builder
-
withPort
Sets the member port.- Parameters:
port- the member port- Returns:
- the cluster builder
-
withAddress
Sets the member address.The constructed
AtomixClusterwill bind to the given address for intra-cluster communication. The provided address should be visible to other nodes in the cluster.- Parameters:
address- the member address- Returns:
- the cluster builder
-
withProperties
Sets the member properties.The properties are arbitrary settings that will be replicated along with this node's member information. Properties can be used to enable other nodes to determine metadata about this node.
- Parameters:
properties- the member properties- Returns:
- the cluster builder
- Throws:
NullPointerException- if the properties are null
-
withMessagingInterface
Sets the interface to which to bind the instance.- Parameters:
iface- the interface to which to bind the instance- Returns:
- the cluster builder
-
withMessagingInterfaces
Sets the interface(s) to which to bind the instance.- Parameters:
ifaces- the interface(s) to which to bind the instance- Returns:
- the cluster builder
-
withMessagingPort
Sets the local port to which to bind the node.- Parameters:
bindPort- the local port to which to bind the node- Returns:
- the cluster builder
-
withMembershipProtocol
Sets the cluster membership protocol.The membership protocol is responsible for determining the active set of members in the cluster, replicating member metadata, and detecting failures.
- Parameters:
protocol- the cluster membership protocol- Returns:
- the cluster builder
- See Also:
-
withMembershipProvider
Sets the cluster membership provider.The membership provider determines how peers are located and the cluster is bootstrapped.
- Parameters:
locationProvider- the membership provider- Returns:
- the cluster builder
- See Also:
-
withSecurity
Enables TLS encryption of the messaging service.- Parameters:
certificateChain- the certificate chain to useprivateKey- the private key of the chain- Returns:
- the cluster builder
- See Also:
-
withMessageCompression
public AtomixClusterBuilder withMessageCompression(MessagingConfig.CompressionAlgorithm messageCompression) -
build
- Specified by:
buildin interfaceBuilder<AtomixCluster>
-