Class AtomixClusterBuilder

java.lang.Object
io.atomix.cluster.AtomixClusterBuilder
All Implemented Interfaces:
Builder<AtomixCluster>

public class AtomixClusterBuilder extends Object implements Builder<AtomixCluster>
Builder for an 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 Details

  • Constructor Details

    • AtomixClusterBuilder

      public AtomixClusterBuilder(ClusterConfig config, io.micrometer.core.instrument.MeterRegistry meterRegistry)
  • Method Details

    • withClusterId

      public AtomixClusterBuilder withClusterId(String clusterId)
      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

      public AtomixClusterBuilder withMemberId(String localMemberId)
      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 UUID based identifier will be generated.

      Parameters:
      localMemberId - the local member identifier
      Returns:
      the cluster builder
    • withMemberId

      public AtomixClusterBuilder withMemberId(MemberId localMemberId)
      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 UUID based identifier will be generated.

      Parameters:
      localMemberId - the local member identifier
      Returns:
      the cluster builder
    • withHost

      public AtomixClusterBuilder withHost(String host)
      Sets the member host.
      Parameters:
      host - the member host
      Returns:
      the cluster builder
    • withPort

      public AtomixClusterBuilder withPort(int port)
      Sets the member port.
      Parameters:
      port - the member port
      Returns:
      the cluster builder
    • withAddress

      public AtomixClusterBuilder withAddress(Address address)
      Sets the member address.

      The constructed AtomixCluster will 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

      public AtomixClusterBuilder withProperties(Properties properties)
      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

      public AtomixClusterBuilder withMessagingInterface(String iface)
      Sets the interface to which to bind the instance.
      Parameters:
      iface - the interface to which to bind the instance
      Returns:
      the cluster builder
    • withMessagingInterfaces

      public AtomixClusterBuilder withMessagingInterfaces(Collection<String> ifaces)
      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

      public AtomixClusterBuilder withMessagingPort(int bindPort)
      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

      public AtomixClusterBuilder withMembershipProtocol(GroupMembershipProtocol protocol)
      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

      public AtomixClusterBuilder withMembershipProvider(NodeDiscoveryProvider locationProvider)
      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

      public AtomixClusterBuilder withSecurity(File certificateChain, File privateKey)
      Enables TLS encryption of the messaging service.
      Parameters:
      certificateChain - the certificate chain to use
      privateKey - the private key of the chain
      Returns:
      the cluster builder
      See Also:
    • withMessageCompression

      public AtomixClusterBuilder withMessageCompression(MessagingConfig.CompressionAlgorithm messageCompression)
    • build

      public AtomixCluster build()
      Specified by:
      build in interface Builder<AtomixCluster>