public void shutdown() { //TODO should this be shutdown? hazelcastInstance.getLifecycleService().terminate(); portToHazelcastManagerMap.remove(getHazelcastPort()); }
public void kill() { if (connectionFactory != null) { connectionFactory.shutdown(); connectionFactory = null; } if (hazelcast != null) { hazelcast.getLifecycleService().terminate(); hazelcast = null; } }
public static void main(String[] args) { HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(null); HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(null); // initialize partitions instance1.getMap("map1").put(0, 0); instance1.getPartitionService().addPartitionLostListener(new PartitionLostListener() { @Override public void partitionLost(PartitionLostEvent event) { System.out.println("Instance2 has lost a partition for data with 0 backup! " + event); } }); instance2.getLifecycleService().terminate(); } }
private Thread shutdownHookThread(NodeEngine nodeEngine) { return new Thread(() -> { String policy = nodeEngine.getProperties().getString(SHUTDOWNHOOK_POLICY); if (policy.equals("TERMINATE")) { jetInstance.getHazelcastInstance().getLifecycleService().terminate(); } else { jetInstance.shutdown(); } }, "jet.ShutdownThread"); } }
@Override public void onApplicationEvent(final ContextClosedEvent event) { log.info("Stopping context detected, shutdown the Hazelcast instance"); // Get any cache to retrieve the Hazelcast instance final String name = cacheManager.getCacheNames().iterator().next(); final AbstractDistributedObject<?> cache = (AbstractDistributedObject<?>) cacheManager.getCache(name) .getNativeCache(); try { cache.getNodeEngine().getHazelcastInstance().getLifecycleService().terminate(); } catch (HazelcastInstanceNotActiveException he) { log.info("Hazelcast node was already terminated"); } } }
public static void closeDataNodes(List<HazelcastInstance> dataNodes) throws Exception { for (HazelcastInstance dataNode : dataNodes) { dataNode.getLifecycleService().terminate(); } }
public static void main(String[] args) throws Exception { HazelcastInstance[] instances = new HazelcastInstance[3]; instances[0] = Hazelcast.newHazelcastInstance(); instances[1] = Hazelcast.newHazelcastInstance(); instances[2] = Hazelcast.newHazelcastInstance(); String key = generateKeyOwnedBy(instances[1]); IScheduledExecutorService scheduler = instances[0].getScheduledExecutorService("scheduler"); IScheduledFuture<String> future = scheduler.scheduleOnKeyOwner(new EchoTask("My Task"), key, 5, TimeUnit.SECONDS); instances[1].getLifecycleService().terminate(); Object result = future.get(); System.out.println("Result: " + result); future.dispose(); Hazelcast.shutdownAll(); } }
taskOwner.getLifecycleService().terminate();
private static void shutdownAll(boolean terminate) { List<HazelcastInstanceProxy> instances = new LinkedList<HazelcastInstanceProxy>(); for (InstanceFuture future : INSTANCE_MAP.values()) { try { HazelcastInstanceProxy instanceProxy = future.get(); instances.add(instanceProxy); } catch (RuntimeException ignored) { ignore(ignored); } } INSTANCE_MAP.clear(); OutOfMemoryErrorDispatcher.clearServers(); ManagementService.shutdownAll(instances); Collections.sort(instances, new Comparator<HazelcastInstanceProxy>() { public int compare(HazelcastInstanceProxy o1, HazelcastInstanceProxy o2) { return o1.getName().compareTo(o2.getName()); } }); for (HazelcastInstanceProxy proxy : instances) { if (terminate) { proxy.getLifecycleService().terminate(); } else { proxy.getLifecycleService().shutdown(); } proxy.original = null; } }
private static void shutdownAll(boolean terminate) { List<HazelcastInstanceProxy> instances = new LinkedList<HazelcastInstanceProxy>(); for (InstanceFuture future : INSTANCE_MAP.values()) { try { HazelcastInstanceProxy instanceProxy = future.get(); instances.add(instanceProxy); } catch (RuntimeException ignored) { ignore(ignored); } } INSTANCE_MAP.clear(); OutOfMemoryErrorDispatcher.clearServers(); ManagementService.shutdownAll(instances); Collections.sort(instances, new Comparator<HazelcastInstanceProxy>() { public int compare(HazelcastInstanceProxy o1, HazelcastInstanceProxy o2) { return o1.getName().compareTo(o2.getName()); } }); for (HazelcastInstanceProxy proxy : instances) { if (terminate) { proxy.getLifecycleService().terminate(); } else { proxy.getLifecycleService().shutdown(); } proxy.original = null; } }
instance2.getLifecycleService().terminate();
@Override public void stop() { log.info( String.format( "HazelcastCoreTopologyService stopping and unbinding from %s", config.get( CoreEdgeClusterSettings.discovery_listen_address ) ) ); try { hazelcastInstance.getCluster().removeMembershipListener( membershipRegistrationId ); hazelcastInstance.getMap( EDGE_SERVER_BOLT_ADDRESS_MAP_NAME ).removeEntryListener( mapRegistrationId ); hazelcastInstance.getLifecycleService().terminate(); } catch ( Throwable e ) { log.warn( "Failed to stop Hazelcast", e ); } finally { jobHandle.cancel( true ); } }
System.out.println(entry.getKey() + ": " + entry.getValue()); client.getLifecycleService().terminate(); ctx.stop();
serverInstance2.getLifecycleService().terminate();
@Test public void testMigrationEvent() { final IMap<Integer, String> distributedMap = hazelcastInstance3.getMap("Test_Distributed_Map2"); distributedMap.put(1, "TestValue1"); distributedMap.put(2, "TestValue2"); hazelcastInstance3.getLifecycleService().terminate(); final Message<?> msg = this.cmChannel3.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); verifyMigrationEvent(msg); }
private void testClientEventByChannelAndGroupName(final PollableChannel channel, final String groupName) { final HazelcastInstance client = getHazelcastClientByGroupName(groupName); Message<?> msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); verifyClientEvent(msg); client.getLifecycleService().terminate(); msg = channel.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); verifyClientEvent(msg); }
@Test public void testLifecycleEvent() { hazelcastInstance2.getLifecycleService().terminate(); Message<?> msg = cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); verifyLifecycleEvent(msg, LifecycleState.SHUTTING_DOWN); msg = cmChannel4.receive(HazelcastInboundChannelAdapterTestUtils.TIMEOUT); verifyLifecycleEvent(msg, LifecycleState.SHUTDOWN); }