From 1326e9fa5cffe326b82aeee9d82d008526aff947 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Mon, 5 Sep 2016 12:10:26 +0200 Subject: Cleanup TODOs and FIXMEs - Fix minor ones - Report bigger and include issue number in comment - Pull common dependencies into dependency management of common/parents Change-Id: I06a6ac37c52b603fd73ed42023d6b2e7fa18010f Signed-off-by: Maros Marsalek --- infra/artifacts/pom.xml | 96 ---------------------- infra/cfg-init/pom.xml | 1 + .../data/init/AbstractDataTreeConverter.java | 5 +- .../data/init/InitializerRegistryImpl.java | 2 +- infra/data-api/pom.xml | 3 - infra/data-impl/pom.xml | 17 ---- .../data/impl/ModifiableDataTreeDelegator.java | 4 +- .../fd/honeycomb/data/impl/ModificationDiff.java | 2 +- .../data/impl/PersistingDataTreeAdapter.java | 8 +- .../data/impl/ReadableDataTreeDelegator.java | 5 +- infra/impl/pom.xml | 14 ---- .../impl/NetconfMonitoringReaderFactory.java | 45 ---------- .../impl/NorthboundFacadeHoneycombDOMBroker.java | 7 +- infra/it/it-test/pom.xml | 9 +- .../data/impl/HoneycombSubtreeReadInfraTest.java | 4 +- .../data/impl/HoneycombWriteInfraTest.java | 2 +- infra/it/pom.xml | 1 + infra/minimal-distribution/pom.xml | 48 ++++------- .../java/io/fd/honeycomb/infra/distro/Main.java | 1 - .../data/HoneycombNotificationManagerProvider.java | 4 +- .../distro/data/InmemoryDOMDataBrokerProvider.java | 2 +- .../HoneycombNotification2NetconfProvider.java | 4 +- .../infra/distro/netconf/NetconfModule.java | 3 +- .../NetconfMonitoringReaderFactoryProvider.java | 27 +++++- .../distro/netconf/NetconfSshServerProvider.java | 2 +- .../infra/distro/netconf/NettyTimerProvider.java | 35 -------- .../distro/restconf/HttpsConnectorProvider.java | 2 +- .../config/WEB-INF/web.xml | 2 +- infra/notification/api/pom.xml | 3 - infra/notification/impl/pom.xml | 5 +- infra/notification/pom.xml | 1 + infra/pom.xml | 3 +- infra/translate-api/pom.xml | 15 ---- .../io/fd/honeycomb/translate/read/Reader.java | 2 +- .../registry/ModifiableReaderRegistryBuilder.java | 2 +- .../translate/write/registry/WriterRegistry.java | 2 +- infra/translate-impl/pom.xml | 1 - .../translate/impl/read/GenericListReader.java | 6 +- .../translate/impl/read/GenericReader.java | 6 +- .../translate/impl/write/GenericListWriter.java | 18 +++- .../translate/impl/write/GenericWriter.java | 20 +++-- infra/translate-spi/pom.xml | 15 ---- .../translate/spi/read/ListReaderCustomizer.java | 1 - .../translate/spi/read/ReaderCustomizer.java | 5 +- infra/translate-utils/pom.xml | 26 +----- ...stractSubtreeManagerRegistryBuilderBuilder.java | 4 +- .../io/fd/honeycomb/translate/util/RWUtils.java | 13 +-- .../translate/util/TransactionMappingContext.java | 2 +- .../translate/util/read/AbstractGenericReader.java | 3 +- .../util/read/registry/SubtreeReader.java | 23 ++---- .../util/write/TransactionWriteContext.java | 5 +- .../util/write/registry/FlatWriterRegistry.java | 5 +- .../write/util/TransactionWriteContextTest.java | 7 +- 53 files changed, 161 insertions(+), 387 deletions(-) delete mode 100644 infra/artifacts/pom.xml delete mode 100644 infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java delete mode 100644 infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyTimerProvider.java (limited to 'infra') diff --git a/infra/artifacts/pom.xml b/infra/artifacts/pom.xml deleted file mode 100644 index f3bb46ee1..000000000 --- a/infra/artifacts/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - 4.0.0 - io.fd.honeycomb - honeycomb-artifacts - 1.16.12-SNAPSHOT - pom - - - - - ${project.groupId} - data-api - ${project.version} - - - ${project.groupId} - notification-api - ${project.version} - - - ${project.groupId} - notification-impl - ${project.version} - - - ${project.groupId} - notification-spi - ${project.version} - - - ${project.groupId} - data-utils - ${project.version} - - - ${project.groupId} - data-impl - ${project.version} - - - ${project.groupId} - translate-api - ${project.version} - - - ${project.groupId} - translate-spi - ${project.version} - - - ${project.groupId} - translate-impl - ${project.version} - - - ${project.groupId} - translate-utils - ${project.version} - - - ${project.groupId} - cfg-init - ${project.version} - - - ${project.groupId} - honeycomb-impl - ${project.version} - - - ${project.groupId} - honeycomb-features - ${project.version} - features - xml - - - - diff --git a/infra/cfg-init/pom.xml b/infra/cfg-init/pom.xml index df481b7da..c1fd353dc 100644 --- a/infra/cfg-init/pom.xml +++ b/infra/cfg-init/pom.xml @@ -39,6 +39,7 @@ data-api ${project.version} + junit 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 5476bb423..86188dd3f 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 @@ -97,9 +97,10 @@ public abstract class AbstractDataTreeConverter org.opendaylight.controller sal-common-api - - 1.3.2-Beryllium-SR2 - \ No newline at end of file diff --git a/infra/data-impl/pom.xml b/infra/data-impl/pom.xml index f90c7cd84..341378192 100644 --- a/infra/data-impl/pom.xml +++ b/infra/data-impl/pom.xml @@ -51,30 +51,13 @@ org.opendaylight.controller sal-core-api - - 1.3.2-Beryllium-SR2 - - - org.opendaylight.netconf - ietf-netconf-monitoring - 1.0.2-Beryllium-SR2 - - - - org.opendaylight.netconf - ietf-netconf-monitoring-extension - 1.0.2-Beryllium-SR2 - - - junit junit test - org.mockito mockito-all 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 d5d810e0a..7af9847d7 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 @@ -60,7 +60,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager private final WriterRegistry writerRegistry; private final org.opendaylight.controller.md.sal.binding.api.DataBroker contextBroker; - // TODO what to use instead of deprecated BindingNormalizedNodeSerializer ? + // TODO HONEYCOMB-161 what to use instead of deprecated BindingNormalizedNodeSerializer ? private final BindingNormalizedNodeSerializer serializer; /** @@ -145,7 +145,7 @@ public final class ModifiableDataTreeDelegator extends ModifiableDataTreeManager throw e; // fail with success revert } catch (TransactionCommitFailedException e) { - // FIXME revert should probably occur when context is not written successfully + // TODO HONEYCOMB-162 revert should probably occur when context is not written successfully final String msg = "Error while updating mapping context data"; LOG.error(msg, e); throw new TranslationException(msg, e); diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java index 710f8a053..1c87bc03a 100644 --- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java +++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ModificationDiff.java @@ -114,7 +114,7 @@ final class ModificationDiff { // Check if there are any modified leaves and if so, consider current node as modified final Boolean directLeavesModified = currentCandidate.getChildNodes().stream() .filter(ModificationDiff::isLeaf) - // For some reason, we get modifications on unmodified list keys TODO debug and report ODL bug + // For some reason, we get modifications on unmodified list keys // and that messes up our modifications collection here, so we need to skip .filter(ModificationDiff::isBeforeAndAfterDifferent) .filter(child -> LEAF_MODIFICATIONS.contains(child.getModificationType())) diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapter.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapter.java index 94c5e4446..459971436 100644 --- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapter.java +++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/PersistingDataTreeAdapter.java @@ -103,17 +103,17 @@ public class PersistingDataTreeAdapter implements DataTree, AutoCloseable { delegateDependency.commit(dataTreeCandidate); LOG.debug("Delegate commit successful. Persisting data"); - // FIXME doing full read and full write might not be the fastest way of persisting data here + // TODO HONEYCOMB-163 doing full read and full write might not be the fastest way of persisting data here final DataTreeSnapshot dataTreeSnapshot = delegateDependency.takeSnapshot(); - // TODO this can be handled in background by a dedicated thread + a limited blocking queue - // TODO enable configurable granularity for persists. Maybe doing write on every modification is too much + // TODO HONEYCOMB-163 this can be handled in background by a dedicated thread + a limited blocking queue + // TODO HONEYCOMB-163 enable configurable granularity for persists. Maybe doing write on every modification is too much // and we could do bulk persist persistCurrentData(dataTreeSnapshot.readNode(YangInstanceIdentifier.EMPTY)); } private void persistCurrentData(final Optional> currentRoot) { - if(currentRoot.isPresent()) { + if (currentRoot.isPresent()) { try { LOG.trace("Persisting current data: {} into: {}", currentRoot.get(), path); JsonUtils.writeJsonRoot(currentRoot.get(), schemaServiceDependency.getGlobalContext(), diff --git a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java index 775f6326c..ae29fa08b 100644 --- a/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java +++ b/infra/data-impl/src/main/java/io/fd/honeycomb/data/impl/ReadableDataTreeDelegator.java @@ -91,7 +91,7 @@ public final class ReadableDataTreeDelegator implements ReadableDataManager { org.opendaylight.controller.md.sal.common.api.data.ReadFailedException> read( @Nonnull final YangInstanceIdentifier yangInstanceIdentifier) { - try(TransactionMappingContext mappingContext = new TransactionMappingContext(contextBroker.newReadWriteTransaction()); + try (TransactionMappingContext mappingContext = new TransactionMappingContext(contextBroker.newReadWriteTransaction()); ReadContext ctx = new ReadContextImpl(mappingContext)) { final Optional> value; @@ -113,7 +113,8 @@ public final class ReadableDataTreeDelegator implements ReadableDataManager { return Futures.immediateFailedCheckedFuture( new org.opendaylight.controller.md.sal.common.api.data.ReadFailedException("Failed to read data", e)); } catch (TransactionCommitFailedException e) { - // FIXME revert should probably occur when context is not written successfully + // Context write failed. This should not happen, but if it does, there's not much that can be done here + // ... try to read again final String msg = "Error while updating mapping context data"; LOG.error(msg, e); return Futures.immediateFailedCheckedFuture( diff --git a/infra/impl/pom.xml b/infra/impl/pom.xml index f3548965a..0bbe23e6c 100644 --- a/infra/impl/pom.xml +++ b/infra/impl/pom.xml @@ -49,30 +49,16 @@ cfg-init ${project.version} - - - org.opendaylight.netconf - ietf-netconf-monitoring - 1.0.2-Beryllium-SR2 - - - org.opendaylight.netconf - ietf-netconf-monitoring-extension - 1.0.2-Beryllium-SR2 - - org.opendaylight.mdsal.model ietf-topology - junit junit test - org.mockito mockito-all diff --git a/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java b/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java deleted file mode 100644 index 244ae585e..000000000 --- a/infra/impl/src/main/java/io/fd/honeycomb/impl/NetconfMonitoringReaderFactory.java +++ /dev/null @@ -1,45 +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.impl; - -import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.BindingBrokerReader; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfStateBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -/** - * {@link ReaderFactory} initiating reader into NETCONF's dedicated data store. - * Making NETCONF operational data available over NETCONF/RESTCONF - */ -public final class NetconfMonitoringReaderFactory implements ReaderFactory { - - private final DataBroker netconfMonitoringBindingBrokerDependency; - - public NetconfMonitoringReaderFactory(final DataBroker netconfMonitoringBindingBrokerDependency) { - this.netconfMonitoringBindingBrokerDependency = netconfMonitoringBindingBrokerDependency; - } - - @Override - public void init(final ModifiableReaderRegistryBuilder registry) { - registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(NetconfState.class), - netconfMonitoringBindingBrokerDependency, - LogicalDatastoreType.OPERATIONAL, NetconfStateBuilder.class)); - } -} 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 4af0a9d4a..d49741797 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 @@ -61,13 +61,12 @@ public class NorthboundFacadeHoneycombDOMBroker implements AutoCloseable, Broker @Nonnull final DOMNotificationService domNotificatioNService) { services = Maps.newHashMap(); services.put(DOMDataBroker.class, domDataBrokerDependency); - // All services below are required to be present by Restconf northbound services.put(SchemaService.class, schemaBiService); - services.put(DOMRpcService.class, EMPTY_DOM_RPC_SERVICE); - services.put(DOMMountPointService.class, EMPTY_DOM_MOUNT_SERVICE); services.put(DOMNotificationService.class, domNotificatioNService); - // TODO do both notification service types have to be registered ? services.put(DOMNotificationPublishService.class, domNotificatioNService); + // All services below are required to be present by Restconf northbound even if not used + services.put(DOMRpcService.class, EMPTY_DOM_RPC_SERVICE); + services.put(DOMMountPointService.class, EMPTY_DOM_MOUNT_SERVICE); } @Override diff --git a/infra/it/it-test/pom.xml b/infra/it/it-test/pom.xml index 5cde7b00b..5a55c339f 100644 --- a/infra/it/it-test/pom.xml +++ b/infra/it/it-test/pom.xml @@ -28,6 +28,10 @@ honeycomb-it-test 1.16.12-SNAPSHOT + + 1.0.8 + + ${project.groupId} @@ -40,9 +44,10 @@ ${project.version} + org.skinny-framework skinny-logback - 1.0.8 + ${skinny.logback.version} test @@ -61,6 +66,4 @@ ${project.version} - - \ No newline at end of file diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java index a43f70a84..5bb81b477 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombSubtreeReadInfraTest.java @@ -68,7 +68,7 @@ public class HoneycombSubtreeReadInfraTest extends AbstractInfraTest { public List getAllIds(@Nonnull final InstanceIdentifier id, @Nonnull final ReadContext context) throws ReadFailedException { - // FIXME this is the only way of extending subtree reader via its list child + // This is the only way of extending subtree reader's list child // Reflexive list reader has to be used in place of the list(managed by subtree reader perent) // to enable further children readers. However, it will not work out of the box, because // reflexive list reader has no way to tell what are the IDs to correctly invoke its children. @@ -89,7 +89,7 @@ public class HoneycombSubtreeReadInfraTest extends AbstractInfraTest { private Reader containerInListReader = HoneycombReadInfraTest.mockReader(Ids.CONTAINER_IN_LIST_ID, this::readContainerInList, ContainerInListBuilder.class); - // TODO Test subtree readers especially composite structure where readers are under subtree reader + // TODO HONEYCOMB-178 Test subtree readers especially composite structure where readers are under subtree reader @Override void postSetup() { diff --git a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java index 90a18dd7a..fe679d14f 100644 --- a/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java +++ b/infra/it/it-test/src/test/java/io/fd/honeycomb/data/impl/HoneycombWriteInfraTest.java @@ -169,7 +169,7 @@ public class HoneycombWriteInfraTest extends AbstractInfraTest { private void verifyOrderedWrites(final Writer[] orderedWriters, final InOrder inOrder) throws WriteFailedException { - // TODO Modifications are not produced for nodes that do not contain any actual leaves (except when choice is a child) do we need those triggers ? + // Modifications are not produced for nodes that do not contain any actual leaves (except when choice is a child) // Unordered // verify(complexAugmentWriter).update(eq(COMPLEX_AUGMENT_ID), eq(null), eq(getComplexAugment()), any(WriteContext.class)); // 1 diff --git a/infra/it/pom.xml b/infra/it/pom.xml index 93265ee61..6151ec6ac 100644 --- a/infra/it/pom.xml +++ b/infra/it/pom.xml @@ -24,6 +24,7 @@ 3.1.1 + test-model it-test diff --git a/infra/minimal-distribution/pom.xml b/infra/minimal-distribution/pom.xml index 4094c56e9..a03e3a97e 100644 --- a/infra/minimal-distribution/pom.xml +++ b/infra/minimal-distribution/pom.xml @@ -61,123 +61,111 @@ com.google.inject guice - ${guice.version} net.jmob guice.conf - ${guice.config.version} com.google.inject.extensions guice-multibindings - ${guice.version} org.opendaylight.yangtools yang-data-impl - ${yangtools.version} org.opendaylight.controller sal-core-api - ${mdsal.version} org.opendaylight.netconf sal-rest-connector - ${restconf.version} org.opendaylight.netconf netconf-impl - ${netconf.version} org.opendaylight.netconf netconf-ssh - ${netconf.version} org.opendaylight.netconf mdsal-netconf-notification - ${netconf.version} org.opendaylight.netconf mdsal-netconf-monitoring - ${netconf.version} org.opendaylight.netconf mdsal-netconf-connector - ${netconf.version} + + + org.opendaylight.netconf + ietf-netconf-monitoring + + + org.opendaylight.netconf + ietf-netconf-monitoring-extension org.eclipse.jetty jetty-server - ${jetty.version} javax.servlet javax.servlet-api - ${servlet.version} org.eclipse.jetty jetty-webapp - ${jetty.version} org.eclipse.jetty jetty-servlets - ${jetty.version} com.sun.jersey jersey-server - ${jersey.version} com.sun.jersey jersey-core - ${jersey.version} com.sun.jersey jersey-servlet - ${jersey.version} + + + + + org.osgi + org.osgi.core + compile - io.fd.honeycomb + ${project.groupId} data-impl ${project.version} - io.fd.honeycomb + ${project.groupId} honeycomb-impl ${project.version} - io.fd.honeycomb + ${project.groupId} notification-impl ${project.version} - - - - org.osgi - org.osgi.core - ${osgi.core.version} - compile - - 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 d43e33096..c592fd3b3 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 @@ -69,7 +69,6 @@ public final class Main { private Main() {} public static void main(String[] args) { - // TODO add "clean" argument init(BASE_MODULES); } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java index e25cb1569..f2e81a9f6 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.java @@ -59,9 +59,9 @@ public final class HoneycombNotificationManagerProvider extends ProviderTrait map = new LinkedHashMap<>(); map.put(LogicalDatastoreType.CONFIGURATION, cfgDataStore); diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java index 3954af896..f60366c7e 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java @@ -68,7 +68,7 @@ public final class HoneycombNotification2NetconfProvider new TranslatingNotificationListener(netconfNotifReg, streamType, schemaService); // NotificationManager is used to provide list of available notifications (which are all of the notifications registered) - // TODO make available notifications configurable here so that any number of notification streams for HONEYCOMB_NETCONF + // TODO HONEYCOMB-165 make available notifications configurable here so that any number of notification streams for netconf // can be configured on top of a single notification manager LOG.debug("Current notifications to be exposed over HONEYCOMB_NETCONF: {}", hcNotificationCollector.getNotificationTypes()); @@ -77,7 +77,7 @@ public final class HoneycombNotification2NetconfProvider .collect(Collectors.toList()); // Register as listener to HC'OPERATIONAL DOM notification service - // TODO This should only be triggered when HONEYCOMB_NETCONF notifications are activated + // TODO HONEYCOMB-166 This should only be triggered when HONEYCOMB_NETCONF notifications are activated // Because this way we actually start all notification producers // final Collection notificationQNames = ListenerRegistration domNotifListenerReg = notificationRouter diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java index 9beb10dbc..3466362cf 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java @@ -29,6 +29,7 @@ import io.fd.honeycomb.infra.distro.data.HoneycombNotificationManagerProvider; import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider; import io.fd.honeycomb.notification.NotificationCollector; import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.HashedWheelTimer; import io.netty.util.Timer; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -118,7 +119,7 @@ public class NetconfModule extends PrivateModule { */ private AnnotatedElementBuilder configureServer() { bind(NioEventLoopGroup.class).toProvider(NettyThreadGroupProvider.class).in(Singleton.class); - bind(Timer.class).toProvider(NettyTimerProvider.class).in(Singleton.class); + bind(Timer.class).toInstance(new HashedWheelTimer()); bind(NetconfServerDispatcher.class).toProvider(NetconfServerDispatcherProvider.class).in(Singleton.class); bind(NetconfTcpServerProvider.NetconfTcpServer.class).toProvider(NetconfTcpServerProvider.class) .in(Singleton.class); diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java index 583b15055..3a4c13697 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java @@ -18,10 +18,15 @@ package io.fd.honeycomb.infra.distro.netconf; import com.google.inject.Inject; import com.google.inject.name.Named; -import io.fd.honeycomb.impl.NetconfMonitoringReaderFactory; import io.fd.honeycomb.infra.distro.ProviderTrait; import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; +import io.fd.honeycomb.translate.util.read.BindingBrokerReader; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfStateBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public final class NetconfMonitoringReaderFactoryProvider extends ProviderTrait { @@ -34,4 +39,24 @@ public final class NetconfMonitoringReaderFactoryProvider extends ProviderTrait< protected NetconfMonitoringReaderFactory create() { return new NetconfMonitoringReaderFactory(netconfDataBroker); } + + /** + * {@link io.fd.honeycomb.translate.read.ReaderFactory} initiating reader into NETCONF's dedicated data store. + * Making NETCONF operational data available over NETCONF/RESTCONF + */ + private static final class NetconfMonitoringReaderFactory implements ReaderFactory { + + private final DataBroker netconfMonitoringBindingBrokerDependency; + + NetconfMonitoringReaderFactory(final DataBroker netconfMonitoringBindingBrokerDependency) { + this.netconfMonitoringBindingBrokerDependency = netconfMonitoringBindingBrokerDependency; + } + + @Override + public void init(final ModifiableReaderRegistryBuilder registry) { + registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(NetconfState.class), + netconfMonitoringBindingBrokerDependency, + LogicalDatastoreType.OPERATIONAL, NetconfStateBuilder.class)); + } + } } 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 0b3be9f1f..2c1eceeaf 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 @@ -75,7 +75,7 @@ public final class NetconfSshServerProvider extends ProviderTrait { - - @Inject - private HoneycombConfiguration cfgAttributes; - - @Override - protected HashedWheelTimer create() { - // TODO expose configuration, - return new HashedWheelTimer(); - } -} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java index 76fc72f3f..8dca157a6 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.java @@ -53,7 +53,7 @@ public final class HttpsConnectorProvider extends ProviderTrait URL truststoreURL = getClass().getResource(cfg.restconfTruststore.get()); sslContextFactory.setTrustStorePath(truststoreURL.getPath()); sslContextFactory.setTrustStorePassword((cfg.truststorePassword.get())); - // TODO make this more configurable + // TODO HONEYCOMB-167 make this more configurable sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"); diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/WEB-INF/web.xml b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/WEB-INF/web.xml index 7e59a1a7d..45fcce741 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/WEB-INF/web.xml +++ b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/WEB-INF/web.xml @@ -42,7 +42,7 @@ application/xml,application/yang.data+xml,xml,application/json,application/yang.data+json - + GzipFilter /* diff --git a/infra/notification/api/pom.xml b/infra/notification/api/pom.xml index 1c4f3d933..81913591d 100644 --- a/infra/notification/api/pom.xml +++ b/infra/notification/api/pom.xml @@ -32,9 +32,6 @@ org.opendaylight.mdsal mdsal-dom-api - 2.0.2-Beryllium-SR2 - - diff --git a/infra/notification/impl/pom.xml b/infra/notification/impl/pom.xml index 53223ef65..083cb98eb 100644 --- a/infra/notification/impl/pom.xml +++ b/infra/notification/impl/pom.xml @@ -29,7 +29,6 @@ bundle - ${project.groupId} notification-api @@ -38,14 +37,12 @@ org.opendaylight.controller sal-binding-config - 1.3.2-Beryllium-SR2 - org.opendaylight.netconf netconf-notifications-api - 1.0.2-Beryllium-SR2 + junit junit diff --git a/infra/notification/pom.xml b/infra/notification/pom.xml index dc4f4d28d..6d4c15fa0 100644 --- a/infra/notification/pom.xml +++ b/infra/notification/pom.xml @@ -31,6 +31,7 @@ 3.1.1 + api impl diff --git a/infra/pom.xml b/infra/pom.xml index 91395356e..782f1f442 100644 --- a/infra/pom.xml +++ b/infra/pom.xml @@ -31,6 +31,7 @@ 3.1.1 + data-api data-impl @@ -42,9 +43,9 @@ cfg-init impl minimal-distribution - artifacts it + diff --git a/infra/translate-api/pom.xml b/infra/translate-api/pom.xml index bb9f6f1df..88801f13c 100644 --- a/infra/translate-api/pom.xml +++ b/infra/translate-api/pom.xml @@ -28,18 +28,6 @@ 1.16.12-SNAPSHOT bundle - - - - org.opendaylight.mdsal - mdsal-artifacts - 2.0.2-Beryllium-SR2 - pom - import - - - - com.google.guava @@ -50,7 +38,6 @@ mdsal-binding-api - junit junit @@ -61,7 +48,5 @@ mockito-all test - - diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/Reader.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/Reader.java index 177b52415..dd9944624 100644 --- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/Reader.java +++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/Reader.java @@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @Beta public interface Reader> extends SubtreeManager { - // TODO make async + // TODO HONEYCOMB-169 make async /** * Reads data identified by id diff --git a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/registry/ModifiableReaderRegistryBuilder.java b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/registry/ModifiableReaderRegistryBuilder.java index 10dcd9280..67029b17c 100644 --- a/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/registry/ModifiableReaderRegistryBuilder.java +++ b/infra/translate-api/src/main/java/io/fd/honeycomb/translate/read/registry/ModifiableReaderRegistryBuilder.java @@ -31,7 +31,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public interface ModifiableReaderRegistryBuilder extends ModifiableSubtreeManagerRegistryBuilder>> { - // TODO we should be able to add structural/reflexive readers automatically in the registry builder, we just need builder class + // TODO HONEYCOMB-179 we should be able to add structural/reflexive readers automatically in the registry builder, we just need builder class // We would need generated class loading strategy instance and then load builder classes relying on naming + package conventions of Binding spec /** * Add a structural reader that performs no read operation on its own, just fills in the hierarchy. 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 402335115..d281ee558 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 @@ -183,7 +183,7 @@ public interface WriterRegistry { @Beta class RevertFailedException extends TranslationException { - // TODO change to list of VppDataModifications to make debugging easier + // TODO HONEYCOMB-170 change to list of VppDataModifications to make debugging easier private final Set> notRevertedChanges; /** diff --git a/infra/translate-impl/pom.xml b/infra/translate-impl/pom.xml index 1dbc734d1..99b3a9846 100644 --- a/infra/translate-impl/pom.xml +++ b/infra/translate-impl/pom.xml @@ -45,7 +45,6 @@ ${project.version} - junit junit diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java index c6e7f3cb5..d8accec91 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericListReader.java @@ -106,7 +106,11 @@ public final class GenericListReader, K e public void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder, ctx); + try { + customizer.readCurrentAttributes(id, builder, ctx); + } catch (RuntimeException e) { + throw new ReadFailedException(id, e); + } } @Override diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java index 1c638317a..f60c8f137 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/GenericReader.java @@ -54,7 +54,11 @@ public final class GenericReader> ext public void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, @Nonnull final ReadContext ctx) throws ReadFailedException { - customizer.readCurrentAttributes(id, builder, ctx); + try { + customizer.readCurrentAttributes(id, builder, ctx); + } catch (RuntimeException e) { + throw new ReadFailedException(id, e); + } } @Override diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java index f61812931..4e05ce018 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericListWriter.java @@ -46,20 +46,32 @@ public final class GenericListWriter, K e @Override protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final D data, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.writeCurrentAttributes(id, data, ctx); + try { + customizer.writeCurrentAttributes(id, data, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.CreateFailedException(id, data, e); + } } @Override protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final D dataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.deleteCurrentAttributes(id, dataBefore, ctx); + try { + customizer.deleteCurrentAttributes(id, dataBefore, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.DeleteFailedException(id, e); + } } @Override protected void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final D dataBefore, @Nonnull final D dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); + try { + customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); + } } @Override diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java index 486da9b4a..30d15e370 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/GenericWriter.java @@ -40,15 +40,21 @@ public final class GenericWriter extends AbstractGenericWr @Override protected void writeCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final D data, @Nonnull final WriteContext ctx) throws WriteFailedException { - // TODO wrap all customizer invocations in try catch, and wrap runtime exceptions in ReadFailed - // TODO same for readers - customizer.writeCurrentAttributes(id, data, ctx); + try { + customizer.writeCurrentAttributes(id, data, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.CreateFailedException(id, data, e); + } } @Override protected void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final D dataBefore, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.deleteCurrentAttributes(id, dataBefore, ctx); + try { + customizer.deleteCurrentAttributes(id, dataBefore, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.DeleteFailedException(id, e); + } } @Override @@ -56,6 +62,10 @@ public final class GenericWriter extends AbstractGenericWr @Nonnull final D dataBefore, @Nonnull final D dataAfter, @Nonnull final WriteContext ctx) throws WriteFailedException { - customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); + try { + customizer.updateCurrentAttributes(id, dataBefore, dataAfter, ctx); + } catch (RuntimeException e) { + throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e); + } } } diff --git a/infra/translate-spi/pom.xml b/infra/translate-spi/pom.xml index f1e3148f5..18de9b1d4 100644 --- a/infra/translate-spi/pom.xml +++ b/infra/translate-spi/pom.xml @@ -28,18 +28,6 @@ 1.16.12-SNAPSHOT bundle - - - - org.opendaylight.mdsal - mdsal-artifacts - 2.0.2-Beryllium-SR2 - pom - import - - - - com.google.guava @@ -55,7 +43,6 @@ mdsal-binding-api - junit junit @@ -66,7 +53,5 @@ mockito-all test - - diff --git a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ListReaderCustomizer.java b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ListReaderCustomizer.java index deb0a279d..7c64e7f7b 100644 --- a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ListReaderCustomizer.java +++ b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ListReaderCustomizer.java @@ -49,7 +49,6 @@ public interface ListReaderCustomizer, K @Nonnull List getAllIds(@Nonnull final InstanceIdentifier id, @Nonnull final ReadContext context) throws ReadFailedException; - // TODO does it make sense with vpp APIs ? Should we replace it with a simple readAll ? /** * Merge read data into provided parent builder. diff --git a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java index 610fe1514..a13e518a6 100644 --- a/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java +++ b/infra/translate-spi/src/main/java/io/fd/honeycomb/translate/spi/read/ReaderCustomizer.java @@ -44,16 +44,13 @@ public interface ReaderCustomizer> { * * @param id id of current data object * @param builder builder for creating read value - * @param ctx + * @param ctx context for current read * @throws ReadFailedException if read was unsuccessful */ void readCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final B builder, @Nonnull final ReadContext ctx) throws ReadFailedException; - // FIXME need to capture parent builder type, but that's inconvenient at best, is it ok to leave it Builder and - // cast in specific customizers ? ... probably better than adding another type parameter - /** * Merge read data into provided parent builder. */ diff --git a/infra/translate-utils/pom.xml b/infra/translate-utils/pom.xml index 51b1194f1..f2b5a0c75 100644 --- a/infra/translate-utils/pom.xml +++ b/infra/translate-utils/pom.xml @@ -28,24 +28,9 @@ 1.16.12-SNAPSHOT bundle - - - - org.opendaylight.mdsal - mdsal-artifacts - 2.0.2-Beryllium-SR2 - pom - import - - - org.opendaylight.controller - mdsal-artifacts - 1.3.2-Beryllium-SR2 - pom - import - - - + + 0.9.2 + @@ -73,10 +58,9 @@ org.jgrapht jgrapht-core - 0.9.2 + ${jgrapht.version} - junit junit @@ -87,7 +71,5 @@ mockito-all test - - diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/AbstractSubtreeManagerRegistryBuilderBuilder.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/AbstractSubtreeManagerRegistryBuilderBuilder.java index bf1e89c12..07f2bf1ee 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/AbstractSubtreeManagerRegistryBuilderBuilder.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/AbstractSubtreeManagerRegistryBuilderBuilder.java @@ -192,10 +192,10 @@ public abstract class AbstractSubtreeManagerRegistryBuilderBuilder Collector singleItemCollector() { return Collectors.collectingAndThen( @@ -56,12 +58,11 @@ public final class RWUtils { } /** - * Find next item in ID after provided type + * Find next item in ID after provided type. */ @Nonnull public static InstanceIdentifier.PathArgument getNextId(@Nonnull final InstanceIdentifier id, @Nonnull final InstanceIdentifier type) { - // TODO this is inefficient(maybe, depending on actual Iterable type) final Iterable pathArguments = id.getPathArguments(); final int i = Iterables.indexOf(pathArguments, new Predicate() { @Override @@ -74,7 +75,7 @@ public final class RWUtils { } /** - * Replace last item in ID with a provided IdentifiableItem of the same type + * Replace last item in ID with a provided IdentifiableItem of the same type. */ @SuppressWarnings("unchecked") @Nonnull @@ -90,7 +91,7 @@ public final class RWUtils { } /** - * Create IdentifiableItem from target type of provided ID with provided key + * Create IdentifiableItem from target type of provided ID with provided key. */ @Nonnull public static , K extends Identifier> InstanceIdentifier.IdentifiableItem getCurrentIdItem( @@ -99,7 +100,7 @@ public final class RWUtils { } /** - * Trim InstanceIdentifier at indexOf(type) + * Trim InstanceIdentifier at indexOf(type). */ @SuppressWarnings("unchecked") @Nonnull diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java index 1b6504c78..4d4e9fddd 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/TransactionMappingContext.java @@ -34,7 +34,7 @@ public class TransactionMappingContext implements MappingContext { private final ReadWriteTransaction readWriteTransaction; - // TODO make async + // TODO HONEYCOMB-169 make async public TransactionMappingContext(final ReadWriteTransaction readWriteTransaction) { this.readWriteTransaction = readWriteTransaction; diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java index 75a2a673c..40c78b3c9 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/read/AbstractGenericReader.java @@ -56,7 +56,8 @@ public abstract class AbstractGenericReader> implements Reade private static Optional findNextParent(@Nonnull final DataObject parent, @Nonnull final InstanceIdentifier.PathArgument nextId, @Nonnull final Class managedType) { - // TODO is there a better way than reflection ? e.g. convert into NN and filter out with a utility Optional method = ReflectionUtils.findMethodReflex(managedType, "get", Collections.emptyList(), nextId.getType()); @@ -172,19 +169,13 @@ class SubtreeReader> implements Reade checkArgument(nextId instanceof InstanceIdentifier.IdentifiableItem, "Unable to perform wildcarded read for %s", nextId); final Identifier key = ((InstanceIdentifier.IdentifiableItem) nextId).getKey(); - // TODO replace with stream().filter().findFirst() when we switch to using java's Optional instead of Guava's - // because now we would have to do awkward Optional transformation since findFirstReturns guava's optional - return Iterables.tryFind(invoke, new Predicate() { - - @Override - public boolean apply(@Nullable final DataObject input) { - final Optional keyGetter = ReflectionUtils.findMethodReflex(nextId.getType(), "get", - Collections.emptyList(), key.getClass()); - final Object actualKey; - actualKey = invoke(keyGetter.get(), nextId, input); - return key.equals(actualKey); - } - }); + + final Method keyGetter = ReflectionUtils.findMethodReflex(nextId.getType(), "get", + Collections.emptyList(), key.getClass()).get(); + + return Optional.fromNullable(invoke.stream() + .filter(item -> key.equals(invoke(keyGetter, nextId, item))) + .findFirst().orElse(null)); } private static DataObject filterSingle(final DataObject parent, 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 5d801edab..0128ee4a8 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 @@ -50,14 +50,13 @@ public final class TransactionWriteContext implements WriteContext { final DOMDataReadOnlyTransaction afterTx, final MappingContext mappingContext) { this.serializer = serializer; - // TODO do we have a BA transaction adapter ? If so, use it here and don't pass serializer this.beforeTx = beforeTx; this.afterTx = afterTx; this.mappingContext = mappingContext; this.ctx = new ModificationCache(); } - // TODO make this asynchronous + // TODO HONEYCOMB-169 make this asynchronous @Override public Optional readBefore(@Nonnull final InstanceIdentifier currentId) { @@ -78,7 +77,7 @@ public final class TransactionWriteContext implements WriteContext { tx.read(LogicalDatastoreType.CONFIGURATION, path); try { - // TODO once the APIs are asynchronous use just Futures.transform + // TODO HONEYCOMB-169 once the APIs are asynchronous use just Futures.transform final Optional> optional = read.checkedGet(); if (!optional.isPresent()) { diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistry.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistry.java index df8ec107b..ab80eb4ac 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistry.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/registry/FlatWriterRegistry.java @@ -139,13 +139,11 @@ final class FlatWriterRegistry implements WriterRegistry { } private Writer getSubtreeWriterResponsible(final InstanceIdentifier singleType) { - final Writer writer;// This is slow ( minor TODO-perf ) - writer = writers.values().stream() + return writers.values().stream() .filter(w -> w instanceof SubtreeWriter) .filter(w -> ((SubtreeWriter) w).getHandledChildTypes().contains(singleType)) .findFirst() .get(); - return writer; } private Collection getParentDataObjectUpdate(final WriteContext ctx, @@ -255,7 +253,6 @@ final class FlatWriterRegistry implements WriterRegistry { return writers.get(singleType); } - // FIXME unit test private final class ReverterImpl implements Reverter { private final Collection> processedNodes; diff --git a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java index 001e5567a..79155bdd6 100644 --- a/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java +++ b/infra/translate-utils/src/test/java/io/fd/honeycomb/translate/impl/write/util/TransactionWriteContextTest.java @@ -29,10 +29,10 @@ import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.base.Optional; import com.google.common.util.concurrent.Futures; +import io.fd.honeycomb.translate.MappingContext; import io.fd.honeycomb.translate.ModificationCache; import io.fd.honeycomb.translate.util.DataObjects; import io.fd.honeycomb.translate.util.write.TransactionWriteContext; -import io.fd.honeycomb.translate.MappingContext; import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -125,7 +125,10 @@ public class TransactionWriteContextTest { @Test public void testClose() throws Exception { final ModificationCache context = transactionWriteContext.getModificationCache(); + final Object o = new Object(); + context.put(o, o); + assertTrue(context.containsKey(o)); transactionWriteContext.close(); - // TODO verify context was closed + assertFalse(context.containsKey(o)); } } \ No newline at end of file -- cgit 1.2.3-korg