Package com.fasterxml.clustermate.api

Examples of com.fasterxml.clustermate.api.KeyRange


            if (ip == null) {
                throw new IllegalStateException("Missing 'ipAndPort' value for node #"
                        +index+" (out of "+end+")");
            }
            // Range definitions depend on strategy; static or somewhat dynamic...
            KeyRange range;
           
            switch (strategy) {
            case STATIC:
                if (node.keyRangeStart == 0 && node.keyRangeLength == 0) {
                    throw new IllegalStateException("Missing 'keyRangeStart' and/or 'keyRangeLength' for node "
                            +index+" (out of "+end+"), when using STATIC cluster type");
                }
                range = _keyspace.range(node.keyRangeStart, node.keyRangeLength);
                break;
            case SIMPLE_LINEAR:
                range = _keyspace.calcSegment(i, nodeCount, copies);
                // sanity check: no empty segments
                if (range.getLength() == 0) {
                    throw new IllegalStateException("Empty range calculated for node "+index+" (of "+nodeCount
                            +" nodes), keyspace="+_keyspace+", "+copies+" copies");
                }
                break;
            case DYNAMIC_WITH_APPEND: // not (yet!) supported
View Full Code Here


    protected ActiveNodeState _updatePersistentState(NodeStateStore nodeStore,
            ActiveNodeState localNode,
            NodeDefinition remoteDef, ActiveNodeState remoteNode)
    {
        // The main thing is to see if sync range has changed...
        final KeyRange oldSyncRange = remoteNode.getRangeSync();
        KeyRange newSyncRange = localNode.totalRange().intersection(remoteNode.totalRange());
       
        if (newSyncRange.equals(remoteNode.getRangeSync())) {
            LOG.info("Sync range between local and {} unchanged: {}"
                    ,remoteNode.getAddress(), newSyncRange);
        } else {
            long syncedTo = remoteNode.getSyncedUpTo();
            // only need to reset if expanding...
View Full Code Here

        rangeActive = remoteNode.getActiveRange();
        rangePassive = remoteNode.getPassiveRange();
        lastUpdated = updateTime;

        // need to know total range of remove node
        KeyRange remoteRange = rangeActive.union(rangePassive);
        KeyRange localRange = localNode.totalRange();

        // any overlap?
        if (remoteRange.overlapsWith(localRange)) { // yes!
            rangeSync = remoteRange.union(localRange);
        } else { // nope; create empty sync range
View Full Code Here

        rangeActive = remoteNode.getRangeActive();
        rangePassive = remoteNode.getRangePassive();
        lastUpdated = updateTime;

        // need to know total range of remove node
        KeyRange remoteRange = rangeActive.union(rangePassive);
        KeyRange localRange = localNode.totalRange();

        // any overlap?
        if (remoteRange.overlapsWith(localRange)) { // yes!
            rangeSync = remoteRange.union(localRange);
        } else { // nope; create empty sync range
View Full Code Here

     * Fluent factory for creating new state with sync range calculated
     * using specified local node state.
     */
    public ActiveNodeState withSyncRange(ActiveNodeState localNode) {
        long syncTimestamp = syncedUpTo;
        KeyRange newSync = localNode.totalRange().intersection(totalRange());
        if (!rangeSync.contains(newSync)) {
            syncTimestamp = 0L;
        }
        return new ActiveNodeState(this, newSync, syncTimestamp);
    }
View Full Code Here

        /* Need to be sure to pass the full range; remote end can do filtering,
         * (to reduce range if need be), but it needs to know full range
         * for initial auto-registration. Although ideally maybe we should
         * pass active and passive separately... has to do, for now.
         */
        final KeyRange syncRange = local.totalRange();
        final ServiceConfig config = _stuff.getServiceConfig();
        RequestPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remote.getAddress())
            .addPathSegments(config.servicePathRoot);
        pathBuilder = _stuff.getPathStrategy().appendPath(pathBuilder, PathType.SYNC_LIST);
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_SINCE,
                String.valueOf(syncedUpTo));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_KEYRANGE_START, String.valueOf(syncRange.getStart()));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_KEYRANGE_LENGTH, String.valueOf(syncRange.getLength()));
        // this will include 'caller' param:
        pathBuilder = cluster.addClusterStateInfo(pathBuilder);
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_CLUSTER_HASH,
                String.valueOf(lastClusterHash));
        return pathBuilder.toString();
View Full Code Here

    }
   
    protected String _buildNodeStatusUpdateUrl(ClusterViewByServerUpdatable cluster, IpAndPort remote,
            String state)
    {
        final KeyRange syncRange = cluster.getLocalState().totalRange();
        RequestPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remote)
            .addPathSegments(_stuff.getServiceConfig().servicePathRoot);
        pathBuilder = _stuff.getPathStrategy().appendPath(pathBuilder, PathType.NODE_STATUS);
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_KEYRANGE_START, String.valueOf(syncRange.getStart()));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_KEYRANGE_LENGTH, String.valueOf(syncRange.getLength()));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_TIMESTAMP,
                String.valueOf(_stuff.getTimeMaster().currentTimeMillis()));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.QUERY_PARAM_STATE, state);
        // this will include 'caller' param:
        pathBuilder = cluster.addClusterStateInfo(pathBuilder);
View Full Code Here

        rangeActive = remoteNode.getActiveRange();
        rangePassive = remoteNode.getPassiveRange();
        lastUpdated = updateTime;

        // need to know total range of remove node
        KeyRange remoteRange = rangeActive.union(rangePassive);
        KeyRange localRange = localNode.totalRange();

        // any overlap?
        if (remoteRange.overlapsWith(localRange)) { // yes!
            rangeSync = remoteRange.union(localRange);
        } else { // nope; create empty sync range
View Full Code Here

     * Fluent factory for creating new state with sync range calculated
     * using specified local node state.
     */
    public ActiveNodeState withSyncRange(ActiveNodeState localNode) {
        long syncTimestamp = syncedUpTo;
        KeyRange newSync = localNode.totalRange().intersection(totalRange());
        if (!rangeSync.contains(newSync)) {
            syncTimestamp = 0L;
        }
        return new ActiveNodeState(this, newSync, syncTimestamp);
    }
View Full Code Here

        /* Need to be sure to pass the full range; remote end can do filtering,
         * (to reduce range if need be), but it needs to know full range
         * for initial auto-registration. Although ideally maybe we should
         * pass active and passive separately... has to do, for now.
         */
        final KeyRange syncRange = local.totalRange();
        final ServiceConfig config = _stuff.getServiceConfig();
        RequestPathBuilder pathBuilder = new JdkHttpClientPathBuilder(remote.getAddress())
            .addPathSegments(config.servicePathRoot);
        pathBuilder = _stuff.getPathStrategy().appendSyncListPath(pathBuilder);
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.HTTP_QUERY_PARAM_SINCE,
                String.valueOf(syncedUpTo));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.HTTP_QUERY_PARAM_KEYRANGE_START, String.valueOf(syncRange.getStart()));
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.HTTP_QUERY_PARAM_KEYRANGE_LENGTH, String.valueOf(syncRange.getLength()));
        pathBuilder = cluster.addClusterStateInfo(pathBuilder);
        pathBuilder = pathBuilder.addParameter(ClusterMateConstants.HTTP_QUERY_CLUSTER_HASH,
                String.valueOf(lastClusterHash));
        return pathBuilder.toString();
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.clustermate.api.KeyRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.