All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.core.OutOfMemoryHandler Maven / Gradle / Ivy

There is a newer version: 5.0-BETA-1
Show newest version
/*
 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.core;

import com.hazelcast.instance.OutOfMemoryErrorDispatcher;

/**
 * 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 OutOfMemoryError * @see Hazelcast#setOutOfMemoryHandler(OutOfMemoryHandler) * */ public abstract class OutOfMemoryHandler { /** * 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. *

* * @see OutOfMemoryHandler#inactivate(HazelcastInstance) * @see OutOfMemoryHandler#tryCloseConnections(HazelcastInstance) * @see OutOfMemoryHandler#tryStopThreads(HazelcastInstance) * @see OutOfMemoryHandler#tryShutdown(HazelcastInstance) * * @param oom OutOfMemoryError thrown by JVM * @param hazelcastInstances All HazelcastInstances known by JVM, * can include inactive or NULL instances. */ public abstract void onOutOfMemory(OutOfMemoryError oom, HazelcastInstance[] hazelcastInstances); /** * Just inactivates HazelcastInstance; leaves threads, connections untouched. * * @param hazelcastInstance */ protected final void inactivate(final HazelcastInstance hazelcastInstance) { OutOfMemoryErrorDispatcher.Helper.inactivate(hazelcastInstance); } /** * Tries to close server socket and connections to other HazelcastInstances. * * @param hazelcastInstance */ protected final void tryCloseConnections(HazelcastInstance hazelcastInstance) { OutOfMemoryErrorDispatcher.Helper.tryCloseConnections(hazelcastInstance); } /** * Tries to stop internal Hazelcast threads (such as service thread, IO threads, executor threads). * * @param hazelcastInstance */ protected final void tryStopThreads(final HazelcastInstance hazelcastInstance) { OutOfMemoryErrorDispatcher.Helper.tryStopThreads(hazelcastInstance); } /** * Tries to shutdown HazelcastInstance forcefully; * including closing sockets and connections, stopping threads etc. * * @param hazelcastInstance */ protected final void tryShutdown(final HazelcastInstance hazelcastInstance) { OutOfMemoryErrorDispatcher.Helper.tryShutdown(hazelcastInstance); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy