com.hazelcast.core
Class OutOfMemoryHandler

java.lang.Object
  extended by com.hazelcast.core.OutOfMemoryHandler
Direct Known Subclasses:
ClientOutOfMemoryHandler

public abstract class OutOfMemoryHandler
extends Object

Handler for OutOfMemoryError

When an OutOfMemoryError is caught by Hazelcast threads, OutOfMemoryHandler is called for ALL HazelcastInstances knows by current JVM (actually ClassLoader).

Warning: OutOfMemoryHandler may not be called although JVM throws OutOfMemoryError. Because error may be thrown from an external (user thread) thread and Hazelcast may not be informed about OutOfMemoryError.

See Also:
OutOfMemoryError, Hazelcast.setOutOfMemoryHandler(OutOfMemoryHandler)

Constructor Summary
OutOfMemoryHandler()
           
 
Method Summary
protected  void inactivate(HazelcastInstance hazelcastInstance)
          Just inactivates HazelcastInstance; leaves threads, connections untouched.
abstract  void onOutOfMemory(OutOfMemoryError oom, HazelcastInstance[] hazelcastInstances)
          When an OutOfMemoryError is caught by Hazelcast threads, this method is called for ALL HazelcastInstances knows by current JVM (actually ClassLoader).
protected  void tryCloseConnections(HazelcastInstance hazelcastInstance)
          Tries to close server socket and connections to other HazelcastInstances.
protected  void tryShutdown(HazelcastInstance hazelcastInstance)
          Tries to shutdown HazelcastInstance forcefully; including closing sockets and connections, stopping threads etc.
protected  void tryStopThreads(HazelcastInstance hazelcastInstance)
          Tries to stop internal Hazelcast threads (such as service thread, IO threads, executor threads).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutOfMemoryHandler

public OutOfMemoryHandler()
Method Detail

onOutOfMemory

public abstract void onOutOfMemory(OutOfMemoryError oom,
                                   HazelcastInstance[] hazelcastInstances)
When an OutOfMemoryError is caught by Hazelcast threads, this method is called for ALL HazelcastInstances knows by current JVM (actually ClassLoader).

User can shutdown HazelcastInstance, call System.exit(), just log the error etc. Default handler tries to close socket connections to other nodes and shutdown HazelcastInstance.

Warning: OutOfMemoryHandler may not be called although JVM throws OutOfMemoryError. Because error may be thrown from an external (user thread) thread and Hazelcast may not be informed about OutOfMemoryError.

Parameters:
oom - OutOfMemoryError thrown by JVM
hazelcastInstances - All HazelcastInstances known by JVM, can include inactive or NULL instances.
See Also:
inactivate(HazelcastInstance), tryCloseConnections(HazelcastInstance), tryStopThreads(HazelcastInstance), tryShutdown(HazelcastInstance)

inactivate

protected final void inactivate(HazelcastInstance hazelcastInstance)
Just inactivates HazelcastInstance; leaves threads, connections untouched.

Parameters:
hazelcastInstance -

tryCloseConnections

protected final void tryCloseConnections(HazelcastInstance hazelcastInstance)
Tries to close server socket and connections to other HazelcastInstances.

Parameters:
hazelcastInstance -

tryStopThreads

protected final void tryStopThreads(HazelcastInstance hazelcastInstance)
Tries to stop internal Hazelcast threads (such as service thread, IO threads, executor threads).

Parameters:
hazelcastInstance -

tryShutdown

protected final void tryShutdown(HazelcastInstance hazelcastInstance)
Tries to shutdown HazelcastInstance forcefully; including closing sockets and connections, stopping threads etc.

Parameters:
hazelcastInstance -


Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.