summaryrefslogtreecommitdiffstats
path: root/ioam
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-08-11 14:05:30 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-08-14 08:20:18 +0000
commit2a39a0f17d82ecf7c75840d53960c42c6ea2c6ac (patch)
treebe89dcd0d219dc2ff9c928c77a4fc218458e071f /ioam
parent72493bf45a8823dbb2bc8e0745ebb7106a7ae01f (diff)
HONEYCOMB-381 - Usage of ShutdownHandler for jvpp components
and notification producer Change-Id: I70e749de5b290c84e86a28625d5ec79c98de80f2 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'ioam')
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java13
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java20
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java20
3 files changed, 21 insertions, 32 deletions
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
index 0ffc8dd94..a90bafee2 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.vppioam.impl.util;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
+import io.fd.honeycomb.data.init.ShutdownHandler;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.ioamexport.JVppIoamexportImpl;
import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade;
@@ -32,19 +33,15 @@ public class JVppIoamExportProvider extends ProviderTrait<FutureJVppIoamexportFa
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoamexportFacade create() {
try {
final JVppIoamexportImpl jVppIoamexport = new JVppIoamexportImpl();
// Free jvpp-ioam-export plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-export plugin");
- jVppIoamexport.close();
- LOG.info("Successfully unloaded jvpp-ioam-export plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioamexport", jVppIoamexport);
LOG.info("Successfully loaded jvpp-ioam-export plugin");
return new FutureJVppIoamexportFacade(registry, jVppIoamexport);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
index a8ae2dc70..03db9f01a 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
@@ -18,17 +18,17 @@ package io.fd.hc2vpp.vppioam.impl.util;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
+import io.fd.honeycomb.data.init.ShutdownHandler;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.ioampot.JVppIoampotImpl;
import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
/**
- * Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage.
- * Registers shutdown hook to free plugin's resources on shutdown.
+ * Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage. Registers shutdown hook to
+ * free plugin's resources on shutdown.
*/
public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFacade> {
@@ -37,19 +37,15 @@ public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFa
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoampotFacade create() {
try {
final JVppIoampotImpl jVppIoamPot = new JVppIoampotImpl();
// Free jvpp-ioam plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-pot plugin");
- jVppIoamPot.close();
- LOG.info("Successfully unloaded jvpp-ioam-pot plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioampot", jVppIoamPot);
LOG.info("Successfully loaded jvpp-ioam-pot plugin");
return new FutureJVppIoampotFacade(registry, jVppIoamPot);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
index caf098e2d..f7e15fb68 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
@@ -18,17 +18,17 @@ package io.fd.hc2vpp.vppioam.impl.util;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
+import io.fd.honeycomb.data.init.ShutdownHandler;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.ioamtrace.JVppIoamtraceImpl;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
/**
- * Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage.
- * Registers shutdown hook to free plugin's resources on shutdown.
+ * Provides future API for jvpp-ioam plugin. Must be a singleton due to shutdown hook usage. Registers shutdown hook to
+ * free plugin's resources on shutdown.
*/
public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
@@ -37,19 +37,15 @@ public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtra
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoamtraceFacade create() {
try {
final JVppIoamtraceImpl jVppIoamTr = new JVppIoamtraceImpl();
// Free jvpp-ioam plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-trace plugin");
- jVppIoamTr.close();
- LOG.info("Successfully unloaded jvpp-ioam-trace plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioamtrace", jVppIoamTr);
LOG.info("Successfully loaded jvpp-ioam-trace plugin");
return new FutureJVppIoamtraceFacade(registry, jVppIoamTr);