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

net.spy.memcached.config.ClusterConfiguration Maven / Gradle / Ivy

/**
 * Copyright (C) 2012-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 
 *
 * SPDX-License-Identifier: Apache-2.0
 */
package net.spy.memcached.config;

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

/**
 * A type to capture the configuration version number and the server list 
 * contained the response for getConfig API for "cluster" configuration type.
 */
public class ClusterConfiguration {

  private long configVersion;
  private List cacheNodeEndPoints;
  
  public ClusterConfiguration(final long configVersion, final List cacheNodeEndPoints){
    this.configVersion = configVersion;
    this.cacheNodeEndPoints = cacheNodeEndPoints;
  }
  
  public long getConfigVersion() {
    return configVersion;
  }

  public List getCacheNodeEndPoints() {
    return cacheNodeEndPoints;
  }
  
  public List getInetSocketAddresses(){
    List addrs = new ArrayList(cacheNodeEndPoints.size());
    for(NodeEndPoint endPoint : cacheNodeEndPoints){
      addrs.add(endPoint.getInetSocketAddress());
    }
    
    return addrs;
  }
  
  @Override
  public String toString(){
    StringBuilder nodeList = new StringBuilder("Version:" + configVersion + "  CacheNode List:");
    for(NodeEndPoint endPoint : cacheNodeEndPoints){
      nodeList.append(" " + endPoint.getHostName() + ":" + endPoint.getPort());
    }
    
    return nodeList.toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy