summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/AbstractDataTreeConverter.java7
-rw-r--r--infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/DataTreeInitializer.java8
-rw-r--r--infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistry.java5
-rw-r--r--infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistryImpl.java8
-rw-r--r--infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java7
-rw-r--r--infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/InitializerRegistryImplTest.java9
-rw-r--r--infra/data-api/src/main/java/io/fd/honeycomb/data/ReadableDataManager.java1
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java8
-rw-r--r--infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java8
-rw-r--r--infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java84
-rw-r--r--infra/impl/src/main/java/io/fd/honeycomb/impl/NorthboundFacadeHoneycombDOMBroker.java11
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/InitializationException.java31
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java5
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java3
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java5
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java3
-rw-r--r--infra/notification/impl/src/main/java/io/fd/honeycomb/notification/impl/HoneycombNotificationCollector.java2
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteContext.java2
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteFailedException.java10
-rw-r--r--infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java2
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/JsonUtils.java17
-rw-r--r--infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java5
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java30
23 files changed, 143 insertions, 128 deletions
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/AbstractDataTreeConverter.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/AbstractDataTreeConverter.java
index 74cdc3058..5476bb423 100644
--- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/AbstractDataTreeConverter.java
+++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/AbstractDataTreeConverter.java
@@ -55,13 +55,6 @@ public abstract class AbstractDataTreeConverter<O extends DataObject, C extends
}
@Override
- public void close() throws Exception {
- LOG.debug("AbstractDataTreeConverter.close()");
- // Not removing initialized data, since this works in cooperation with persistence, it could remove
- // data restored by persistence or remove user configured data when shutting down HC
- }
-
- @Override
public final void initialize() throws InitializeException {
LOG.debug("AbstractDataTreeConverter.initialize() from(oper): {}, to(cfg): {}", idOper, idConfig);
final Optional<O> data = readData();
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/DataTreeInitializer.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/DataTreeInitializer.java
index c0ff8c2be..c5ef1e819 100644
--- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/DataTreeInitializer.java
+++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/DataTreeInitializer.java
@@ -24,7 +24,7 @@ import com.google.common.annotations.Beta;
* Initialization does not cause any change in VPP state, unlike ordinary writes to config.
*/
@Beta
-public interface DataTreeInitializer extends AutoCloseable {
+public interface DataTreeInitializer {
/**
* Initializes config data tree for supported root node.
@@ -32,12 +32,6 @@ public interface DataTreeInitializer extends AutoCloseable {
*/
void initialize() throws InitializeException;
- /**
- * Removes all data managed by the initializer.
- */
- @Override
- void close() throws Exception;
-
class InitializeException extends Exception {
public InitializeException(final String message, final Throwable cause) {
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistry.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistry.java
index b662a4fae..f2e12a36a 100644
--- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistry.java
+++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistry.java
@@ -25,8 +25,9 @@ import com.google.common.annotations.Beta;
public interface InitializerRegistry extends DataTreeInitializer {
/**
- * Performs initialize on all registered root initializers.
- * @throws if initialization failed
+ * Performs initialize on all registered root intializers.
+ *
+ * @throws InitializeException if initialization failed
*/
@Override
void initialize() throws InitializeException;
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistryImpl.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistryImpl.java
index b83dd1e04..2433130a9 100644
--- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistryImpl.java
+++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/InitializerRegistryImpl.java
@@ -34,14 +34,6 @@ public class InitializerRegistryImpl implements InitializerRegistry {
}
@Override
- public void close() throws Exception {
- LOG.debug("InitializerRegistryImpl.close()");
- for (DataTreeInitializer initializer : initializers) {
- initializer.close();
- }
- }
-
- @Override
public void initialize() throws InitializeException {
// TODO check if readers are there
LOG.debug("InitializerRegistryImpl.initialize()");
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java
index c4033a98c..ed517b4f0 100644
--- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java
+++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java
@@ -69,7 +69,7 @@ public class RestoringInitializer implements DataTreeInitializer {
@Override
public void initialize() throws InitializeException {
LOG.debug("Starting restoration of {} from {} using {}", dataTree, path, restorationType);
- if(!Files.exists(path)) {
+ if (!Files.exists(path)) {
LOG.debug("Persist file {} does not exist. Skipping restoration", path);
return;
}
@@ -106,11 +106,8 @@ public class RestoringInitializer implements DataTreeInitializer {
}
}
- @Override
- public void close() {}
-
/**
- * Type of operation to use when writing restored data
+ * Type of operation to use when writing restored data.
*/
public static enum RestorationType {
Put, Merge
diff --git a/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/InitializerRegistryImplTest.java b/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/InitializerRegistryImplTest.java
index 009b7c9b4..08d5d66e0 100644
--- a/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/InitializerRegistryImplTest.java
+++ b/infra/cfg-init/src/test/java/io/fd/honeycomb/data/init/InitializerRegistryImplTest.java
@@ -54,13 +54,4 @@ public class InitializerRegistryImplTest {
verify(dti2).initialize();
verify(dti3).initialize();
}
-
- @Test
- public void testClose() throws Exception {
- initializerRegistry.close();
-
- verify(dti1).close();
- verify(dti2).close();
- verify(dti3).close();
- }
} \ No newline at end of file
diff --git a/infra/data-api/src/main/java/io/fd/honeycomb/data/ReadableDataManager.java b/infra/data-api/src/main/java/io/fd/honeycomb/data/ReadableDataManager.java
index 887732ad4..0e772b79c 100644
--- a/infra/data-api/src/main/java/io/fd/honeycomb/data/ReadableDataManager.java
+++ b/infra/data-api/src/main/java/io/fd/honeycomb/data/ReadableDataManager.java
@@ -28,6 +28,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
* Facade over data tree that allows reading tree nodes.
*/
@Beta
+@FunctionalInterface
public interface ReadableDataManager {
/**
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
index e9a616eea..d5d810e0a 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModifiableDataTreeDelegator.java
@@ -83,10 +83,10 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager
@Override
public DataModification newModification() {
- return new ConfigSnapshot(super.newModification());
+ return new DelegatingConfigSnapshot(super.newModification());
}
- private final class ConfigSnapshot extends ModifiableDataTreeManager.ConfigSnapshot {
+ private final class DelegatingConfigSnapshot extends ModifiableDataTreeManager.ConfigSnapshot {
private final DataModification untouchedModification;
@@ -96,7 +96,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager
* (state without current modifications).
* It must be captured as close as possible to when current modification started.
*/
- ConfigSnapshot(final DataModification untouchedModification) {
+ DelegatingConfigSnapshot(final DataModification untouchedModification) {
this.untouchedModification = untouchedModification;
}
@@ -188,7 +188,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager
final DataObjectUpdate dataObjectUpdate = toDataObjectUpdate(normalizedNodeUpdate, serializer);
if (dataObjectUpdate != null) {
if (dataObjectUpdate instanceof DataObjectUpdate.DataObjectDelete) {
- dataObjectDeletes.put(unkeyedIid, ((DataObjectUpdate.DataObjectDelete) dataObjectUpdate));
+ dataObjectDeletes.put(unkeyedIid, (DataObjectUpdate.DataObjectDelete) dataObjectUpdate);
} else {
dataObjectUpdates.put(unkeyedIid, dataObjectUpdate);
}
diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
index 6bc6b1b4b..2cbe1ec8b 100644
--- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
+++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/WriteTransaction.java
@@ -75,16 +75,18 @@ final class WriteTransaction implements DOMDataWriteTransaction {
}
private void handleOperation(final LogicalDatastoreType store,
- final Consumer<DataModification> r) {
+ final Consumer<DataModification> modificationHandler) {
switch (store) {
case CONFIGURATION:
checkArgument(configModification != null, "Modification of %s is not supported", store);
- r.accept(configModification);
+ modificationHandler.accept(configModification);
break;
case OPERATIONAL:
checkArgument(operationalModification != null, "Modification of %s is not supported", store);
- r.accept(operationalModification);
+ modificationHandler.accept(operationalModification);
break;
+ default:
+ throw new IllegalArgumentException("Unable to handle operation for type " + store);
}
}
diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java
index f11848ac7..c978135cb 100644
--- a/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java
+++ b/infra/impl/src/main/java/io/fd/honeycomb/impl/FakeBindingAwareBroker.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.impl;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -28,7 +29,7 @@ import org.opendaylight.yangtools.yang.binding.RpcService;
import org.osgi.framework.BundleContext;
/**
- * Binding aware broker wrapping just a DataBroker
+ * Binding aware broker wrapping just a DataBroker.
*/
public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoCloseable {
@@ -39,7 +40,6 @@ public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoClo
this.netconfBindingBrokerDependency = netconfBindingBrokerDependency;
}
- @Deprecated
@Override
public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer,
final BundleContext bundleContext) {
@@ -50,14 +50,14 @@ public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoClo
public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer) {
final ConsumerContext consumerContext = new ConsumerContext() {
@Override
- public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
- return aClass.equals(DataBroker.class)
- ? (T) netconfBindingBrokerDependency
- : null;
+ public <T extends BindingAwareService> T getSALService(final Class<T> serviceClass) {
+ return serviceClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null;
}
@Override
- public <T extends RpcService> T getRpcService(final Class<T> aClass) {
+ public <T extends RpcService> T getRpcService(final Class<T> serviceClass) {
return null;
}
};
@@ -73,36 +73,7 @@ public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoClo
@Override
public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider) {
- final ProviderContext context = new ProviderContext() {
- @Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L l) {
- throw new UnsupportedOperationException("Unsupported");
- }
-
- @Override
- public <T extends RpcService> T getRpcService(final Class<T> aClass) {
- throw new UnsupportedOperationException("Unsupported");
- }
-
- @Override
- public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> aClass, final T t)
- throws IllegalStateException {
- throw new UnsupportedOperationException("Unsupported");
- }
-
- @Override
- public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(
- final Class<T> aClass, final T t) throws IllegalStateException {
- throw new UnsupportedOperationException("Unsupported");
- }
-
- @Override
- public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
- return aClass.equals(DataBroker.class)
- ? (T) netconfBindingBrokerDependency
- : null; }
- };
+ final ProviderContext context = new FakeProviderContext(netconfBindingBrokerDependency);
bindingAwareProvider.onSessionInitiated(context);
return context;
}
@@ -111,4 +82,43 @@ public final class FakeBindingAwareBroker implements BindingAwareBroker, AutoClo
public void close() throws Exception {
netconfBindingBrokerDependency = null;
}
+
+ private static final class FakeProviderContext implements ProviderContext {
+
+ private Object netconfBindingBrokerDependency;
+
+ FakeProviderContext(final DataBroker netconfBindingBrokerDependency) {
+ this.netconfBindingBrokerDependency = netconfBindingBrokerDependency;
+ }
+
+ @Override
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
+ final L listener) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> T getRpcService(final Class<T> serviceClass) {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> rpcClass, final T t)
+ throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(
+ final Class<T> rpcClass, final T type) throws IllegalStateException {
+ throw new UnsupportedOperationException("Unsupported");
+ }
+
+ @Override
+ public <T extends BindingAwareService> T getSALService(final Class<T> serviceClass) {
+ return serviceClass.equals(DataBroker.class)
+ ? (T) netconfBindingBrokerDependency
+ : null;
+ }
+ }
}
diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/NorthboundFacadeHoneycombDOMBroker.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/NorthboundFacadeHoneycombDOMBroker.java
index 7e5dfd873..4af0a9d4a 100644
--- a/infra/impl/src/main/java/io/fd/honeycomb/impl/NorthboundFacadeHoneycombDOMBroker.java
+++ b/infra/impl/src/main/java/io/fd/honeycomb/impl/NorthboundFacadeHoneycombDOMBroker.java
@@ -47,7 +47,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.osgi.framework.BundleContext;
/**
- * Implementation of dom broker to facade VPP pipeline for northbound APIs
+ * Implementation of dom broker to facade VPP pipeline for northbound APIs.
*/
public class NorthboundFacadeHoneycombDOMBroker implements AutoCloseable, Broker {
@@ -82,7 +82,6 @@ public class NorthboundFacadeHoneycombDOMBroker implements AutoCloseable, Broker
return session;
}
- @Deprecated
@Override
public ConsumerSession registerConsumer(final Consumer consumer, final BundleContext bundleContext) {
throw new UnsupportedOperationException();
@@ -115,8 +114,8 @@ public class NorthboundFacadeHoneycombDOMBroker implements AutoCloseable, Broker
}
@Override
- public <T extends BrokerService> T getService(final Class<T> aClass) {
- return (T)services.get(aClass);
+ public <T extends BrokerService> T getService(final Class<T> serviceClass) {
+ return (T)services.get(serviceClass);
}
@Override
@@ -140,8 +139,8 @@ public class NorthboundFacadeHoneycombDOMBroker implements AutoCloseable, Broker
}
@Override
- public <T extends BrokerService> T getService(final Class<T> aClass) {
- return (T)services.get(aClass);
+ public <T extends BrokerService> T getService(final Class<T> serviceClass) {
+ return (T)services.get(serviceClass);
}
@Override
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/InitializationException.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/InitializationException.java
new file mode 100644
index 000000000..0ed530cdb
--- /dev/null
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/InitializationException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.infra.distro;
+
+/**
+ * Exception thrown when a failure occurs during HC initialization.
+ */
+public class InitializationException extends RuntimeException {
+
+ public InitializationException(final String s) {
+ super(s);
+ }
+
+ public InitializationException(final String s, final Throwable throwable) {
+ super(s, throwable);
+ }
+}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
index 44b6cd35b..d43e33096 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
@@ -66,6 +66,8 @@ public final class Main {
// Json config attributes
new CfgAttrsModule());
+ private Main() {}
+
public static void main(String[] args) {
// TODO add "clean" argument
init(BASE_MODULES);
@@ -107,7 +109,7 @@ public final class Main {
server.start();
} catch (Exception e) {
LOG.error("Unable to start Restconf", e);
- throw new RuntimeException("Unable to start Restconf", e);
+ throw new InitializationException("Unable to start Restconf", e);
}
}
@@ -157,4 +159,5 @@ public final class Main {
System.gc();
}
}
+
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
index 4d488cfdb..8add9fdf0 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryAdapter.java
@@ -45,7 +45,6 @@ final class InitializerRegistryAdapter implements InitializerRegistry {
LOG.info("Config initialization started");
final InitializerRegistry initializer = new InitializerRegistryImpl(pluginInitializers);
-
try {
// Initialize contexts first so that other initializers can find any relevant mapping before initializing
// configuration to what is already in VPP
@@ -64,6 +63,4 @@ final class InitializerRegistryAdapter implements InitializerRegistry {
LOG.info("Honeycomb initialized");
}
- @Override
- public void close() throws Exception {}
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java
index 53be6b5d9..0b3be9f1f 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java
@@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.distro.netconf;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.inject.Inject;
+import io.fd.honeycomb.infra.distro.InitializationException;
import io.fd.honeycomb.infra.distro.ProviderTrait;
import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
import io.netty.channel.ChannelFuture;
@@ -137,12 +138,12 @@ public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServ
sshProxyServer.bind(sshConfigBuilder.createSshProxyServerConfiguration());
LOG.info("Netconf SSH endpoint started successfully at {}", bindingAddress);
} catch (final IOException e) {
- throw new RuntimeException("Unable to start SSH netconf server", e);
+ throw new InitializationException("Unable to start SSH netconf server", e);
}
} else {
LOG.warn("Unable to start SSH netconf server at {}", bindingAddress, future.cause());
- throw new RuntimeException("Unable to start SSH netconf server", future.cause());
+ throw new InitializationException("Unable to start SSH netconf server", future.cause());
}
}
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java
index d6ab47446..66b82eed9 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java
@@ -17,6 +17,7 @@
package io.fd.honeycomb.infra.distro.netconf;
import com.google.inject.Inject;
+import io.fd.honeycomb.infra.distro.InitializationException;
import io.fd.honeycomb.infra.distro.ProviderTrait;
import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
import io.netty.channel.ChannelFuture;
@@ -78,7 +79,7 @@ public final class NetconfTcpServerProvider extends ProviderTrait<NetconfTcpServ
LOG.info("Netconf TCP endpoint started successfully at {}", unresolved);
} else {
LOG.warn("Unable to start TCP netconf server at {}", unresolved, future.cause());
- throw new RuntimeException("Unable to start TCP netconf server", future.cause());
+ throw new InitializationException("Unable to start TCP netconf server", future.cause());
}
}
}
diff --git a/infra/notification/impl/src/main/java/io/fd/honeycomb/notification/impl/HoneycombNotificationCollector.java b/infra/notification/impl/src/main/java/io/fd/honeycomb/notification/impl/HoneycombNotificationCollector.java
index c37e6925c..18b32020c 100644
--- a/infra/notification/impl/src/main/java/io/fd/honeycomb/notification/impl/HoneycombNotificationCollector.java
+++ b/infra/notification/impl/src/main/java/io/fd/honeycomb/notification/impl/HoneycombNotificationCollector.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package io.fd.honeycomb.notification.impl;
import io.fd.honeycomb.notification.NotificationCollector;
@@ -54,7 +55,6 @@ public final class HoneycombNotificationCollector implements NotificationCollect
} catch (InterruptedException e) {
LOG.warn("Interrupted", e);
Thread.currentThread().interrupt();
- throw new RuntimeException(e);
}
}
diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteContext.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteContext.java
index 17aea8d8a..c92bffeca 100644
--- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteContext.java
+++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteContext.java
@@ -24,7 +24,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- * Context providing information about current state of DataTree to writers
+ * Context providing information about current state of DataTree to writers.
*/
@Beta
public interface WriteContext extends ModificationContext {
diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteFailedException.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteFailedException.java
index 8f89d3163..875a92d6c 100644
--- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteFailedException.java
+++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/WriteFailedException.java
@@ -97,11 +97,11 @@ public class WriteFailedException extends TranslationException {
}
/**
- * Create specific write failed exception
+ * Create specific write failed exception.
*/
public static class CreateFailedException extends WriteFailedException {
- private final DataObject data;
+ private final transient DataObject data;
public CreateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
@Nonnull final DataObject data,
@@ -126,12 +126,12 @@ public class WriteFailedException extends TranslationException {
}
/**
- * Update specific write failed exception
+ * Update specific write failed exception.
*/
public static class UpdateFailedException extends WriteFailedException {
- private final DataObject dataBefore;
- private final DataObject dataAfter;
+ private final transient DataObject dataBefore;
+ private final transient DataObject dataAfter;
public UpdateFailedException(@Nonnull final InstanceIdentifier<?> failedId,
@Nonnull final DataObject dataBefore,
diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java
index 2467972da..402335115 100644
--- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java
+++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/write/registry/WriterRegistry.java
@@ -133,7 +133,7 @@ public interface WriterRegistry {
@Beta
class BulkUpdateException extends TranslationException {
- private final Reverter reverter;
+ private final transient Reverter reverter;
private final Set<InstanceIdentifier<?>> failedIds;
/**
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/JsonUtils.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/JsonUtils.java
index a26334454..d551802e4 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/JsonUtils.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/JsonUtils.java
@@ -40,13 +40,17 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class JsonUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(JsonUtils.class);
+
private JsonUtils() {}
/**
- * Serialize normalized node root structure into provided output stream
+ * Serialize normalized node root structure into provided output stream.
*
* @throws IOException if serialized data cannot be written into provided output stream
*/
@@ -79,15 +83,18 @@ public final class JsonUtils {
Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schemaContext.getQName()));
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(builder);
- final JsonParserStream jsonParser = JsonParserStream.create(writer, schemaContext);
- final JsonReader reader = new JsonReader(new InputStreamReader(stream, Charsets.UTF_8));
- jsonParser.parse(reader);
+ try (final JsonParserStream jsonParser = JsonParserStream.create(writer, schemaContext)) {
+ final JsonReader reader = new JsonReader(new InputStreamReader(stream, Charsets.UTF_8));
+ jsonParser.parse(reader);
+ } catch (IOException e) {
+ LOG.warn("Unable to close json parser. Ignoring exception", e);
+ }
return builder.build();
}
private static void writeChildren(final NormalizedNodeWriter nnWriter, final ContainerNode data) throws IOException {
- for(final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> child : data.getValue()) {
+ for (final DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?> child : data.getValue()) {
nnWriter.write(child);
}
}
diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
index 51f999294..5d801edab 100644
--- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
+++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/TransactionWriteContext.java
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * Transaction based WriteContext
+ * Transaction backed WriteContext.
*/
public final class TransactionWriteContext implements WriteContext {
@@ -110,11 +110,12 @@ public final class TransactionWriteContext implements WriteContext {
}
/**
- * Does not close the transactions
+ * Does not close the transactions.
*/
@Override
public void close() {
ctx.close();
+ mappingContext.close();
beforeTx.close();
afterTx.close();
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java
index b2c2f7b1e..b2fc436e7 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/initializers/VppInitializer.java
@@ -64,24 +64,18 @@ public class VppInitializer extends AbstractDataTreeConverter<VppState, Vpp> {
}
private static final Function<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain, BridgeDomain>
- CONVERT_BD =
- new Function<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain, BridgeDomain>() {
- @Nullable
- @Override
- public BridgeDomain apply(
- @Nullable final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomain input) {
- final BridgeDomainBuilder builder = new BridgeDomainBuilder();
- builder.setLearn(input.isLearn());
- builder.setUnknownUnicastFlood(input.isUnknownUnicastFlood());
- builder.setArpTermination(input.isArpTermination());
- builder.setFlood(input.isFlood());
- builder.setForward(input.isForward());
- builder.setKey(new BridgeDomainKey(input.getKey().getName()));
- builder.setName(input.getName());
- setL2FibTable(builder, input.getL2FibTable());
- return builder.build();
- }
- };
+ CONVERT_BD = input -> {
+ final BridgeDomainBuilder builder = new BridgeDomainBuilder();
+ builder.setLearn(input.isLearn());
+ builder.setUnknownUnicastFlood(input.isUnknownUnicastFlood());
+ builder.setArpTermination(input.isArpTermination());
+ builder.setFlood(input.isFlood());
+ builder.setForward(input.isForward());
+ builder.setKey(new BridgeDomainKey(input.getKey().getName()));
+ builder.setName(input.getName());
+ setL2FibTable(builder, input.getL2FibTable());
+ return builder.build();
+ };
private static void setL2FibTable(@Nonnull final BridgeDomainBuilder builder,
@Nullable final L2FibTable l2FibTable) {