From 31f01fcfadf8707aefe6bf3a09daf570ce248fc5 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Fri, 19 Aug 2016 12:20:33 +0200 Subject: HONEYCOMB-18 Fixing comments from reviews Change-Id: Ic0565d601d13b5f50ec3c714a43600e32a7e456b Signed-off-by: Maros Marsalek --- v3po/v3po2vpp/pom.xml | 18 -------- .../io/fd/honeycomb/translate/v3po/V3poModule.java | 19 ++------ .../v3po/VppStateHoneycombReaderFactory.java | 8 ++-- .../v3po/initializers/VppClasifierInitializer.java | 52 ---------------------- .../initializers/VppClassifierInitializer.java | 52 ++++++++++++++++++++++ 5 files changed, 59 insertions(+), 90 deletions(-) delete mode 100644 v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClasifierInitializer.java create mode 100644 v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClassifierInitializer.java (limited to 'v3po') diff --git a/v3po/v3po2vpp/pom.xml b/v3po/v3po2vpp/pom.xml index 4848ae949..62fced58d 100644 --- a/v3po/v3po2vpp/pom.xml +++ b/v3po/v3po2vpp/pom.xml @@ -55,29 +55,11 @@ ${project.version} - - - org.opendaylight.controller - config-util - 0.4.2-Beryllium-SR2 - - - org.opendaylight.controller - threadpool-config-api - 0.4.2-Beryllium-SR2 - - - io.fd.honeycomb translate-impl ${project.version} - - io.fd.honeycomb.vpp - vpp-jvpp-cfg - ${project.version} - io.fd.honeycomb cfg-init diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/V3poModule.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/V3poModule.java index aafd0154a..4effb70e3 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/V3poModule.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/V3poModule.java @@ -24,7 +24,7 @@ import io.fd.honeycomb.notification.ManagedNotificationProducer; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.v3po.cfgattrs.V3poConfiguration; import io.fd.honeycomb.translate.v3po.initializers.InterfacesInitializer; -import io.fd.honeycomb.translate.v3po.initializers.VppClasifierInitializer; +import io.fd.honeycomb.translate.v3po.initializers.VppClassifierInitializer; import io.fd.honeycomb.translate.v3po.initializers.VppInitializer; import io.fd.honeycomb.translate.v3po.notification.InterfaceChangeNotificationProducer; import io.fd.honeycomb.translate.v3po.util.NamingContext; @@ -32,7 +32,6 @@ import io.fd.honeycomb.translate.write.WriterFactory; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import net.jmob.guice.conf.core.ConfigurationModule; -import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; public class V3poModule extends AbstractModule { @@ -53,19 +52,7 @@ public class V3poModule extends AbstractModule { .toInstance(new NamingContext("classify-table-", "classify-table-context")); // Executor needed for keepalives - // TODO-minimal remove the funny wrapper. it is only here because of config subsystem - final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); - bind(ScheduledThreadPool.class).toInstance(new ScheduledThreadPool() { - @Override - public ScheduledExecutorService getExecutor() { - return executor; - } - - @Override - public int getMaxThreadCount() { - return 1; - } - }); + bind(ScheduledExecutorService.class).toInstance(Executors.newScheduledThreadPool(1)); // Readers final Multibinder readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class); @@ -83,7 +70,7 @@ public class V3poModule extends AbstractModule { final Multibinder initializerBinder = Multibinder.newSetBinder(binder(), DataTreeInitializer.class); initializerBinder.addBinding().to(InterfacesInitializer.class); - initializerBinder.addBinding().to(VppClasifierInitializer.class); + initializerBinder.addBinding().to(VppClassifierInitializer.class); initializerBinder.addBinding().to(VppInitializer.class); // Notifications diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/VppStateHoneycombReaderFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/VppStateHoneycombReaderFactory.java index f39502c09..d8e4f29b5 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/VppStateHoneycombReaderFactory.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/VppStateHoneycombReaderFactory.java @@ -28,7 +28,7 @@ import io.fd.honeycomb.translate.v3po.util.ReadTimeoutException; import io.fd.honeycomb.translate.v3po.vppstate.BridgeDomainCustomizer; import io.fd.honeycomb.translate.v3po.vppstate.L2FibEntryCustomizer; import io.fd.honeycomb.translate.v3po.vppstate.VersionCustomizer; -import org.opendaylight.controller.config.threadpool.ScheduledThreadPool; +import java.util.concurrent.ScheduledExecutorService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppState; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.L2FibTable; @@ -50,13 +50,13 @@ public final class VppStateHoneycombReaderFactory implements ReaderFactory, Auto private final FutureJVpp jVpp; private final NamingContext ifcCtx; private final NamingContext bdCtx; - private final ScheduledThreadPool keepaliveExecutor; + private final ScheduledExecutorService keepaliveExecutor; @Inject public VppStateHoneycombReaderFactory(final FutureJVpp jVpp, @Named("interface-context") final NamingContext ifcCtx, @Named("bridge-domain-context") final NamingContext bdCtx, - final ScheduledThreadPool keepaliveExecutorDependency) { + final ScheduledExecutorService keepaliveExecutorDependency) { this.jVpp = jVpp; this.ifcCtx = ifcCtx; this.bdCtx = bdCtx; @@ -75,7 +75,7 @@ public final class VppStateHoneycombReaderFactory implements ReaderFactory, Auto // is truly generic registry.add(new KeepaliveReaderWrapper<>( new GenericReader<>(vppStateId.child(Version.class), new VersionCustomizer(jVpp)), - keepaliveExecutor.getExecutor(), ReadTimeoutException.class, 30, + keepaliveExecutor, ReadTimeoutException.class, 30, // FIXME-minimal trigger jvpp reinitialization here () -> LOG.error("Keepalive failed. VPP is probably DOWN!"))); // BridgeDomains(Structural) diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClasifierInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClasifierInitializer.java deleted file mode 100644 index b97586830..000000000 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClasifierInitializer.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.honeycomb.translate.v3po.initializers; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.data.init.AbstractDataTreeConverter; -import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifier; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierState; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * Initializes vpp-classfier node in config data tree based on operational state. - */ -public final class VppClasifierInitializer extends AbstractDataTreeConverter { - private static final InstanceIdentifier OPER_ID = - InstanceIdentifier.create(VppClassifierState.class); - private static final InstanceIdentifier CFG_ID = InstanceIdentifier.create(VppClassifier.class); - - @Inject - public VppClasifierInitializer(@Named("honeycomb-initializer") @Nonnull final DataBroker bindingDataBroker) { - super(bindingDataBroker, OPER_ID, CFG_ID); - } - - @Override - protected VppClassifier convert(final VppClassifierState operationalData) { - final VppClassifierBuilder builder = new VppClassifierBuilder(); - builder.setClassifyTable(operationalData.getClassifyTable().stream() - .map(oper -> new ClassifyTableBuilder(oper).setName(oper.getName()).build()) - .collect(Collectors.toList())); - return builder.build(); - } -} diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClassifierInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClassifierInitializer.java new file mode 100644 index 000000000..038b6caa3 --- /dev/null +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppClassifierInitializer.java @@ -0,0 +1,52 @@ +/* + * 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.honeycomb.translate.v3po.initializers; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.data.init.AbstractDataTreeConverter; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifier; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierState; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +/** + * Initializes vpp-classfier node in config data tree based on operational state. + */ +public final class VppClassifierInitializer extends AbstractDataTreeConverter { + private static final InstanceIdentifier OPER_ID = + InstanceIdentifier.create(VppClassifierState.class); + private static final InstanceIdentifier CFG_ID = InstanceIdentifier.create(VppClassifier.class); + + @Inject + public VppClassifierInitializer(@Named("honeycomb-initializer") @Nonnull final DataBroker bindingDataBroker) { + super(bindingDataBroker, OPER_ID, CFG_ID); + } + + @Override + protected VppClassifier convert(final VppClassifierState operationalData) { + final VppClassifierBuilder builder = new VppClassifierBuilder(); + builder.setClassifyTable(operationalData.getClassifyTable().stream() + .map(oper -> new ClassifyTableBuilder(oper).setName(oper.getName()).build()) + .collect(Collectors.toList())); + return builder.build(); + } +} -- cgit 1.2.3-korg