All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.client.hotrod.impl.topology.ClusterInfo Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.client.hotrod.impl.topology;

import java.net.InetSocketAddress;
import java.util.List;
import java.util.Objects;

import org.infinispan.client.hotrod.configuration.ClientIntelligence;
import org.infinispan.commons.util.Immutables;

/**
 * Cluster definition
 *
 * @author Dan Berindei
 */
public class ClusterInfo {
   private final String clusterName;
   private final List servers;
   // Topology age provides a way to avoid concurrent cluster view changes,
   // affecting a cluster switch. After a cluster switch, the topology age is
   // increased and so any old requests that might have received topology
   // updates won't be allowed to apply since they refer to older views.
   private final int topologyAge;
   private final ClientIntelligence intelligence;
   private final String sniHostName;

   public ClusterInfo(String clusterName, List servers, ClientIntelligence intelligence, String sniHostName) {
      this(clusterName, servers, -1, intelligence, sniHostName);
   }

   private ClusterInfo(String clusterName, List servers, int topologyAge, ClientIntelligence intelligence, String sniHostName) {
      this.clusterName = clusterName;
      this.servers = Immutables.immutableListCopy(servers);
      this.topologyAge = topologyAge;
      this.intelligence = Objects.requireNonNull(intelligence);
      this.sniHostName = sniHostName;
   }

   public ClusterInfo withTopologyAge(int topologyAge) {
      return new ClusterInfo(clusterName, servers, topologyAge, intelligence, sniHostName);
   }

   public String getName() {
      return clusterName;
   }

   public List getInitialServers() {
      return servers;
   }

   public int getTopologyAge() {
      return topologyAge;
   }

   public ClientIntelligence getIntelligence() {
      return intelligence;
   }

   public String getSniHostName() {
      return sniHostName;
   }

   @Override
   public String toString() {
      return "ClusterInfo{" +
            "name='" + clusterName + '\'' +
            ", servers=" + servers +
            ", age=" + topologyAge +
            ", intelligence=" + intelligence +
            ", sniHostname=" + sniHostName +
            '}';
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy