Search in sources :

Example 1 with OCallableNoParamNoReturn

use of com.orientechnologies.common.util.OCallableNoParamNoReturn in project orientdb by orientechnologies.

the class OHazelcastPlugin method shutdown.

@Override
public void shutdown() {
    if (!enabled)
        return;
    Orient.instance().getSignalHandler().unregisterListener(signalListener);
    for (OServerNetworkListener nl : serverInstance.getNetworkListeners()) nl.unregisterBeforeConnectNetworkEventListener(this);
    OLogManager.instance().warn(this, "Shutting down node '%s'...", nodeName);
    setNodeStatus(NODE_STATUS.SHUTTINGDOWN);
    try {
        final Set<String> databases = new HashSet<String>();
        if (hazelcastInstance.getLifecycleService().isRunning())
            for (Map.Entry<String, Object> entry : configurationMap.entrySet()) {
                if (entry.getKey().toString().startsWith(CONFIG_DBSTATUS_PREFIX)) {
                    final String nodeDb = entry.getKey().toString().substring(CONFIG_DBSTATUS_PREFIX.length());
                    if (nodeDb.startsWith(nodeName))
                        databases.add(entry.getKey());
                }
            }
        // PUT DATABASES AS NOT_AVAILABLE
        for (String k : databases) configurationMap.put(k, DB_STATUS.NOT_AVAILABLE);
    } catch (HazelcastInstanceNotActiveException e) {
    // HZ IS ALREADY DOWN, IGNORE IT
    }
    try {
        super.shutdown();
    } catch (HazelcastInstanceNotActiveException e) {
    // HZ IS ALREADY DOWN, IGNORE IT
    }
    if (membershipListenerRegistration != null) {
        try {
            hazelcastInstance.getCluster().removeMembershipListener(membershipListenerRegistration);
        } catch (HazelcastInstanceNotActiveException e) {
        // HZ IS ALREADY DOWN, IGNORE IT
        }
    }
    if (hazelcastInstance != null)
        try {
            hazelcastInstance.shutdown();
        } catch (Exception e) {
            OLogManager.instance().error(this, "Error on shutting down Hazelcast instance", e);
        } finally {
            hazelcastInstance = null;
        }
    OCallableUtils.executeIgnoringAnyExceptions(new OCallableNoParamNoReturn() {

        @Override
        public void call() {
            configurationMap.destroy();
        }
    });
    OCallableUtils.executeIgnoringAnyExceptions(new OCallableNoParamNoReturn() {

        @Override
        public void call() {
            configurationMap.getHazelcastMap().removeEntryListener(membershipListenerMapRegistration);
        }
    });
    setNodeStatus(NODE_STATUS.OFFLINE);
}
Also used : OCallableNoParamNoReturn(com.orientechnologies.common.util.OCallableNoParamNoReturn) OServerNetworkListener(com.orientechnologies.orient.server.network.OServerNetworkListener) OException(com.orientechnologies.common.exception.OException) OInterruptedException(com.orientechnologies.common.concur.lock.OInterruptedException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) ODatabaseException(com.orientechnologies.orient.core.exception.ODatabaseException) IOException(java.io.IOException) OOfflineNodeException(com.orientechnologies.common.concur.OOfflineNodeException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)1 OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)1 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1 OException (com.orientechnologies.common.exception.OException)1 OCallableNoParamNoReturn (com.orientechnologies.common.util.OCallableNoParamNoReturn)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 OServerNetworkListener (com.orientechnologies.orient.server.network.OServerNetworkListener)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1