<configuration>
<instructions>
<Export-Package>
+ org.opendaylight.ovsdb.lib,
org.opendaylight.ovsdb.lib.*,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.library.impl.rev141210.*
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.library.impl.rev141210
</Export-Package>
</instructions>
</configuration>
+++ /dev/null
-/*
- * Copyright © 2015 Red Hat, 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.ovsdb.lib.impl;
-
-import java.net.InetAddress;
-import java.util.Collection;
-
-import javax.net.ssl.SSLContext;
-
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.ovsdb.lib.OvsdbClient;
-import org.opendaylight.ovsdb.lib.OvsdbConnection;
-import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
-import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LibraryProvider implements BindingAwareProvider, AutoCloseable, OvsdbConnection {
-
- private static final Logger LOG = LoggerFactory.getLogger(LibraryProvider.class);
-
- public LibraryProvider(BundleContext bundleContext) {
- LOG.info("LibraryProvider: bundleContext: {}", bundleContext);
- }
-
- @Override
- public void onSessionInitiated(ProviderContext providerContext) {
- LOG.info("LibraryProvider Session Initiated");
- }
-
- @Override
- public void close() throws Exception {
- LOG.info("LibraryProvider Closed");
- }
-
- @Override
- public OvsdbClient connect(InetAddress address, int port) {
- return OvsdbConnectionService.getService().connect(address, port);
- }
-
- @Override
- public OvsdbClient connectWithSsl(
- InetAddress address, int port, SSLContext sslContext) {
- return OvsdbConnectionService.getService().connectWithSsl(address, port, sslContext);
- }
-
- @Override
- public void disconnect(OvsdbClient client) {
- OvsdbConnectionService.getService().disconnect(client);
- }
-
- @Override
- public boolean startOvsdbManager(int ovsdbListenPort) {
- return OvsdbConnectionService.getService().startOvsdbManager(ovsdbListenPort);
- }
-
- @Override
- public boolean startOvsdbManagerWithSsl(int ovsdbListenPort, SSLContext sslContext) {
- return OvsdbConnectionService.getService().startOvsdbManagerWithSsl(ovsdbListenPort, sslContext);
- }
-
- @Override
- public void registerConnectionListener(OvsdbConnectionListener listener) {
- OvsdbConnectionService.getService().registerConnectionListener(listener);
- }
-
- @Override
- public void unregisterConnectionListener(OvsdbConnectionListener listener) {
- OvsdbConnectionService.getService().unregisterConnectionListener(listener);
- }
-
- @Override
- public Collection<OvsdbClient> getConnections() {
- return OvsdbConnectionService.getService().getConnections();
- }
-}
* environment. Hence a single instance of the service will be active (via Service Registry in OSGi)
* and a Singleton object in a non-OSGi environment.
*/
-public class OvsdbConnectionService implements OvsdbConnection {
+public class OvsdbConnectionService implements AutoCloseable, OvsdbConnection {
private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionService.class);
private static final int NUM_THREADS = 3;
public Collection<OvsdbClient> getConnections() {
return connections.keySet();
}
+
+ @Override
+ public void close() throws Exception {
+ LOG.info("OvsdbConnectionService closed");
+ }
}
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.ovsdb.lib.impl.LibraryProvider;
+import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
import org.osgi.framework.BundleContext;
import com.google.common.base.Preconditions;
@Override
public java.lang.AutoCloseable createInstance() {
- LibraryProvider provider = new LibraryProvider(bundleContext);
- getBrokerDependency().registerProvider(provider);
+ OvsdbConnectionService provider = new OvsdbConnectionService();
return provider;
}
import org.opendaylight.controller.config.api.JmxAttribute;
import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.ovsdb.lib.impl.LibraryProvider;
import org.osgi.framework.BundleContext;
import javax.management.ObjectName;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class LibraryModuleTest {
// getInstance calls resolveInstance to get the broker dependency and then calls createInstance
AutoCloseable closeable = module.getInstance();
- // verify that the module registered the returned provider with the broker
- verify(broker).registerProvider((LibraryProvider)closeable);
-
// ensure no exceptions on close
closeable.close();
}
<failsOnError>true</failsOnError>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
</plugins>
</build>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <!--<Private-Package>!org.opendaylight.ovsdb.lib.osgi,org.opendaylight.ovsdb.lib.*,org.opendaylight.ovsdb.schema.openvswitch</Private-Package>-->
- <Export-Package>org.opendaylight.ovsdb.southbound.*,org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.*</Export-Package>
+ <Export-Package>
+ org.opendaylight.ovsdb.southbound.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.southbound.impl.rev141210.*</Export-Package>
</instructions>
</configuration>
</plugin>
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.ovsdb.lib.OvsdbClient;
+import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.lib.OvsdbConnectionListener;
-import org.opendaylight.ovsdb.lib.impl.OvsdbConnectionService;
import org.opendaylight.ovsdb.lib.operations.Operation;
import org.opendaylight.ovsdb.lib.operations.OperationResult;
import org.opendaylight.ovsdb.lib.operations.Select;
new ConcurrentHashMap<>();
private EntityOwnershipService entityOwnershipService;
private OvsdbDeviceEntityOwnershipListener ovsdbDeviceEntityOwnershipListener;
+ private OvsdbConnection ovsdbConnection;
public OvsdbConnectionManager(DataBroker db,TransactionInvoker txInvoker,
- EntityOwnershipService entityOwnershipService) {
+ EntityOwnershipService entityOwnershipService,
+ OvsdbConnection ovsdbConnection) {
this.db = db;
this.txInvoker = txInvoker;
this.entityOwnershipService = entityOwnershipService;
this.ovsdbDeviceEntityOwnershipListener = new OvsdbDeviceEntityOwnershipListener(this, entityOwnershipService);
+ this.ovsdbConnection = ovsdbConnection;
}
@Override
// TODO use transaction chains to handle ordering issues between disconnected
// TODO and connected when writing to the operational store
InetAddress ip = SouthboundMapper.createInetAddress(ovsdbNode.getConnectionInfo().getRemoteIp());
- OvsdbClient client = OvsdbConnectionService.getService().connect(ip,
+ OvsdbClient client = ovsdbConnection.connect(ip,
ovsdbNode.getConnectionInfo().getRemotePort().getValue());
// For connections from the controller to the ovs instance, the library doesn't call
// this method for us
LOG.info("SouthboundProvider Session Initiated");
db = session.getSALService(DataBroker.class);
this.txInvoker = new TransactionInvokerImpl(db);
- cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService);
+ cm = new OvsdbConnectionManager(db,txInvoker,entityOwnershipService, ovsdbConnection);
ovsdbDataChangeListener = new OvsdbDataChangeListener(db,cm);
//Register listener for entityOnwership changes
@Mock private DataBroker db;
@Mock private TransactionInvoker txInvoker;
@Mock private EntityOwnershipService entityOwnershipService;
+ @Mock private OvsdbConnection ovsdbConnection;
private Map<ConnectionInfo,OvsdbConnectionInstance> clients;
private Map<ConnectionInfo,InstanceIdentifier<Node>> instanceIdentifiers;
private Map<Entity, OvsdbConnectionInstance> entityConnectionMap;
MemberModifier.field(OvsdbConnectionManager.class, "db").set(ovsdbConnectionManager, db);
MemberModifier.field(OvsdbConnectionManager.class, "txInvoker").set(ovsdbConnectionManager, txInvoker);
MemberModifier.field(OvsdbConnectionManager.class, "entityOwnershipService").set(ovsdbConnectionManager, entityOwnershipService);
+ MemberModifier.field(OvsdbConnectionManager.class, "ovsdbConnection")
+ .set(ovsdbConnectionManager, ovsdbConnection);
entityConnectionMap = new ConcurrentHashMap<>();
}
@Test
when(SouthboundMapper.createInetAddress(any(IpAddress.class))).thenReturn(ip);
OvsdbClient client = mock(OvsdbClient.class);
- OvsdbConnection ovsdbConnection = mock(OvsdbConnection.class);
PowerMockito.mockStatic(OvsdbConnectionService.class);
when(OvsdbConnectionService.getService()).thenReturn(ovsdbConnection);
PortNumber port = mock(PortNumber.class);
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvokerImpl;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
when(session.getSALService(DataBroker.class)).thenReturn(db);
TransactionInvokerImpl transactionInvokerImpl = mock(TransactionInvokerImpl.class);
PowerMockito.whenNew(TransactionInvokerImpl.class).withArguments(any(DataBroker.class)).thenReturn(transactionInvokerImpl);
- PowerMockito.whenNew(OvsdbConnectionManager.class).withArguments(any(DataBroker.class), any(TransactionInvoker.class), any(EntityOwnershipService.class)).thenReturn(cm);
+ PowerMockito.whenNew(OvsdbConnectionManager.class).withArguments(any(DataBroker.class), any(TransactionInvoker.class), any(EntityOwnershipService.class), any(OvsdbConnection.class)).thenReturn(cm);
PowerMockito.whenNew(OvsdbDataChangeListener.class).withArguments(any(DataBroker.class), any(OvsdbConnectionManager.class)).thenReturn(ovsdbDataChangeListener);
when(entityOwnershipService.registerListener(anyString(), any(EntityOwnershipListener.class))).thenReturn(mock(EntityOwnershipListenerRegistration.class));