Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.clustermate.service.cfg;
 
 
Configuration settings for a single cluster node. Exact usage of fields depends on KeyRangeAllocationStrategy used for cluster handling, but all strategies at least use end point definition.

Note that two alternate representations are accepted: either "full" one with multiple fields, represented by JSON Object; or "simple", a String that only contains ipAndPort. Latter is useful for dynamic configurations.

public class NodeConfig
{
    
Ip name (or number) and port that this node instance listens to. Usually used in conjunction with node index (which is either initialized externally or defined via KeyRangeAllocationStrategy) to match incoming configuration settings and stored node state information.
    @NotNull
    public IpAndPort ipAndPort;

    
Start offset of they key range this node covers. Only used with KeyRangeAllocationStrategy.STATIC; ignored with other strategies.
    @Min(0)
    public int keyRangeStart = 0;

    
Length of they key range this node covers. Only used with KeyRangeAllocationStrategy.STATIC; ignored with other strategies.
    @Min(0)
    public int keyRangeLength = 0;
    // Default ctor used by deserializer when binding from JSON Object
    protected NodeConfig() { }
    // Alternate internal ctor used when deserializing from simple String
    public NodeConfig(String strthrows IllegalArgumentException
    {
        try {
             = new IpAndPort(str);
        } catch (Exception e) {
            throw new IllegalArgumentException("Invalid endpoint definition for constructing NodeConfig: \""
                    +str+"\"");
        }
    }
    // yet another constructor for tests, to use with non-static range settings
    public NodeConfig(IpAndPort endpoint) {
        this(endpoint, 0, 0);
    }
    // constructor for unit tests
    public NodeConfig(String endpointint keyStartint keyLength)
    {
        this(new IpAndPort(endpoint), keyStartkeyLength);
    }
    public NodeConfig(IpAndPort endpointint keyStartint keyLength)
    {
         = endpoint;
         = keyStart;
         = keyLength;
    }
New to GrepCode? Check out our FAQ X