Package com.fasterxml.clustermate.api

Examples of com.fasterxml.clustermate.api.KeyRange$External


        /* 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.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().appendNodeStatusPath(pathBuilder);
        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

            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 "
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

        /* 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

        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

        Integer keyRangeLength = _findIntParam(request, ClusterMateConstants.HTTP_QUERY_PARAM_KEYRANGE_LENGTH);
        if (keyRangeLength == null) {
            return (OUT) missingArgument(response, ClusterMateConstants.HTTP_QUERY_PARAM_KEYRANGE_LENGTH);
        }
        long clusterHash = _findLongParam(request, ClusterMateConstants.HTTP_QUERY_CLUSTER_HASH);
        KeyRange range;
        try {
            range = _keyspace.range(keyRangeStart, keyRangeLength);
        } catch (Exception e) {
            return (OUT) badRequest(response, "Invalid key-range definition (start '%s', end '%s'): %s",
                    keyRangeStart, keyRangeLength, e.getMessage());
        }

        /* 20-Nov-2012, tatu: We can now piggyback auto-registration by sending minimal
         *   info about caller...
         */
        IpAndPort caller = null;
        String str = request.getQueryParameter(ClusterMateConstants.HTTP_QUERY_PARAM_CALLER);
        if (str != null && (str = str.trim()).length() > 0) {
            try {
                caller = new IpAndPort(str);
            } catch (Exception e) {
                LOG.warn("Invalid value for {}: '{}', problem: {}",
                        ClusterMateConstants.HTTP_QUERY_PARAM_CALLER,
                        str, e.getMessage());
            }
        }
        if (caller != null) {
            _cluster.checkMembership(caller, range);
        }
       
        String acceptHeader = request.getHeader(ClusterMateConstants.HTTP_HEADER_ACCEPT);
        // what do they request? If not known, serve JSON (assumed to be from browser)
        boolean useSmile = (acceptHeader != null)
                && acceptHeader.trim().indexOf(ClusterMateConstants.CONTENT_TYPE_SMILE) >= 0;
        long currentTime = _timeMaster.currentTimeMillis();

        final long upUntil = currentTime - _cfgSyncGracePeriod.getMillis();

        AtomicLong timestamp = new AtomicLong(0L);
        long since = (sinceL == null) ? 0L : sinceL.longValue();
       
        /* One more thing: let's sanity check that our key range overlaps request
         * range. If not, can avoid (possibly huge) database scan.
         */
        NodeState localState = _cluster.getLocalState();       
        List<E> entries;

        KeyRange localRange = localState.totalRange();
        if (localRange.overlapsWith(range)) {
            entries = _listEntries(range, since, upUntil, _maxToListPerRequest, timestamp);
        /*
System.err.println("Sync for "+_localState.getRangeActive()+" (slice of "+range+"); between "+sinceL+" and "+upUntil+", got "+entries.size()+"/"
+_stores.getEntryStore().getEntryCount()+" entries... (time: "+_timeMaster.currentTimeMillis()+")");
*/
 
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.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

TOP

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

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.