public static void inspectOutOfMemoryError(Throwable throwable) { if (throwable == null) { return; } if (throwable instanceof OutOfMemoryError) { onOutOfMemory((OutOfMemoryError) throwable); } }
public static void deregisterServer(HazelcastInstance instance) { deregister(SERVER_INSTANCES_REF, instance); }
private static void deregister(AtomicReference<HazelcastInstance[]> ref, HazelcastInstance instance) { isNotNull(instance, "instance"); for (;;) { HazelcastInstance[] oldInstances = ref.get(); int indexOf = indexOf(oldInstances, instance); if (indexOf == -1) { return; } HazelcastInstance[] newInstances; if (oldInstances.length == 1) { newInstances = EMPTY_INSTANCES; } else { newInstances = new HazelcastInstance[oldInstances.length - 1]; arraycopy(oldInstances, 0, newInstances, 0, indexOf); if (indexOf < newInstances.length) { arraycopy(oldInstances, indexOf + 1, newInstances, indexOf, newInstances.length - indexOf); } } if (ref.compareAndSet(oldInstances, newInstances)) { return; } } }
@Override public void run() { try { run0(); } catch (Throwable t) { inspectOutOfMemoryError(t); logger.severe(t); } }
public static void registerClient(HazelcastInstance instance) { register(CLIENT_INSTANCES_REF, instance); }
public static void shutdown(String instanceName) { HazelcastClientProxy proxy = INSTANCE.clients.remove(instanceName); if (proxy == null) { return; } HazelcastClientInstanceImpl client = proxy.client; if (client == null) { return; } proxy.client = null; try { client.shutdown(); } catch (Throwable ignored) { ignore(ignored); } finally { OutOfMemoryErrorDispatcher.deregisterClient(client); } }
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 void shutdownAll() { for (HazelcastClientProxy proxy : INSTANCE.clients.values()) { HazelcastClientInstanceImpl client = proxy.client; if (client == null) { continue; } proxy.client = null; try { client.shutdown(); } catch (Throwable ignored) { ignore(ignored); } } OutOfMemoryErrorDispatcher.clearClients(); INSTANCE.clients.clear(); }
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; } }
@Override public void run() { try { run0(); } catch (Throwable t) { inspectOutOfMemoryError(t); logger.severe(t); } }
public static void registerServer(HazelcastInstance instance) { register(SERVER_INSTANCES_REF, instance); }
/** * Shutdown the provided client and remove it from the managed list * * @param instanceName the hazelcast client instance name */ public static void shutdown(String instanceName) { HazelcastClientProxy proxy = CLIENTS.remove(instanceName); if (proxy == null) { return; } HazelcastClientInstanceImpl client = proxy.client; if (client == null) { return; } proxy.client = null; try { client.shutdown(); } catch (Throwable ignored) { EmptyStatement.ignore(ignored); } finally { OutOfMemoryErrorDispatcher.deregisterClient(client); } }
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()); } }
/** * Shuts down all the client HazelcastInstance created in this JVM. * <p/> * To be more precise it shuts down the HazelcastInstances loaded using the same classloader this HazelcastClient has been * loaded with. * <p/> * This method is mostly used for testing purposes. * * @see #getAllHazelcastClients() */ public static void shutdownAll() { for (HazelcastClientProxy proxy : CLIENTS.values()) { HazelcastClientInstanceImpl client = proxy.client; if (client == null) { continue; } proxy.client = null; try { client.shutdown(); } catch (Throwable ignored) { EmptyStatement.ignore(ignored); } } OutOfMemoryErrorDispatcher.clearClients(); CLIENTS.clear(); }
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; } }
public static void inspectOutOfMemoryError(Throwable throwable) { if (throwable == null) { return; } if (throwable instanceof OutOfMemoryError) { onOutOfMemory((OutOfMemoryError) throwable); } }
private void process(Runnable task) { processed.inc(); try { task.run(); } catch (Throwable e) { OutOfMemoryErrorDispatcher.inspectOutOfMemoryError(e); logger.severe(getName() + " caught an exception while processing:" + task, e); } }
public static void deregisterClient(HazelcastInstance instance) { deregister(CLIENT_INSTANCES_REF, instance); }
public static void registerServer(HazelcastInstance instance) { register(SERVER_INSTANCES_REF, instance); }
public static void shutdown(HazelcastInstance instance) { if (instance instanceof HazelcastClientProxy) { final HazelcastClientProxy proxy = (HazelcastClientProxy) instance; HazelcastClientInstanceImpl client = proxy.client; if (client == null) { return; } proxy.client = null; INSTANCE.clients.remove(client.getName()); try { client.shutdown(); } catch (Throwable ignored) { ignore(ignored); } finally { OutOfMemoryErrorDispatcher.deregisterClient(client); } } }