Bug 5596 Cleaning part 1 71/44471/1
authorJozef Bacigal <jbacigal@cisco.com>
Mon, 25 Jul 2016 12:00:28 +0000 (14:00 +0200)
committerJozef Bacigal <jozef.bacigal@pantheon.tech>
Mon, 22 Aug 2016 12:06:04 +0000 (14:06 +0200)
- Device Context
- Device Manager
- Device State

Change-Id: I85a1269f1acc17a3e09cbe1d92fb993a9be5a4da
Signed-off-by: Jozef Bacigal <jbacigal@cisco.com>
18 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/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/device/DeviceSynchronizeListener.java [deleted file]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceValidListener.java [deleted file]
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/DeviceManagerImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/lifecycle/LifecycleServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/LifecycleConductorImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceContextImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/device/DeviceStateImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/MultipartRequestOnTheFlyCallbackTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/SalExperimenterMessageServiceImplTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsGatheringUtilsTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/statistics/StatisticsManagerImplTest.java

index 871adf3bc707a5aac7f98023cab3363dc91087a3..c7dca5069ad58c2d8c97c429a833c8be21e2f2b1 100644 (file)
@@ -13,7 +13,6 @@ import io.netty.util.Timeout;
 import java.math.BigInteger;
 import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
@@ -51,6 +50,8 @@ public interface DeviceContext extends
      */
     void shutdownConnection();
 
+    void initialSubmitTransaction();
+
     /**
      * Method add auxiliary connection contexts to this context representing single device connection.
      * @param connectionContext new connection context
@@ -130,7 +131,5 @@ public interface DeviceContext extends
 
     void setSwitchFeaturesMandatory(boolean switchFeaturesMandatory);
 
-    void registerClusterSingletonServices(ClusterSingletonServiceProvider singletonServiceProvider);
-
 }
 
index db07c8f8f8562d96f2db8ed18325c0521a277025..3f73661fc1bcf1253cf9883a7f1c2db96601bc6e 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.api.openflow.device;
 
-import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.openflowplugin.api.openflow.OFPManager;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
@@ -16,7 +15,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitia
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 
 /**
  * This interface is responsible for instantiating DeviceContext and
@@ -32,46 +30,6 @@ public interface DeviceManager extends DeviceConnectedHandler, DeviceDisconnecte
      */
     void initialize();
 
-    /**
-     * Method has to activate (MASTER) or deactivate (SLAVE) TransactionChainManager.
-     * TransactionChainManager represents possibility to write or delete Node subtree data
-     * for actual Controller Cluster Node. We are able to have an active TxManager only if
-     * newRole is {@link OfpRole#BECOMESLAVE}.
-     * Parameters are used as marker to be sure it is change to SLAVE from MASTER or from
-     * MASTER to SLAVE and the last parameter "cleanDataStore" is used for validation only.
-     *
-     * @param deviceInfo which device
-     * @param role - NewRole expect to be {@link OfpRole#BECOMESLAVE} or {@link OfpRole#BECOMEMASTER}
-     * @return RoleChangeTxChainManager future for activation/deactivation
-     */
-    ListenableFuture<Void> onClusterRoleChange(final DeviceInfo deviceInfo, final OfpRole role);
-
-    /**
-     * Register device synchronize listeners
-     * @param deviceSynchronizeListener are notified if device is synchronized or not
-     */
-    void addDeviceSynchronizeListener(final DeviceSynchronizeListener deviceSynchronizeListener);
-
-    /**
-     * Notify all registered listeners about synchronized status
-     * @param deviceInfo which device
-     * @param deviceSynchronized true if device is synchronized
-     */
-    void notifyDeviceSynchronizeListeners(final DeviceInfo deviceInfo, final boolean deviceSynchronized);
-
-    /**
-     * Register device valid listeners
-     * @param deviceValidListener are notified if device is valid or not
-     */
-    void addDeviceValidListener(final DeviceValidListener deviceValidListener);
-
-    /**
-     * Notify all registered listeners about valid status
-     * @param deviceInfo which device
-     * @param deviceValid true if device is valid
-     */
-    void notifyDeviceValidListeners(final DeviceInfo deviceInfo, final boolean deviceValid);
-
     void setIsNotificationFlowRemovedOff(boolean value);
 
     boolean getIsNotificationFlowRemovedOff();
index 0ca7e2df60eb99d58c089dde12e859b1ff83e81d..becc8d09cb25ee177bad18cfe1e3178a760d06d2 100644 (file)
@@ -11,12 +11,7 @@ package org.opendaylight.openflowplugin.api.openflow.device;
 /**
  * Holder of device's structure
  */
-public interface DeviceState extends DeviceSynchronizeListener, DeviceValidListener {
-
-    /**
-     * @return true if this session is valid
-     */
-    boolean isValid();
+public interface DeviceState {
 
     /**
      * Return true if we have relevant meter information
@@ -44,13 +39,6 @@ public interface DeviceState extends DeviceSynchronizeListener, DeviceValidListe
      */
     void setGroupAvailable(boolean available);
 
-    /**
-     * Method returns true if initial statistics data were collected and written to DS.
-     *
-     * @return
-     */
-    boolean deviceSynchronized();
-
     /**
      * Method returns true, if device capabilities provides flow statistics.
      *
@@ -89,6 +77,4 @@ public interface DeviceState extends DeviceSynchronizeListener, DeviceValidListe
 
     boolean isStatisticsPollingEnabled();
 
-    void setStatisticsPollingEnabledProp(boolean statPollEnabled);
-
 }
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceSynchronizeListener.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceSynchronizeListener.java
deleted file mode 100644 (file)
index 6c49c52..0000000
+++ /dev/null
@@ -1,17 +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.device;
-
-/**
- * API for device synchronized listeners
- */
-public interface DeviceSynchronizeListener {
-
-    void deviceIsSynchronized(final DeviceInfo deviceInfo, final boolean isSynchronized);
-
-}
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceValidListener.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/device/DeviceValidListener.java
deleted file mode 100644 (file)
index 55153a0..0000000
+++ /dev/null
@@ -1,17 +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.device;
-
-/**
- * API for device synchronized listeners
- */
-public interface DeviceValidListener {
-
-    void deviceIsValid(final DeviceInfo deviceInfo, final boolean isValid);
-
-}
index 6cd8fcf2f5f8071ec942705be33636073a87c6db..32b2d768faae2a0db2d2dca441c691cc8a7086d0 100644 (file)
@@ -144,7 +144,6 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
         LOG.debug("Close connection called for node {}", deviceInfo);
         final DeviceContext deviceContext = getDeviceContext(deviceInfo);
         if (null != deviceContext) {
-            deviceManager.notifyDeviceValidListeners(deviceInfo, false);
             deviceContext.shutdownConnection();
         }
     }
@@ -164,10 +163,7 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
 
         LOG.info("Role change to {} in role context for node {} was successful.", newRole, deviceInfo.getNodeId().getValue());
 
-        final String logText;
-
         if (OfpRole.BECOMEMASTER.equals(newRole)) {
-            logText = "Start";
             fillDeviceFlowRegistry(deviceInfo, deviceContext.getDeviceFlowRegistry());
             MdSalRegistrationUtils.registerServices(rpcContext, deviceContext, this.extensionConverterProvider, convertorExecutor);
 
@@ -178,7 +174,6 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
                         notificationPublishService, convertorExecutor);
             }
         } else {
-            logText = "Stopp";
             statisticsManager.stopScheduling(deviceInfo);
 
             // Clean device flow registry if we became slave
@@ -189,22 +184,6 @@ final class LifecycleConductorImpl implements LifecycleConductor, RoleChangeList
             MdSalRegistrationUtils.unregisterServices(rpcContext);
         }
 
-        final ListenableFuture<Void> onClusterRoleChange = deviceManager.onClusterRoleChange(deviceInfo, newRole);
-        Futures.addCallback(onClusterRoleChange, new FutureCallback<Void>() {
-            @Override
-            public void onSuccess(@Nullable final Void aVoid) {
-                LOG.info("{}ing services for node {} was successful", logText, deviceInfo);
-                if (newRole.equals(OfpRole.BECOMESLAVE)) {
-                    notifyServiceChangeListeners(deviceInfo, true);
-                }
-            }
-
-            @Override
-            public void onFailure(final Throwable throwable) {
-                LOG.warn("{}ing services for node {} was NOT successful, closing connection", logText, deviceInfo.getNodeId().getValue());
-                closeConnection(deviceInfo);
-            }
-        });
     }
 
     private void fillDeviceFlowRegistry(final DeviceInfo deviceInfo, final DeviceFlowRegistry deviceFlowRegistry) {
index 5d68cc981e874828cf6ed778f82f06d3b3212510..63f97c73afcd8f04e90a77758e2048e324f9f121 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
 import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
@@ -142,17 +141,17 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
     private final ConvertorExecutor convertorExecutor;
     private volatile CONTEXT_STATE state;
 
-    public DeviceContextImpl(@Nonnull final ConnectionContext primaryConnectionContext,
-                             @Nonnull final DeviceState deviceState,
-                             @Nonnull final DataBroker dataBroker,
-                             @Nonnull final LifecycleConductor conductor,
-                             @Nonnull final OutboundQueueProvider outboundQueueProvider,
-                             @Nonnull final TranslatorLibrary translatorLibrary,
-                             final DeviceManager manager,
-                             @Nonnull final DeviceInfo deviceInfo,
-                             final ConvertorExecutor convertorExecutor) {
+    public DeviceContextImpl(
+            @Nonnull final ConnectionContext primaryConnectionContext,
+            @Nonnull final DataBroker dataBroker,
+            @Nonnull final LifecycleConductor conductor,
+            @Nonnull final OutboundQueueProvider outboundQueueProvider,
+            @Nonnull final TranslatorLibrary translatorLibrary,
+            @Nonnull final DeviceManager manager,
+           final ConvertorExecutor convertorExecutor) {
         this.primaryConnectionContext = Preconditions.checkNotNull(primaryConnectionContext);
-        this.deviceState = Preconditions.checkNotNull(deviceState);
+        this.deviceInfo = primaryConnectionContext.getDeviceInfo();
+        this.deviceState = new DeviceStateImpl();
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
         Preconditions.checkNotNull(conductor);
         this.outboundQueueProvider = Preconditions.checkNotNull(outboundQueueProvider);
@@ -178,7 +177,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         itemLifeCycleSourceRegistry = new ItemLifeCycleRegistryImpl();
         flowLifeCycleKeeper = new ItemLifeCycleSourceImpl();
         itemLifeCycleSourceRegistry.registerLifeCycleSource(flowLifeCycleKeeper);
-        this.deviceInfo = deviceInfo;
         this.state = CONTEXT_STATE.INITIALIZATION;
         this.convertorExecutor = convertorExecutor;
     }
@@ -187,7 +185,8 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
      * This method is called from {@link DeviceManagerImpl} only. So we could say "posthandshake process finish"
      * and we are able to set a scheduler for an automatic transaction submitting by time (0,5sec).
      */
-    void initialSubmitTransaction() {
+    @Override
+    public void initialSubmitTransaction() {
         transactionChainManager.initialSubmitWriteTransaction();
     }
 
@@ -538,11 +537,6 @@ public class DeviceContextImpl implements DeviceContext, ExtensionConverterProvi
         this.switchFeaturesMandatory = switchFeaturesMandatory;
     }
 
-    @Override
-    public void registerClusterSingletonServices(ClusterSingletonServiceProvider singletonServiceProvider) {
-
-    }
-
     @Override
     public CONTEXT_STATE getState() {
         return this.state;
index 8d5b50625413b86037c52ac0f191afed5e9d910b..3d076300a96f4046488acc0127dc0c6eb071156a 100644 (file)
@@ -8,19 +8,15 @@
 package org.opendaylight.openflowplugin.impl.device;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Verify;
 import com.google.common.collect.Iterators;
-import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import io.netty.util.TimerTask;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ExecutionException;
@@ -40,15 +36,11 @@ import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProv
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceSynchronizeListener;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceValidListener;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleConductor;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
-import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
 import org.opendaylight.openflowplugin.extension.api.ExtensionConverterProviderKeeper;
 import org.opendaylight.openflowplugin.extension.api.core.extension.ExtensionConverterProvider;
 import org.opendaylight.openflowplugin.impl.connection.OutboundQueueProviderImpl;
@@ -59,7 +51,6 @@ import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorE
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -90,8 +81,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
     private final int barrierCountLimit;
     private ExtensionConverterProvider extensionConverterProvider;
     private ScheduledThreadPoolExecutor spyPool;
-    private Set<DeviceSynchronizeListener> deviceSynchronizedListeners;
-    private Set<DeviceValidListener> deviceValidListeners;
     private final ClusterSingletonServiceProvider singletonServiceProvider;
 
     private final LifecycleConductor conductor;
@@ -128,8 +117,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
         this.conductor = lifecycleConductor;
         spyPool = new ScheduledThreadPoolExecutor(1);
-        this.deviceSynchronizedListeners = new HashSet<>();
-        this.deviceValidListeners = new HashSet<>();
         this.singletonServiceProvider = singletonServiceProvider;
     }
 
@@ -181,18 +168,12 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
                 connectionAdapter.registerOutboundQueueHandler(outboundQueueProvider, barrierCountLimit, barrierIntervalNanos);
         connectionContext.setOutboundQueueHandleRegistration(outboundQueueHandlerRegistration);
 
-        final DeviceState deviceState = new DeviceStateImpl(deviceInfo);
-        this.addDeviceSynchronizeListener(deviceState);
-        this.addDeviceValidListener(deviceState);
-
         final DeviceContext deviceContext = new DeviceContextImpl(connectionContext,
-                deviceState,
                 dataBroker,
                 conductor,
                 outboundQueueProvider,
                 translatorLibrary,
                 this,
-                connectionContext.getDeviceInfo(),
                 convertorExecutor);
 
         final LifecycleService lifecycleService = new LifecycleServiceImpl();
@@ -210,13 +191,9 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
 
         final OpenflowProtocolListenerFullImpl messageListener = new OpenflowProtocolListenerFullImpl(
                 connectionAdapter, deviceContext);
-        connectionAdapter.setMessageListener(messageListener);
-        notifyDeviceValidListeners(deviceInfo, true);
-
-        deviceInitPhaseHandler.onDeviceContextLevelUp(connectionContext.getDeviceInfo(), lifecycleServices.get(deviceInfo));
-
-        notifyDeviceSynchronizeListeners(deviceInfo, true);
 
+        connectionAdapter.setMessageListener(messageListener);
+        deviceInitPhaseHandler.onDeviceContextLevelUp(connectionContext.getDeviceInfo(), lifecycleService);
         return true;
     }
 
@@ -251,7 +228,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         for (final Iterator<DeviceContext> iterator = Iterators.consumingIterator(deviceContexts.values().iterator());
                 iterator.hasNext();) {
             final DeviceContext deviceCtx = iterator.next();
-            notifyDeviceValidListeners(deviceCtx.getDeviceInfo(), false);
             deviceCtx.shutdownConnection();
             deviceCtx.shuttingDownDataStoreTransactions();
         }
@@ -310,7 +286,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
             /* Connection is not PrimaryConnection so try to remove from Auxiliary Connections */
             deviceCtx.removeAuxiliaryConnectionContext(connectionContext);
         } else {
-            notifyDeviceValidListeners(deviceInfo, false);
             /* Device is disconnected and so we need to close TxManager */
             final ListenableFuture<Void> future = deviceCtx.shuttingDownDataStoreTransactions();
             Futures.addCallback(future, new FutureCallback<Void>() {
@@ -348,40 +323,6 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         return (T) deviceContexts.get(deviceInfo);
     }
 
-    @Override
-    public ListenableFuture<Void> onClusterRoleChange(final DeviceInfo deviceInfo, final OfpRole role) {
-        DeviceContext deviceContext = deviceContexts.get(deviceInfo);
-        LOG.trace("onClusterRoleChange {} for node:", role, deviceInfo.getNodeId());
-        if (OfpRole.BECOMEMASTER.equals(role)) {
-            return onDeviceTakeClusterLeadership(deviceInfo);
-        }
-        return ((DeviceContextImpl)deviceContext).getTransactionChainManager().deactivateTransactionManager();
-    }
-
-    @Override
-    public void addDeviceSynchronizeListener(final DeviceSynchronizeListener deviceSynchronizeListener) {
-        this.deviceSynchronizedListeners.add(deviceSynchronizeListener);
-    }
-
-    @Override
-    public void notifyDeviceSynchronizeListeners(final DeviceInfo deviceInfo, final boolean deviceSynchronized) {
-        for (DeviceSynchronizeListener listener : deviceSynchronizedListeners) {
-            listener.deviceIsSynchronized(deviceInfo, deviceSynchronized);
-        }
-    }
-
-    @Override
-    public void addDeviceValidListener(final DeviceValidListener deviceValidListener) {
-        this.deviceValidListeners.add(deviceValidListener);
-    }
-
-    @Override
-    public void notifyDeviceValidListeners(final DeviceInfo deviceInfo, final boolean deviceValid) {
-        for (DeviceValidListener listener : deviceValidListeners) {
-            listener.deviceIsValid(deviceInfo, deviceValid);
-        }
-    }
-
     @Override
     public void setIsNotificationFlowRemovedOff(boolean isNotificationFlowRemovedOff) {
         this.isNotificationFlowRemovedOff = isNotificationFlowRemovedOff;
@@ -392,62 +333,4 @@ public class DeviceManagerImpl implements DeviceManager, ExtensionConverterProvi
         return this.isNotificationFlowRemovedOff;
     }
 
-    private ListenableFuture<Void> onDeviceTakeClusterLeadership(final DeviceInfo deviceInfo) {
-        LOG.trace("onDeviceTakeClusterLeadership for node: {}", deviceInfo.getNodeId());
-        /* validation */
-        StatisticsContext statisticsContext = conductor.getStatisticsContext(deviceInfo);
-        if (statisticsContext == null) {
-            final String errMsg = String.format("DeviceCtx %s is up but we are missing StatisticsContext", deviceInfo.getDatapathId());
-            LOG.warn(errMsg);
-            return Futures.immediateFailedFuture(new IllegalStateException(errMsg));
-        }
-        DeviceContext deviceContext = deviceContexts.get(deviceInfo);
-        /* Prepare init info collecting */
-        notifyDeviceSynchronizeListeners(deviceInfo, false);
-        ((DeviceContextImpl)deviceContext).getTransactionChainManager().activateTransactionManager();
-        ((DeviceContextImpl)deviceContext).getTransactionChainManager().initialSubmitWriteTransaction();
-        /* Init Collecting NodeInfo */
-        final ListenableFuture<Void> initCollectingDeviceInfo = DeviceInitializationUtils.initializeNodeInformation(
-                deviceContext, switchFeaturesMandatory, convertorExecutor);
-        /* Init Collecting StatInfo */
-        final ListenableFuture<Boolean> statPollFuture = Futures.transform(initCollectingDeviceInfo,
-                new AsyncFunction<Void, Boolean>() {
-
-                    @Override
-                    public ListenableFuture<Boolean> apply(@Nonnull final Void input) throws Exception {
-                        statisticsContext.statListForCollectingInitialization();
-                        return statisticsContext.initialGatherDynamicData();
-                    }
-                });
-
-        return Futures.transform(statPollFuture, getInitialDeviceInformation(deviceContext));
-    }
-
-    private Function<Boolean, Void> getInitialDeviceInformation(final DeviceContext deviceContext) {
-        return input -> {
-            if (ConnectionContext.CONNECTION_STATE.RIP.equals(
-                    conductor.gainConnectionStateSafely(deviceContext.getDeviceInfo())
-            )) {
-                final String errMsg =
-                        String.format("We lost connection for Device %s, context has to be closed.",
-                        deviceContext.getDeviceInfo().getNodeId());
-                LOG.warn(errMsg);
-                throw new IllegalStateException(errMsg);
-            }
-
-            if (input == null || !input) {
-                final String errMsg =
-                        String.format("Get Initial Device %s information fails",
-                        deviceContext.getDeviceInfo().getNodeId());
-                LOG.warn(errMsg);
-                throw new IllegalStateException(errMsg);
-            }
-            LOG.debug("Get Initial Device {} information is successful",
-                    deviceContext.getDeviceInfo().getNodeId());
-            notifyDeviceSynchronizeListeners(deviceContext.getDeviceInfo(), true);
-            deviceContext.getDeviceState().setStatisticsPollingEnabledProp(true);
-            return null;
-        };
-    }
-
 }
index 42162c8ab85e528d039cd3c0f07925d784793561..93c0e803574fa189ab6e32018b169a0c3ebda417 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.openflowplugin.impl.device;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
@@ -23,26 +22,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 class DeviceStateImpl implements DeviceState {
 
-    private final DeviceInfo deviceInfo;
-    private boolean valid;
     private boolean meterIsAvailable;
     private boolean groupIsAvailable;
-    private boolean deviceSynchronized;
     private boolean flowStatisticsAvailable;
     private boolean tableStatisticsAvailable;
     private boolean portStatisticsAvailable;
     private boolean statPollEnabled;
     private boolean queueStatisticsAvailable;
 
-    public DeviceStateImpl(final DeviceInfo deviceInfo) {
-        this.deviceInfo = deviceInfo;
+    public DeviceStateImpl() {
         statPollEnabled = false;
-        deviceSynchronized = false;
-    }
-
-    @Override
-    public boolean isValid() {
-        return valid;
     }
 
     @Override
@@ -65,11 +54,6 @@ class DeviceStateImpl implements DeviceState {
         groupIsAvailable = available;
     }
 
-    @Override
-    public boolean deviceSynchronized() {
-        return deviceSynchronized;
-    }
-
     @Override
     public boolean isFlowStatisticsAvailable() {
         return flowStatisticsAvailable;
@@ -116,22 +100,4 @@ class DeviceStateImpl implements DeviceState {
         return statPollEnabled;
     }
 
-    @Override
-    public void setStatisticsPollingEnabledProp(final boolean statPollEnabled) {
-        this.statPollEnabled = statPollEnabled;
-    }
-
-    @Override
-    public void deviceIsSynchronized(final DeviceInfo deviceInfo, final boolean isSynchronized) {
-        if (this.deviceInfo.equals(deviceInfo)) {
-            this.deviceSynchronized = isSynchronized;
-        }
-    }
-
-    @Override
-    public void deviceIsValid(final DeviceInfo deviceInfo, final boolean isValid) {
-        if (this.deviceInfo.equals(deviceInfo)) {
-            this.valid = isValid;
-        }
-    }
 }
index 77ea3e975340452c5a772884b7fcb320dbf58366..43e78fc3ea03bc1ad6401c7c808634e8ef671363 100644 (file)
@@ -41,6 +41,9 @@ public class LifecycleServiceImpl implements LifecycleService {
             LOG.info("Starting statistics context cluster services for node {}", getIdentifier());
             this.statContext.startupClusterServices();
 
+            LOG.info("Statistics initial gathering OK, submitting data for node {}", getIdentifier());
+            this.deviceContext.initialSubmitTransaction();
+
             LOG.info("Starting rpc context cluster services for node {}", getIdentifier());
             this.rpcContext.startupClusterServices();
 
index 8255e35adb9ec27957c7b1e78d6c068c4ef1e73a..6bc426dafc1b25c3f9e223180485cc47b35a201b 100644 (file)
@@ -111,11 +111,6 @@ public class StatisticsManagerImpl implements StatisticsManager, StatisticsManag
             LOG.debug("Disabling statistics scheduling for device: {}", deviceInfo.getNodeId());
             return;
         }
-        
-        if (!deviceState.isValid()) {
-            LOG.debug("Session is not valid for device: {}", deviceInfo.getNodeId());
-            return;
-        }
 
         if (!deviceState.isStatisticsPollingEnabled()) {
             LOG.debug("Statistics polling is currently disabled for device: {}", deviceInfo.getNodeId());
index 298a40e35a97a95c142e3f090bb367e5e7ae7aef..723cb79723a2cb5ee74f1ba8a83f4ce2bbb66456 100644 (file)
@@ -183,7 +183,6 @@ public class LifecycleConductorImplTest {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(dataBroker, nodeInstanceIdentifier));
         when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
-        when(deviceManager.onClusterRoleChange(deviceInfo, OfpRole.BECOMEMASTER)).thenReturn(listenableFuture);
         lifecycleConductor.roleChangeOnDevice(deviceInfo,OfpRole.BECOMEMASTER);
         verify(statisticsManager).startScheduling(Mockito.<DeviceInfo>any());
     }
@@ -198,7 +197,6 @@ public class LifecycleConductorImplTest {
         when(deviceContext.getDeviceState()).thenReturn(deviceState);
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl(dataBroker, nodeInstanceIdentifier));
         when(deviceManager.gainContext(deviceInfo)).thenReturn(deviceContext);
-        when(deviceManager.onClusterRoleChange(deviceInfo, OfpRole.BECOMESLAVE)).thenReturn(listenableFuture);
 
         lifecycleConductor.roleChangeOnDevice(deviceInfo,OfpRole.BECOMESLAVE);
         verify(statisticsManager).stopScheduling(Mockito.<DeviceInfo>any());
index f5840204e57eab9de3059c1c712ce3e3bf0e8d65..9498beeda74935ccda14dc15f7ffd3d0b2478754 100644 (file)
@@ -230,13 +230,11 @@ public class DeviceContextImplTest {
 
         deviceContext = new DeviceContextImpl(
                 connectionContext,
-                deviceState,
                 dataBroker,
                 lifecycleConductor,
                 outboundQueueProvider,
                 translatorLibrary,
                        deviceManager,
-                deviceInfo,
                 convertorExecutor);
         deviceContextSpy = Mockito.spy(deviceContext);
 
@@ -248,24 +246,14 @@ public class DeviceContextImplTest {
 
     @Test(expected = NullPointerException.class)
     public void testDeviceContextImplConstructorNullDataBroker() throws Exception {
-        new DeviceContextImpl(connectionContext, deviceState, null, lifecycleConductor, outboundQueueProvider, translatorLibrary, deviceManager, deviceInfo, convertorExecutor).close();
-    }
+        new DeviceContextImpl(connectionContext, null, lifecycleConductor, outboundQueueProvider, translatorLibrary, deviceManager, convertorExecutor).close();
 
-    @Test(expected = NullPointerException.class)
-    public void testDeviceContextImplConstructorNullDeviceState() throws Exception {
-        new DeviceContextImpl(connectionContext, null, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, deviceManager, deviceInfo, convertorExecutor).close();
     }
 
     @Test(expected = NullPointerException.class)
     public void testDeviceContextImplConstructorNullTimer() throws Exception {
-        new DeviceContextImpl(null, deviceState, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, deviceManager, deviceInfo, convertorExecutor).close();
-    }
 
-    @Test
-    public void testGetDeviceState() {
-        final DeviceState deviceSt = deviceContext.getDeviceState();
-        assertNotNull(deviceSt);
-        assertEquals(deviceState, deviceSt);
+        new DeviceContextImpl(null, dataBroker, lifecycleConductor, outboundQueueProvider, translatorLibrary, deviceManager, convertorExecutor).close();
     }
 
     @Test
@@ -433,8 +421,6 @@ public class DeviceContextImplTest {
 
         final ConnectionContext mockedAuxiliaryConnectionContext = prepareConnectionContext();
         deviceContext.addAuxiliaryConnectionContext(mockedAuxiliaryConnectionContext);
-        final DeviceTerminationPhaseHandler mockedDeviceContextClosedHandler = mock(DeviceTerminationPhaseHandler.class);
-        when(deviceState.isValid()).thenReturn(true);
         deviceContext.shutdownConnection();
         verify(connectionContext).closeConnection(true);
     }
index 5170dd75d64d088b0ace332bd524ef9f36e966c4..071743ba3e451b30b8c940964edea9ed4b7b713b 100644 (file)
@@ -32,17 +32,7 @@ public class DeviceStateImplTest {
 
     @Before
     public void initialization() {
-        deviceState = new DeviceStateImpl(deviceInfo);
-    }
-
-    @Test
-    public void testIsValid_initialValue(){
-        Assert.assertFalse(deviceState.isValid());
-    }
-
-    @Test
-    public void testDeviceSynchronized_initialValue(){
-        Assert.assertFalse(deviceState.deviceSynchronized());
+        deviceState = new DeviceStateImpl();
     }
 
     @Test
index a085ce1e4cfb591c670a9b60aced993eef958abf..9cef7daae3e4cdcb313d4fd3d2a0a5dceb6dd9ef 100644 (file)
@@ -127,7 +127,6 @@ public class MultipartRequestOnTheFlyCallbackTest {
 
         when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
         when(mockedDeviceInfo.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
-        when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
         when(mockedDeviceInfo.getNodeId()).thenReturn(mockedNodeId);
         when(mockedDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
         when(mockedDeviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
index af336d62c7ee983f05f4d48dd4c21669865d67db..d1760f0cda386653cf8fea123df8d5f24218b952 100644 (file)
@@ -44,7 +44,6 @@ public class SalExperimenterMessageServiceImplTest extends ServiceMocking {
     @Override
     protected void setup() {
         salExperimenterMessageService = new SalExperimenterMessageServiceImpl(mockedRequestContextStack, mockedDeviceContext, extensionConverterProvider);
-        Mockito.when(mockedDeviceContext.getExtensionConverterProvider()).thenReturn(extensionConverterProvider);
         Mockito.when(extensionConverterProvider.getMessageConverter(Matchers.<TypeVersionKey>any()))
                 .thenReturn(extensionConverter);
         Mockito.when(extensionConverter.getExperimenterId()).thenReturn(new ExperimenterId(43L));
index 57a890ed4cd3ed0d1ef16eda4f3a641d2cd89453..7076e6b8862d7c97994e3abe69e1fac885c39979 100644 (file)
@@ -518,7 +518,6 @@ public class StatisticsGatheringUtilsTest {
     @Test
     public void testDeleteAllKnownFlows() throws Exception {
         final short tableId = 0;
-        when(deviceState.deviceSynchronized()).thenReturn(true);
         final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
         final TableBuilder tableDataBld = new TableBuilder();
         tableDataBld.setId(tableId);
index 37eb28c5a4eaad1f862a481661441b91b4f7edd7..68ed88b8d2d9032ff734957cf9954845e2e8341f 100644 (file)
@@ -380,7 +380,6 @@ public class StatisticsManagerImplTest {
         statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
         verify(mockedDeviceContext).getDeviceState();
 
-        when(mockedDeviceContext.getDeviceState().isValid()).thenReturn(true);
         statisticsManager.pollStatistics(mockedDeviceContext.getDeviceState(), statisticsContext, mockTimerCounter, mockedDeviceInfo);
 
         when(mockedDeviceContext.getDeviceState().isStatisticsPollingEnabled()).thenReturn(true);