Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.client;
 
 import java.util.*;

Container class for an ordered set of references to server nodes that should be contacted for accessing content for given key, based on key hash based matching.
 
public class NodesForKey implements Iterable<ClusterServerNode>
    private final static ClusterServerNode[] NO_NODES = new ClusterServerNode[0];
    
    private final int _version;
    private final ClusterServerNode[] _nodes;
    
    /*
    /**********************************************************************
    /* Construction
    /**********************************************************************
     */
    
    public NodesForKey(int versionClusterServerNode[] nodes)
    {
         = version;
         = nodes;
    }
    public static NodesForKey empty(int version) {
        return new NodesForKey(version);
    }
    
    /*
    /**********************************************************************
    /* Accessors
    /**********************************************************************
     */
    
    public int version() { return ; }
    public boolean isEmpty() { return . == 0; }
    public int size() { return .; }
    public ClusterServerNode node(int index) {
        return [index];
    }
    @Override
    public Iterator<ClusterServerNodeiterator() {
        if (. == 0) {
            return Collections.<ClusterServerNode>emptyList().iterator();
        }
        return Arrays.asList().iterator();
    }
    
    public List<ClusterServerNodeasList() {
        final int len = .;
        if (len == 0) {
            return Collections.emptyList();
        }
        List<ClusterServerNodelist = new ArrayList<ClusterServerNode>(len);
        for (int i = 0; i < len; ++i) {
            list.add([i]);
        }
        return list;
    }
    /*
    /**********************************************************************
    /* Overrides
    /**********************************************************************
     */
    @Override
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("[Nodes (").append(.).append(") ");
        for (int i = 0, end = .i < end; ++i) {
            if (i > 0) {
                sb.append(", ");
            }
            ClusterServerNode node = [i];
            sb.append(node.getAddress()).append(": ranges=");
            sb.append(node.getActiveRange()).append('/').append(node.getPassiveRange());
        }
        sb.append(")");
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X