void setHeartBeatState(HeartBeatState newHbState) { updateTimestamp(); hbState = newHbState; }
void setHeartBeatState(HeartBeatState newHbState) { updateTimestamp(); hbState = newHbState; }
void setHeartBeatState(HeartBeatState newHbState) { updateTimestamp(); hbState = newHbState; }
void setHeartBeatState(HeartBeatState newHbState) { updateTimestamp(); hbState = newHbState; }
@VisibleForTesting public void realMarkAlive(final InetAddress addr, final EndpointState localState) { if (logger.isTraceEnabled()) logger.trace("marking as alive {}", addr); localState.markAlive(); localState.updateTimestamp(); // prevents doStatusCheck from racing us and evicting if it was down > aVeryLongTime liveEndpoints.add(addr); unreachableEndpoints.remove(addr); expireTimeEndpointMap.remove(addr); logger.debug("removing expire time for endpoint : {}", addr); logger.info("InetAddress {} is now UP", addr); for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onAlive(addr, localState); if (logger.isTraceEnabled()) logger.trace("Notified {}", subscribers); }
@VisibleForTesting public void realMarkAlive(final InetAddress addr, final EndpointState localState) { if (logger.isTraceEnabled()) logger.trace("marking as alive {}", addr); localState.markAlive(); localState.updateTimestamp(); // prevents doStatusCheck from racing us and evicting if it was down > aVeryLongTime liveEndpoints.add(addr); unreachableEndpoints.remove(addr); expireTimeEndpointMap.remove(addr); logger.debug("removing expire time for endpoint : {}", addr); logger.info("InetAddress {} is now UP", addr); for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onAlive(addr, localState); if (logger.isTraceEnabled()) logger.trace("Notified {}", subscribers); }
@VisibleForTesting public void realMarkAlive(final InetAddress addr, final EndpointState localState) { if (logger.isTraceEnabled()) logger.trace("marking as alive {}", addr); localState.markAlive(); localState.updateTimestamp(); // prevents doStatusCheck from racing us and evicting if it was down > aVeryLongTime liveEndpoints.add(addr); unreachableEndpoints.remove(addr); expireTimeEndpointMap.remove(addr); logger.debug("removing expire time for endpoint : {}", addr); logger.info("InetAddress {} is now UP", addr); for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onAlive(addr, localState); if (logger.isTraceEnabled()) logger.trace("Notified {}", subscribers); }
@VisibleForTesting public void realMarkAlive(final InetAddress addr, final EndpointState localState) { if (logger.isTraceEnabled()) logger.trace("marking as alive {}", addr); localState.markAlive(); localState.updateTimestamp(); // prevents doStatusCheck from racing us and evicting if it was down > aVeryLongTime liveEndpoints.add(addr); unreachableEndpoints.remove(addr); expireTimeEndpointMap.remove(addr); logger.debug("removing expire time for endpoint : " + addr); logger.info("InetAddress {} is now UP", addr); for (IEndpointStateChangeSubscriber subscriber : subscribers) subscriber.onAlive(addr, localState); if (logger.isTraceEnabled()) logger.trace("Notified " + subscribers); }
/** * This method will begin removing an existing endpoint from the cluster by spoofing its state * This should never be called unless this coordinator has had 'removenode' invoked * * @param endpoint - the endpoint being removed * @param hostId - the ID of the host being removed * @param localHostId - my own host ID for replication coordination */ public void advertiseRemoving(InetAddress endpoint, UUID hostId, UUID localHostId) { EndpointState epState = endpointStateMap.get(endpoint); // remember this node's generation int generation = epState.getHeartBeatState().getGeneration(); logger.info("Removing host: {}", hostId); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); // make sure it did not change epState = endpointStateMap.get(endpoint); if (epState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it"); // update the other node's generation to mimic it as if it had changed it itself logger.info("Advertising removal for {}", endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); Map<ApplicationState, VersionedValue> states = new EnumMap<>(ApplicationState.class); states.put(ApplicationState.STATUS, StorageService.instance.valueFactory.removingNonlocal(hostId)); states.put(ApplicationState.REMOVAL_COORDINATOR, StorageService.instance.valueFactory.removalCoordinator(localHostId)); epState.addApplicationStates(states); endpointStateMap.put(endpoint, epState); }
/** * Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN * This should only be called after advertiseRemoving * * @param endpoint * @param hostId */ public void advertiseTokenRemoved(InetAddress endpoint, UUID hostId) { EndpointState epState = endpointStateMap.get(endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); long expireTime = computeExpireTime(); epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.removedNonlocal(hostId, expireTime)); logger.info("Completing removal of {}", endpoint); addExpireTimeForEndpoint(endpoint, expireTime); endpointStateMap.put(endpoint, epState); // ensure at least one gossip round occurs before returning Uninterruptibles.sleepUninterruptibly(intervalInMillis * 2, TimeUnit.MILLISECONDS); }
/** * This method will begin removing an existing endpoint from the cluster by spoofing its state * This should never be called unless this coordinator has had 'removenode' invoked * * @param endpoint - the endpoint being removed * @param hostId - the ID of the host being removed * @param localHostId - my own host ID for replication coordination */ public void advertiseRemoving(InetAddress endpoint, UUID hostId, UUID localHostId) { EndpointState epState = endpointStateMap.get(endpoint); // remember this node's generation int generation = epState.getHeartBeatState().getGeneration(); logger.info("Removing host: {}", hostId); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); // make sure it did not change epState = endpointStateMap.get(endpoint); if (epState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it"); // update the other node's generation to mimic it as if it had changed it itself logger.info("Advertising removal for {}", endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); Map<ApplicationState, VersionedValue> states = new EnumMap<>(ApplicationState.class); states.put(ApplicationState.STATUS, StorageService.instance.valueFactory.removingNonlocal(hostId)); states.put(ApplicationState.REMOVAL_COORDINATOR, StorageService.instance.valueFactory.removalCoordinator(localHostId)); epState.addApplicationStates(states); endpointStateMap.put(endpoint, epState); }
/** * Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN * This should only be called after advertiseRemoving * * @param endpoint * @param hostId */ public void advertiseTokenRemoved(InetAddress endpoint, UUID hostId) { EndpointState epState = endpointStateMap.get(endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); long expireTime = computeExpireTime(); epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.removedNonlocal(hostId, expireTime)); logger.info("Completing removal of {}", endpoint); addExpireTimeForEndpoint(endpoint, expireTime); endpointStateMap.put(endpoint, epState); // ensure at least one gossip round occurs before returning Uninterruptibles.sleepUninterruptibly(intervalInMillis * 2, TimeUnit.MILLISECONDS); }
/** * This method will begin removing an existing endpoint from the cluster by spoofing its state * This should never be called unless this coordinator has had 'removenode' invoked * * @param endpoint - the endpoint being removed * @param hostId - the ID of the host being removed * @param localHostId - my own host ID for replication coordination */ public void advertiseRemoving(InetAddress endpoint, UUID hostId, UUID localHostId) { EndpointState epState = endpointStateMap.get(endpoint); // remember this node's generation int generation = epState.getHeartBeatState().getGeneration(); logger.info("Removing host: {}", hostId); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); // make sure it did not change epState = endpointStateMap.get(endpoint); if (epState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it"); // update the other node's generation to mimic it as if it had changed it itself logger.info("Advertising removal for {}", endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); Map<ApplicationState, VersionedValue> states = new EnumMap<>(ApplicationState.class); states.put(ApplicationState.STATUS, StorageService.instance.valueFactory.removingNonlocal(hostId)); states.put(ApplicationState.REMOVAL_COORDINATOR, StorageService.instance.valueFactory.removalCoordinator(localHostId)); epState.addApplicationStates(states); endpointStateMap.put(endpoint, epState); }
/** * This method will begin removing an existing endpoint from the cluster by spoofing its state * This should never be called unless this coordinator has had 'removenode' invoked * * @param endpoint - the endpoint being removed * @param hostId - the ID of the host being removed * @param localHostId - my own host ID for replication coordination */ public void advertiseRemoving(InetAddress endpoint, UUID hostId, UUID localHostId) { EndpointState epState = endpointStateMap.get(endpoint); // remember this node's generation int generation = epState.getHeartBeatState().getGeneration(); logger.info("Removing host: {}", hostId); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); // make sure it did not change epState = endpointStateMap.get(endpoint); if (epState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it"); // update the other node's generation to mimic it as if it had changed it itself logger.info("Advertising removal for {}", endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); Map<ApplicationState, VersionedValue> states = new EnumMap<>(ApplicationState.class); states.put(ApplicationState.STATUS, StorageService.instance.valueFactory.removingNonlocal(hostId)); states.put(ApplicationState.REMOVAL_COORDINATOR, StorageService.instance.valueFactory.removalCoordinator(localHostId)); epState.addApplicationStates(states); endpointStateMap.put(endpoint, epState); }
/** * Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN * This should only be called after advertiseRemoving * * @param endpoint * @param hostId */ public void advertiseTokenRemoved(InetAddress endpoint, UUID hostId) { EndpointState epState = endpointStateMap.get(endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); long expireTime = computeExpireTime(); epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.removedNonlocal(hostId, expireTime)); logger.info("Completing removal of {}", endpoint); addExpireTimeForEndpoint(endpoint, expireTime); endpointStateMap.put(endpoint, epState); // ensure at least one gossip round occurs before returning Uninterruptibles.sleepUninterruptibly(intervalInMillis * 2, TimeUnit.MILLISECONDS); }
/** * Handles switching the endpoint's state from REMOVING_TOKEN to REMOVED_TOKEN * This should only be called after advertiseRemoving * * @param endpoint * @param hostId */ public void advertiseTokenRemoved(InetAddress endpoint, UUID hostId) { EndpointState epState = endpointStateMap.get(endpoint); epState.updateTimestamp(); // make sure we don't evict it too soon epState.getHeartBeatState().forceNewerGenerationUnsafe(); long expireTime = computeExpireTime(); epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.removedNonlocal(hostId, expireTime)); logger.info("Completing removal of {}", endpoint); addExpireTimeForEndpoint(endpoint, expireTime); endpointStateMap.put(endpoint, epState); // ensure at least one gossip round occurs before returning Uninterruptibles.sleepUninterruptibly(intervalInMillis * 2, TimeUnit.MILLISECONDS); }
if (remoteGeneration > localGeneration) localEndpointState.updateTimestamp(); if (remoteVersion > localVersion) localEndpointState.updateTimestamp();
if (remoteGeneration > localGeneration) localEndpointState.updateTimestamp(); if (remoteVersion > localVersion) localEndpointState.updateTimestamp();
if (remoteGeneration > localGeneration) localEndpointState.updateTimestamp(); if (remoteVersion > localVersion) localEndpointState.updateTimestamp();
if (remoteGeneration > localGeneration) localEndpointState.updateTimestamp(); if (remoteVersion > localVersion) localEndpointState.updateTimestamp();