From: Anil Vishnoi Date: Fri, 8 Dec 2017 21:57:35 +0000 (+0000) Subject: Merge "Rename addDeleteOperationTotTxChain => addDeleteOperationToTxChain" X-Git-Tag: release/oxygen~47 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=4183c0e3b1787072ced04f3e4fb1ae29c7d59929;hp=43a1665a869b36536d861cf67f2957d11a791bc2;p=openflowplugin.git Merge "Rename addDeleteOperationTotTxChain => addDeleteOperationToTxChain" --- diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/diagstatus/OpenflowPluginDiagStatusProvider.java similarity index 56% rename from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java rename to openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/diagstatus/OpenflowPluginDiagStatusProvider.java index 83b17ac733..af37224ff4 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/diagstatus/OpenflowPluginDiagStatusProvider.java @@ -5,22 +5,23 @@ * 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.diagstatus; +package org.opendaylight.openflowplugin.api.diagstatus; +import java.io.IOException; +import java.net.Socket; import org.opendaylight.infrautils.diagstatus.DiagStatusService; import org.opendaylight.infrautils.diagstatus.ServiceDescriptor; import org.opendaylight.infrautils.diagstatus.ServiceState; import org.opendaylight.infrautils.diagstatus.ServiceStatusProvider; - -import org.ops4j.pax.cdi.api.OsgiServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@OsgiServiceProvider(classes = ServiceStatusProvider.class) public class OpenflowPluginDiagStatusProvider implements ServiceStatusProvider { private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginDiagStatusProvider.class); private static final String OPENFLOW_SERVICE_NAME = "OPENFLOW"; + private static final int OF_PORT_11 = 6633; + private static final int OF_PORT_13 = 6653; private final DiagStatusService diagStatusService; private volatile ServiceDescriptor serviceDescriptor; @@ -38,7 +39,35 @@ public class OpenflowPluginDiagStatusProvider implements ServiceStatusProvider { @Override public ServiceDescriptor getServiceDescriptor() { - // TODO Check 6653/6633 port status to report dynamic status + + if (serviceDescriptor.getServiceState().equals(ServiceState.OPERATIONAL)) { + if (getApplicationNetworkState(OF_PORT_13) && getApplicationNetworkState(OF_PORT_11)) { + return serviceDescriptor; + } else { + serviceDescriptor = new ServiceDescriptor(OPENFLOW_SERVICE_NAME, ServiceState.ERROR, + "OF::PORTS:: 6653 and 6633 are not up yet"); + return serviceDescriptor; + } + } return serviceDescriptor; } + + private boolean getApplicationNetworkState(int port) { + Socket socket = null; + try { + socket = new Socket("localhost", port); + LOG.debug("Socket connection established"); + return true; + } catch (IOException e) { + return false; + } finally { + try { + if (socket != null) { + socket.close(); + } + } catch (IOException ex) { + LOG.error("Failed to close socket : {}", socket, ex); + } + } + } } \ No newline at end of file diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java index d8f42f6dfd..dbde3c6a02 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java @@ -12,9 +12,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.infrautils.diagstatus.DiagStatusService; +import org.opendaylight.infrautils.ready.SystemReadyMonitor; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; @@ -30,5 +31,6 @@ public interface OpenFlowPluginProviderFactory { List switchConnectionProviders, ClusterSingletonServiceProvider singletonServiceProvider, MastershipChangeServiceManager mastershipChangeServiceManager, - DiagStatusService diagStatusService); + OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider, + SystemReadyMonitor systemReadyMonitor); } diff --git a/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml b/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml index f3f8b8bb08..fabb5ee34c 100644 --- a/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml +++ b/openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml @@ -10,6 +10,7 @@ + @@ -40,6 +41,13 @@ update-method="update"/> + + + + + + - + + diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java index 8ddd0e7c97..ecbabd0dcf 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java @@ -12,9 +12,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.infrautils.diagstatus.DiagStatusService; +import org.opendaylight.infrautils.ready.SystemReadyMonitor; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider; import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider; import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; @@ -39,7 +40,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider final List switchConnectionProviders, final ClusterSingletonServiceProvider singletonServiceProvider, final MastershipChangeServiceManager mastershipChangeServiceManager, - final DiagStatusService diagStatusService) { + final OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider, + final SystemReadyMonitor systemReadyMonitor) { LOG.info("Initializing new OFP southbound."); final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl( configurationService, @@ -50,7 +52,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider singletonServiceProvider, entityOwnershipService, mastershipChangeServiceManager, - diagStatusService); + ofPluginDiagstatusProvider, + systemReadyMonitor); openflowPluginProvider.initialize(); return openflowPluginProvider; diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java index cf960fb28d..034245b55e 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java @@ -37,10 +37,12 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.infrautils.diagstatus.DiagStatusService; import org.opendaylight.infrautils.diagstatus.ServiceState; +import org.opendaylight.infrautils.ready.SystemReadyListener; +import org.opendaylight.infrautils.ready.SystemReadyMonitor; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider; import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionManager; @@ -59,7 +61,6 @@ import org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl; import org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl; import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProvider; import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProviderFactory; -import org.opendaylight.openflowplugin.impl.diagstatus.OpenflowPluginDiagStatusProvider; import org.opendaylight.openflowplugin.impl.lifecycle.ContextChainHolderImpl; import org.opendaylight.openflowplugin.impl.protocol.deserialization.DeserializerInjector; import org.opendaylight.openflowplugin.impl.protocol.serialization.SerializerInjector; @@ -80,7 +81,8 @@ import org.slf4j.LoggerFactory; public class OpenFlowPluginProviderImpl implements OpenFlowPluginProvider, - OpenFlowPluginExtensionRegistratorProvider { + OpenFlowPluginExtensionRegistratorProvider, + SystemReadyListener { private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderImpl.class); @@ -128,7 +130,8 @@ public class OpenFlowPluginProviderImpl implements final ClusterSingletonServiceProvider singletonServiceProvider, final EntityOwnershipService entityOwnershipService, final MastershipChangeServiceManager mastershipChangeServiceManager, - final DiagStatusService diagStatusService) { + final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor, + final SystemReadyMonitor systemReadyMonitor) { this.switchConnectionProviders = switchConnectionProviders; this.dataBroker = dataBroker; this.rpcProviderRegistry = rpcProviderRegistry; @@ -140,9 +143,16 @@ public class OpenFlowPluginProviderImpl implements deviceInitializerProvider = DeviceInitializerProviderFactory.createDefaultProvider(); config = new OpenFlowProviderConfigImpl(configurationService); this.mastershipChangeServiceManager = mastershipChangeServiceManager; - openflowPluginStatusMonitor = new OpenflowPluginDiagStatusProvider(diagStatusService); + this.openflowPluginStatusMonitor = openflowPluginStatusMonitor; + systemReadyMonitor.registerListener(this); + LOG.debug("registered onSystemBootReady() listener for deferred startSwitchConnections()"); } + @Override + public void onSystemBootReady() { + LOG.debug("onSystemBootReady() received, starting the switch connections"); + startSwitchConnections(); + } private void startSwitchConnections() { Futures.addCallback(Futures.allAsList(switchConnectionProviders.stream().map(switchConnectionProvider -> { @@ -259,7 +269,6 @@ public class OpenFlowPluginProviderImpl implements connectionManager.setDeviceDisconnectedHandler(contextChainHolder); deviceManager.initialize(); - startSwitchConnections(); } @Override diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java index 656b9d6de0..e9c1f7e42e 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java @@ -27,10 +27,10 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipL import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.infrautils.diagstatus.DiagStatusService; +import org.opendaylight.infrautils.ready.SystemReadyMonitor; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider; +import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty; import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService; import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager; @@ -49,7 +49,10 @@ public class OpenFlowPluginProviderImplTest { NotificationPublishService notificationPublishService; @Mock - DiagStatusService diagStatusService; + OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider; + + @Mock + SystemReadyMonitor systemReadyMonitor; @Mock WriteTransaction writeTransaction; @@ -110,17 +113,21 @@ public class OpenFlowPluginProviderImplTest { @Test public void testInitializeAndClose() throws Exception { - final OpenFlowPluginProvider provider = new OpenFlowPluginProviderFactoryImpl().newInstance( + final OpenFlowPluginProviderImpl provider = new OpenFlowPluginProviderImpl( configurationService, + Lists.newArrayList(switchConnectionProvider), dataBroker, rpcProviderRegistry, notificationPublishService, - entityOwnershipService, - Lists.newArrayList(switchConnectionProvider), clusterSingletonServiceProvider, + entityOwnershipService, mastershipChangeServiceManager, - diagStatusService); + ofPluginDiagstatusProvider, + systemReadyMonitor); + provider.initialize(); + // Calling the onSystemBootReady() callback + provider.onSystemBootReady(); verify(switchConnectionProvider).startup(); provider.close(); verify(switchConnectionProvider).shutdown();