Şu satırı dahil ederiz
import com.hazelcast.instance.imp.NodeShutdownHookThread;
Örnek
Şöyle yaparız. Böylece kill -15 ile SIGTERM gönderilirse graceful shutdown yapılır
<property name="hazelcast.shutdownhook.enabled">true</property>
<property name="hazelcast.shutdownhook.policy">GRACEFUL</property>
Açıklaması şöyle
... when the process is terminated by SIGTERM the JVM invokes registered shutdown hooks with no defined sequence (or maybe even in parallel).So our own shutdown hook that handles graceful shutdown may run in parallel or after a shutdown hook registered by the logging implementation that closes loggers
Kod şöyle
switch (policy) {
case TERMINATE:
hazelcastInstance.getLifecycleService().terminate();
break;
case GRACEFUL:
hazelcastInstance.getLifecycleService().shutdown();
break;
default:
throw new IllegalArgumentException("Unimplemented shutdown hook policy: " + policy);
}
Hiç yorum yok:
Yorum Gönder