summaryrefslogtreecommitdiffstats
path: root/ioam/impl/src/main/java/io/fd
diff options
context:
space:
mode:
Diffstat (limited to 'ioam/impl/src/main/java/io/fd')
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java25
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java149
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java36
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java27
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java11
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java4
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java45
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java (renamed from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java)18
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java61
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java (renamed from ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java)15
10 files changed, 330 insertions, 61 deletions
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
index a378a0669..204d003c9 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/VppIoamModule.java
@@ -20,11 +20,14 @@ import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import io.fd.hc2vpp.vppioam.impl.config.VppIoamWriterFactory;
import io.fd.hc2vpp.vppioam.impl.oper.VppIoamReaderFactory;
-import io.fd.hc2vpp.vppioam.impl.util.JVppIoamProvider;
import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.hc2vpp.vppioam.impl.config.VppIoamWriterFactory;
+import io.fd.hc2vpp.vppioam.impl.util.JVppIoamPotProvider;
+import io.fd.hc2vpp.vppioam.impl.util.JVppIoamTraceProvider;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import org.slf4j.Logger;
@@ -36,28 +39,32 @@ import org.slf4j.LoggerFactory;
public final class VppIoamModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(VppIoamModule.class);
- private final Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamProviderClass;
+ private final Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamTraceProviderClass;
+ private final Class<? extends Provider<FutureJVppIoampotFacade>> jvppIoamPotProviderClass;
public VppIoamModule() {
- this(JVppIoamProvider.class);
+ this(JVppIoamTraceProvider.class, JVppIoamPotProvider.class);
}
@VisibleForTesting
- VppIoamModule(Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamProvider) {
- this.jvppIoamProviderClass = jvppIoamProvider;
+ VppIoamModule(Class<? extends Provider<FutureJVppIoamtraceFacade>> jvppIoamTraceProvider,
+ Class<? extends Provider<FutureJVppIoampotFacade>> jvppIoamPotProviderClass) {
+ this.jvppIoamTraceProviderClass = jvppIoamTraceProvider;
+ this.jvppIoamPotProviderClass = jvppIoamPotProviderClass;
}
@Override
protected void configure() {
- LOG.debug("Installing iOAM module");
+ LOG.info("Installing iOAM module");
// Bind to Plugin's JVPP.
- bind(FutureJVppIoamtrace.class).toProvider(jvppIoamProviderClass).in(Singleton.class);
+ bind(FutureJVppIoamtrace.class).toProvider(jvppIoamTraceProviderClass).in(Singleton.class);
+ bind(FutureJVppIoampot.class).toProvider(jvppIoamPotProviderClass).in(Singleton.class);
// Below are classes picked up by HC framework
Multibinder.newSetBinder(binder(), WriterFactory.class).addBinding().to(VppIoamWriterFactory.class);
Multibinder.newSetBinder(binder(), ReaderFactory.class).addBinding().to(VppIoamReaderFactory.class);
- LOG.debug("Module iOAM successfully configured");
+ LOG.info("Module iOAM successfully configured");
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java
new file mode 100644
index 000000000..6d80493a3
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamPotWriterCustomizer.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.fd.hc2vpp.vppioam.impl.config;
+
+
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoampotCustomizer;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileAdd;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileAddReply;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDel;
+import io.fd.vpp.jvpp.ioampot.dto.PotProfileDelReply;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import java.nio.charset.StandardCharsets;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profile.PotProfileList;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSet;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class IoamPotWriterCustomizer extends FutureJVppIoampotCustomizer implements
+ ListWriterCustomizer<PotProfileSet,PotProfileSetKey>, JvppReplyConsumer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(IoamPotWriterCustomizer.class);
+
+ public IoamPotWriterCustomizer(@Nonnull FutureJVppIoampot futureJVppIoampot) {
+ super(futureJVppIoampot);
+ }
+
+
+ /**
+ * Handle write operation. C from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataAfter New data to be written
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if write was unsuccessful
+ */
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataAfter, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ addPotProfile(dataAfter,id);
+ } catch (WriteFailedException exCreate) {
+ LOG.error("Add POT profile failed", exCreate);
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, exCreate);
+ }
+
+ LOG.info("POT profile added iid={}, added {}", id, dataAfter);
+ }
+
+ /**
+ * Handle update operation. U from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataBefore Old data
+ * @param dataAfter New, updated data
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if update was unsuccessful
+ */
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataBefore, @Nonnull PotProfileSet dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+ try {
+ delPotProfile(dataBefore,id);
+ addPotProfile(dataAfter,id);
+ } catch (WriteFailedException exUpdate) {
+ LOG.error("Update POT Profile failed", exUpdate);
+ throw new WriteFailedException.UpdateFailedException(id,dataBefore,dataAfter,exUpdate);
+ }
+
+ LOG.info("POT profile updated iid={}, added {}", id, dataAfter);
+ }
+
+ /**
+ * Handle delete operation. D from CRUD.
+ *
+ * @param id Identifier(from root) of data being written
+ * @param dataBefore Old data being deleted
+ * @param writeContext Write context can be used to store any useful information and then utilized by other customizers
+ * @throws WriteFailedException if delete was unsuccessful
+ */
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<PotProfileSet> id,
+ @Nonnull PotProfileSet dataBefore, @Nonnull WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ delPotProfile(dataBefore,id);
+ } catch (WriteFailedException exDelete) {
+ LOG.error("Del POT Profile failed", exDelete);
+ throw new WriteFailedException.DeleteFailedException(id, exDelete);
+ }
+
+ LOG.info("POT profile deleted iid={}, added {}", id, dataBefore);
+ }
+
+ private void addPotProfile(PotProfileSet potProfileSet, InstanceIdentifier<PotProfileSet> id) throws WriteFailedException{
+ for(PotProfileList potProfileList:potProfileSet.getPotProfileList()) {
+ writePotProfileList(potProfileList,potProfileSet.getName(),id);
+ }
+ }
+
+ private PotProfileAddReply writePotProfileList(PotProfileList potProfileList, String name,
+ InstanceIdentifier<PotProfileSet> id) throws WriteFailedException{
+ PotProfileAdd request = new PotProfileAdd();
+ request.id = potProfileList.getIndex().getValue().byteValue();
+ request.validator = (byte) (potProfileList.isValidator() ? 1 : 0);
+ request.secretKey = 1;
+ request.secretShare = potProfileList.getSecretShare().longValue();
+ request.prime = potProfileList.getPrimeNumber().longValue();
+ request.secretKey = potProfileList.getValidatorKey().longValue();
+ request.maxBits = 64;
+ request.lpc = potProfileList.getLpc().longValue();
+ request.polynomialPublic = potProfileList.getPublicPolynomial().longValue();
+ request.listNameLen = (byte) name.getBytes(StandardCharsets.UTF_8).length;
+ request.listName = name.getBytes(StandardCharsets.UTF_8);
+
+ return getReplyForWrite(getFutureJVppIoampot().potProfileAdd(request).toCompletableFuture(), id);
+ }
+
+ private PotProfileDelReply delPotProfile(PotProfileSet potProfileSet, InstanceIdentifier<PotProfileSet> id)
+ throws WriteFailedException{
+ PotProfileDel request = new PotProfileDel();
+ request.listNameLen = (byte)potProfileSet.getName().getBytes(StandardCharsets.UTF_8).length;
+ request.listName = potProfileSet.getName().getBytes(StandardCharsets.UTF_8);
+
+ return getReplyForWrite(getFutureJVppIoampot().potProfileDel(request).toCompletableFuture(),id);
+ }
+}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
index bab92fc5d..12347946f 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/IoamTraceWriterCustomizer.java
@@ -15,29 +15,20 @@
*/
package io.fd.hc2vpp.vppioam.impl.config;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamCustomizer;
-import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamtraceCustomizer;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
-
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAdd;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAddReply;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileDel;
import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileDelReply;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
-
import javax.annotation.Nonnull;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.IoamTraceConfig;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig.TraceOp;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.trace.config.NodeInterfaces;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfigKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.trace.config.NodeInterfaces;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,13 +36,13 @@ import org.slf4j.LoggerFactory;
/**
* Writer customizer responsible for Ioam Trace create/delete.
*/
-public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
+public class IoamTraceWriterCustomizer extends FutureJVppIoamtraceCustomizer
implements ListWriterCustomizer<TraceConfig, TraceConfigKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(IoamTraceWriterCustomizer.class);
- public IoamTraceWriterCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoam) {
- super(futureJVppIoam);
+ public IoamTraceWriterCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoamtrace) {
+ super(futureJVppIoamtrace);
}
@Override
@@ -61,7 +52,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
throws WriteFailedException {
try {
- addTraceConfig(dataCurr, writeContext, id);
+ addTraceConfig(dataCurr, id);
} catch (Exception exCreate) {
LOG.error("Add Trace Configuration failed", exCreate);
throw new WriteFailedException.CreateFailedException(id, dataCurr, exCreate);
@@ -77,7 +68,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
@Nonnull final WriteContext ctx) throws WriteFailedException {
try {
deleteTraceConfig(dataBefore, id);
- addTraceConfig(dataAfter, ctx, id);
+ addTraceConfig(dataAfter, id);
} catch (Exception exUpdate) {
LOG.error("Update Trace Configuration failed", exUpdate);
throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, exUpdate);
@@ -101,18 +92,17 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
}
public TraceProfileAddReply addTraceConfig(TraceConfig traceConfig,
- WriteContext ctx,
final InstanceIdentifier<TraceConfig> id) throws Exception {
TraceProfileAdd traceProfileAdd = new TraceProfileAdd();
- traceProfileAdd.traceType = (byte) traceConfig.getTraceType().byteValue(); //trace type
- traceProfileAdd.numElts = (byte) traceConfig.getTraceNumElt().byteValue(); //num of elts
+ traceProfileAdd.traceType = traceConfig.getTraceType().byteValue(); //trace type
+ traceProfileAdd.numElts = traceConfig.getTraceNumElt().byteValue(); //num of elts
traceProfileAdd.traceTsp = (byte) traceConfig.getTraceTsp().getIntValue(); // tsp
- traceProfileAdd.appData = (int) traceConfig.getTraceAppData().intValue(); // appdata
- traceProfileAdd.nodeId = (int) traceConfig.getNodeId().intValue(); // nodeid
+ traceProfileAdd.appData = traceConfig.getTraceAppData().intValue(); // appdata
+ traceProfileAdd.nodeId = traceConfig.getNodeId().intValue(); // nodeid
/* Write to VPP */
- final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoam().
+ final TraceProfileAddReply reply = getReplyForWrite((getFutureJVppIoamtrace().
traceProfileAdd(traceProfileAdd).
toCompletableFuture()), id);
return reply;
@@ -123,7 +113,7 @@ public class IoamTraceWriterCustomizer extends FutureJVppIoamCustomizer
TraceProfileDel del = new TraceProfileDel();
/* Write to VPP */
- TraceProfileDelReply reply = getReplyForWrite((getFutureJVppIoam().
+ TraceProfileDelReply reply = getReplyForWrite((getFutureJVppIoamtrace().
traceProfileDel(del).toCompletableFuture()), id);
return reply;
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
index a5773956c..f4b2cea19 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/config/VppIoamWriterFactory.java
@@ -20,27 +20,40 @@ import com.google.inject.Inject;
import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
-import javax.annotation.Nonnull;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.IoamTraceConfig;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev160512.ioam.trace.config.TraceConfig;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.PotProfiles;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev160615.pot.profiles.PotProfileSet;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtrace;
+
+import javax.annotation.Nonnull;
public class VppIoamWriterFactory implements WriterFactory {
@Nonnull
- private final FutureJVppIoamtrace jvppIoam;
+ private final FutureJVppIoamtrace jVppIoamtrace;
+ @Nonnull
+ private final FutureJVppIoampot jVppIoampot;
@Inject
- public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jvppIoam) {
- this.jvppIoam = jvppIoam;
+ public VppIoamWriterFactory(@Nonnull final FutureJVppIoamtrace jVppIoamtrace,
+ @Nonnull final FutureJVppIoampot jVppIoampot) {
+ this.jVppIoamtrace = jVppIoamtrace;
+ this.jVppIoampot = jVppIoampot;
}
@Override
public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
- // TraceConfig
+ // Trace Config
final InstanceIdentifier<TraceConfig> trId =
InstanceIdentifier.create(IoamTraceConfig.class).child(TraceConfig.class);
- registry.add(new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jvppIoam)));
+ registry.add(new GenericListWriter<>(trId, new IoamTraceWriterCustomizer(jVppIoamtrace)));
+ // POT Config
+ final InstanceIdentifier<PotProfileSet> potId =
+ InstanceIdentifier.create(PotProfiles.class).child(PotProfileSet.class);
+ registry.add(new GenericListWriter<>(potId, new IoamPotWriterCustomizer(jVppIoampot)));
+
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
index d378385ef..dee207b48 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/TraceProfileReaderCustomizer.java
@@ -17,7 +17,7 @@ package io.fd.hc2vpp.vppioam.impl.oper;
import com.google.common.collect.Lists;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamCustomizer;
+import io.fd.hc2vpp.vppioam.impl.util.FutureJVppIoamtraceCustomizer;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
@@ -37,13 +37,14 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class TraceProfileReaderCustomizer extends FutureJVppIoamCustomizer
+public class TraceProfileReaderCustomizer extends FutureJVppIoamtraceCustomizer
implements InitializingListReaderCustomizer<TraceConfig, TraceConfigKey, TraceConfigBuilder>, JvppReplyConsumer{
private static final Logger LOG = LoggerFactory.getLogger(TraceProfileReaderCustomizer.class);
- public TraceProfileReaderCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoam) {
- super(futureJVppIoam);
+ public TraceProfileReaderCustomizer(@Nonnull FutureJVppIoamtrace futureJVppIoamtrace) {
+
+ super(futureJVppIoamtrace);
}
/**
@@ -88,7 +89,7 @@ public class TraceProfileReaderCustomizer extends FutureJVppIoamCustomizer
LOG.debug("reading attribute for trace config {}",id);
final TraceProfileShowConfig request = new TraceProfileShowConfig();
- TraceProfileShowConfigReply reply = getReplyForRead(getFutureJVppIoam().traceProfileShowConfig(request)
+ TraceProfileShowConfigReply reply = getReplyForRead(getFutureJVppIoamtrace().traceProfileShowConfig(request)
.toCompletableFuture(),id);
if(reply == null) {
LOG.debug("{} returned null as reply from vpp",id);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
index 8c34f54e5..83fd5667a 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/oper/VppIoamReaderFactory.java
@@ -32,6 +32,7 @@ public class VppIoamReaderFactory implements ReaderFactory {
@Inject
VppIoamReaderFactory(FutureJVppIoamtrace jVppIoamtrace){
+
this.jVppIoamtrace = jVppIoamtrace;
}
@@ -49,6 +50,7 @@ public class VppIoamReaderFactory implements ReaderFactory {
//TraceConfig
final InstanceIdentifier<TraceConfig> traceConfigId = ioamTraceConfigId.child(TraceConfig.class);
- registry.add(new GenericInitListReader<>(traceConfigId,new TraceProfileReaderCustomizer(jVppIoamtrace)));
+ registry.add(new GenericInitListReader<>(traceConfigId,
+ new TraceProfileReaderCustomizer(jVppIoamtrace)));
}
}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java
new file mode 100755
index 000000000..f59f91e18
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoampotCustomizer.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.vppioam.impl.util;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampot;
+import javax.annotation.Nonnull;
+
+/**
+ * Abstract utility to hold the IoamApi reference.
+ */
+@Beta
+public abstract class FutureJVppIoampotCustomizer {
+
+ private final FutureJVppIoampot futureJVppIoampot;
+
+ public FutureJVppIoampotCustomizer(@Nonnull final FutureJVppIoampot futureJVppIoampot) {
+ this.futureJVppIoampot = Preconditions.checkNotNull(futureJVppIoampot,
+ "futureJVppIoampot should not be null");
+ }
+
+ /**
+ * Get Ioam POT Api reference
+ *
+ * @return Ioam POT Api reference
+ */
+ public FutureJVppIoampot getFutureJVppIoampot() {
+ return futureJVppIoampot;
+ }
+}
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java
index a93ea379c..8a5d2833c 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamCustomizer.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/FutureJVppIoamtraceCustomizer.java
@@ -25,21 +25,21 @@ import javax.annotation.Nonnull;
* Abstract utility to hold the IoamApi reference.
*/
@Beta
-public abstract class FutureJVppIoamCustomizer {
+public abstract class FutureJVppIoamtraceCustomizer {
- private final FutureJVppIoamtrace futureJVppIoam;
+ private final FutureJVppIoamtrace futureJVppIoamtrace;
- public FutureJVppIoamCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoam) {
- this.futureJVppIoam = Preconditions.checkNotNull(futureJVppIoam,
- "futureJVppIoam should not be null");
+ public FutureJVppIoamtraceCustomizer(@Nonnull final FutureJVppIoamtrace futureJVppIoamtrace) {
+ this.futureJVppIoamtrace = Preconditions.checkNotNull(futureJVppIoamtrace,
+ "futureJVppIoamtrace should not be null");
}
/**
- * Get IoamApi reference
+ * Get Ioam Trace Api reference
*
- * @return IoamApi reference
+ * @return Ioam trace Api reference
*/
- public FutureJVppIoamtrace getFutureJVppIoam() {
- return futureJVppIoam;
+ public FutureJVppIoamtrace getFutureJVppIoamtrace() {
+ return futureJVppIoamtrace;
}
}
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
new file mode 100644
index 000000000..bd560a762
--- /dev/null
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Cisco and its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.vppioam.impl.util;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.infra.distro.ProviderTrait;
+import io.fd.vpp.jvpp.JVppRegistry;
+import io.fd.vpp.jvpp.ioampot.JVppIoampotImpl;
+import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
+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.
+ */
+public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFacade> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JVppIoamPotProvider.class);
+
+ @Inject
+ private JVppRegistry registry;
+
+ @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");
+ }
+ });
+
+ LOG.info("Successfully loaded jvpp-ioam-pot plugin");
+ return new FutureJVppIoampotFacade(registry, jVppIoamPot);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to open VPP management connection", e);
+ }
+ }
+}
+
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
index 0b5e3e79e..697cd1255 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
@@ -18,20 +18,21 @@ package io.fd.hc2vpp.vppioam.impl.util;
import com.google.inject.Inject;
import io.fd.honeycomb.infra.distro.ProviderTrait;
-import java.io.IOException;
import io.fd.vpp.jvpp.JVppRegistry;
-import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
import io.fd.vpp.jvpp.ioamtrace.JVppIoamtraceImpl;
+import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
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.
*/
-public final class JVppIoamProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
+public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
- private static final Logger LOG = LoggerFactory.getLogger(JVppIoamProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(JVppIoamTraceProvider.class);
@Inject
private JVppRegistry registry;
@@ -44,13 +45,13 @@ public final class JVppIoamProvider extends ProviderTrait<FutureJVppIoamtraceFac
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
- LOG.info("Unloading jvpp-ioam plugin");
+ LOG.info("Unloading jvpp-ioam-trace plugin");
jVppIoamTr.close();
- LOG.info("Successfully unloaded jvpp-ioam plugin");
+ LOG.info("Successfully unloaded jvpp-ioam-trace plugin");
}
});
- LOG.info("Successfully loaded jvpp-ioam plugin");
+ LOG.info("Successfully loaded jvpp-ioam-trace plugin");
return new FutureJVppIoamtraceFacade(registry, jVppIoamTr);
} catch (IOException e) {
throw new IllegalStateException("Unable to open VPP management connection", e);