public static Set<HazelcastInstance> getAllHazelcastInstances() { Set<HazelcastInstance> result = createHashSet(INSTANCE_MAP.size()); for (InstanceFuture f : INSTANCE_MAP.values()) { result.add(f.get()); } return result; }
future.set(proxy); hazelcastInstance.lifecycleService.fireLifecycleEvent(STARTED); } catch (Throwable t) {
future.set(proxy); hazelcastInstance.lifecycleService.fireLifecycleEvent(STARTED); } catch (Throwable t) {
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; } }
/** * Creates a new Hazelcast instance. * * @param config the configuration to use; if <code>null</code>, the set of defaults * as specified in the XSD for the configuration XML will be used. * @param instanceName the name of the {@link HazelcastInstance} * @param nodeContext the {@link NodeContext} to use * @return the configured {@link HazelcastInstance} */ public static HazelcastInstance newHazelcastInstance(Config config, String instanceName, NodeContext nodeContext) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = getInstanceName(instanceName, config); InstanceFuture future = new InstanceFuture(); if (INSTANCE_MAP.putIfAbsent(name, future) != null) { throw new DuplicateInstanceNameException("HazelcastInstance with name '" + name + "' already exists!"); } try { return constructHazelcastInstance(config, name, nodeContext, future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
/** * Creates a new Hazelcast instance. * * @param config the configuration to use; if <code>null</code>, the set of defaults * as specified in the XSD for the configuration XML will be used. * @param instanceName the name of the {@link HazelcastInstance} * @param nodeContext the {@link NodeContext} to use * @return the configured {@link HazelcastInstance} */ public static HazelcastInstance newHazelcastInstance(Config config, String instanceName, NodeContext nodeContext) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = getInstanceName(instanceName, config); InstanceFuture future = new InstanceFuture(); if (INSTANCE_MAP.putIfAbsent(name, future) != null) { throw new DuplicateInstanceNameException("HazelcastInstance with name '" + name + "' already exists!"); } try { return constructHazelcastInstance(config, name, nodeContext, future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = config.getInstanceName(); checkHasText(name, "instanceName must contain text"); InstanceFuture future = INSTANCE_MAP.get(name); if (future != null) { return future.get(); } future = new InstanceFuture(); InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future); if (found != null) { return found.get(); } try { return constructHazelcastInstance(config, name, new DefaultNodeContext(), future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
public static HazelcastInstance getOrCreateHazelcastInstance(Config config) { if (config == null) { config = new XmlConfigBuilder().build(); } String name = config.getInstanceName(); checkHasText(name, "instanceName must contain text"); InstanceFuture future = INSTANCE_MAP.get(name); if (future != null) { return future.get(); } future = new InstanceFuture(); InstanceFuture found = INSTANCE_MAP.putIfAbsent(name, future); if (found != null) { return found.get(); } try { return constructHazelcastInstance(config, name, new DefaultNodeContext(), future); } catch (Throwable t) { INSTANCE_MAP.remove(name, future); future.setFailure(t); throw ExceptionUtil.rethrow(t); } }
public static void remove(HazelcastInstanceImpl instance) { OutOfMemoryErrorDispatcher.deregisterServer(instance); InstanceFuture future = INSTANCE_MAP.remove(instance.getName()); if (future != null && future.isSet()) { future.get().original = null; } if (INSTANCE_MAP.size() == 0) { ManagementService.shutdown(instance.getName()); } }
public static Set<HazelcastInstance> getAllHazelcastInstances() { Set<HazelcastInstance> result = createHashSet(INSTANCE_MAP.size()); for (InstanceFuture f : INSTANCE_MAP.values()) { result.add(f.get()); } return result; }
public static HazelcastInstance getHazelcastInstance(String instanceName) { InstanceFuture instanceFuture = INSTANCE_MAP.get(instanceName); if (instanceFuture == null) { return null; } try { return instanceFuture.get(); } catch (IllegalStateException t) { return null; } }
public static void remove(HazelcastInstanceImpl instance) { OutOfMemoryErrorDispatcher.deregisterServer(instance); InstanceFuture future = INSTANCE_MAP.remove(instance.getName()); if (future != null && future.isSet()) { future.get().original = null; } if (INSTANCE_MAP.size() == 0) { ManagementService.shutdown(instance.getName()); } }
public static HazelcastInstance getHazelcastInstance(String instanceName) { InstanceFuture instanceFuture = INSTANCE_MAP.get(instanceName); if (instanceFuture == null) { return null; } try { return instanceFuture.get(); } catch (IllegalStateException t) { return null; } }