Remove Itemlifecycle 72/61772/5
authorTomas Slusny <tomas.slusny@pantheon.tech>
Thu, 28 Sep 2017 08:52:31 +0000 (10:52 +0200)
committerTomas Slusny <tomas.slusny@pantheon.tech>
Thu, 28 Sep 2017 08:52:31 +0000 (10:52 +0200)
ItemLifecycle was created for one time use case. Devices without
statistics possibility at all
and this workaround was made to store flows, groups, meters to the DS
as a reaction on services (flow, group, meters) when statistics
gathering could not be used.

Resolves: Bug 9010

Change-Id: Ic6eeb79d720284b7f139063ea238f40cef32a11a
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
21 files changed:
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceContext.java
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/ItemLifeCycleRegistry.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleKeeper.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleSource.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/listener/ItemLifecycleListener.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/ItemLifeCycleSourceImpl.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/ItemLifeCycleRegistryImpl.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainHolderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/ContextChainImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/listener/ItemLifecycleListenerImpl.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsContextImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/ItemLifecycleListenerImplTest.java [deleted file]
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/RpcManagerImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalFlowServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalGroupServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalMeterServiceImplTest.java

index ad0a8a1462d18097af1b90336f679872daf4c345..073bc131060ba3b0861e641079a7f3b173045c6a 100644 (file)
@@ -15,7 +15,6 @@ import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainStateListener;
-import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 
@@ -96,12 +95,6 @@ public interface DeviceContext extends
      */
     void updatePacketInRateLimit(long upperBound);
 
-    /**
-     * Getter.
-     * @return registry point for item life cycle sources of device
-     */
-    ItemLifeCycleRegistry getItemLifeCycleSourceRegistry();
-
     /**
      * Checks if device and controller supports single layer serialization.
      * @return true if single layer serialization is supported
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/ItemLifeCycleRegistry.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/registry/ItemLifeCycleRegistry.java
deleted file mode 100644 (file)
index 60e061e..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2015 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.registry;
-
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
-import org.opendaylight.yangtools.concepts.Registration;
-
-/**
- * Registration point for any kind of lifecycle sources per device.
- */
-public interface ItemLifeCycleRegistry {
-
-    /**
-     * register given life cycle source to known sources of device.
-     *
-     * @param lifeCycleSource life cycle changes provider
-     * @return closeable registration
-     */
-    Registration registerLifeCycleSource(ItemLifeCycleSource lifeCycleSource);
-
-    /**
-     * close all existing registrations.
-     */
-    void clear();
-
-    /**
-     * Registered sources.
-     * @return registered sources
-     */
-    Iterable<ItemLifeCycleSource> getLifeCycleSources();
-}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleKeeper.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleKeeper.java
deleted file mode 100644 (file)
index c47dcdf..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2015 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.rpc;
-
-import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-
-/**
- * provides read-write access to assigned {@link ItemLifecycleListener}.
- */
-public interface ItemLifeCycleKeeper extends ItemLifeCycleSource {
-
-    /**
-     * lifecycle listener.
-     * @return assigned item lifecycle listener
-     */
-    @Nullable
-    ItemLifecycleListener getItemLifecycleListener();
-}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleSource.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/ItemLifeCycleSource.java
deleted file mode 100644 (file)
index a62e909..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015 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.rpc;
-
-import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-
-/**
- * A source of switch item lifecycle enables for injecting of
- * a {@link org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener}
- * in order to act upon item lifecycle changes.
- */
-public interface ItemLifeCycleSource {
-
-    /**
-     * lifecycle changes.
-     * @param itemLifecycleListener acts upon lifecycle changes
-     */
-    void setItemLifecycleListener(@Nullable ItemLifecycleListener itemLifecycleListener);
-
-
-}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/listener/ItemLifecycleListener.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/rpc/listener/ItemLifecycleListener.java
deleted file mode 100644 (file)
index 1518075..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2015 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.rpc.listener;
-
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-/**
- * Flow/group/meter lifecycle listener - aimed on rpc result approved by barrier message.
- */
-public interface ItemLifecycleListener {
-
-    /**
-     * react upon item added event.
-     *
-     * @param itemPath keyed path in DS
-     * @param itemBody item body
-     */
-
-    <I extends Identifiable<K> & DataObject, K extends Identifier<I>> void onAdded(
-            KeyedInstanceIdentifier<I, K> itemPath, I itemBody);
-
-    /**
-     * react upon item removed event.
-     *
-     * @param itemPath keyed path in DS
-     */
-    <I extends Identifiable<K> & DataObject, K extends Identifier<I>> void onRemoved(
-            KeyedInstanceIdentifier<I, K> itemPath);
-
-    /**
-     * react upon item updated event.
-     *
-     * @param itemPath keyed path in DS
-     * @param itemBody item body
-     */
-
-    <I extends Identifiable<K> & DataObject, K extends Identifier<I>> void onUpdated(
-            KeyedInstanceIdentifier<I, K> itemPath, I itemBody);
-}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/ItemLifeCycleSourceImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/ItemLifeCycleSourceImpl.java
deleted file mode 100644 (file)
index d657208..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2015 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.impl.common;
-
-import javax.annotation.Nullable;
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleKeeper;
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-
-/**
- * simple standalone {@link ItemLifeCycleSource} implementation.
- */
-public class ItemLifeCycleSourceImpl implements ItemLifeCycleKeeper {
-
-    private ItemLifecycleListener itemLifecycleListener;
-
-    @Override
-    public void setItemLifecycleListener(@Nullable ItemLifecycleListener itemLifecycleListener) {
-
-        this.itemLifecycleListener = itemLifecycleListener;
-    }
-
-    @Override
-    public ItemLifecycleListener getItemLifecycleListener() {
-        return itemLifecycleListener;
-    }
-}
index a01f2cb936f6d085458ed1b9a13a88547570d1a2..9429b45e08fe7a135b7d4d21183647997661e9a6 100644 (file)
@@ -47,14 +47,9 @@ import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMaster
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainState;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
-import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleKeeper;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
@@ -62,14 +57,12 @@ import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderK
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.extension.api.exception.ConversionException;
 import org.opendaylight.openflowplugin.extension.api.path.MessagePath;
-import org.opendaylight.openflowplugin.impl.common.ItemLifeCycleSourceImpl;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProviderFactory;
 import org.opendaylight.openflowplugin.impl.device.initialization.AbstractDeviceInitializer;
 import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProvider;
 import org.opendaylight.openflowplugin.impl.device.listener.MultiMsgCollectorImpl;
 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.AbstractRequestContext;
@@ -80,9 +73,6 @@ import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil
 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.ExperimenterMessageFromDevBuilder;
 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.tables.Table;
-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.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
@@ -138,13 +128,11 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     private final DataBroker dataBroker;
     private final Collection<RequestContext<?>> requestContexts = new HashSet<>();
     private final MessageSpy messageSpy;
-    private final ItemLifeCycleKeeper flowLifeCycleKeeper;
     private final MessageTranslator<PortGrouping, FlowCapableNodeConnector> portStatusTranslator;
     private final MessageTranslator<PacketInMessage, PacketReceived> packetInTranslator;
     private final MessageTranslator<FlowRemoved, org.opendaylight.yang.gen.v1.urn.opendaylight
             .flow.service.rev130819.FlowRemoved> flowRemovedTranslator;
     private final TranslatorLibrary translatorLibrary;
-    private final ItemLifeCycleRegistry itemLifeCycleSourceRegistry;
     private final ConvertorExecutor convertorExecutor;
     private final DeviceInitializerProvider deviceInitializerProvider;
     private final PacketInRateLimiter packetInLimiter;
@@ -200,9 +188,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         this.flowRemovedTranslator = translatorLibrary.lookupTranslator(
                 new TranslatorKey(deviceInfo.getVersion(), FlowRemoved.class.getName()));
 
-        this.itemLifeCycleSourceRegistry = new ItemLifeCycleRegistryImpl();
-        this.flowLifeCycleKeeper = new ItemLifeCycleSourceImpl();
-        this.itemLifeCycleSourceRegistry.registerLifeCycleSource(flowLifeCycleKeeper);
         this.convertorExecutor = convertorExecutor;
         this.skipTableFeatures = skipTableFeatures;
         this.useSingleLayerSerialization = useSingleLayerSerialization;
@@ -314,28 +299,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
             // Trigger off a notification
             notificationPublishService.offerNotification(flowRemovedNotification);
         }
-
-        final ItemLifecycleListener itemLifecycleListener = flowLifeCycleKeeper.getItemLifecycleListener();
-        if (itemLifecycleListener != null) {
-            //2. create registry key
-            final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(getDeviceInfo().getVersion(),
-                    flowRemovedNotification);
-            //3. lookup flowId
-            final FlowDescriptor flowDescriptor = deviceFlowRegistry.retrieveDescriptor(flowRegKey);
-            //4. if flowId present:
-            if (flowDescriptor != null) {
-                // a) construct flow path
-                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = getDeviceInfo().getNodeInstanceIdentifier()
-                        .augmentation(FlowCapableNode.class)
-                        .child(Table.class, flowDescriptor.getTableKey())
-                        .child(Flow.class, new FlowKey(flowDescriptor.getFlowId()));
-                // b) notify listener
-                itemLifecycleListener.onRemoved(flowPath);
-            } else {
-                LOG.debug("flow id not found: nodeId={} tableId={}, priority={}",
-                        getDeviceInfo().getNodeId(), flowRegKey.getTableId(), flowRemovedNotification.getPriority());
-            }
-        }
     }
 
     @Override
@@ -541,11 +504,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
                 (int) (HIGH_WATERMARK_FACTOR * upperBound));
     }
 
-    @Override
-    public ItemLifeCycleRegistry getItemLifeCycleSourceRegistry() {
-        return itemLifeCycleSourceRegistry;
-    }
-
     @Override
     public void setExtensionConverterProvider(final ExtensionConverterProvider extensionConverterProvider) {
         this.extensionConverterProvider = extensionConverterProvider;
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/ItemLifeCycleRegistryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/ItemLifeCycleRegistryImpl.java
deleted file mode 100644 (file)
index c1ca0e9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2015 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.impl.device;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
-import org.opendaylight.yangtools.concepts.Registration;
-
-/**
- * Default implementation.
- */
-public class ItemLifeCycleRegistryImpl implements ItemLifeCycleRegistry {
-
-    private final Set<ItemLifeCycleSource> registry;
-
-    public ItemLifeCycleRegistryImpl() {
-        registry = Collections.newSetFromMap(new ConcurrentHashMap<ItemLifeCycleSource, Boolean>());
-    }
-
-
-    @Override
-
-    public Registration registerLifeCycleSource(final ItemLifeCycleSource lifeCycleSource) {
-        registry.add(lifeCycleSource);
-        return () -> registry.remove(lifeCycleSource);
-    }
-
-    @Override
-    public void clear() {
-        registry.clear();
-    }
-
-    @Override
-    public Iterable<ItemLifeCycleSource> getLifeCycleSources() {
-        return Collections.unmodifiableCollection(registry);
-    }
-}
index 1389e33a488aa45d355e31893817161d0e342e22..dcccb79f993683d053dce7083a28e961823349fe 100644 (file)
@@ -145,10 +145,8 @@ public class ContextChainHolderImpl implements ContextChainHolder, MasterChecker
 
     @Override
     public ConnectionStatus deviceConnected(final ConnectionContext connectionContext) throws Exception {
-
         final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
         final ContextChain contextChain = contextChainMap.get(deviceInfo);
-
         final FeaturesReply featuresReply = connectionContext.getFeatures();
         final Short auxiliaryId = featuresReply != null ? featuresReply.getAuxiliaryId() : null;
 
index 7a012d6bca22139eb6deda2fff1907942ca26d9c..39a349ca1c8208a11efe285ae239d90bbf9375b0 100644 (file)
@@ -70,7 +70,6 @@ public class ContextChainImpl implements ContextChain {
     @Override
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void instantiateServiceInstance() {
-
         try {
             contexts.forEach(OFPContext::instantiateServiceInstance);
             LOG.info("Started clustering services for node {}", deviceInfo);
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/listener/ItemLifecycleListenerImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/rpc/listener/ItemLifecycleListenerImpl.java
deleted file mode 100644 (file)
index 8843ed2..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2015 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.impl.rpc.listener;
-
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * General implementation of {@link ItemLifecycleListener} - keeping of DS/operational reflection up-to-date.
- */
-public class ItemLifecycleListenerImpl implements ItemLifecycleListener {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ItemLifecycleListenerImpl.class);
-    private static final String NOT_ABLE_TO_WRITE_TO_TRANSACTION = "Not able to write to transaction: ";
-
-    private final TxFacade txFacade;
-
-    public ItemLifecycleListenerImpl(final TxFacade txFacade) {
-        this.txFacade = txFacade;
-    }
-
-    @Override
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    public <I extends Identifiable<K> & DataObject, K extends Identifier<I>>
-            void onAdded(KeyedInstanceIdentifier<I, K> itemPath, I itemBody) {
-        try {
-            txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, itemPath, itemBody);
-            txFacade.submitTransaction();
-        } catch (Exception e) {
-            LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
-        }
-    }
-
-    @Override
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    public <I extends Identifiable<K> & DataObject, K extends Identifier<I>>
-            void onRemoved(KeyedInstanceIdentifier<I, K> itemPath) {
-        try {
-            txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, itemPath);
-            txFacade.submitTransaction();
-        } catch (Exception e) {
-            LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
-        }
-    }
-
-    @Override
-    @SuppressWarnings("checkstyle:IllegalCatch")
-    public <I extends Identifiable<K> & DataObject, K extends Identifier<I>>
-            void onUpdated(KeyedInstanceIdentifier<I, K> itemPath, I itemBody) {
-        try {
-            txFacade.addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, itemPath);
-            txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, itemPath, itemBody);
-            txFacade.submitTransaction();
-        } catch (Exception e) {
-            LOG.warn(NOT_ABLE_TO_WRITE_TO_TRANSACTION, e);
-        }
-    }
-}
index da990566cbd3e6a69033de9ae0244c29cfb23b8c..6d9e09b8bf9111f12b142df030f5977f222ef881 100644 (file)
@@ -16,27 +16,23 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Future;
-import javax.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
-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.openflowplugin.impl.registry.flow.FlowRegistryKeyFactory;
 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerFlowService;
 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerFlowService;
 import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.openflowplugin.impl.util.FlowCreatorUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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;
 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.flow.service.rev130819.AddFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
@@ -59,7 +55,7 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
+public class SalFlowServiceImpl implements SalFlowService {
     private static final Logger LOG = LoggerFactory.getLogger(SalFlowServiceImpl.class);
     private final MultiLayerFlowService<UpdateFlowOutput> flowUpdate;
     private final MultiLayerFlowService<AddFlowOutput> flowAdd;
@@ -68,7 +64,6 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
     private final SingleLayerFlowService<UpdateFlowOutput> flowUpdateMessage;
     private final SingleLayerFlowService<RemoveFlowOutput> flowRemoveMessage;
     private final DeviceContext deviceContext;
-    private ItemLifecycleListener itemLifecycleListener;
 
     public SalFlowServiceImpl(final RequestContextStack requestContextStack,
                               final DeviceContext deviceContext,
@@ -91,11 +86,6 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
         flowRemoveMessage = new SingleLayerFlowService<>(requestContextStack, deviceContext, RemoveFlowOutput.class);
     }
 
-    @Override
-    public void setItemLifecycleListener(@Nullable ItemLifecycleListener itemLifecycleListener) {
-        this.itemLifecycleListener = itemLifecycleListener;
-    }
-
     @Override
     public Future<RpcResult<AddFlowOutput>> addFlow(final AddFlowInput input) {
         final FlowRegistryKey flowRegistryKey =
@@ -242,13 +232,6 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow add with id={} finished without error", flowDescriptor.getFlowId().getValue());
                 }
-
-                if (itemLifecycleListener != null) {
-                    KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                            deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-                    final FlowBuilder flowBuilder = new FlowBuilder(input).setId(flowDescriptor.getFlowId());
-                    itemLifecycleListener.onAdded(flowPath, flowBuilder.build());
-                }
             } else {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow add failed for flow={}, errors={}", input,
@@ -279,17 +262,6 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                 FlowRegistryKey flowRegistryKey =
                         FlowRegistryKeyFactory.create(deviceContext.getDeviceInfo().getVersion(), input);
                 deviceContext.getDeviceFlowRegistry().addMark(flowRegistryKey);
-
-                if (itemLifecycleListener != null) {
-                    final FlowDescriptor flowDescriptor =
-                            deviceContext.getDeviceFlowRegistry().retrieveDescriptor(flowRegistryKey);
-
-                    if (flowDescriptor != null) {
-                        KeyedInstanceIdentifier<Flow, FlowKey> flowPath = createFlowPath(flowDescriptor,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-                        itemLifecycleListener.onRemoved(flowPath);
-                    }
-                }
             } else {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Flow remove failed for flow={}, errors={}", input,
@@ -343,23 +315,6 @@ public class SalFlowServiceImpl implements SalFlowService, ItemLifeCycleSource {
                 deviceFlowRegistry.addMark(origFlowRegistryKey);
                 deviceFlowRegistry.storeDescriptor(updatedFlowRegistryKey, updatedFlowDescriptor);
             }
-
-            if (itemLifecycleListener != null) {
-                final KeyedInstanceIdentifier<Flow, FlowKey> flowPath =
-                        createFlowPath(
-                                updatedFlowDescriptor,
-                                deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-
-                final Flow flow = new FlowBuilder(updated)
-                        .setId(updatedFlowDescriptor.getFlowId())
-                        .build();
-
-                if (Objects.nonNull(origFlowDescriptor)) {
-                    itemLifecycleListener.onUpdated(flowPath, flow);
-                } else {
-                    itemLifecycleListener.onAdded(flowPath, flow);
-                }
-            }
         }
 
         @Override
index 47a3970d0b0a189aaa8326be402239419e072466..2436d854ad7e006001fd3cf45933de06300cfe07 100644 (file)
@@ -11,11 +11,8 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 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;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerGroupService;
 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerGroupService;
 import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
@@ -30,7 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.Upd
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
@@ -39,7 +35,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource {
+public class SalGroupServiceImpl implements SalGroupService {
     private static final Logger LOG = LoggerFactory.getLogger(SalGroupServiceImpl.class);
     private final MultiLayerGroupService<AddGroupInput, AddGroupOutput> addGroup;
     private final MultiLayerGroupService<Group, UpdateGroupOutput> updateGroup;
@@ -49,7 +45,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
     private final SingleLayerGroupService<RemoveGroupOutput> removeGroupMessage;
 
     private final DeviceContext deviceContext;
-    private ItemLifecycleListener itemLifecycleListener;
 
     public SalGroupServiceImpl(final RequestContextStack requestContextStack,
                                final DeviceContext deviceContext,
@@ -75,11 +70,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         removeGroupMessage = new SingleLayerGroupService<>(requestContextStack, deviceContext, RemoveGroupOutput.class);
     }
 
-    @Override
-    public void setItemLifecycleListener(@Nullable ItemLifecycleListener itemLifecycleListener) {
-        this.itemLifecycleListener = itemLifecycleListener;
-    }
-
     @Override
     public Future<RpcResult<AddGroupOutput>> addGroup(final AddGroupInput input) {
         final ListenableFuture<RpcResult<AddGroupOutput>> resultFuture =
@@ -95,7 +85,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
                         LOG.debug("Group add with id={} finished without error", input.getGroupId().getValue());
                     }
                     deviceContext.getDeviceGroupRegistry().store(input.getGroupId());
-                    addIfNecessaryToDS(input.getGroupId(), input);
                 } else {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Group add with id={} failed, errors={}", input.getGroupId().getValue(),
@@ -130,8 +119,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
                         LOG.debug("Group update with original id={} finished without error",
                             input.getOriginalGroup().getGroupId().getValue());
                     }
-                    removeIfNecessaryFromDS(input.getOriginalGroup().getGroupId());
-                    addIfNecessaryToDS(input.getUpdatedGroup().getGroupId(), input.getUpdatedGroup());
                 } else {
                     LOG.warn("Group update with original id={} failed, errors={}",
                         input.getOriginalGroup().getGroupId(), ErrorUtil.errorsToString(result.getErrors()));
@@ -163,7 +150,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
                         LOG.debug("Group remove with id={} finished without error", input.getGroupId().getValue());
                     }
                     removeGroup.getDeviceRegistry().getDeviceGroupRegistry().addMark(input.getGroupId());
-                    removeIfNecessaryFromDS(input.getGroupId());
                 } else {
                     LOG.warn("Group remove with id={} failed, errors={}", input.getGroupId().getValue(),
                         ErrorUtil.errorsToString(result.getErrors()));
@@ -180,26 +166,6 @@ public class SalGroupServiceImpl implements SalGroupService, ItemLifeCycleSource
         return resultFuture;
     }
 
-    private void removeIfNecessaryFromDS(final GroupId groupId) {
-        if (itemLifecycleListener != null) {
-            KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
-                    .opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
-                    = createGroupPath(groupId,
-                                      deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-            itemLifecycleListener.onRemoved(groupPath);
-        }
-    }
-
-    private void addIfNecessaryToDS(final GroupId groupId, final Group data) {
-        if (itemLifecycleListener != null) {
-            KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
-                    .opendaylight.group.types.rev131018.groups.Group, GroupKey> groupPath
-                    = createGroupPath(groupId,
-                                      deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-            itemLifecycleListener.onAdded(groupPath, new GroupBuilder(data).build());
-        }
-    }
-
     private static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
             .opendaylight.group.types.rev131018.groups.Group, GroupKey>
         createGroupPath(final GroupId groupId, final KeyedInstanceIdentifier<Node, NodeKey> nodePath) {
index 993b4bc7d8d975415d501390ab5a3990ced359fb..51a9c55b6f9a6585939db294c4fcf5154684cac7 100644 (file)
@@ -11,17 +11,13 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 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;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.impl.services.multilayer.MultiLayerMeterService;
 import org.opendaylight.openflowplugin.impl.services.singlelayer.SingleLayerMeterService;
 import org.opendaylight.openflowplugin.impl.util.ErrorUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 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.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
@@ -39,7 +35,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource {
+public class SalMeterServiceImpl implements SalMeterService {
     private static final Logger LOG = LoggerFactory.getLogger(SalMeterServiceImpl.class);
     private final MultiLayerMeterService<AddMeterInput, AddMeterOutput> addMeter;
     private final MultiLayerMeterService<Meter, UpdateMeterOutput> updateMeter;
@@ -48,7 +44,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
     private final SingleLayerMeterService<UpdateMeterOutput> updateMeterMessage;
     private final SingleLayerMeterService<RemoveMeterOutput> removeMeterMessage;
 
-    private ItemLifecycleListener itemLifecycleListener;
     private final DeviceContext deviceContext;
 
     public SalMeterServiceImpl(final RequestContextStack requestContextStack,
@@ -75,11 +70,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         removeMeterMessage = new SingleLayerMeterService<>(requestContextStack, deviceContext, RemoveMeterOutput.class);
     }
 
-    @Override
-    public void setItemLifecycleListener(@Nullable ItemLifecycleListener itemLifecycleListener) {
-        this.itemLifecycleListener = itemLifecycleListener;
-    }
-
     @Override
     public Future<RpcResult<AddMeterOutput>> addMeter(final AddMeterInput input) {
         final ListenableFuture<RpcResult<AddMeterOutput>> resultFuture =
@@ -95,7 +85,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
                         LOG.debug("Meter add with id={} finished without error", input.getMeterId());
                     }
                     deviceContext.getDeviceMeterRegistry().store(input.getMeterId());
-                    addIfNecessaryToDS(input.getMeterId(),input);
                 } else {
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Meter add with id={} failed, errors={}", input.getMeterId(),
@@ -128,10 +117,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
                         LOG.debug("Meter update with id={} finished without error",
                                   input.getOriginalMeter().getMeterId());
                     }
-                    if (itemLifecycleListener != null) {
-                        removeIfNecessaryFromDS(input.getOriginalMeter().getMeterId());
-                        addIfNecessaryToDS(input.getUpdatedMeter().getMeterId(),input.getUpdatedMeter());
-                    }
                 } else {
                         LOG.warn("Meter update with id={} failed, errors={}", input.getOriginalMeter().getMeterId(),
                                 ErrorUtil.errorsToString(result.getErrors()));
@@ -163,7 +148,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
                         LOG.debug("Meter remove with id={} finished without error", input.getMeterId());
                     }
                     removeMeter.getDeviceRegistry().getDeviceMeterRegistry().addMark(input.getMeterId());
-                    removeIfNecessaryFromDS(input.getMeterId());
                 } else {
                     LOG.warn("Meter remove with id={} failed, errors={}", input.getMeterId(),
                         ErrorUtil.errorsToString(result.getErrors()));
@@ -179,24 +163,6 @@ public class SalMeterServiceImpl implements SalMeterService, ItemLifeCycleSource
         return resultFuture;
     }
 
-    private void removeIfNecessaryFromDS(final MeterId meterId) {
-        if (itemLifecycleListener != null) {
-            KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
-                    .opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> meterPath
-                    = createMeterPath(meterId, deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-            itemLifecycleListener.onRemoved(meterPath);
-        }
-    }
-
-    private void addIfNecessaryToDS(final MeterId meterId, final Meter data) {
-        if (itemLifecycleListener != null) {
-            KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
-                    .opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> groupPath
-                    = createMeterPath(meterId, deviceContext.getDeviceInfo().getNodeInstanceIdentifier());
-            itemLifecycleListener.onAdded(groupPath, new MeterBuilder(data).build());
-        }
-    }
-
     private static KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn
             .opendaylight.flow.inventory.rev130819.meters.Meter, MeterKey> createMeterPath(
                                                             final MeterId meterId,
index d38423f75f400b996d96732331f9aca91125045a..d2b909f1979f125c7c17652794fa4a7791d4b0e2 100644 (file)
@@ -35,11 +35,9 @@ import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipState;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChainMastershipWatcher;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.impl.datastore.MultipartWriterProvider;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.listener.ItemLifecycleListenerImpl;
 import org.opendaylight.openflowplugin.impl.services.util.RequestContextUtil;
 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringOnTheFlyService;
 import org.opendaylight.openflowplugin.impl.statistics.services.dedicated.StatisticsGatheringService;
@@ -54,7 +52,6 @@ class StatisticsContextImpl<T extends OfHeader> implements StatisticsContext {
     private static final Logger LOG = LoggerFactory.getLogger(StatisticsContextImpl.class);
     private static final String CONNECTION_CLOSED = "Connection closed.";
 
-    private final ItemLifecycleListener itemLifeCycleListener;
     private final Collection<RequestContext<?>> requestContexts = new HashSet<>();
     private final DeviceContext deviceContext;
     private final DeviceState devState;
@@ -88,7 +85,6 @@ class StatisticsContextImpl<T extends OfHeader> implements StatisticsContext {
         this.executorService = executorService;
         this.isStatisticsPollingOn = isStatisticsPollingOn;
         this.convertorExecutor = convertorExecutor;
-        this.itemLifeCycleListener = new ItemLifecycleListenerImpl(deviceContext);
         this.deviceInfo = deviceContext.getDeviceInfo();
         this.statisticsPollingInterval = statisticsPollingInterval;
         this.maximumPollingDelay = maximumPollingDelay;
@@ -132,17 +128,11 @@ class StatisticsContextImpl<T extends OfHeader> implements StatisticsContext {
     @Override
     public void enableGathering() {
         this.schedulingEnabled.set(true);
-        deviceContext.getItemLifeCycleSourceRegistry()
-                .getLifeCycleSources().forEach(itemLifeCycleSource -> itemLifeCycleSource
-                .setItemLifecycleListener(null));
     }
 
     @Override
     public void disableGathering() {
         this.schedulingEnabled.set(false);
-        deviceContext.getItemLifeCycleSourceRegistry()
-                .getLifeCycleSources().forEach(itemLifeCycleSource -> itemLifeCycleSource
-                .setItemLifecycleListener(itemLifeCycleListener));
     }
 
     @Override
index 60265c5d53309424931c26020e6e4a9907c877a6..6b2e76408ad10ad15667bb05246b6ea739fd140c 100644 (file)
@@ -58,8 +58,6 @@ import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
 import org.opendaylight.openflowplugin.api.openflow.registry.group.DeviceGroupRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.meter.DeviceMeterRegistry;
-import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
 import org.opendaylight.openflowplugin.extension.api.ConvertorMessageFromOFJava;
@@ -433,13 +431,6 @@ public class DeviceContextImplTest {
         final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 0, new FlowId("ut-ofp:f456"));
         deviceContext.getDeviceFlowRegistry().storeDescriptor(flowRegKey, flowDescriptor);
 
-        // plug in lifecycleListener
-        final ItemLifecycleListener itemLifecycleListener = Mockito.mock(ItemLifecycleListener.class);
-        for (final ItemLifeCycleSource lifeCycleSource : deviceContext.getItemLifeCycleSourceRegistry()
-                .getLifeCycleSources()) {
-            lifeCycleSource.setItemLifecycleListener(itemLifecycleListener);
-        }
-
         // prepare empty input message
         final FlowRemovedMessageBuilder flowRemovedBld = new FlowRemovedMessageBuilder();
 
@@ -451,8 +442,6 @@ public class DeviceContextImplTest {
 
         deviceContext.setNotificationPublishService(mockedNotificationPublishService);
         deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
-
-        Mockito.verify(itemLifecycleListener).onRemoved(flowToBeRemovedPath);
     }
 
     @Test
diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/ItemLifecycleListenerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/rpc/ItemLifecycleListenerImplTest.java
deleted file mode 100644 (file)
index 23b5063..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Copyright (c) 2015 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.impl.rpc;
-
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import org.junit.After;
-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.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
-import org.opendaylight.openflowplugin.impl.rpc.listener.ItemLifecycleListenerImpl;
-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;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-
-@RunWith(MockitoJUnitRunner.class)
-public class ItemLifecycleListenerImplTest {
-
-    @Mock
-    private DeviceContext deviceContext;
-
-    @Mock
-    private Node node;
-
-    private KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier;
-    private ItemLifecycleListener itemLifecycleListener;
-
-
-    @Before
-    public void setUp() {
-        final NodeId nodeId = new NodeId("openflow:1");
-        nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(nodeId));
-        itemLifecycleListener = new ItemLifecycleListenerImpl(deviceContext);
-    }
-
-    @After
-    public void tearDown() {
-        verifyNoMoreInteractions(deviceContext);
-    }
-
-    @Test
-    public void testOnAdded() throws Exception {
-        itemLifecycleListener.onAdded(nodeInstanceIdentifier, node);
-        verify(deviceContext)
-                .writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), eq(nodeInstanceIdentifier), eq(node));
-        verify(deviceContext).submitTransaction();
-    }
-
-    @Test
-    public void testOnRemoved() throws Exception {
-        itemLifecycleListener.onRemoved(nodeInstanceIdentifier);
-        verify(deviceContext).addDeleteToTxChain(eq(LogicalDatastoreType.OPERATIONAL), eq(nodeInstanceIdentifier));
-        verify(deviceContext).submitTransaction();
-    }
-}
index 06e04cf8192932959b30e674284f5191f46e3ea2..65e57b6ef5511a567fffcb2846d81509e8fbca0b 100644 (file)
@@ -27,7 +27,6 @@ import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
@@ -60,8 +59,6 @@ public class RpcManagerImplTest {
     @Mock
     private ConnectionContext connectionContext;
     @Mock
-    private ItemLifeCycleRegistry itemLifeCycleRegistry;
-    @Mock
     private MessageSpy messageSpy;
     @Mock
     private RpcContext removedContexts;
@@ -96,7 +93,6 @@ public class RpcManagerImplTest {
         Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
         Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
         Mockito.when(connectionContext.getFeatures()).thenReturn(features);
-        Mockito.when(deviceContext.getItemLifeCycleSourceRegistry()).thenReturn(itemLifeCycleRegistry);
         Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
         Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
         Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
index 476ec1bbfd8dadf149283e981fba8c4e7bbaddae..4f1fd3c62669d42370a40873ee5f5fa87cf0b50f 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.openflowplugin.impl.services.sal;
 
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.when;
 
 import com.google.common.util.concurrent.Futures;
@@ -36,7 +35,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
@@ -148,8 +146,8 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testAddFlow() throws Exception {
-        addFlow(null, OFConstants.OFP_VERSION_1_0);
-        addFlow(null, OFConstants.OFP_VERSION_1_3);
+        addFlow(OFConstants.OFP_VERSION_1_0);
+        addFlow(OFConstants.OFP_VERSION_1_3);
     }
 
     @Test
@@ -211,72 +209,57 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testAddFlowWithItemLifecycle() throws Exception {
-        addFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_0);
-        addFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_3);
+        addFlow(OFConstants.OFP_VERSION_1_0);
+        addFlow(OFConstants.OFP_VERSION_1_3);
     }
 
-    private void addFlow(final ItemLifecycleListener itemLifecycleListener, short version) throws ExecutionException,
+    private void addFlow(short version) throws ExecutionException,
                                                                                                   InterruptedException {
         AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder()
                 .setMatch(match)
                 .setTableId((short)1)
                 .build();
         SalFlowServiceImpl salFlowService = mockSalFlowService(version);
-        salFlowService.setItemLifecycleListener(itemLifecycleListener);
 
         mockingFlowRegistryLookup();
         verifyOutput(salFlowService.addFlow(mockedAddFlowInput));
-        if (itemLifecycleListener != null) {
-            Mockito.verify(itemLifecycleListener)
-                    .onAdded(Matchers.<KeyedInstanceIdentifier<Flow, FlowKey>>any(), Matchers.<Flow>any());
-        }
     }
 
     @Test
     public void testRemoveFlow() throws Exception {
-        removeFlow(null, OFConstants.OFP_VERSION_1_0);
-        removeFlow(null, OFConstants.OFP_VERSION_1_3);
+        removeFlow(OFConstants.OFP_VERSION_1_0);
+        removeFlow(OFConstants.OFP_VERSION_1_3);
     }
 
     @Test
     public void testRemoveFlowWithItemLifecycle() throws Exception {
-        removeFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_0);
-        removeFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_3);
+        removeFlow(OFConstants.OFP_VERSION_1_0);
+        removeFlow(OFConstants.OFP_VERSION_1_3);
     }
 
-    private void removeFlow(final ItemLifecycleListener itemLifecycleListener, short version) throws Exception {
+    private void removeFlow(short version) throws Exception {
         RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder()
                 .setMatch(match)
                 .setTableId((short)1)
                 .build();
 
         SalFlowServiceImpl salFlowService = mockSalFlowService(version);
-        if (itemLifecycleListener != null) {
-            salFlowService.setItemLifecycleListener(itemLifecycleListener);
-            mockingFlowRegistryLookup();
-
-        }
-
         verifyOutput(salFlowService.removeFlow(mockedRemoveFlowInput));
-        if (itemLifecycleListener != null) {
-            Mockito.verify(itemLifecycleListener).onRemoved(Matchers.<KeyedInstanceIdentifier<Flow, FlowKey>>any());
-        }
-
     }
 
     @Test
     public void testUpdateFlow() throws Exception {
-        updateFlow(null, OFConstants.OFP_VERSION_1_0);
-        updateFlow(null, OFConstants.OFP_VERSION_1_3);
+        updateFlow(OFConstants.OFP_VERSION_1_0);
+        updateFlow(OFConstants.OFP_VERSION_1_3);
     }
 
     @Test
     public void testUpdateFlowWithItemLifecycle() throws Exception {
-        updateFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_0);
-        updateFlow(mock(ItemLifecycleListener.class), OFConstants.OFP_VERSION_1_3);
+        updateFlow(OFConstants.OFP_VERSION_1_0);
+        updateFlow(OFConstants.OFP_VERSION_1_3);
     }
 
-    private void updateFlow(final ItemLifecycleListener itemLifecycleListener, short version) throws Exception {
+    private void updateFlow(short version) throws Exception {
         UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
         UpdateFlowInput mockedUpdateFlowInput1 = mock(UpdateFlowInput.class);
 
@@ -315,19 +298,9 @@ public class SalFlowServiceImplTest extends TestCase {
         when(mockedUpdateFlowInput1.getOriginalFlow()).thenReturn(mockedOriginalFlow1);
 
         SalFlowServiceImpl salFlowService = mockSalFlowService(version);
-        if (itemLifecycleListener != null) {
-            salFlowService.setItemLifecycleListener(itemLifecycleListener);
-            mockingFlowRegistryLookup();
-        }
 
         verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput));
         verifyOutput(salFlowService.updateFlow(mockedUpdateFlowInput1));
-
-        if (itemLifecycleListener != null) {
-            Mockito.verify(itemLifecycleListener, times(2))
-                    .onUpdated(Matchers.<KeyedInstanceIdentifier<Flow, FlowKey>>any(), Matchers.<Flow>any());
-        }
-
     }
 
     private void mockingFlowRegistryLookup() {
index a9b81e510fc232a20e6adf86f9966ca6c8c0e94f..717f628384b264b39662505f92b8f4bafffdd16d 100644 (file)
@@ -8,15 +8,12 @@
 package org.opendaylight.openflowplugin.impl.services.sal;
 
 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.openflowplugin.impl.services.ServiceMocking;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
@@ -34,9 +31,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.gro
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
-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;
 
 public class SalGroupServiceImplTest extends ServiceMocking {
 
@@ -56,86 +50,64 @@ public class SalGroupServiceImplTest extends ServiceMocking {
 
     @Test
     public void testAddGroup() throws Exception {
-        addGroup(null);
+        addGroup();
     }
 
     @Test
     public void testAddGroupWithItemLifecycle() throws Exception {
-        addGroup(mock(ItemLifecycleListener.class));
+        addGroup();
     }
 
-    private void addGroup(final ItemLifecycleListener itemLifecycleListener) {
+    private void addGroup() {
         final GroupId dummyGroupId = new GroupId(DUMMY_GROUP_ID);
         AddGroupInput addGroupInput = new AddGroupInputBuilder().setGroupId(dummyGroupId).build();
 
         this.<AddGroupOutput>mockSuccessfulFuture();
 
-        salGroupService.setItemLifecycleListener(itemLifecycleListener);
-
         salGroupService.addGroup(addGroupInput);
         verify(mockedRequestContextStack).createRequestContext();
         verify(mockedDeviceGroupRegistry).store(eq(dummyGroupId));
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener)
-                    .onAdded(Matchers.<KeyedInstanceIdentifier<Group, GroupKey>>any(),Matchers.<Group>any());
-        }
     }
 
     @Test
     public void testUpdateGroup() throws Exception {
-        updateGroup(null);
+        updateGroup();
     }
 
     @Test
     public void testUpdateGroupWithItemLifecycle() throws Exception {
-        updateGroup(mock(ItemLifecycleListener.class));
+        updateGroup();
     }
 
-    private void updateGroup(final ItemLifecycleListener itemLifecycleListener) {
+    private void updateGroup() {
         final UpdatedGroup updatedGroup = new UpdatedGroupBuilder().setGroupId(new GroupId(DUMMY_GROUP_ID)).build();
         final OriginalGroup originalGroup = new OriginalGroupBuilder().setGroupId(new GroupId(DUMMY_GROUP_ID)).build();
         final UpdateGroupInput updateGroupInput =
                 new UpdateGroupInputBuilder().setUpdatedGroup(updatedGroup).setOriginalGroup(originalGroup).build();
 
         this.<UpdateGroupOutput>mockSuccessfulFuture();
-
-        salGroupService.setItemLifecycleListener(itemLifecycleListener);
-
         salGroupService.updateGroup(updateGroupInput);
         verify(mockedRequestContextStack).createRequestContext();
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener)
-                    .onAdded(Matchers.<KeyedInstanceIdentifier<Group, GroupKey>>any(),Matchers.<Group>any());
-            verify(itemLifecycleListener).onRemoved(Matchers.<KeyedInstanceIdentifier<Group, GroupKey>>any());
-        }
     }
 
     @Test
     public void testRemoveGroup() throws Exception {
-        removeGroup(null);
+        removeGroup();
     }
 
     @Test
     public void testRemoveGroupWithItemLifecycle() throws Exception {
-        removeGroup(mock(ItemLifecycleListener.class));
+        removeGroup();
     }
 
-    private void removeGroup(final ItemLifecycleListener itemLifecycleListener) throws Exception {
+    private void removeGroup() throws Exception {
         final GroupId dummyGroupId = new GroupId(DUMMY_GROUP_ID);
         RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder().setGroupId(dummyGroupId).build();
 
         this.<RemoveGroupOutput>mockSuccessfulFuture();
 
-        salGroupService.setItemLifecycleListener(itemLifecycleListener);
-
         salGroupService.removeGroup(removeGroupInput);
         verify(mockedRequestContextStack).createRequestContext();
         verify(mockedDeviceGroupRegistry).addMark(eq(dummyGroupId));
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener).onRemoved(Matchers.<KeyedInstanceIdentifier<Group, GroupKey>>any());
-        }
     }
 }
index a29c25e3d4454732a17b974befe55ffdc7b78d5f..a49ff0db78fb3c6f8faf39cdd8ff6f7c44601de1 100644 (file)
@@ -8,20 +8,15 @@
 package org.opendaylight.openflowplugin.impl.services.sal;
 
 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.meter.DeviceMeterRegistry;
-import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
-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.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;
@@ -35,7 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.met
 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.KeyedInstanceIdentifier;
 
 public class SalMeterServiceImplTest extends ServiceMocking {
 
@@ -56,43 +50,36 @@ public class SalMeterServiceImplTest extends ServiceMocking {
 
     @Test
     public void testAddMeter() throws Exception {
-        addMeter(null);
+        addMeter();
     }
 
     @Test
     public void testAddMeterWithItemLifecycle() throws Exception {
-        addMeter(mock(ItemLifecycleListener.class));
+        addMeter();
     }
 
-    private void addMeter(final ItemLifecycleListener itemLifecycleListener) {
+    private void addMeter() {
         final MeterId dummyMeterId = new MeterId(DUMMY_METER_ID);
         AddMeterInput addMeterInput = new AddMeterInputBuilder().setMeterId(dummyMeterId).build();
 
         this.<AddMeterOutput>mockSuccessfulFuture();
 
-        salMeterService.setItemLifecycleListener(itemLifecycleListener);
-
         salMeterService.addMeter(addMeterInput);
         verify(mockedRequestContextStack).createRequestContext();
         verify(mockedDeviceMeterRegistry).store(eq(dummyMeterId));
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener)
-                    .onAdded(Matchers.<KeyedInstanceIdentifier<Meter, MeterKey>>any(),Matchers.<Meter>any());
-        }
     }
 
     @Test
     public void testUpdateMeter() throws Exception {
-        updateMeter(null);
+        updateMeter();
     }
 
     @Test
     public void testUpdateMeterWithItemLifecycle() throws Exception {
-        updateMeter(mock(ItemLifecycleListener.class));
+        updateMeter();
     }
 
-    private void updateMeter(final ItemLifecycleListener itemLifecycleListener) throws Exception {
+    private void updateMeter() throws Exception {
         final UpdatedMeter dummyUpdatedMeter =
                 new UpdatedMeterBuilder().setMeterId(new MeterId(DUMMY_METTER_ID)).build();
         final OriginalMeter dummyOriginalMeter =
@@ -103,42 +90,28 @@ public class SalMeterServiceImplTest extends ServiceMocking {
 
         this.<AddMeterOutput>mockSuccessfulFuture();
 
-        salMeterService.setItemLifecycleListener(itemLifecycleListener);
-
         salMeterService.updateMeter(updateMeterInput);
         verify(mockedRequestContextStack).createRequestContext();
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener)
-                    .onAdded(Matchers.<KeyedInstanceIdentifier<Meter, MeterKey>>any(),Matchers.<Meter>any());
-            verify(itemLifecycleListener).onRemoved(Matchers.<KeyedInstanceIdentifier<Meter, MeterKey>>any());
-        }
     }
 
     @Test
     public void testRemoveMeter() throws Exception {
-        removeMeter(null);
+        removeMeter();
     }
 
     @Test
     public void testRemoveMeterWithItemLifecycle() throws Exception {
-        removeMeter(mock(ItemLifecycleListener.class));
+        removeMeter();
     }
 
-    private void removeMeter(final ItemLifecycleListener itemLifecycleListener) throws Exception {
+    private void removeMeter() throws Exception {
         final MeterId dummyMeterId = new MeterId(DUMMY_METER_ID);
         RemoveMeterInput removeMeterInput = new RemoveMeterInputBuilder().setMeterId(dummyMeterId).build();
 
         this.<RemoveMeterOutput>mockSuccessfulFuture();
 
-        salMeterService.setItemLifecycleListener(itemLifecycleListener);
-
         salMeterService.removeMeter(removeMeterInput);
         verify(mockedRequestContextStack).createRequestContext();
         verify(mockedDeviceMeterRegistry).addMark(eq(dummyMeterId));
-
-        if (itemLifecycleListener != null) {
-            verify(itemLifecycleListener).onRemoved(Matchers.<KeyedInstanceIdentifier<Meter, MeterKey>>any());
-        }
     }
 }