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);
}
Aggregations