int localHbGeneration = heartBeatState.getGeneration(); int localHbVersion = heartBeatState.getHeartBeatVersion(); if (localHbVersion > version) reqdEndpointState = new EndpointState(new HeartBeatState(localHbGeneration, localHbVersion)); if (logger.isTraceEnabled()) logger.trace("local heartbeat version {} greater than {} for {}", localHbVersion, version, forEndpoint); reqdEndpointState = new EndpointState(new HeartBeatState(localHbGeneration, localHbVersion));
public void forceNewerGeneration() { EndpointState epstate = endpointStateMap.get(FBUtilities.getBroadcastAddress()); epstate.getHeartBeatState().forceNewerGenerationUnsafe(); }
public void serialize(HeartBeatState hbState, DataOutputPlus out, int version) throws IOException { out.writeInt(hbState.getGeneration()); out.writeInt(hbState.getHeartBeatVersion()); }
/** * Add an endpoint we knew about previously, but whose state is unknown */ public void addSavedEndpoint(InetAddress ep) { if (ep.equals(FBUtilities.getBroadcastAddress())) { logger.debug("Attempt to add self as saved endpoint"); return; } //preserve any previously known, in-memory data about the endpoint (such as DC, RACK, and so on) EndpointState epState = endpointStateMap.get(ep); if (epState != null) { logger.debug("not replacing a previous epState for {}, but reusing it: {}", ep, epState); epState.setHeartBeatState(new HeartBeatState(0)); } else { epState = new EndpointState(new HeartBeatState(0)); } epState.markDead(); endpointStateMap.put(ep, epState); unreachableEndpoints.put(ep, System.nanoTime()); if (logger.isTraceEnabled()) logger.trace("Adding saved endpoint {} {}", ep, epState.getHeartBeatState().getGeneration()); }
epState = new EndpointState(new HeartBeatState((int) ((System.currentTimeMillis() + 60000) / 1000), 9999)); int generation = epState.getHeartBeatState().getGeneration(); int heartbeat = epState.getHeartBeatState().getHeartBeatVersion(); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); if (newState == null) logger.warn("Endpoint {} disappeared while trying to assassinate, continuing anyway", endpoint); else if (newState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint still alive: " + endpoint + " generation changed while trying to assassinate it"); else if (newState.getHeartBeatState().getHeartBeatVersion() != heartbeat) throw new RuntimeException("Endpoint still alive: " + endpoint + " heartbeat changed while trying to assassinate it"); epState.getHeartBeatState().forceNewerGenerationUnsafe();
public int getCurrentGenerationNumber(InetAddress endpoint) { return endpointStateMap.get(endpoint).getHeartBeatState().getGeneration(); }
epState = new EndpointState(new HeartBeatState((int) ((System.currentTimeMillis() + 60000) / 1000), 9999)); tokens = Collections.singletonList(StorageService.getPartitioner().getRandomToken()); int generation = epState.getHeartBeatState().getGeneration(); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); if (newState == null) logger.warn("Endpoint {} disappeared while trying to assassinate, continuing anyway", endpoint); else if (newState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint " + endpoint + " generation changed while trying to remove it"); epState.getHeartBeatState().forceNewerGenerationUnsafe();
/** * 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); }
endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().updateHeartBeat(); if (logger.isTraceEnabled()) logger.trace("My heartbeat is now {}", endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().getHeartBeatVersion()); final List<GossipDigest> gDigests = new ArrayList<GossipDigest>(); Gossiper.instance.makeRandomGossipDigest(gDigests);
public HeartBeatState deserialize(DataInput in, int version) throws IOException { return new HeartBeatState(in.readInt(), in.readInt()); }
/** * Return either: the greatest heartbeat or application state * * @param epState * @return */ int getMaxEndpointStateVersion(EndpointState epState) { int maxVersion = epState.getHeartBeatState().getHeartBeatVersion(); for (Map.Entry<ApplicationState, VersionedValue> state : epState.states()) maxVersion = Math.max(maxVersion, state.getValue().version); return maxVersion; }
/** * This method is used to mark a node as shutdown; that is it gracefully exited on its own and told us about it * @param endpoint endpoint that has shut itself down */ protected void markAsShutdown(InetAddress endpoint) { EndpointState epState = endpointStateMap.get(endpoint); if (epState == null) return; epState.addApplicationState(ApplicationState.STATUS, StorageService.instance.valueFactory.shutdown(true)); epState.getHeartBeatState().forceHighestPossibleVersionUnsafe(); markDead(endpoint, epState); FailureDetector.instance.forceConviction(endpoint); }
public void serialize(HeartBeatState hbState, DataOutputPlus out, int version) throws IOException { out.writeInt(hbState.getGeneration()); out.writeInt(hbState.getHeartBeatVersion()); }
epState = new EndpointState(new HeartBeatState((int) ((System.currentTimeMillis() + 60000) / 1000), 9999)); int generation = epState.getHeartBeatState().getGeneration(); int heartbeat = epState.getHeartBeatState().getHeartBeatVersion(); logger.info("Sleeping for {}ms to ensure {} does not change", StorageService.RING_DELAY, endpoint); Uninterruptibles.sleepUninterruptibly(StorageService.RING_DELAY, TimeUnit.MILLISECONDS); if (newState == null) logger.warn("Endpoint {} disappeared while trying to assassinate, continuing anyway", endpoint); else if (newState.getHeartBeatState().getGeneration() != generation) throw new RuntimeException("Endpoint still alive: " + endpoint + " generation changed while trying to assassinate it"); else if (newState.getHeartBeatState().getHeartBeatVersion() != heartbeat) throw new RuntimeException("Endpoint still alive: " + endpoint + " heartbeat changed while trying to assassinate it"); epState.getHeartBeatState().forceNewerGenerationUnsafe();
public int getCurrentGenerationNumber(InetAddress endpoint) { return endpointStateMap.get(endpoint).getHeartBeatState().getGeneration(); }
/** * Add an endpoint we knew about previously, but whose state is unknown */ public void addSavedEndpoint(InetAddress ep) { if (ep.equals(FBUtilities.getBroadcastAddress())) { logger.debug("Attempt to add self as saved endpoint"); return; } //preserve any previously known, in-memory data about the endpoint (such as DC, RACK, and so on) EndpointState epState = endpointStateMap.get(ep); if (epState != null) { logger.debug("not replacing a previous epState for {}, but reusing it: {}", ep, epState); epState.setHeartBeatState(new HeartBeatState(0)); } else { epState = new EndpointState(new HeartBeatState(0)); } epState.markDead(); endpointStateMap.put(ep, epState); unreachableEndpoints.put(ep, System.nanoTime()); if (logger.isTraceEnabled()) logger.trace("Adding saved endpoint {} {}", ep, epState.getHeartBeatState().getGeneration()); }
/** * 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); }
endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().updateHeartBeat(); if (logger.isTraceEnabled()) logger.trace("My heartbeat is now {}", endpointStateMap.get(FBUtilities.getBroadcastAddress()).getHeartBeatState().getHeartBeatVersion()); final List<GossipDigest> gDigests = new ArrayList<GossipDigest>(); Gossiper.instance.makeRandomGossipDigest(gDigests);
public HeartBeatState deserialize(DataInputPlus in, int version) throws IOException { return new HeartBeatState(in.readInt(), in.readInt()); }
/** * Return either: the greatest heartbeat or application state * * @param epState * @return */ int getMaxEndpointStateVersion(EndpointState epState) { int maxVersion = epState.getHeartBeatState().getHeartBeatVersion(); for (Map.Entry<ApplicationState, VersionedValue> state : epState.states()) maxVersion = Math.max(maxVersion, state.getValue().version); return maxVersion; }