ClusterMergeTask(Node node) { this.node = node; this.lifecycleService = node.hazelcastInstance.getLifecycleService(); }
ClusterMergeTask(Node node) { this.node = node; this.lifecycleService = node.hazelcastInstance.getLifecycleService(); }
@Override public LifecycleService getLifecycleService() { final HazelcastInstanceImpl hz = original; return hz != null ? hz.getLifecycleService() : new TerminatedLifecycleService(); }
@Override public LifecycleService getLifecycleService() { final HazelcastInstanceImpl hz = original; return hz != null ? hz.getLifecycleService() : new TerminatedLifecycleService(); }
@Override public void shutdown() { getLifecycleService().shutdown(); }
@Override public void shutdown() { getLifecycleService().shutdown(); }
@Override public void run() { final Node node = nodeEngine.getNode(); node.hazelcastInstance.getLifecycleService().shutdown(); } }, createThreadName(nodeEngine.getHazelcastInstance().getName(), ".clusterShutdown")).start();
@Override public void run() { final Node node = nodeEngine.getNode(); node.hazelcastInstance.getLifecycleService().shutdown(); } }, createThreadName(nodeEngine.getHazelcastInstance().getName(), ".clusterShutdown")).start();
/** * This is a best effort approach; there is no guarantee that events in publishers internal buffers will be fired, * {@link com.hazelcast.spi.EventService} can drop them. */ private void flushPublishersOnNodeShutdown() { Node node = ((NodeEngineImpl) this.nodeEngine).getNode(); LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService(); lifecycleService.addLifecycleListener(new LifecycleListener() { @Override public void stateChanged(LifecycleEvent event) { if (SHUTTING_DOWN == event.getState()) { publisherContext.flush(); } } }); }
/** * This is a best effort approach; there is no guarantee that events in publishers internal buffers will be fired, * {@link com.hazelcast.spi.EventService} can drop them. */ private void flushPublishersOnNodeShutdown() { Node node = ((NodeEngineImpl) this.nodeEngine).getNode(); LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService(); lifecycleService.addLifecycleListener(new LifecycleListener() { @Override public void stateChanged(LifecycleEvent event) { if (SHUTTING_DOWN == event.getState()) { publisherContext.flush(); } } }); }
@ManagedAnnotation(value = "shutdown", operation = true) @ManagedDescription("Shutdown the Node") public void shutdown() { managedObject.getLifecycleService().shutdown(); }
@ManagedAnnotation("running") @ManagedDescription("Running state") public boolean isRunning() { return managedObject.getLifecycleService().isRunning(); }
@Override public void run() { try { if (isRunning()) { logger.info("Running shutdown hook... Current state: " + state); switch (policy) { case TERMINATE: hazelcastInstance.getLifecycleService().terminate(); break; case GRACEFUL: hazelcastInstance.getLifecycleService().shutdown(); break; default: throw new IllegalArgumentException("Unimplemented shutdown hook policy: " + policy); } } } catch (Exception e) { logger.warning(e); } } }
@ManagedAnnotation("running") @ManagedDescription("Running state") public boolean isRunning() { return managedObject.getLifecycleService().isRunning(); }
@ManagedAnnotation(value = "shutdown", operation = true) @ManagedDescription("Shutdown the Node") public void shutdown() { managedObject.getLifecycleService().shutdown(); }
/** * Shutdowns a node by firing lifecycle events. Do not call this method for every node shutdown scenario * since {@link com.hazelcast.core.LifecycleListener}s will end up more than one * {@link com.hazelcast.core.LifecycleEvent.LifecycleState#SHUTTING_DOWN} * or {@link com.hazelcast.core.LifecycleEvent.LifecycleState#SHUTDOWN} events. * * @param node Node to shutdown. * @param terminate <code>false</code> for graceful shutdown, <code>true</code> for terminate (un-graceful shutdown) */ public static void shutdownNodeByFiringEvents(Node node, boolean terminate) { final HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance; final LifecycleServiceImpl lifecycleService = hazelcastInstance.getLifecycleService(); lifecycleService.fireLifecycleEvent(LifecycleEvent.LifecycleState.SHUTTING_DOWN); node.shutdown(terminate); lifecycleService.fireLifecycleEvent(LifecycleEvent.LifecycleState.SHUTDOWN); } }
/** * Shutdowns a node by firing lifecycle events. Do not call this method for every node shutdown scenario * since {@link com.hazelcast.core.LifecycleListener}s will end up more than one * {@link com.hazelcast.core.LifecycleEvent.LifecycleState#SHUTTING_DOWN} * or {@link com.hazelcast.core.LifecycleEvent.LifecycleState#SHUTDOWN} events. * * @param node Node to shutdown. * @param terminate <code>false</code> for graceful shutdown, <code>true</code> for terminate (un-graceful shutdown) */ public static void shutdownNodeByFiringEvents(Node node, boolean terminate) { final HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance; final LifecycleServiceImpl lifecycleService = hazelcastInstance.getLifecycleService(); lifecycleService.fireLifecycleEvent(LifecycleEvent.LifecycleState.SHUTTING_DOWN); node.shutdown(terminate); lifecycleService.fireLifecycleEvent(LifecycleEvent.LifecycleState.SHUTDOWN); } }
public void merge(Address newTargetAddress) { node.getJoiner().setTargetAddress(newTargetAddress); LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService(); lifecycleService.runUnderLifecycleLock(new ClusterMergeTask(node)); }
public void merge(Address newTargetAddress) { node.getJoiner().setTargetAddress(newTargetAddress); LifecycleServiceImpl lifecycleService = node.hazelcastInstance.getLifecycleService(); lifecycleService.runUnderLifecycleLock(new ClusterMergeTask(node)); }
private void shutdownNodes(final long timeoutNanos) { final Operation op = new ShutdownNodeOp(); logger.info("Sending shutting down operations to all members..."); Collection<Member> members = getMembers(NON_LOCAL_MEMBER_SELECTOR); final long startTime = System.nanoTime(); while ((System.nanoTime() - startTime) < timeoutNanos && !members.isEmpty()) { for (Member member : members) { nodeEngine.getOperationService().send(op, member.getAddress()); } try { Thread.sleep(CLUSTER_SHUTDOWN_SLEEP_DURATION_IN_MILLIS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.warning("Shutdown sleep interrupted. ", e); break; } members = getMembers(NON_LOCAL_MEMBER_SELECTOR); } logger.info("Number of other nodes remaining: " + getSize(NON_LOCAL_MEMBER_SELECTOR) + ". Shutting down itself."); final HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance; hazelcastInstance.getLifecycleService().shutdown(); }