summaryrefslogtreecommitdiffstats
path: root/vpp-common
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-07-16 09:05:42 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-07-17 18:40:00 +0000
commit220404db4488c6562f50f4b45ba75c8c256c8121 (patch)
tree4779f2d71f5e9ed6a7fae1bd0ad941ac088eeb72 /vpp-common
parentbbf757556378fa52b0b0446d19b0c4cf806c9cef (diff)
HC2VPP-176: add support for api-segment prefix
VPP can be run with custom SHM segment prefix: sudo vpp unix {cli-listen /run/vpp/cli-vpp1.sock} api-segment { prefix vpp1 } sudo vppctl -s /run/vpp/cli-vpp1.sock this patch adds optional api-segment-prefix parameter to /opt/honeycomb/config/jvpp.json file. Example configuration: { "jvpp-connection-name": "honeycomb", "api-segment-prefix": "vpp1", "jvpp-request-timeout": 5 } Change-Id: I7ca298644891602afe7898db88bb90d59b49ce4d Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-common')
-rw-r--r--vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/JVppRegistryProvider.java19
-rw-r--r--vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/VppConfigAttributes.java4
2 files changed, 16 insertions, 7 deletions
diff --git a/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/JVppRegistryProvider.java b/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/JVppRegistryProvider.java
index 300e03806..1432f2c53 100644
--- a/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/JVppRegistryProvider.java
+++ b/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/JVppRegistryProvider.java
@@ -16,6 +16,9 @@
package io.fd.hc2vpp.common.integration;
+import static com.google.common.base.Preconditions.checkState;
+import static java.lang.String.format;
+
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import com.google.common.primitives.UnsignedInts;
@@ -25,15 +28,11 @@ import io.fd.honeycomb.data.init.ShutdownHandler;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.VppJNIConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
-
-import static com.google.common.base.Preconditions.checkState;
-import static java.lang.String.format;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Provides JVppRegistry. Must be a singleton due to shutdown hook usage. Registers shutdown hook to disconnect from
@@ -54,7 +53,13 @@ public final class JVppRegistryProvider extends ProviderTrait<JVppRegistry> {
protected JVppRegistry create() {
final JVppRegistry registry;
try {
- registry = new JVppRegistryImpl(config.jvppConnectionName);
+ if (config.apiSegmentPrefix.isPresent()) {
+ // TODO(VPP-1342): JVppRegistryImpl requires full SHM region name
+ final String shmName = String.format("/%s-vpe-api", config.apiSegmentPrefix.get());
+ registry = new JVppRegistryImpl(config.jvppConnectionName, shmName);
+ } else {
+ registry = new JVppRegistryImpl(config.jvppConnectionName);
+ }
connectedVppPid = initConnectedVppPid(registry);
shutdownHandler.register("jvpp-registry", () -> {
// Closing JVpp connection with shutdown hook to erase the connection from VPP so HC will be able
diff --git a/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/VppConfigAttributes.java b/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/VppConfigAttributes.java
index 9c351cb7c..ba1a843a4 100644
--- a/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/VppConfigAttributes.java
+++ b/vpp-common/vpp-common-integration/src/main/java/io/fd/hc2vpp/common/integration/VppConfigAttributes.java
@@ -16,6 +16,7 @@
package io.fd.hc2vpp.common.integration;
+import java.util.Optional;
import net.jmob.guice.conf.core.BindConfig;
import net.jmob.guice.conf.core.InjectConfig;
import net.jmob.guice.conf.core.Syntax;
@@ -26,6 +27,9 @@ public class VppConfigAttributes {
@InjectConfig("jvpp-connection-name")
public String jvppConnectionName;
+ @InjectConfig("api-segment-prefix")
+ public Optional<String> apiSegmentPrefix;
+
@InjectConfig("jvpp-request-timeout")
public int jvppRequestTimeout;
}