Merge changes from topic 'blueprint'
authorAnil Vishnoi <vishnoianil@gmail.com>
Thu, 9 Jun 2016 01:41:20 +0000 (01:41 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 9 Jun 2016 01:41:20 +0000 (01:41 +0000)
* changes:
  Add blueprint wiring for the drop-test app
  Add blueprint wiring for the bulk-o-matic app
  Add blueprint wiring for the lldp-speaker app
  Add blueprint wiring for the of-switch-config-pusher app
  Add blueprint wiring for the table-miss-enforcer app

95 files changed:
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/FlowNodeReconciliation.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/NodeListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/SyncReactor.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeCachedDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeOdlDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/dao/FlowCapableNodeSnapshotDao.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/AbstractFrmSyncListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProvider.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/FrmExecutors.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListener.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorFutureWithCompressionDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecorator.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarder.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/FlowCapableNodeLookups.java
applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperGuavaImpl.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/FlowForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/ForwardingRulesSyncProviderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/GroupForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/MeterForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedConfigListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SimplifiedOperationalListenerTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java [new file with mode: 0644]
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/TableForwarderTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/DiffInputFactory.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImplTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/ReconcileUtilTest.java
applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/util/SemaphoreKeeperTest.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceState.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/lifecycle/DeviceContextChangeListener.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitch.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java [new file with mode: 0644]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/session/SessionContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/role/RoleManager.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/RpcManager.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/role/RoleContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/RoleService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalRoleServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/SinglePurposeMultipartReplyTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedV10Translator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PortUpdateTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtils.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslator.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/TransactionChainManagerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/AbstractRequestCallbackTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalGroupServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalMeterServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/ServiceMocking.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/SinglePurposeMultipartReplyTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImplParamTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/MessageIntelligenceAgencyImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/AggregatedFlowStatisticsTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/translator/FlowRemovedTranslatorTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/util/NodeConnectorRefToPortTranslatorTest.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/role/OfEntityManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/AbstractModelDrivenSwitch.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContextOFImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/RoleUtil.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/ModelDrivenSwitchImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/SalRegistrationManagerTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/FlowConvertorTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/OFRoleManagerTest.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginGroupTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginMeterTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginStatsTestCommandProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTableFeaturesTestServiceProvider.java
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestServiceProvider.java

index 5e891b1721188c1eaf69e75ba80f396e48bcd53c..9bf1f26732f96af104febb614013420437e016df 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.openflowplugin.applications.frm;
 
 import org.opendaylight.controller.md.sal.binding.api.ClusteredDataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -35,7 +36,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  *
  * Created: Aug 26, 2014
  */
-public interface FlowNodeReconciliation extends ClusteredDataChangeListener, AutoCloseable {
+public interface FlowNodeReconciliation extends ClusteredDataTreeChangeListener<FlowCapableNode>, AutoCloseable {
 
     /**
      * Method contains Node registration to {@link ForwardingRulesManager} functionality
index 2b62037b373c20eade1284e0ff6d14fdcd43a556..b85fe411b848581c517ed9628cd4596a031e8c56 100644 (file)
@@ -8,25 +8,20 @@
 
 package org.opendaylight.openflowplugin.applications.frm.impl;
 
+import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
+
 import java.util.concurrent.Callable;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+
+import org.opendaylight.controller.md.sal.binding.api.*;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -38,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
@@ -59,6 +55,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
@@ -71,6 +69,8 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nonnull;
+
 
 /**
  * forwardingrules-manager
@@ -92,7 +92,13 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     private final ForwardingRulesManager provider;
     public static final String SEPARATOR = ":";
 
-    private ListenerRegistration<DataChangeListener> listenerRegistration;
+    private ListenerRegistration<FlowNodeReconciliationImpl> listenerRegistration;
+
+    private static final InstanceIdentifier<FlowCapableNode> II_TO_FLOW_CAPABLE_NODE
+            = InstanceIdentifier.builder(Nodes.class)
+            .child(Node.class)
+            .augmentation(FlowCapableNode.class)
+            .build();
 
     public FlowNodeReconciliationImpl (final ForwardingRulesManager manager, final DataBroker db) {
         this.provider = Preconditions.checkNotNull(manager, "ForwardingRulesManager can not be null!");
@@ -101,14 +107,17 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
         final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class).augmentation(FlowCapableNode.class);
 
+        final DataTreeIdentifier<FlowCapableNode> treeId =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
+
+        try {
         SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK,
                 ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
-        try {
-            listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<DataChangeListener>>() {
+
+            listenerRegistration = looper.loopUntilNoException(new Callable<ListenerRegistration<FlowNodeReconciliationImpl>>() {
                 @Override
-                public ListenerRegistration<DataChangeListener> call() throws Exception {
-                    return db.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
-                            flowNodeWildCardIdentifier, FlowNodeReconciliationImpl.this, DataChangeScope.BASE);
+                public ListenerRegistration<FlowNodeReconciliationImpl> call() throws Exception {
+                    return dataBroker.registerDataTreeChangeListener(treeId, FlowNodeReconciliationImpl.this);
                 }
             });
         } catch (Exception e) {
@@ -132,46 +141,70 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     }
 
     @Override
-    public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
-        Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
-        /* All DataObjects for create */
-        final Set<InstanceIdentifier<?>>  createdData = changeEvent.getCreatedData() != null
-                ? changeEvent.getCreatedData().keySet() : Collections.<InstanceIdentifier<?>> emptySet();
-        /* All DataObjects for remove */
-        final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
-                ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
-        /* All updated DataObjects */
-        final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
-                ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject>emptyMap();
-
-        for (InstanceIdentifier<?> entryKey : removeData) {
-            final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
-                    .firstIdentifierOf(FlowCapableNode.class);
+    public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> changes) {
+        Preconditions.checkNotNull(changes, "Changes may not be null!");
+
+        for (DataTreeModification<FlowCapableNode> change : changes) {
+            final InstanceIdentifier<FlowCapableNode> key = change.getRootPath().getRootIdentifier();
+            final DataObjectModification<FlowCapableNode> mod = change.getRootNode();
+            final InstanceIdentifier<FlowCapableNode> nodeIdent =
+                    key.firstIdentifierOf(FlowCapableNode.class);
+
+            switch (mod.getModificationType()) {
+                case DELETE:
+                    remove(key, mod.getDataBefore(), nodeIdent);
+                    break;
+                case SUBTREE_MODIFIED:
+                    update(key, mod.getDataBefore(), mod.getDataAfter(), nodeIdent);
+                    break;
+                case WRITE:
+                    if (mod.getDataBefore() == null) {
+                        add(key, mod.getDataAfter(), nodeIdent);
+                    } else {
+                        update(key, mod.getDataBefore(), mod.getDataAfter(), nodeIdent);
+                    }
+                    break;
+                default:
+                    throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
+            }
+        }
+    }
+
+
+
+    public void remove(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode del,
+                       InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
+            LOG.warn("Node removed: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+
             if ( ! nodeIdent.isWildcarded()) {
                 flowNodeDisconnected(nodeIdent);
             }
+
         }
-        for (InstanceIdentifier<?> entryKey : createdData) {
-            final InstanceIdentifier<FlowCapableNode> nodeIdent = entryKey
-                    .firstIdentifierOf(FlowCapableNode.class);
-            if ( ! nodeIdent.isWildcarded()) {
-                flowNodeConnected(nodeIdent);
+    }
+
+
+    public void update(InstanceIdentifier<FlowCapableNode> identifier,
+                       FlowCapableNode original, FlowCapableNode update, InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
+            LOG.warn("Node updated: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+            //donot need to do anything as we are not considering updates here
+            if (!nodeIdent.isWildcarded()) {
+                // then force registration to local node cache and reconcile
+                flowNodeConnected(nodeIdent, true);
             }
         }
+    }
 
-        // FIXME: just a hack to cover DS/operational dirty start
-        // if all conventional ways failed and there is update
-        if (removeData.isEmpty() && createdData.isEmpty() && updateData.size() == 1) {
-            for (Map.Entry<InstanceIdentifier<?>, DataObject> entry : updateData.entrySet()) {
-                // and only if this update covers top element (flow-capable-node)
-                if (FlowCapableNode.class.equals(entry.getKey().getTargetType())) {
-                    final InstanceIdentifier<FlowCapableNode> nodeIdent = entry.getKey()
-                            .firstIdentifierOf(FlowCapableNode.class);
-                    if (!nodeIdent.isWildcarded()) {
-                        // then force registration to local node cache and reconcile
-                        flowNodeConnected(nodeIdent, true);
-                    }
-                }
+
+    public void add(InstanceIdentifier<FlowCapableNode> identifier, FlowCapableNode add,
+                    InstanceIdentifier<FlowCapableNode> nodeIdent) {
+        if(compareInstanceIdentifierTail(identifier,II_TO_FLOW_CAPABLE_NODE)){
+            LOG.warn("Node added: {}",nodeIdent.firstKeyOf(Node.class).getId().getValue());
+
+            if ( ! nodeIdent.isWildcarded()) {
+                flowNodeConnected(nodeIdent);
             }
         }
     }
@@ -534,8 +567,9 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
     }
 
 
-
-
-
+    private boolean compareInstanceIdentifierTail(InstanceIdentifier<?> identifier1,
+                                                  InstanceIdentifier<?> identifier2) {
+        return Iterables.getLast(identifier1.getPathArguments()).equals(Iterables.getLast(identifier2.getPathArguments()));
+    }
 }
 
index df1bab02168f862c57ff3c57da67dad9545d157a..f3bc24928f31b93f4188d706568c66ae0c9883fd 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync;
 
 import java.util.EventListener;
-
 import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
index 12cffd1362eb6bdaab84810cba078d04521cf493..141e3b465ae915b87fa06c0e1490d9c7ae7f68bd 100644 (file)
@@ -8,11 +8,10 @@
 
 package org.opendaylight.openflowplugin.applications.frsync;
 
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Device synchronization API.
  */
index 0aebb06b0c7bc5c8370f33dbf2bc7cb85379e4a0..149c25959605e1eb272fb2da055708034b62c5b7 100644 (file)
@@ -8,13 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Implementation of data access object for {@link FlowCapableNode}.\r
  * Contains pair of snapshot and odl DAOs.\r
index 0bc6b991ce9ff3e3dbd058c15e6d857e466c95d8..469fc13cde12b082f50ae9054ba067271872dbcb 100644 (file)
@@ -8,13 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Data access object for {@link FlowCapableNode}.\r
  */\r
index 724c43ad67d0f73b7602f76e08bc2793d614aa57..a97fcc170836e9898245710a2a872aa78c675395 100644 (file)
@@ -9,10 +9,8 @@
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
 import com.google.common.base.Optional;\r
-\r
 import java.util.concurrent.TimeUnit;\r
 import java.util.concurrent.TimeoutException;\r
-\r
 import javax.annotation.Nonnull;\r
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;\r
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;\r
index 2c40af77b91beb73f339f8a41f59c10e5eb1d082..5cbf726cc53af6400e2c82a8682f764649761991 100644 (file)
@@ -8,15 +8,12 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.dao;\r
 \r
+import com.google.common.base.Optional;\r
 import java.util.concurrent.ConcurrentHashMap;\r
-\r
 import javax.annotation.Nonnull;\r
-\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
 \r
-import com.google.common.base.Optional;\r
-\r
 /**\r
  * Adding cache to data access object of {@link FlowCapableNode}.\r
  */\r
index 4d1e53a6932ff16f9fc5671122eb19639aa5a49f..2a4d1bd0f5b3d4559cb41778b138203b02b6e67d 100644 (file)
@@ -52,9 +52,9 @@ public abstract class AbstractFrmSyncListener<T extends DataObject> implements N
     protected abstract Optional<ListenableFuture<Boolean>> processNodeModification(
             DataTreeModification<T> modification) throws ReadFailedException, InterruptedException;
 
-    public abstract LogicalDatastoreType dsType();
+    protected abstract LogicalDatastoreType dsType();
 
-    static String threadName() {
+    private static String threadName() {
         final Thread currentThread = Thread.currentThread();
         return currentThread.getName();
     }
index f0babcba30af0ae1659b4bfe4a1397e37613f0b7..8bc18dd0ffec6c228a7f3548b78ebe4a8e30ff56 100644 (file)
@@ -8,8 +8,8 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Preconditions;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
@@ -26,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Upda
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -36,8 +35,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 /**
  * Implements {@link ForwardingRulesCommitter} methods for processing add, update and remove of {@link Flow}.
  */
index 57c404b6d8cca5c7a0913e960e1e8cb5f189aa12..a35cde26003ea1ab3dc2008615f3deabc32e1e36 100644 (file)
@@ -31,12 +31,8 @@ import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperG
 import org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -53,11 +49,7 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     public static final int STARTUP_LOOP_MAX_RETRIES = 8;
 
     private final DataBroker dataService;
-    private final SalFlowService salFlowService;
-    private final SalGroupService salGroupService;
-    private final SalMeterService salMeterService;
     private final SalTableService salTableService;
-    private final FlowCapableTransactionService transactionService;
     private final SalFlatBatchService flatBatchService;
 
     /** wildcard path to flow-capable-node augmentation of inventory node */
@@ -78,27 +70,14 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
     public ForwardingRulesSyncProvider(final BindingAwareBroker broker,
                                        final DataBroker dataBroker,
                                        final RpcConsumerRegistry rpcRegistry) {
-        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
-
         Preconditions.checkArgument(rpcRegistry != null, "RpcConsumerRegistry can not be null !");
-
-        this.salFlowService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlowService.class),
-                "RPC SalFlowService not found.");
-        this.salGroupService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalGroupService.class),
-                "RPC SalGroupService not found.");
-        this.salMeterService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalMeterService.class),
-                "RPC SalMeterService not found.");
+        this.dataService = Preconditions.checkNotNull(dataBroker, "DataBroker can not be null!");
         this.salTableService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalTableService.class),
                 "RPC SalTableService not found.");
-        this.transactionService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(FlowCapableTransactionService.class),
-                        "RPC SalTableService not found.");
-        this.flatBatchService =
-                Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
-                        "RPC SalFlatBatchService not found.");
-
-        nodeConfigDataTreePath =
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
+        this.flatBatchService = Preconditions.checkNotNull(rpcRegistry.getRpcService(SalFlatBatchService.class),
+                "RPC SalFlatBatchService not found.");
+
+        nodeConfigDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, FLOW_CAPABLE_NODE_WC_PATH);
         nodeOperationalDataTreePath = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, NODE_WC_PATH);
 
         broker.registerProvider(this);
@@ -121,69 +100,52 @@ public class ForwardingRulesSyncProvider implements AutoCloseable, BindingAwareP
 
     @Override
     public void onSessionInitiated(final BindingAwareBroker.ProviderContext providerContext) {
-        final FlowForwarder flowForwarder = new FlowForwarder(salFlowService);
-        final GroupForwarder groupForwarder = new GroupForwarder(salGroupService);
-        final MeterForwarder meterForwarder = new MeterForwarder(salMeterService);
         final TableForwarder tableForwarder = new TableForwarder(salTableService);
 
-        {
-            //TODO: make is switchable
-//            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl()
-//                    .setFlowForwarder(flowForwarder)
-//                    .setGroupForwarder(groupForwarder)
-//                    .setMeterForwarder(meterForwarder)
-//                    .setTableForwarder(tableForwarder)
-//                    .setTransactionService(transactionService);
-
-            final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
-                    .setFlatBatchService(flatBatchService)
-                    .setTableForwarder(tableForwarder);
-
-            final SyncReactorImpl syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
-            final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorImpl,
-                    new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
-
-            final SyncReactor cfgReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-            final SyncReactor operReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
-
-            final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
-            final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
-            final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
-                    new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
-
-            final NodeListener<FlowCapableNode> nodeListenerConfig =
-                    new SimplifiedConfigListener(
-                            cfgReactor,
-                            configSnapshot, operationalDao);
-            final NodeListener<Node> nodeListenerOperational =
-                    new SimplifiedOperationalListener(operReactor, operationalSnapshot, configDao);
-
-            try {
-                SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeConfigChangeListener = looper1.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeConfigDataTreePath, nodeListenerConfig);
-                            }
-                        });
-
-                SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
-                dataTreeOperationalChangeListener = looper2.loopUntilNoException(
-                        new Callable<ListenerRegistration<NodeListener>>() {
-                            @Override
-                            public ListenerRegistration<NodeListener> call() throws Exception {
-                                return dataService.registerDataTreeChangeListener(
-                                        nodeOperationalDataTreePath, nodeListenerOperational);
-                            }
-                        });
-            } catch (final Exception e) {
-                LOG.warn("FR-Sync node DataChange listener registration fail!", e);
-                throw new IllegalStateException("FR-Sync startup fail!", e);
-            }
+        final SyncPlanPushStrategy syncPlanPushStrategy = new SyncPlanPushStrategyFlatBatchImpl()
+                .setFlatBatchService(flatBatchService)
+                .setTableForwarder(tableForwarder);
+
+        final SyncReactorImpl syncReactorImpl = new SyncReactorImpl(syncPlanPushStrategy);
+        final SyncReactor syncReactorGuard = new SyncReactorGuardDecorator(syncReactorImpl,
+                new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+
+        final SyncReactor cfgReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
+        final SyncReactor operReactor = new SyncReactorFutureWithCompressionDecorator(syncReactorGuard, syncThreadPool);
+
+        final FlowCapableNodeSnapshotDao configSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeSnapshotDao operationalSnapshot = new FlowCapableNodeSnapshotDao();
+        final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.CONFIGURATION));
+        final FlowCapableNodeDao operationalDao = new FlowCapableNodeCachedDao(operationalSnapshot,
+                new FlowCapableNodeOdlDao(dataService, LogicalDatastoreType.OPERATIONAL));
+
+        final NodeListener<FlowCapableNode> nodeListenerConfig = new SimplifiedConfigListener(cfgReactor, configSnapshot, operationalDao);
+        final NodeListener<Node> nodeListenerOperational = new SimplifiedOperationalListener(operReactor, operationalSnapshot, configDao);
+
+        try {
+            SimpleTaskRetryLooper looper1 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeConfigChangeListener = looper1.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeConfigDataTreePath, nodeListenerConfig);
+                        }
+                    });
+
+            SimpleTaskRetryLooper looper2 = new SimpleTaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
+            dataTreeOperationalChangeListener = looper2.loopUntilNoException(
+                    new Callable<ListenerRegistration<NodeListener>>() {
+                        @Override
+                        public ListenerRegistration<NodeListener> call() throws Exception {
+                            return dataService.registerDataTreeChangeListener(
+                                    nodeOperationalDataTreePath, nodeListenerOperational);
+                        }
+                    });
+        } catch (final Exception e) {
+            LOG.warn("FR-Sync node DataChange listener registration fail!", e);
+            throw new IllegalStateException("FR-Sync startup fail!", e);
         }
         LOG.info("ForwardingRulesSync has started.");
     }
index 44e625dd239a712a896c8bd108b90e7a551567dc..17c500f003ca86bf992eed0db8ea6ea0d42de5be 100644 (file)
@@ -8,33 +8,32 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
-import java.util.concurrent.ExecutorService;\r
-import java.util.concurrent.Executors;\r
-import java.util.concurrent.ThreadFactory;\r
-\r
 import com.google.common.annotations.VisibleForTesting;\r
 import com.google.common.util.concurrent.ListeningExecutorService;\r
 import com.google.common.util.concurrent.MoreExecutors;\r
+import java.util.concurrent.ExecutorService;\r
+import java.util.concurrent.Executors;\r
+import java.util.concurrent.ThreadFactory;\r
 \r
 /**\r
- * Static Factory for creating ExecutorServicess (because there is no dependency injection but\r
+ * Static Factory for creating ExecutorServices (because there is no dependency injection but\r
  * static getInstance).\r
  */\r
 public final class FrmExecutors {\r
-    public static PceExecursFactory instance() {\r
+    public static PceExecutorsFactory instance() {\r
         return DEFAULT_EXECUTORS;\r
     }\r
 \r
-    public interface PceExecursFactory {\r
+    public interface PceExecutorsFactory {\r
 \r
-        public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);\r
+        ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory);\r
     }\r
 \r
     /**\r
      * This will be rewritten in JUnits using SynchronousExecutorService\r
      */\r
     @VisibleForTesting // should not be private and final\r
-    static PceExecursFactory DEFAULT_EXECUTORS = new PceExecursFactory() {\r
+    static PceExecutorsFactory DEFAULT_EXECUTORS = new PceExecutorsFactory() {\r
 \r
         public ListeningExecutorService newFixedThreadPool(int nThreads, ThreadFactory factory) {\r
             final ExecutorService executorService = Executors.newFixedThreadPool(nThreads, factory);\r
index 9e69f2c40e078dc6b47d2bd38afef6fdb8b6d6cc..58faaab38f5706135eebd49fa8406e70ffe1aca8 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
index 94265eccfc737c3c4c3248429039e538c146bfa9..c2298aa7dec155ac6b99bfbe26794d47a0de3779 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -23,15 +24,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to config changes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedConfigListener extends AbstractFrmSyncListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedConfigListener.class);
-    protected final SyncReactor reactor;
+    private final SyncReactor reactor;
     private final FlowCapableNodeSnapshotDao configSnaphot;
     private final FlowCapableNodeDao operationalDao;
 
index e66bf3f25f8f4c5106b6bc70c6099ddf4afc30a2..573ca80d68d66a9314271af5653d167561d037b9 100644 (file)
@@ -8,9 +8,10 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.List;
-
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
@@ -29,25 +30,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
-
 /**
  * Listens to operational new nodes and delegates add/remove/update/barrier to {@link SyncReactor}.
  */
 public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(SimplifiedOperationalListener.class);
 
-    protected final SyncReactor reactor;
-
-    private FlowCapableNodeSnapshotDao operationalSnaphot;
-
+    private final SyncReactor reactor;
+    private FlowCapableNodeSnapshotDao operationalSnapshot;
     private FlowCapableNodeDao configDao;
 
     public SimplifiedOperationalListener(SyncReactor reactor,
-            FlowCapableNodeSnapshotDao operationalSnaphot, FlowCapableNodeDao configDao) {
+            FlowCapableNodeSnapshotDao operationalSnapshot, FlowCapableNodeDao configDao) {
         this.reactor = reactor;
-        this.operationalSnaphot = operationalSnaphot;
+        this.operationalSnapshot = operationalSnapshot;
         this.configDao = configDao;
     }
 
@@ -82,17 +78,17 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
     /**
      * Remove if delete. Update only if FlowCapableNode Augmentation modified.
      *
-     * @param modification
+     * @param modification Datastore modification
      */
     protected void updateCache(DataTreeModification<Node> modification) {
         try {
             boolean isDelete = isDelete(modification) || isDeleteLogical(modification);
             if (isDelete) {
-                operationalSnaphot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
+                operationalSnapshot.updateCache(nodeId(modification), Optional.<FlowCapableNode>absent());
                 return;
             }
 
-            operationalSnaphot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
+            operationalSnapshot.updateCache(nodeId(modification), Optional.fromNullable(flowCapableNodeAfter(modification)));
         } catch(Exception e) {
             LOG.error("update cache failed {}", nodeId(modification), e);
         }
@@ -159,14 +155,16 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
             DataTreeModification<Node> modification) throws InterruptedException {
         final NodeId nodeId = nodeId(modification);
 
-        LOG.debug("reconciliation {}", nodeId.getValue());
+        LOG.debug("Reconciliation: {}", nodeId.getValue());
 
         final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
         final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class)
                 .child(Node.class, new NodeKey(nodeId(modification))).augmentation(FlowCapableNode.class);
-        final ListenableFuture<Boolean> rpcResult =
-                reactor.syncup(nodePath, nodeConfiguration.orNull(), flowCapableNodeAfter(modification));
-        return Optional.of(rpcResult);
+
+        if (nodeConfiguration.isPresent())
+            return Optional.of(reactor.syncup(nodePath, nodeConfiguration.get(), flowCapableNodeAfter(modification)));
+        else
+            return skipModification(modification);
     }
 
     static FlowCapableNode flowCapableNodeAfter(DataTreeModification<Node> modification) {
@@ -183,11 +181,8 @@ public class SimplifiedOperationalListener extends AbstractFrmSyncListener<Node>
         }
 
         final List<NodeConnector> nodeConnectors = node.getNodeConnector();
-        if (nodeConnectors == null || nodeConnectors.isEmpty()) {
-            return true;
-        }
 
-        return false;
+        return nodeConnectors == null || nodeConnectors.isEmpty();
     }
 
     static String nodeIdValue(DataTreeModification<Node> modification) {
index fb0b3e98503f6cb08bd245631e5c10ce338c5edd..33db6ea9c54f467253abea1125571fba0a2f2f0d 100644 (file)
@@ -8,10 +8,11 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.util.concurrent.ListenableFuture;\r
+import com.google.common.util.concurrent.ListeningExecutorService;\r
 import java.util.concurrent.Callable;\r
 import java.util.concurrent.TimeUnit;\r
 import java.util.concurrent.TimeoutException;\r
-\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;\r
@@ -20,9 +21,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
 /**\r
  * Decorator for running delegate syncup in Future.\r
  */\r
index 44f3ee7fbe6a7dcad507a296cf71b52850c0e8f5..ce7c579070def5a766b439cdb7e6e8d3e5076e76 100644 (file)
@@ -8,12 +8,13 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.util.concurrent.Futures;\r
+import com.google.common.util.concurrent.ListenableFuture;\r
+import com.google.common.util.concurrent.ListeningExecutorService;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
 import java.util.concurrent.Semaphore;\r
-\r
 import javax.annotation.concurrent.GuardedBy;\r
-\r
 import org.apache.commons.lang3.tuple.Pair;\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
@@ -23,10 +24,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-import com.google.common.util.concurrent.ListeningExecutorService;\r
-\r
 /**\r
  * Enriches {@link SyncReactorFutureDecorator} with state compression.\r
  */\r
@@ -34,10 +31,10 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
 \r
     private static final Logger LOG = LoggerFactory.getLogger(SyncReactorFutureWithCompressionDecorator.class);\r
 \r
-    @GuardedBy("beforeCompressionGuard")\r
-    final Map<InstanceIdentifier<FlowCapableNode>, Pair<FlowCapableNode, FlowCapableNode>> beforeCompression =\r
+    @GuardedBy("compressionGuard")\r
+    final Map<InstanceIdentifier<FlowCapableNode>, Pair<FlowCapableNode, FlowCapableNode>> compressionQueue =\r
             new HashMap<>();\r
-    final Semaphore beforeCompressionGuard = new Semaphore(1, false);\r
+    final Semaphore compressionGuard = new Semaphore(1, false);\r
 \r
     public SyncReactorFutureWithCompressionDecorator(SyncReactor delegate, ListeningExecutorService executorService) {\r
         super(delegate, executorService);\r
@@ -49,7 +46,7 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
         LOG.trace("syncup {}", nodeId.getValue());\r
 \r
         try {\r
-            beforeCompressionGuard.acquire();\r
+            compressionGuard.acquire();\r
 \r
             final boolean newFutureNecessary = updateCompressionState(flowcapableNodePath, configTree, operationalTree);\r
             if (newFutureNecessary) {\r
@@ -57,7 +54,7 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
             }\r
             return Futures.immediateFuture(true);\r
         } finally {\r
-            beforeCompressionGuard.release();\r
+            compressionGuard.release();\r
         }\r
     }\r
 \r
@@ -79,13 +76,13 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
 \r
     protected boolean updateCompressionState(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath,\r
             final FlowCapableNode configTree, final FlowCapableNode operationalTree) {\r
-        final Pair<FlowCapableNode, FlowCapableNode> previous = beforeCompression.get(flowcapableNodePath);\r
+        final Pair<FlowCapableNode, FlowCapableNode> previous = compressionQueue.get(flowcapableNodePath);\r
         if (previous != null) {\r
             final FlowCapableNode previousOperational = previous.getRight();\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, previousOperational));\r
+            compressionQueue.put(flowcapableNodePath, Pair.of(configTree, previousOperational));\r
             return false;\r
         } else {\r
-            beforeCompression.put(flowcapableNodePath, Pair.of(configTree, operationalTree));\r
+            compressionQueue.put(flowcapableNodePath, Pair.of(configTree, operationalTree));\r
             return true;\r
         }\r
     }\r
@@ -94,14 +91,14 @@ public class SyncReactorFutureWithCompressionDecorator extends SyncReactorFuture
             final InstanceIdentifier<FlowCapableNode> flowcapableNodePath) {\r
         try {\r
             try {\r
-                beforeCompressionGuard.acquire();\r
+                compressionGuard.acquire();\r
             } catch (InterruptedException e) {\r
                 return null;\r
             }\r
 \r
-            return beforeCompression.remove(flowcapableNodePath);\r
+            return compressionQueue.remove(flowcapableNodePath);\r
         } finally {\r
-            beforeCompressionGuard.release();\r
+            compressionGuard.release();\r
         }\r
     }\r
 }\r
index ea019e5ee6bd72bf2c0266ee24f596014bf362c5..92627831e7b8f007a086a5434a82dec0522f1f31 100644 (file)
@@ -8,11 +8,13 @@
 \r
 package org.opendaylight.openflowplugin.applications.frsync.impl;\r
 \r
+import com.google.common.base.Preconditions;\r
+import com.google.common.util.concurrent.FutureCallback;\r
+import com.google.common.util.concurrent.Futures;\r
+import com.google.common.util.concurrent.ListenableFuture;\r
 import java.util.concurrent.Semaphore;\r
 import java.util.concurrent.TimeUnit;\r
-\r
 import javax.annotation.Nullable;\r
-\r
 import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;\r
 import org.opendaylight.openflowplugin.applications.frsync.SyncReactor;\r
 import org.opendaylight.openflowplugin.applications.frsync.util.PathUtil;\r
@@ -22,11 +24,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-import com.google.common.base.Preconditions;\r
-import com.google.common.util.concurrent.FutureCallback;\r
-import com.google.common.util.concurrent.Futures;\r
-import com.google.common.util.concurrent.ListenableFuture;\r
-\r
 /**\r
  * Decorator for NodeId level syncup locking.\r
  */\r
@@ -73,10 +70,10 @@ public class SyncReactorGuardDecorator implements SyncReactor {
                                 formatNanos(stampAfterGuard - stampBeforeGuard),\r
                                 guard, threadName());\r
                     }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
+\r
+                    releaseGuardForNodeId(nodeId, guard);\r
                 }\r
-                \r
+\r
                 @Override\r
                 public void onFailure(final Throwable t) {\r
                     if (LOG.isDebugEnabled()) {\r
@@ -87,13 +84,13 @@ public class SyncReactorGuardDecorator implements SyncReactor {
                                 formatNanos(stampAfterGuard - stampBeforeGuard),\r
                                 guard, threadName());\r
                     }\r
-                    \r
-                    lockReleaseForNodeId(nodeId, guard);\r
+\r
+                    releaseGuardForNodeId(nodeId, guard);\r
                 }\r
             });\r
             return endResult;\r
         } catch(InterruptedException e) {\r
-            lockReleaseForNodeId(nodeId, guard);\r
+            releaseGuardForNodeId(nodeId, guard);\r
             throw e;\r
         }\r
     }\r
@@ -105,8 +102,8 @@ public class SyncReactorGuardDecorator implements SyncReactor {
     /**\r
      * get guard\r
      *\r
-     * @param flowcapableNodePath\r
-     * @return\r
+     * @param flowcapableNodePath II of node for which guard should be acquired\r
+     * @return semaphore guard\r
      */\r
     protected Semaphore summonGuardAndAcquire(final InstanceIdentifier<FlowCapableNode> flowcapableNodePath)\r
             throws InterruptedException {\r
@@ -129,11 +126,10 @@ public class SyncReactorGuardDecorator implements SyncReactor {
     /**\r
      * unlock per node\r
      *\r
-     * @param nodeId\r
-     * @param guard\r
+     * @param nodeId NodeId of node which should be unlocked\r
+     * @param guard semaphore guard\r
      */\r
-    protected void lockReleaseForNodeId(final NodeId nodeId,\r
-            final Semaphore guard) {\r
+    protected void releaseGuardForNodeId(final NodeId nodeId, final Semaphore guard) {\r
         if (guard == null) {\r
             return;\r
         }\r
index f2dc532bb6596369caaef4c5ff22e8c02766ab92..74347b1a8735107de89b32b64e3c355c4eb50999 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 
 import java.util.Collections;
 import java.util.concurrent.Future;
-
 import org.opendaylight.openflowplugin.applications.frsync.ForwardingRulesUpdateCommitter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
index 48560a457581128ec451afe58805d2a9b93dea1a..ed90d2854624002de508eda5556f6ce1b3fca027 100644 (file)
@@ -180,7 +180,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
             @Override
             public void onSuccess(@Nullable final RpcResult<ProcessFlatBatchOutput> result) {
                 if (!result.isSuccessful() && result.getResult() != null && !result.getResult().getBatchFailure().isEmpty()) {
-                    Map<Range<Integer>, Batch> batchMap = mapBachesToRanges(inputBatchBag, failureIndexLimit);
+                    Map<Range<Integer>, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit);
 
                     for (BatchFailure batchFailure : result.getResult().getBatchFailure()) {
                         for (Map.Entry<Range<Integer>, Batch> rangeBatchEntry : batchMap.entrySet()) {
@@ -224,7 +224,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         }
     }
 
-    static Map<Range<Integer>, Batch> mapBachesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
+    static Map<Range<Integer>, Batch> mapBatchesToRanges(final List<Batch> inputBatchBag, final int failureIndexLimit) {
         final Map<Range<Integer>, Batch> batchMap = new LinkedHashMap<>();
         final PeekingIterator<Batch> batchPeekingIterator = Iterators.peekingIterator(inputBatchBag.iterator());
         while (batchPeekingIterator.hasNext()) {
@@ -248,7 +248,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow remove
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
@@ -422,7 +421,6 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy {
         // process flow add+update
         if (flowItemSyncTableMap != null) {
             for (Map.Entry<TableKey, ItemSyncBox<Flow>> syncBoxEntry : flowItemSyncTableMap.entrySet()) {
-                final TableKey tableKey = syncBoxEntry.getKey();
                 final ItemSyncBox<Flow> flowItemSyncBox = syncBoxEntry.getValue();
 
                 if (!flowItemSyncBox.getItemsToPush().isEmpty()) {
index df3a3db7951c0e3e2641e1d81b51d67fb90b0ff2..1a6b277962b0fc36011366ea7261338d0543733f 100644 (file)
@@ -14,10 +14,8 @@ import java.util.List;
 import java.util.Map;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.openflowplugin.applications.frsync.markandsweep.SwitchFlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
index 1a11c9f16fe509eaccfde0df8bada1325db22815..2cd6204033839af51e4372ff0f9980069c3285dc 100644 (file)
@@ -8,15 +8,12 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.util;
 
-import java.util.concurrent.Semaphore;
-
-import javax.annotation.Nonnull;
-
-import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
-
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import java.util.concurrent.Semaphore;
+import javax.annotation.Nonnull;
+import org.opendaylight.openflowplugin.applications.frsync.SemaphoreKeeper;
 
 /**
  * Key-based semaphore provider.
index 1effafda9442521b74794c7e0a46fc0247aba4e1..7feb84aa58f1324ed504d3bea1b4381a3d263e2d 100644 (file)
@@ -12,7 +12,6 @@ import java.math.BigInteger;
 import java.util.Collections;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 1b1fac25e5f91068fe6239d87c122f0303d6efd2..76fb1fad803b57f91e90879625058f6bb523502f 100644 (file)
@@ -21,11 +21,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.FlowCapableTransactionService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
@@ -57,13 +54,8 @@ public class ForwardingRulesSyncProviderTest {
                 });
 
         provider = new ForwardingRulesSyncProvider(broker, dataBroker, rpcRegistry);
-
-        Mockito.verify(rpcRegistry).getRpcService(SalFlowService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalGroupService.class);
-        Mockito.verify(rpcRegistry).getRpcService(SalMeterService.class);
         Mockito.verify(rpcRegistry).getRpcService(SalTableService.class);
-        Mockito.verify(rpcRegistry).getRpcService(FlowCapableTransactionService.class);
-
+        Mockito.verify(rpcRegistry).getRpcService(SalFlatBatchService.class);
         Mockito.verify(broker).registerProvider(provider);
     }
 
index 2cf2eec9516ef166a8755d256877c538e29eebd4..8e980dcb60bd0bc2b51b9fcb95d3f2b9e99aeba1 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 7c820748d689234a9ca751d2eacfed4bee92b2bb..28ae5dc4c3e637916963a648e30050e3a673f697 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index 3b5caeaec036a414671d888f33755d4d35607640..7e37a1f9a5487b930e4b6286edd4f46277f59129 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,13 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.Futures;
-
 /**
  * Test for {@link SimplifiedConfigListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedConfigListenerTest {
 
index 4be870f5e8bd48dc6225ac7639b523b803787146..04005d2c0cfb72f477029265b7fddf7bbc063729 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.openflowplugin.applications.frsync.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.Futures;
 import java.util.Collections;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -35,16 +36,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.AsyncFunction;
-import com.google.common.util.concurrent.Futures;
 
 /**
  * Test for {@link SimplifiedOperationalListener}.
  */
-@SuppressWarnings("deprecation")
 @RunWith(MockitoJUnitRunner.class)
 public class SimplifiedOperationalListenerTest {
 
@@ -52,31 +47,41 @@ public class SimplifiedOperationalListenerTest {
     @Mock
     private SyncReactor reactor;
     @Mock
-    private DataBroker db;
+    private ReadOnlyTransaction roTx;
     @Mock
     private DataTreeModification<Node> dataTreeModification;
     @Mock
-    private ReadOnlyTransaction roTx;
+    private FlowCapableNode configNode;
     @Mock
-    private DataObjectModification<Node> operationalModification;
+    private FlowCapableNode fcOperationalNode;
 
     private InstanceIdentifier<Node> nodePath;
     private InstanceIdentifier<FlowCapableNode> fcNodePath;
     private SimplifiedOperationalListener nodeListenerOperational;
 
-    @SuppressWarnings("deprecation")
     @Before
     public void setUp() throws Exception {
+        final DataBroker db = Mockito.mock(DataBroker.class);
+        final DataObjectModification<Node> operationalModification = Mockito.mock(DataObjectModification.class);
+        final Node operationalNode = Mockito.mock(Node.class);
+
         final FlowCapableNodeSnapshotDao configSnaphot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeSnapshotDao operationalSnaphot = new FlowCapableNodeSnapshotDao();
         final FlowCapableNodeDao configDao = new FlowCapableNodeCachedDao(configSnaphot,
                 new FlowCapableNodeOdlDao(db, LogicalDatastoreType.CONFIGURATION));
-
-
         nodeListenerOperational = new SimplifiedOperationalListener(reactor, operationalSnaphot, configDao);
-        nodePath = InstanceIdentifier.create(Nodes.class)
-                .child(Node.class, new NodeKey(NODE_ID));
+        nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
         fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final DataTreeIdentifier<Node> dataTreeIdentifier =
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
+        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
+        Mockito.when(operationalModification.getDataAfter()).thenReturn(operationalNode);
     }
 
     @Test
@@ -85,29 +90,27 @@ public class SimplifiedOperationalListenerTest {
     }
 
     @Test
-    public void testOnDataTreeChanged() throws Exception {
-        final FlowCapableNode configTree = Mockito.mock(FlowCapableNode.class);
-        final Node mockOperationalNode = Mockito.mock(Node.class);
-        final FlowCapableNode mockOperationalFlowCapableNode = Mockito.mock(FlowCapableNode.class);
-        Mockito.when(mockOperationalNode.getAugmentation(FlowCapableNode.class))
-            .thenReturn(mockOperationalFlowCapableNode);
-        Mockito.when(mockOperationalNode.getId()).thenReturn(NODE_ID);
+    public void testOnDataTreeChangedSyncup() throws Exception {
+        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.of(configNode)));
 
-        final DataTreeIdentifier<Node> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, nodePath);
+        nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.when(dataTreeModification.getRootPath()).thenReturn(dataTreeIdentifier);
-        Mockito.when(dataTreeModification.getRootNode()).thenReturn(operationalModification);
-        Mockito.when(operationalModification.getDataAfter()).thenReturn(mockOperationalNode);
-        Mockito.when(db.newReadOnlyTransaction()).thenReturn(roTx);
-        Mockito.doReturn(Futures.immediateCheckedFuture(Optional.of(configTree))).when(
-                roTx).read(LogicalDatastoreType.CONFIGURATION, fcNodePath);
-        Mockito.when(reactor.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),Matchers.<FlowCapableNode>any()))
-                .thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        Mockito.verify(reactor, Mockito.times(1)).syncup(fcNodePath, configNode, fcOperationalNode);
+        Mockito.verify(roTx).close();
+    }
+
+    @Test
+    public void testOnDataTreeChangedSkip() throws Exception {
+        // Related to bug 5920 -> https://bugs.opendaylight.org/show_bug.cgi?id=5920
+        Mockito.when(roTx.read(LogicalDatastoreType.CONFIGURATION, fcNodePath))
+                .thenReturn(Futures.immediateCheckedFuture(Optional.absent()));
 
         nodeListenerOperational.onDataTreeChanged(Collections.singleton(dataTreeModification));
 
-        Mockito.verify(reactor).syncup(fcNodePath, configTree, mockOperationalFlowCapableNode);
+        Mockito.verifyZeroInteractions(reactor);
         Mockito.verify(roTx).close();
     }
 }
diff --git a/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java b/applications/forwardingrules-sync/src/test/java/org/opendaylight/openflowplugin/applications/frsync/impl/SyncReactorGuardDecoratorTest.java
new file mode 100644 (file)
index 0000000..8eda58c
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowplugin.applications.frsync.impl;
+
+import com.google.common.util.concurrent.Futures;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.opendaylight.openflowplugin.applications.frsync.util.SemaphoreKeeperGuavaImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Test for {@link SyncReactorGuardDecorator}.
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class SyncReactorGuardDecoratorTest {
+
+    private static final NodeId NODE_ID = new NodeId("test-node");
+    private SyncReactorGuardDecorator reactor;
+    private InstanceIdentifier<FlowCapableNode> fcNodePath;
+
+    @Mock
+    private SyncReactorImpl delegate;
+    @Mock
+    private FlowCapableNode fcConfigNode;
+    @Mock
+    private FlowCapableNode fcOperationalNode;
+
+    @Before
+    public void setUp() throws Exception {
+        reactor = new SyncReactorGuardDecorator(delegate, new SemaphoreKeeperGuavaImpl<InstanceIdentifier<FlowCapableNode>>(1, true));
+        InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(NODE_ID));
+        fcNodePath = nodePath.augmentation(FlowCapableNode.class);
+
+        final Node operationalNode = Mockito.mock(Node.class);
+        Mockito.when(operationalNode.getId()).thenReturn(NODE_ID);
+        Mockito.when(operationalNode.getAugmentation(FlowCapableNode.class)).thenReturn(fcOperationalNode);
+    }
+
+    @Test
+    public void testSyncupSuccess() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFuture(Boolean.TRUE));
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+
+    }
+
+    @Test
+    public void testSyncupFail() throws Exception {
+        Mockito.when(delegate.syncup(Matchers.<InstanceIdentifier<FlowCapableNode>>any(),Matchers.<FlowCapableNode>any(),
+                Matchers.<FlowCapableNode>any())).thenReturn(Futures.immediateFailedFuture(new Exception()));
+        reactor.syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+        Mockito.verify(delegate).syncup(fcNodePath, fcConfigNode, fcOperationalNode);
+
+    }
+
+}
\ No newline at end of file
index 7e88950e84b7b001c4b4a466bd511eea6e802ce7..86cf17bf4cadf39d11b6b41dee709a0b41b03170 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.applications.frsync.impl;
 import java.math.BigInteger;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
index a30d600799df016e1c1c8d2dd2bba8239f956b4f..0eadaef2304f7a106a96f14236ae1358035fb9de 100644 (file)
@@ -43,7 +43,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Group createPlainGroup(final long gid) {
+    private static Group createPlainGroup(final long gid) {
         return new GroupBuilder().setGroupId(new GroupId(gid)).build();
     }
 
@@ -67,7 +67,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Meter createPlainMeter(final long mid) {
+    private static Meter createPlainMeter(final long mid) {
         return new MeterBuilder().setMeterId(new MeterId(mid)).build();
     }
 
@@ -91,7 +91,7 @@ public class DiffInputFactory {
         return groupBox;
     }
 
-    static Flow createPlainFlow(final String fid) {
+    private static Flow createPlainFlow(final String fid) {
         return new FlowBuilder().setId(new FlowId(fid)).build();
     }
 }
index e83d9b036212141eb0c0753d29b10f42440d4d5e..90b7cf8b876e0c0a44a960641d7b1c526be5562e 100644 (file)
@@ -287,7 +287,7 @@ public class SyncPlanPushStrategyFlatBatchImplTest {
                 new BatchBuilder().setBatchOrder(9).build(),
                 new BatchBuilder().setBatchOrder(15).build()
         );
-        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBachesToRanges(inputBatchBag, 42);
+        final Map<Range<Integer>, Batch> rangeBatchMap = SyncPlanPushStrategyFlatBatchImpl.mapBatchesToRanges(inputBatchBag, 42);
 
         Assert.assertEquals(4, rangeBatchMap.size());
         int idx = 0;
index 75aa3b23bcd36e0f8dbe863aeff8bbbf99e5336c..ee09da96ee7447fd94ea482fb237f14537eb5d34 100644 (file)
@@ -12,6 +12,14 @@ import com.google.common.base.Splitter;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
@@ -46,15 +54,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * Test for {@link ReconcileUtil}.
  */
index f874eb7b5de3e8de9de6f21f001a4dda637032a7..b2d38d06ec87c36de820629eb7bbbc4e5f36fae1 100644 (file)
@@ -15,7 +15,6 @@ import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -29,7 +28,7 @@ import org.slf4j.LoggerFactory;
 public class SemaphoreKeeperTest {
     private static final Logger LOG = LoggerFactory.getLogger(SemaphoreKeeperTest.class);
     private SemaphoreKeeperGuavaImpl<String> semaphoreKeeper;
-    final String key = "11";
+    private final String key = "11";
 
     @Before
     public void setUp() throws Exception {
index 3af5e496428bf83d98bb3f948ae68d1eb52dad49..15d59383eb906dbbaf6f8fc9d0449f99bc6c2df7 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.api.openflow.device;
 
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
index 1cbc3c28039dbaaba0b9cb5ca884e4a12b81f494..36161c386ad0e7b14d38240d54e1d3f6e23eb384 100644 (file)
@@ -12,7 +12,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 /**
index a3ca90d6bd1828976e9c28b9ff1cb501de5c4097..19854c7913a1f91eb6307f08043d7d708f8d916a 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowplugin.api.openflow.lifecycle;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * This API is for all listeners who wish to know about device context in cluster
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/AbstractModelDrivenSwitchRegistration.java
new file mode 100644 (file)
index 0000000..e710c60
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow.md;
+
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+
+public abstract class AbstractModelDrivenSwitchRegistration extends AbstractObjectRegistration<ModelDrivenSwitch>
+    implements ModelDrivenSwitchRegistration {
+
+    protected AbstractModelDrivenSwitchRegistration(final ModelDrivenSwitch instance) {
+        super(instance);
+    }
+
+}
index 0120d9004f226ab95a92fd5e6f9f450980d4fdfc..90270c6326ffa39317e73571a727e1fb255c3fba 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.openflowplugin.api.openflow.md;
 
 import com.google.common.base.Optional;
+import java.math.BigInteger;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
@@ -25,12 +26,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalP
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import java.math.BigInteger;
-
 /**
  * interface concatenating all md-sal services provided by OF-switch
  */
@@ -47,7 +45,7 @@ public interface ModelDrivenSwitch
      * @param rpcProviderRegistry
      * @return wrapped list of {service provider + path} registration couples
      */
-    CompositeObjectRegistration<ModelDrivenSwitch> register(RpcProviderRegistry rpcProviderRegistry);
+    ModelDrivenSwitchRegistration register(RpcProviderRegistry rpcProviderRegistry);
 
     /**
      * @return id of encapsulated node (served by this impl)
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/ModelDrivenSwitchRegistration.java
new file mode 100644 (file)
index 0000000..9da85b3
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.api.openflow.md;
+
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+
+public interface ModelDrivenSwitchRegistration extends ObjectRegistration<ModelDrivenSwitch> {
+    @Override
+    void close();
+}
index 221055b4aa847cc592901b25dda28d2b24f3efba..9de1dd7ad4dab0f7594603b54ed8b5ac5039871b 100644 (file)
@@ -12,7 +12,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDist
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 
 /**
  * @author mirehak
@@ -160,12 +159,12 @@ public interface SessionContext {
     /**
      * @param registration provider composite registration
      */
-    void setProviderRegistration(CompositeObjectRegistration<ModelDrivenSwitch> registration);
+    void setProviderRegistration(ModelDrivenSwitchRegistration registration);
 
     /**
      * @return provider composite registration
      */
-    CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration();
+    ModelDrivenSwitchRegistration getProviderRegistration();
 
     /**
      * @return seed value for random operations
index 5a1bb0dbacc884d02ec9487f88a966cadb05f4aa..dee6ec896a289cc605205ef69c079caf16d23261 100644 (file)
@@ -7,12 +7,10 @@
  */
 package org.opendaylight.openflowplugin.api.openflow.role;
 
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * Created by kramesha on 8/31/15.
index f5c8e2894e91eb9d5910b64d9da9f00d1b53b479..63a0c984973c2e3c0eaf668386ae5efb5466a97d 100644 (file)
@@ -8,10 +8,9 @@
 
 package org.opendaylight.openflowplugin.api.openflow.rpc;
 
-import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 
 /**
index ddf73a75cc468af369bcfa7fa373c5f024d6c1b2..b55bff8720b3431029b134b7a853f3fe21e8fa26 100644 (file)
@@ -16,10 +16,14 @@ import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.DeviceContextChangeListener;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.RoleChangeListener;
@@ -31,12 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpR
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
 /**
  */
 public final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeListener, DeviceContextChangeListener {
index 441725723740f439ac10f78b1f03bc1e5d2c5028..28faad3263745e4c863970cc3486e7ae54237672 100644 (file)
@@ -66,7 +66,6 @@ import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl
 import org.opendaylight.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
 import org.opendaylight.openflowplugin.impl.registry.group.DeviceGroupRegistryImpl;
 import org.opendaylight.openflowplugin.impl.registry.meter.DeviceMeterRegistryImpl;
-import org.opendaylight.openflowplugin.impl.rpc.RpcContextImpl;
 import org.opendaylight.openflowplugin.impl.util.DeviceInitializationUtils;
 import org.opendaylight.openflowplugin.impl.util.MdSalRegistrationUtils;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SwitchConnectionCookieOFImpl;
index 16864cd33978183ee249314dbfa55eca8800c892..37768bc5e97d2e1592daaa0a2124cd5b6298858f 100644 (file)
@@ -19,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 /**
index 8cd41133159384c3f360f5538b085a2086590388..ab8136281671a144ef13ac4f0a8743e9b140d190 100644 (file)
@@ -8,12 +8,10 @@
 package org.opendaylight.openflowplugin.impl.role;
 
 import com.google.common.base.Preconditions;
-
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
 import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
@@ -21,7 +19,6 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
-import org.opendaylight.openflowplugin.impl.LifecycleConductorImpl;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
index 91feab60f6580be9199c1d9046cb845fde4c3780..c5dd4eb03f5e4cce0e83e8d6d88f35fe067d4a12 100644 (file)
@@ -15,7 +15,6 @@ import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.Semaphore;
-
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -23,7 +22,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.XidSequencer;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
index 3619e66e914d0f15eeaf0ba0940fc4b27ddac12f..0180530154532b8414c15fe396c5eea4bc6e4a1d 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.collect.Iterators;
 import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
index c677c53a68247079504cb9a8664125eb798020f6..07b5fadcad2b514f16dc89025d166088d1af5827 100644 (file)
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.role.RoleChangeException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInputBuilder;
index 0179f8e3f09112ebe945144dab64893f2b3b78f7..1ebc5d4b5ac461ef00f09877ac892db02bfd0c3f 100644 (file)
@@ -7,24 +7,17 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import java.util.Collection;
-import java.util.concurrent.Future;
-
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
@@ -44,8 +37,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-
 public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource {
     private static final Logger LOG = LoggerFactory.getLogger(SalGroupServiceImpl.class);
     private final GroupService<AddGroupInput, AddGroupOutput> addGroup;
index 946669043a64676799b0c3ad28689bd403c3d086..ced8aa4d3659fe16f22025523897d8b889ec7540 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.openflowplugin.impl.services;
 
-import java.util.Collection;
-import java.util.concurrent.Future;
-
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.Future;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
@@ -20,7 +20,6 @@ import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleLi
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
@@ -38,8 +37,6 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-
 public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource {
     private static final Logger LOG = LoggerFactory.getLogger(SalMeterServiceImpl.class);
     private final MeterService<AddMeterInput, AddMeterOutput> addMeter;
index 32aa20c843413c61f63c9c9ac28f11d45c71c877..c6d15de02fd457be14ab8d7f52c87e7e56f26851 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.role.RoleChangeException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
index 6c8d587854bb42d827dccaa50427e3a449201445..e58ea89b17ff0f09662d2951c10ba636715a2eed 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.statistics;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
@@ -53,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.Meter
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
index 1381bf9a2d57a5a934483c62291261de8ad76b8d..6e7626d4954a3c2855b3f860e551c81455de2e12 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
index 956389a10362294c029f8d2901c5b707538d7b35..4aa08b00288f215fe1ec111544d5600e9e025941 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
@@ -30,7 +29,7 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
                 .setCookie(new FlowCookie(input.getCookie()))
                 .setNode(new NodeRef(deviceState.getNodeInstanceIdentifier()))
                 .setPriority(input.getPriority())
-                .setTableId(input.getTableId().getValue().shortValue());
+                .setTableId(translateTableId(input));
 
         return flowRemovedBld.build();
     }
@@ -39,4 +38,14 @@ public class FlowRemovedTranslator implements MessageTranslator<FlowRemoved, org
         return MatchConvertorImpl.fromOFMatchToSALMatch(flowRemoved.getMatch(),
                 deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF13);
     }
+
+    /**
+     * Translate the table ID in the FLOW_REMOVED message to SAL table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  SAL table ID.
+     */
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return flowRemoved.getTableId().getValue().shortValue();
+    }
 }
index 2436faeaebd3908b79a123a378fb478100f9e753..23efec2ed636a1c5f06feb76987e7b5278c901e1 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
@@ -25,4 +24,15 @@ public class FlowRemovedV10Translator extends FlowRemovedTranslator {
         return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
                 deviceState.getFeatures().getDatapathId(), OpenflowVersion.OF10);
     }
+
+    /**
+     * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  Zero.
+     */
+    @Override
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return Short.valueOf((short)0);
+    }
 }
index 9e9793d66ca62f02a4e624f7bcf0549b7fff268e..08862300d76327896cc993a80abbb34882a90b04 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import com.google.common.annotations.VisibleForTesting;
 import java.math.BigInteger;
-import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
@@ -24,8 +22,6 @@ import org.opendaylight.openflowplugin.openflow.md.util.PacketInUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder;
index 6c35a2a50ec6692c994ef4fe15d72e3329549289..54a2b4c8d6e2baf25899d40e754bb82bda946dd2 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.openflowplugin.impl.translator;
 
 import java.util.Collections;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
 import org.opendaylight.openflowplugin.openflow.md.util.PortTranslatorUtil;
index d4da3cc131c277265c5705d961d0e16dcd444c47..a9a6e190af485f630958d0df2fd1cf479767f1fc 100644 (file)
@@ -15,9 +15,6 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.Arrays;
 import java.util.Collection;
index 4c71ea59e7ed4510d3c9f4f1996d80539ad4170c..477d73ab7ac7fc6fdcdd82afe0f30d30789e2fa9 100644 (file)
@@ -10,26 +10,22 @@ package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
+import java.math.BigInteger;
+import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import java.math.BigInteger;
-import java.util.List;
-import java.util.Objects;
-
 /**
  * Created by Tomas Slusny on 23.3.2016.
  */
index 63c28cdb6349a2d60513a7602fe119c8f39cfda4..1738fe3b130182afb60d6ce5b48383f3dff69df9 100644 (file)
@@ -11,12 +11,12 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.when;
-
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -33,9 +33,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
 @RunWith(MockitoJUnitRunner.class)
 public class LifecycleConductorImplTest {
 
index 3b6f0086ea80fba8467ee7f80f4089ba72718d1b..c32fdc8aab54cbde124a6d2ebcc4ab98e5743007 100644 (file)
@@ -8,9 +8,11 @@
 
 package org.opendaylight.openflowplugin.impl;
 
-import static org.mockito.Mockito.*;
-import static org.junit.Assert.*;
-
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.Futures;
 import org.junit.After;
@@ -23,9 +25,9 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService;
 
index 0d61ca0c7bb3633579f80899ac5b4720fdd153bd..8b254137fb25234bca8bf1fa7920275845e00dc3 100644 (file)
@@ -17,17 +17,15 @@ import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import io.netty.util.TimerTask;
 import java.lang.reflect.Field;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
-
-import com.google.common.util.concurrent.Futures;
-import io.netty.util.TimerTask;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -68,7 +66,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 @RunWith(MockitoJUnitRunner.class)
 public class DeviceManagerImplTest {
index fad7eb67927a5713a1d170aa4ea7a7c1b2166765..012d744252a87cd24ea40bc9b76bd0dc2cc460a4 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * openflowplugin-impl
index cd3a89bc3836509af4441a2a8788753d7c51576b..296ea4ef6b4d4bb89a7321d65e9276d28645b105 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.util.concurrent.Futures;
 import io.netty.util.HashedWheelTimer;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Matchers;
index 854d4d3269ac9fdb7317802680025cc123f28189..f523828cb17d9c76dac987c531dbc1855e352cac 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.openflowplugin.impl.rpc;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -20,7 +20,6 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
@@ -35,7 +34,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
-import java.util.concurrent.Semaphore;
 
 @RunWith(MockitoJUnitRunner.class)
 public class RpcContextImplTest {
index fe01124d6c94ab26c7fd4ccd7e398da7e40eccb3..b123dc1e1003ebc9c11bf71889916bf71006db0d 100644 (file)
@@ -7,7 +7,12 @@
  */
 package org.opendaylight.openflowplugin.impl.rpc;
 
+import static org.mockito.Mockito.atLeastOnce;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 import com.google.common.base.VerifyException;
+import java.util.concurrent.ConcurrentMap;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -35,17 +40,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 
-import java.util.concurrent.ConcurrentMap;
-
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
 
 @RunWith(MockitoJUnitRunner.class)
 public class RpcManagerImplTest {
index d39f9f558c368455ca6d57e659e2da567dbd2548..7b3d80006be936227c5f04bd46dfd577b3a96b4c 100644 (file)
@@ -1,6 +1,9 @@
 package org.opendaylight.openflowplugin.impl.services;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException;
@@ -12,13 +15,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
-import java.util.Collection;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
 public class AbstractRequestCallbackTest {
 
     private static final Class<?> DUMMY_REQUEST_TYPE = String.class;
index cdafaca8fb7850203ff4d57537cb4efabc77121b..61675a940686952d5189923535ac6ce33f7d4e53 100644 (file)
@@ -1,13 +1,23 @@
 package org.opendaylight.openflowplugin.impl.services;
 
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
@@ -16,13 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 public class SalGroupServiceImplTest extends ServiceMocking {
 
index faf1d13f50d601d7c4a4b56606a96f916919a2f9..e30adff06b49d672d06bfc04616fcd9196680f21 100644 (file)
@@ -4,30 +4,27 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
 import org.junit.Test;
 import org.mockito.Matchers;
 import org.mockito.Mock;
-import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.OriginalMeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 
 public class SalMeterServiceImplTest extends ServiceMocking {
 
index d6edde72994d8f0a5e04ff2bc29c229e9926b131..d826926f539fa1b4fce479a28c2b779bb7d20d34 100644 (file)
@@ -1,11 +1,8 @@
 package org.opendaylight.openflowplugin.impl.services;
 
-import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import io.netty.util.HashedWheelTimer;
 import java.math.BigInteger;
 import java.util.List;
 import org.junit.Before;
index 46414d6c822c6315dee8f751c6a87a207e890bf5..b5087063d2d7da9b66ee32e2be73d976ccb055bb 100644 (file)
@@ -1,64 +1,54 @@
 package org.opendaylight.openflowplugin.impl.statistics;
 
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdatedBuilder;
-//import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.*;
-
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 import com.google.common.collect.Lists;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionAware;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 
-import javax.sql.rowset.spi.TransactionalWriter;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 public class SinglePurposeMultipartReplyTranslatorTest {
 
     private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("21");
index 22e5bc44dd914a36eb5117aba0caa099be3a5803..31e74a8b3fcda53964d772d6cd393f1b0b3d7085 100644 (file)
@@ -24,9 +24,7 @@ import java.util.concurrent.ExecutionException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.mockito.Mockito;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yangtools.yang.common.RpcResult;
index f203cfbbc113236b86298b8d3fd77ea37249645b..b558ae343eea461fe50d7ad33129c8b68762e96b 100644 (file)
@@ -7,11 +7,9 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics;
 
-import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -23,7 +21,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Future;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,7 +52,6 @@ import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegist
 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -71,7 +67,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.GetStatisticsWorkModeOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsManagerControlService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.StatisticsWorkMode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
index d599b860b46b84dca3ddee04e168eeedce6e7f32..695a2e14a590ef7f770b175164143e35db5cedb6 100644 (file)
@@ -1,13 +1,10 @@
 package org.opendaylight.openflowplugin.impl.statistics.ofpspecific;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
+import java.util.List;
 import org.junit.Test;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
 
 public class MessageIntelligenceAgencyImplTest {
 
index a840fa9a4ae386fee01e45b4237938827ffd5cf6..bac6d1ebc571885026961161e8d97802f4e9091e 100644 (file)
@@ -15,7 +15,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
index a695ef097017dbdde2df959cea31b6d0ac9061cd..823a5b14651c24b875f6315b5d7d5999706b741e 100644 (file)
@@ -91,21 +91,21 @@ public class FlowRemovedTranslatorTest {
 
         assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
         assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
-        assertEquals((long)flowRemovedMessage.getTableId().getValue(), (long)flowRemoved.getTableId());
+        assertEquals((short)0, flowRemoved.getTableId().shortValue());
     }
 
     private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved buildMessage(boolean isV10) {
         FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder()
                 .setCookie(BigInteger.ONE)
-                .setPriority(1)
-                .setTableId(new TableId(42l));
+                .setPriority(1);
 
         if (isV10) {
             builder.setMatchV10(new MatchV10Builder().setWildcards(flowWildcards).build());
         } else {
-            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build());
+            builder.setMatch(new MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList()).build())
+                .setTableId(new TableId(42l));
         }
 
         return builder.build();
     }
-}
\ No newline at end of file
+}
index 9245bbbe01a4ca8308bd7d8b53e5551fd80caf37..c376457b733add008b2c10a3478ef9b4b31831ff 100644 (file)
@@ -1,20 +1,15 @@
 package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.collect.Lists;
+import java.math.BigInteger;
 import junit.framework.TestCase;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableId;
@@ -24,18 +19,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-import static org.mockito.Mockito.*;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * Created by Tomas Slusny on 24.3.2016.
index 910f930f6527df59be3648fb9de6df67568c92d0..4f446b58a1349af89fcfabe17511b2d1ab21c92a 100644 (file)
@@ -23,9 +23,9 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginConfig;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
@@ -348,13 +348,13 @@ public class OfEntityManager implements TransactionChainListener{
        // NOOP
     }
 
-    private void registerRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
+    private static void registerRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
         // Routed RPC registration is only done when *this* instance is owner of
         // the entity.
         if(entityMetadata.getOfSwitch().isEntityOwner()) {
             if (!entityMetadata.isRPCRegistrationDone.get()) {
                 entityMetadata.setIsRPCRegistrationDone(true);
-                CompositeObjectRegistration<ModelDrivenSwitch> registration =
+                ModelDrivenSwitchRegistration registration =
                         entityMetadata.getOfSwitch().register(entityMetadata.getRpcProviderRegistry());
 
                 entityMetadata.getContext().setProviderRegistration(registration);
@@ -368,9 +368,9 @@ public class OfEntityManager implements TransactionChainListener{
         }
     }
 
-    private void deregisterRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
+    private static void deregisterRoutedRPCForSwitch(MDSwitchMetaData entityMetadata) {
 
-        CompositeObjectRegistration<ModelDrivenSwitch> registration = entityMetadata.getContext().getProviderRegistration();
+        ModelDrivenSwitchRegistration registration = entityMetadata.getContext().getProviderRegistration();
         if (null != registration) {
             registration.close();
             entityMetadata.getContext().setProviderRegistration(null);
@@ -380,7 +380,7 @@ public class OfEntityManager implements TransactionChainListener{
                 entityMetadata.getOfSwitch().getNodeId().getValue());
     }
 
-    private void sendNodeAddedNotification(MDSwitchMetaData entityMetadata) {
+    private static void sendNodeAddedNotification(MDSwitchMetaData entityMetadata) {
         //Node added notification need to be sent irrespective of whether
         // *this* instance is owner of the entity or not. Because yang notifications
         // are local, and we should maintain the behavior across the application.
index ad4bdbc3ffa3a62df25e9eea6eaecc934af13b4b..088bc74800e7238a973bf1d78b2ca5f6c2fad935 100644 (file)
@@ -7,9 +7,14 @@
  */
 package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+import java.util.Collection;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.openflowplugin.api.openflow.md.AbstractModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
@@ -26,8 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalP
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 /**
@@ -52,9 +55,8 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> register(RpcProviderRegistry rpcProviderRegistry) {
-        CompositeObjectRegistrationBuilder<ModelDrivenSwitch> builder = CompositeObjectRegistration
-                .<ModelDrivenSwitch> builderFor(this);
+    public ModelDrivenSwitchRegistration register(RpcProviderRegistry rpcProviderRegistry) {
+        final Builder<RoutedRpcRegistration<?>> builder = ImmutableList.builder();
 
         final RoutedRpcRegistration<SalFlowService> flowRegistration = rpcProviderRegistry.addRoutedRpcImplementation(SalFlowService.class, this);
         flowRegistration.registerPath(NodeContext.class, getIdentifier());
@@ -108,7 +110,15 @@ public abstract class AbstractModelDrivenSwitch implements ModelDrivenSwitch {
         queueStatisticsRegistration.registerPath(NodeContext.class, getIdentifier());
         builder.add(queueStatisticsRegistration);
 
-        return builder.build();
+        final Collection<RoutedRpcRegistration<?>> registrations = builder.build();
+        return new AbstractModelDrivenSwitchRegistration(this) {
+            @Override
+            protected void removeRegistration() {
+                for (RoutedRpcRegistration<?> r : registrations) {
+                    r.close();
+                }
+            }
+        };
     }
 
     /**
index 900cc326cfe5e11d8db21f859b64f9269690faef..8b45aba2a2d6ab5980125e8da52e16d1ddc10e81 100644 (file)
@@ -17,11 +17,13 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationQueueWrapper;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionListener;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionManager;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -39,12 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -130,7 +129,7 @@ public class SalRegistrationManager implements SessionListener, AutoCloseable {
         unregOpenflowEntityOwnership(nodeId);
         NodeRemoved nodeRemoved = nodeRemoved(nodeRef);
 
-        CompositeObjectRegistration<ModelDrivenSwitch> registration = context.getProviderRegistration();
+        ModelDrivenSwitchRegistration registration = context.getProviderRegistration();
         if (null != registration) {
             registration.close();
             context.setProviderRegistration(null);
index 899e1f66c5874d5fb61ff94b7d15fc758a7da6d9..803f41bd7dbda22fec30e2ab6bd7c2fb154e3774 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
@@ -29,7 +29,6 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessio
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ControllerRole;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 
 /**
  * @author mirehak
@@ -46,7 +45,7 @@ public class SessionContextOFImpl implements SessionContext {
     private final AtomicLong xid;
     private final Map<Long, PortGrouping> physicalPorts;
     private final Map<Long, Boolean> portBandwidth;
-    private CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration;
+    private ModelDrivenSwitchRegistration providerRegistration;
     private int seed;
     private ControllerRole roleOnDevice = ControllerRole.OFPCRROLEEQUAL;
 
@@ -212,13 +211,12 @@ public class SessionContextOFImpl implements SessionContext {
     }
 
     @Override
-    public void setProviderRegistration(
-            CompositeObjectRegistration<ModelDrivenSwitch> providerRegistration) {
-                this.providerRegistration = providerRegistration;
+    public void setProviderRegistration(ModelDrivenSwitchRegistration providerRegistration) {
+        this.providerRegistration = providerRegistration;
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+    public ModelDrivenSwitchRegistration getProviderRegistration() {
         return providerRegistration;
     }
 
index f335f11ebd1ea38859f3bedbbb3fae55d491bd2d..1189a2befafb5d4b160e255450c985ec67660de8 100644 (file)
@@ -9,10 +9,10 @@ package org.opendaylight.openflowplugin.openflow.md.util;
 
 import com.google.common.base.Function;
 import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.SettableFuture;
 import java.math.BigInteger;
 import java.util.concurrent.ExecutionException;
@@ -27,7 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import java.util.Date;
 
 /**
  *
index fd13ed0f6e4a250999547a86cf775ee50f236bee..3c21f40734afa74718a6753bfb51541f8baff54e 100644 (file)
@@ -26,6 +26,7 @@ import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -154,8 +155,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 
 /**
  * simple NPE smoke test
index 367f0a0917be5f2df0da62a7364dbb962cec5e77..120107b547a497acf1392c50d58219ff9b039cf5 100644 (file)
@@ -10,11 +10,9 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.math.BigInteger;
-import java.util.Collections;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -24,16 +22,20 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.AbstractModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SwitchSessionKeyOF;
+import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContextOFImpl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
@@ -43,14 +45,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.openflowplugin.openflow.md.core.role.OfEntityManager;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 
 /**
  * Created by Martin Bobak mbobak@cisco.com on 8/26/14.
@@ -90,8 +88,7 @@ public class SalRegistrationManagerTest {
 
     private ModelDrivenSwitch mdSwitchOF13;
 
-    CompositeObjectRegistration<ModelDrivenSwitch> registration;
-
+    ModelDrivenSwitchRegistration registration;
 
     @Before
     public void setUp() {
@@ -107,7 +104,12 @@ public class SalRegistrationManagerTest {
 
        OfEntityManager entManager = new OfEntityManager(entityOwnershipService,getConfig());
         mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context);
-        registration = new CompositeObjectRegistration<>(mdSwitchOF13, Collections.<Registration>emptyList());
+        registration = new AbstractModelDrivenSwitchRegistration(mdSwitchOF13) {
+            @Override
+            protected void removeRegistration() {
+                // no-op
+            }
+        };
         context.setProviderRegistration(registration);
 
         UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
index 383cd9c47b4f6355479023a7cbf94f4ec1fe1f18..6779145b00ffc9d45bdcf98c6be37d60b6b50023 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
@@ -47,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
 \r
 /**\r
index 448fb45ac3d7849739636d116a00a926b0cc42c3..2db23adaaf1c8bc951cd491b1e9cef83d7d37a28 100644 (file)
@@ -24,7 +24,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyList
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitch;
+import org.opendaylight.openflowplugin.api.openflow.md.ModelDrivenSwitchRegistration;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.api.openflow.md.core.ErrorHandler;
 import org.opendaylight.openflowplugin.api.openflow.md.core.NotificationEnqueuer;
@@ -75,7 +75,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.TableModInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -323,7 +322,7 @@ class MockSessionContext implements SessionContext {
     private Map<SwitchConnectionDistinguisher, ConnectionConductor> map;
     private IMessageDispatchService messageService;
     private boolean isValid = true;
-    private CompositeObjectRegistration<ModelDrivenSwitch> registration;
+    private ModelDrivenSwitchRegistration registration;
     private int seed;
     private SwitchSessionKeyOF sessionKey;
 
@@ -450,13 +449,12 @@ class MockSessionContext implements SessionContext {
     }
 
     @Override
-    public CompositeObjectRegistration<ModelDrivenSwitch> getProviderRegistration() {
+    public ModelDrivenSwitchRegistration getProviderRegistration() {
         return registration;
     }
 
     @Override
-    public void setProviderRegistration(
-            CompositeObjectRegistration<ModelDrivenSwitch> registration) {
+    public void setProviderRegistration(ModelDrivenSwitchRegistration registration) {
         this.registration = registration;
     }
 
index f49db254ae36615c8155b76475298ddce8903d05..c1ff9bcfb83dd8d2416e344a36a419352bfac1a8 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.openflowplugin.openflow.md.core.session;
 import com.google.common.util.concurrent.Futures;
 import java.math.BigInteger;
 import java.util.Collections;
-import java.util.List;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
index 3a3e29ff4a3e10f88427aa14dd71e3f49a146c23..6bef0c1926ae316ffc1d8eb103cf8d60df327114 100644 (file)
@@ -13,14 +13,10 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
@@ -77,7 +73,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
 
 public class OpenflowpluginGroupTestCommandProvider implements CommandProvider {
index 3308b94b2199512327d18ba9d49309f7a99667b3..fb75736a36a0a4ac67ac9005dc97dd05f8771dc8 100644 (file)
@@ -24,8 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -147,13 +147,10 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginGroupTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginGroupTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginGroupTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalGroupService> addRoutedRpcImplementation = ctx
                 .<SalGroupService> addRoutedRpcImplementation(
                         SalGroupService.class, this);
@@ -171,8 +168,12 @@ public class OpenflowpluginGroupTestServiceProvider implements AutoCloseable,
         groupRegistration.registerPath(NodeContext.class, instance);
         RoutedRpcRegistration<SalGroupService> groupRegistration1 = this
                 .getGroupRegistration();
-        builder.add(groupRegistration1);
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginGroupTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                groupRegistration1.close();
+            }
+        };
     }
 
 }
index a560f657c7ee27aa09c92428fb158c94e31e0faf..b4b5438efaf206b7916c92120961529c66557597 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.Rem
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -162,12 +162,10 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginMeterTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginMeterTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginMeterTestServiceProvider> builderFor(this);
 
         RoutedRpcRegistration<SalMeterService> addRoutedRpcImplementation = ctx
                 .<SalMeterService> addRoutedRpcImplementation(
@@ -191,9 +189,13 @@ public class OpenflowpluginMeterTestServiceProvider implements AutoCloseable,
         RoutedRpcRegistration<SalMeterService> meterRegistration1 = this
                 .getMeterRegistration();
 
-        builder.add(meterRegistration1);
+        return new AbstractObjectRegistration<OpenflowpluginMeterTestServiceProvider>(this) {
 
-        return builder.build();
+            @Override
+            protected void removeRegistration() {
+                meterRegistration1.close();
+            }
+        };
     }
 
 }
index b73ecc76282fb367ec855c05cabe60e47c305a83..f88053808dd32dc4ad769cd28da9a910e7f0e328 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.test;
 
 import java.util.Iterator;
 import java.util.List;
-
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -44,8 +43,6 @@ import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 public class OpenflowpluginStatsTestCommandProvider implements CommandProvider {
 
  private static final Logger LOG = LoggerFactory
index 261a29cba84971be666fea8b31dc847cca1acbf3..9a0e554b6c746be8569fe917035ec0540afa0340 100644 (file)
@@ -20,8 +20,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -110,13 +110,10 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginTableFeaturesTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginTableFeaturesTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx
                 .<SalTableService> addRoutedRpcImplementation(
                         SalTableService.class, this);
@@ -139,9 +136,12 @@ public class OpenflowpluginTableFeaturesTestServiceProvider implements
         RoutedRpcRegistration<SalTableService> tableRegistration1 = this
                 .getTableRegistration();
 
-        builder.add(tableRegistration1);
-
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                tableRegistration1.close();
+            }
+        };
     }
 
 }
index ec67835b82f8cc184188086fb601c415ed959000..1464509c06d7af4566394f1f4eb83b9b8dcf87e6 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration;
-import org.opendaylight.yangtools.concepts.CompositeObjectRegistration.CompositeObjectRegistrationBuilder;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -166,13 +166,10 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
     /**
      * @param ctx
-     * @return {@link CompositeObjectRegistrationBuilder #toInstance()}
+     * @return {@link ObjectRegistration}
      */
-    public CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(
+    public ObjectRegistration<OpenflowpluginTestServiceProvider> register(
             final ProviderContext ctx) {
-        CompositeObjectRegistrationBuilder<OpenflowpluginTestServiceProvider> builder = CompositeObjectRegistration
-                .<OpenflowpluginTestServiceProvider> builderFor(this);
-
         RoutedRpcRegistration<SalFlowService> addRoutedRpcImplementation = ctx
                 .<SalFlowService> addRoutedRpcImplementation(
                         SalFlowService.class, this);
@@ -194,8 +191,11 @@ public class OpenflowpluginTestServiceProvider implements AutoCloseable,
 
         RoutedRpcRegistration<SalFlowService> flowRegistration2 = getFlowRegistration();
 
-        builder.add(flowRegistration2);
-
-        return builder.build();
+        return new AbstractObjectRegistration<OpenflowpluginTestServiceProvider>(this) {
+            @Override
+            protected void removeRegistration() {
+                flowRegistration2.close();
+            }
+        };
     }
 }