summaryrefslogtreecommitdiffstats
path: root/vpp-common/minimal-distribution/src
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-common/minimal-distribution/src')
-rw-r--r--vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/JVppRegistryProvider.java7
-rw-r--r--vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/VppCommonModule.java2
2 files changed, 9 insertions, 0 deletions
diff --git a/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/JVppRegistryProvider.java b/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/JVppRegistryProvider.java
index 8605fa0cc..33756f273 100644
--- a/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/JVppRegistryProvider.java
+++ b/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/JVppRegistryProvider.java
@@ -18,6 +18,7 @@ package io.fd.honeycomb.vpp.distro;
import com.google.inject.Inject;
import io.fd.honeycomb.infra.distro.ProviderTrait;
+import io.fd.honeycomb.translate.v3po.util.VppStatusListener;
import java.io.IOException;
import org.openvpp.jvpp.JVppRegistry;
import org.openvpp.jvpp.JVppRegistryImpl;
@@ -34,6 +35,8 @@ public final class JVppRegistryProvider extends ProviderTrait<JVppRegistry> {
@Inject
private VppConfigAttributes config;
+ @Inject
+ private VppStatusListener vppStatus;
@Override
protected JVppRegistryImpl create() {
@@ -47,6 +50,10 @@ public final class JVppRegistryProvider extends ProviderTrait<JVppRegistry> {
@Override
public void run() {
LOG.info("Disconnecting from VPP");
+ if (vppStatus.isDown()) {
+ LOG.info("VPP is down. JVppRegistry cleanup is not needed. Exiting");
+ return;
+ }
try {
registry.close();
LOG.info("Successfully disconnected from VPP as {}", config.jvppConnectionName);
diff --git a/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/VppCommonModule.java b/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/VppCommonModule.java
index 87352356b..93ec559b5 100644
--- a/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/VppCommonModule.java
+++ b/vpp-common/minimal-distribution/src/main/java/io/fd/honeycomb/vpp/distro/VppCommonModule.java
@@ -20,6 +20,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.v3po.util.VppStatusListener;
import net.jmob.guice.conf.core.ConfigurationModule;
import org.openvpp.jvpp.JVppRegistry;
import org.openvpp.jvpp.core.future.FutureJVppCore;
@@ -31,6 +32,7 @@ public final class VppCommonModule extends AbstractModule {
// Inject non-dependency configuration
requestInjection(VppConfigAttributes.class);
+ bind(VppStatusListener.class).toInstance(new VppStatusListener());
bind(JVppRegistry.class).toProvider(JVppRegistryProvider.class).in(Singleton.class);
bind(FutureJVppCore.class).toProvider(JVppCoreProvider.class).in(Singleton.class);