Package com.fasterxml.clustermate.service.state

Examples of com.fasterxml.clustermate.service.state.ActiveNodeState


        // Next: load state definitions from local node DB
        List<ActiveNodeState> storedStates = nodes.readAll();
        LOG.info("Read {} persisted node entries from local store", storedStates.size());

        // First things first: find and update node for local node
        ActiveNodeState localAct = _remove(storedStates, localDef.getAddress());
        if (localAct == null) { // need to create?
            if (!_stuff.isRunningTests()) {
                LOG.warn("No persisted entry for local node: will create and store one");
            }
            localAct = new ActiveNodeState(localDef, _startTime);
        } else {
            // index may have changed; if so, override
            if (localAct.getIndex() != localDef.getIndex()) {
                LOG.warn("Node index of current node changed from {} to {} -- may change key range!",
                        localAct.getIndex(), localDef.getIndex());
                localAct = localAct.withIndex(localDef.getIndex());
            }
        }
        // one more thing: force dummy update on restart as well (official startup time too)
        localAct = localAct.withLastUpdated(_startTime);
        // Either way, need to update persisted version
        nodes.upsertEntry(localAct.getAddress(), localAct);
       
        // then merge entries; create/delete orphans
        Map<IpAndPort,ActiveNodeState> activeState = _mergeStates(nodes,
                localAct, nodeDefs, storedStates);
View Full Code Here


       
        // And then reverse check: any config entries for which we have no state?
        // If we do, need to initialize state
        int i = 0;
        for (NodeDefinition def : orphanDefs.values()) {
            ActiveNodeState state = new ActiveNodeState(def, _startTime);
            state = state.withSyncRange(localState);
            if (!_stuff.isRunningTests()) {
                LOG.warn("Configuration entry without state, key {}: will need to (re)create state (sync range {})",
                        def.getAddress(), state.getRangeSync());
            }
            try {
                nodeStore.upsertEntry(state.getAddress(), state);
            } catch (Exception e) {
                LOG.error("Failed to update node state entry #{}, must skip. Problem ({}): {}",
                        i, e.getClass().getName(), e.getMessage());
            }
            result.put(state.getAddress(), state);
            ++i;
        }
        return result;
    }
View Full Code Here

    private ActiveNodeState _remove(Collection<ActiveNodeState> nodes, IpAndPort key)
    {
        Iterator<ActiveNodeState> it = nodes.iterator();
        while (it.hasNext()) {
            ActiveNodeState curr = it.next();
            if (key.equals(curr.getAddress())) {
                it.remove();
                return curr;
            }
        }
        return null;
View Full Code Here

    public void markDisabled(long timestamp, boolean isDisabled)
    {
        if (timestamp <= 0L) { // optional
            timestamp = _syncState.getDisabledUpdated();
        }
        ActiveNodeState state = _syncState.withDisabled(timestamp, isDisabled);
        if (state != _syncState) {
            _syncState = state;
            try {
                _stateStore.upsertEntry(state.getAddress(), state);
            } catch (Exception e) {
                LOG.error("Failed to update node state (disabled to {}) for {}. Problem ({}): {}",
                        isDisabled, _syncState, e.getClass().getName(), e.getMessage());
            }
        }
View Full Code Here

     * @param syncStartTime Timestamp of when sync attempt was done
     * @param lastSeen
     */
    private void _updatePersistentState(long syncStartTime, long lastSeen)
    {
        ActiveNodeState orig = _syncState;
        _syncState = _syncState.withLastSyncAttempt(syncStartTime);
        if (lastSeen > _syncState.getSyncedUpTo()) {
            _syncState = _syncState.withSyncedUpTo(lastSeen);
        }
        if (_syncState != orig) {
View Full Code Here

        // Next: load state definitions from BDB
        List<ActiveNodeState> storedStates = nodes.readAll();
        LOG.info("Read {} persisted node entries from local store", storedStates.size());

        // First things first: find and update node for local node
        ActiveNodeState localAct = _remove(storedStates, localDef.getAddress());
        if (localAct == null) { // need to create?
            if (!_stuff.isRunningTests()) {
                LOG.warn("No persisted entry for local node: will create and store one");
            }
            localAct = new ActiveNodeState(localDef, _startTime);
        } else {
            // index may have changed; if so, override
            if (localAct.getIndex() != localDef.getIndex()) {
                LOG.warn("Node index of current node changed from {} to {} -- may change key range!",
                        localAct.getIndex(), localDef.getIndex());
                localAct = localAct.withIndex(localDef.getIndex());
            }
        }
        // one more thing: force dummy update on restart as well (official startup time too)
        localAct = localAct.withLastUpdated(_startTime);
        // Either way, need to update persisted version
        nodes.upsertEntry(localAct.getAddress(), localAct);
       
        // then merge entries; create/delete orphans
        Map<IpAndPort,ActiveNodeState> activeState = _mergeStates(nodes,
                localAct, nodeDefs, storedStates);
View Full Code Here

       
        // And then reverse check: any config entries for which we have no state?
        // If we do, need to initialize state
        int i = 0;
        for (NodeDefinition def : orphanDefs.values()) {
            ActiveNodeState state = new ActiveNodeState(def, _startTime);
            state = state.withSyncRange(localState);
            if (!_stuff.isRunningTests()) {
                LOG.warn("Configuration entry without state, key {}: will need to (re)create state (sync range {})",
                        def.getAddress(), state.getRangeSync());
            }
            try {
                nodeStore.upsertEntry(state.getAddress(), state);
            } catch (Exception e) {
                LOG.error("Failed to update node state entry #{}, must skip. Problem ({}): {}",
                        i, e.getClass().getName(), e.getMessage());
            }
            result.put(state.getAddress(), state);
            ++i;
        }
        return result;
    }
View Full Code Here

    private ActiveNodeState _remove(Collection<ActiveNodeState> nodes, IpAndPort key)
    {
        Iterator<ActiveNodeState> it = nodes.iterator();
        while (it.hasNext()) {
            ActiveNodeState curr = it.next();
            if (key.equals(curr.getAddress())) {
                it.remove();
                return curr;
            }
        }
        return null;
View Full Code Here

                /* How interesting! Someone who we don't even know seems to be joining...
                 * Two possible cases, then; (a) We are seeing something for which we do
                 * have data in local DB, just not in config file, or (b) New entry for
                 * which no data exists.
                 */
                ActiveNodeState oldState = _stores.getNodeStore().findEntry(endpoint);
                // If such data found, assume it's accurate; we'll be updated soon if not
                if (oldState != null) {
                    peer = _createPeer(oldState);
                    LOG.warn("Request from node {} for which we have info in Local DB, restoring", endpoint);
                } else {
                    // But if not found need minimal bootstrapping
                    ActiveNodeState initialStatus = new ActiveNodeState(_localState,
                            new NodeDefinition(endpoint, NodeDefinition.INDEX_UNKNOWN,
                                    totalRange, totalRange),
                            _timeMaster.currentTimeMillis());
                    peer = _createPeer(initialStatus);
                    LOG.warn("Request from node {} for which we have no information, bootstrap with range of {}",
View Full Code Here

                    LOG.warn("Status for new node {} received: must create a peer", endpoint);
                    // node: should not ever occur for node itself... but...
                    _updateMissingPeer(nodeStatus, byNodeItself);
                } else { // more common, just update...
                    // But first, see that information is more up-to-date
                    ActiveNodeState currentState = peer.getSyncState();
                    if (currentState.getLastUpdated() >= nodeStatus.getLastUpdated()) {
                        return false;
                    }
                    return _updateExistingPeer(nodeStatus, byNodeItself, peer);
                }
            }
View Full Code Here

TOP

Related Classes of com.fasterxml.clustermate.service.state.ActiveNodeState

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.