<build>
<plugins>
- <!-- We still need the activator for interacting with services that rely on activators for
- service discovery, but it should be deprecated soon -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
org.opendaylight.lispflowmapping.implementation.serializer,
org.opendaylight.lispflowmapping.implementation.util
</Export-Package>
- <Bundle-Activator>org.opendaylight.lispflowmapping.implementation.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
<snapshot>
<required-capabilities>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl?module=lfm-mappingservice-impl&revision=2015-05-07</capability>
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl?module=lfm-mappingservice-impl&revision=2015-05-17</capability>
</required-capabilities>
<configuration>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<module>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl">
- prefix:lfm-mappingservice
+ prefix:lfm-mappingservice-impl
</type>
<name>lfm-mappingservice-default</name>
</broker>
</module>
</modules>
+ <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <service>
+ <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl">prefix:lfm-mappingservice</type>
+ <instance>
+ <name>lfm-mappingservice</name>
+ <provider>/modules/module[type='lfm-mappingservice-impl'][name='lfm-mappingservice-default']
+ </provider>
+ </instance>
+ </service>
+ </services>
</data>
</configuration>
package org.opendaylight.controller.config.yang.config.lfm_mappingservice.impl;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.lispflowmapping.implementation.provider.LfmMappingDatabaseProviderRpc;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mapping.database.rev150314.LfmMappingDatabaseService;
+import org.opendaylight.lispflowmapping.implementation.LispMappingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LfmMappingServiceModule extends org.opendaylight.controller.config.yang.config.lfm_mappingservice.impl.AbstractLfmMappingServiceModule {
private static final Logger LOG = LoggerFactory.getLogger(LfmMappingServiceModule.class);
-
+ private LispMappingService lfmService;
public LfmMappingServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
@Override
public java.lang.AutoCloseable createInstance() {
- LOG.info("LfmMappingService Module up!");
- DataBroker dataBrokerService = getDataBrokerDependency();
-
- LfmMappingDatabaseProviderRpc mappingDbProviderRpc = new LfmMappingDatabaseProviderRpc(dataBrokerService);
- final BindingAwareBroker.RpcRegistration<LfmMappingDatabaseService> lfmDbRpc = getRpcRegistryDependency()
- .addRpcImplementation(LfmMappingDatabaseService.class, mappingDbProviderRpc);
-
- final class AutoClosableLfmMappingService implements AutoCloseable {
-
- @Override
- public void close() throws Exception {
- LOG.info("LfmMappingService Module Closing!");
+ LOG.debug("LfmMappingService Module up!");
- lfmDbRpc.close();
- }
- }
+ lfmService = new LispMappingService();
+ lfmService.setDataBrokerService(getDataBrokerDependency());
+ lfmService.setRpcProviderRegistry(getRpcRegistryDependency());
+ lfmService.setBindingAwareBroker(getBrokerDependency());
+ lfmService.initialize();
- return new AutoClosableLfmMappingService();
+ return lfmService;
}
-}
+}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Contextream, 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.lispflowmapping.implementation;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import org.apache.felix.dm.DependencyActivatorBase;
-import org.apache.felix.dm.DependencyManager;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMappingShell;
-import org.osgi.framework.BundleContext;
-
-/**
- * Main application activator class for registering the dependencies and
- * initialising the Mapping Service application.
- *
- */
-
-public class Activator extends DependencyActivatorBase {
-
- @Override
- public void init(BundleContext context, DependencyManager manager) throws Exception {
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("name", "mappingservice");
- manager.add(createComponent().setInterface(new String[] { IFlowMapping.class.getName(), IFlowMappingShell.class.getName() }, props)
- .setImplementation(LispMappingService.class)
- .add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true)
- .setCallbacks("setBindingAwareBroker", "unsetBindingAwareBroker")));
-
- }
-
- @Override
- public void destroy(BundleContext context, DependencyManager manager) throws Exception {
- // TODO Auto-generated method stub
-
- }
-}
* 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.lispflowmapping.implementation.provider;
+package org.opendaylight.lispflowmapping.implementation;
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.lispflowmapping.implementation.LispMappingService;
import org.opendaylight.lispflowmapping.implementation.mdsal.DataStoreBackEnd;
import org.opendaylight.lispflowmapping.implementation.util.MapServerMapResolverUtil;
import org.opendaylight.lispflowmapping.implementation.util.RPCInputConvertorUtil;
* @author Florin Coras
*
*/
-public class LfmMappingDatabaseProviderRpc implements LfmMappingDatabaseService {
- protected static final Logger LOG = LoggerFactory.getLogger(LfmMappingDatabaseProviderRpc.class);
+public class LfmMappingDatabaseRpc implements LfmMappingDatabaseService {
+ protected static final Logger LOG = LoggerFactory.getLogger(LfmMappingDatabaseRpc.class);
private static final String NOT_FOUND_TAG = "data-missing";
private static final String DATA_EXISTS_TAG = "data-exists";
private DataBroker dataBroker;
private DataStoreBackEnd dsbe;
- public LfmMappingDatabaseProviderRpc(DataBroker dataBroker) {
+ public LfmMappingDatabaseRpc(DataBroker dataBroker) {
this.lispMappingService = LispMappingService.getLispMappingService();
this.dataBroker = dataBroker;
this.dsbe = new DataStoreBackEnd(this.dataBroker);
import org.eclipse.osgi.framework.console.CommandInterpreter;
import org.eclipse.osgi.framework.console.CommandProvider;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.lispflowmapping.implementation.config.ConfigIni;
import org.opendaylight.lispflowmapping.implementation.dao.HashMapDb;
import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.maprequestmessage.MapRequestBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.transportaddress.TransportAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.transportaddress.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mapping.database.rev150314.LfmMappingDatabaseService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mapping.database.rev150314.db.instance.Mapping;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.slf4j.LoggerFactory;
public class LispMappingService implements CommandProvider, IFlowMapping, IFlowMappingShell, BindingAwareProvider,
- IMapRequestResultHandler, IMapNotifyHandler {
+ IMapRequestResultHandler, IMapNotifyHandler, AutoCloseable {
protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
private static final ConfigIni configIni = new ConfigIni();
private ThreadLocal<Pair<MapRequest, TransportAddress>> tlsMapRequest = new ThreadLocal<Pair<MapRequest, TransportAddress>>();
private LfmControlPlaneService lispSB = null;
-
private ProviderContext session;
private DataStoreBackEnd dsbe;
private NotificationService notificationService;
private static LispMappingService lfmService = null;
+ private BindingAwareBroker.RpcRegistration<LfmMappingDatabaseService> lfmDbRpc;
+ private DataBroker dataBrokerService;
+ private RpcProviderRegistry rpcRegistry;
+ private BindingAwareBroker broker;
+
+ public LispMappingService() {
+ LOG.debug("LispMappingService Module starting!");
+ lfmService = this;
+ }
+
+ public void setDataBrokerService(DataBroker dataBrokerService) {
+ this.dataBrokerService = dataBrokerService;
+ }
+
+ public void setRpcProviderRegistry(RpcProviderRegistry rpcRegistry) {
+ this.rpcRegistry = rpcRegistry;
+ }
+
+ public void setBindingAwareBroker(BindingAwareBroker broker) {
+ this.broker = broker;
+ }
+
+ public void initialize() {
+ broker.registerProvider(this);
+
+ LfmMappingDatabaseRpc mappingDbProviderRpc = new LfmMappingDatabaseRpc(dataBrokerService);
+ lfmDbRpc = rpcRegistry.addRpcImplementation(LfmMappingDatabaseService.class, mappingDbProviderRpc);
+
+ setLispDao(new HashMapDb());
+ registerWithOSGIConsole();
+ }
+
+ @Override
+ public void onSessionInitiated(ProviderContext session) {
+ LOG.info("Lisp Consumer session initialized!");
+ notificationService = session.getSALService(NotificationService.class);
+ registerNotificationListener(AddMapping.class, new MapRegisterNotificationHandler());
+ registerNotificationListener(RequestMapping.class, new MapRequestNotificationHandler());
+ registerDataListeners(session.getSALService(DataBroker.class));
+ this.session = session;
+ LOG.info("LISP (RFC6830) Mapping Service init finished");
+ }
class LispIpv4AddressInMemoryConverter implements ILispTypeConverter<Ipv4Address, Integer> {
}
return lfmService;
}
- void setBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
- LOG.debug("BindingAwareBroker set!");
- BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- bindingAwareBroker.registerProvider(this, bundleContext);
-
- // For the time being we initialize variables here. But once we remove the activator, these should
- // be moved to the constructor.
- lfmService = this;
- setLispDao(new HashMapDb());
- }
-
- void unsetBindingAwareBroker(BindingAwareBroker bindingAwareBroker) {
- LOG.debug("BindingAwareBroker was unset in LispMappingService");
- lfmService = null;
- }
-
public void basicInit(ILispDAO dao) {
lispDao = dao;
mapResolver = new MapResolver(dao);
lispDao = null;
}
- public void init() {
+ private void registerWithOSGIConsole() {
try {
- registerWithOSGIConsole();
- LOG.info("LISP (RFC6830) Mapping Service init finished");
+ BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+ bundleContext.registerService(CommandProvider.class.getName(), this, null);
} catch (Exception e) {
LOG.error(e.getStackTrace().toString());
}
}
- private void registerWithOSGIConsole() {
- BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
- bundleContext.registerService(CommandProvider.class.getName(), this, null);
- }
-
public void destroy() {
LOG.info("LISP (RFC6830) Mapping Service is destroyed!");
mapResolver = null;
return shouldAuthenticate;
}
- @Override
- public void onSessionInitiated(ProviderContext session) {
- LOG.info("Lisp Consumer session initialized!");
- notificationService = session.getSALService(NotificationService.class);
- dsbe = new DataStoreBackEnd(session.getSALService(DataBroker.class));
- registerNotificationListener(AddMapping.class, new MapRegisterNotificationHandler());
- registerNotificationListener(RequestMapping.class, new MapRequestNotificationHandler());
- registerDataListeners(session.getSALService(DataBroker.class));
- this.session = session;
- }
-
private void registerDataListeners(DataBroker broker) {
keyListener = new AuthenticationKeyDataListener(broker, this);
mappingListener = new MappingDataListener(broker, this);
public void setOverwrite(boolean overwrite) {
mapServer.setOverwrite(overwrite);
}
+
+ @Override
+ public void close() throws Exception {
+ lfmDbRpc.close();
+ destroy();
+ }
}
"This module contains the base YANG definitions for
mappingservice implementation.";
- revision "2015-05-07" {
+ revision "2015-05-17" {
description
"Initial revision.";
}
- // This is the definition of the service implementation as a module identity
+ // This is the definition of lfm-mappingservice interface identity.
identity lfm-mappingservice {
+ base config:service-type;
+ config:java-class "org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping";
+ }
+
+ // This is the definition of the lfm-mappingservice implementation as a module identity
+ identity lfm-mappingservice-impl {
base config:module-type;
// Specifies the prefix for generated java classes.
config:java-name-prefix LfmMappingService;
+ config:provided-service lfm-mappingservice;
}
-
// Augments the 'configuration' choice node under modules/module.
augment "/config:modules/config:module/config:configuration" {
- case lfm-mappingservice {
- when "/config:modules/config:module/config:type = 'lfm-mappingservice'";
+ case lfm-mappingservice-impl {
+ when "/config:modules/config:module/config:type = 'lfm-mappingservice-impl'";
//wires in the data-broker service
container data-broker {
<artifactId>commons.northbound</artifactId>
</dependency>
-->
+ <dependency>
+ <groupId>org.openexi</groupId>
+ <artifactId>nagasena</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openexi</groupId>
+ <artifactId>nagasena-rta</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-api</artifactId>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-persister-file-xml-adapter</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-impl</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>configuration</artifactId>
public static final String LISP = "org.opendaylight.lispflowmapping";
public static final String YANG = "org.opendaylight.yangtools";
public static final String JERSEY = "com.sun.jersey";
+ public static final String YANGTOOLS = "org.opendaylight.yangtools";
public static Option mappingServiceBundles() {
return new DefaultCompositeOption(
mavenBundle("org.codehaus.jettison", "jettison").versionAsInProject(),
// Our bundles
- mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(),
- mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
- mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
- mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.config").versionAsInProject(),
- mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(),
- mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(),
- mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(),
-
+ mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(), //
+ mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(), //
+ mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(), //
+ mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.config").versionAsInProject(), //
+ mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(), //
+ mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(), //
+ mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(), //
+ mavenBundle("org.openexi", "nagasena").versionAsInProject(),
+ mavenBundle("org.openexi", "nagasena-rta").versionAsInProject(),
+ mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(),
+ // Set fail if unresolved bundle present
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
junitBundles());
}
public static Option mappingServiceBundlesWithClusterDAO() {
return new DefaultCompositeOption( //
- mappingServiceBundles(), //
- mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.clusterdao").versionAsInProject() //
+ mappingServiceBundles() //
+// mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.clusterdao").versionAsInProject() //
);
}
@RunWith(PaxExam.class)
public class MappingServiceIntegrationTest {
- private IFlowMapping lms;
protected static final Logger LOG = LoggerFactory.getLogger(MappingServiceIntegrationTest.class);
private byte[] mapRequestPacket;
private byte[] mapRegisterPacketWithNotify;
private BundleContext bc;
private HttpURLConnection connection;
protected static boolean notificationCalled;
+
+ @Inject @Filter(timeout=10000)
+ private IFlowMapping lms;
+
@Inject @Filter(timeout=10000)
private IConfigLispSouthboundPlugin configLispPlugin;
@SuppressWarnings({ "rawtypes", "unchecked" })
private void areWeReady() throws InvalidSyntaxException {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ }
+
assertNotNull(bc);
boolean debugit = false;
Bundle b[] = bc.getBundles();
}
// assertNotNull(broker);
- int retry = 0;
ServiceReference r = null;
- while (this.lms == null && retry < MAX_SERVICE_LOAD_RETRIES) {
-
- r = bc.getServiceReference(IFlowMapping.class.getName());
- // r.getPropertyKeys();
- if (r != null) {
- this.lms = (IFlowMapping) bc.getService(r);
- } else {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- }
- }
- retry += 1;
- }
-
- assertNotNull(IFlowMapping.class.getName() + " service wasn't found in bundle context ", this.lms);
-
configLispPlugin.setLispAddress(lispBindAddress);
// Uncomment this code to Know which services were actually loaded to
// BundleContext
+
/*
- * for (ServiceReference sr : bc.getAllServiceReferences(null, null)) {
- * LOG.trace(sr.getBundle().getSymbolicName());
- * LOG.trace(sr.toString()); }
- */
+ for (ServiceReference sr : bc.getAllServiceReferences(null, null)) {
+ LOG.info(sr.getBundle().getSymbolicName());
+ LOG.info(sr.toString());
+ }
+ */
+
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice-sb:impl?module=lfm-mappingservice-sb-impl&revision=2015-05-17</capability>
-
+ <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl?module=lfm-mappingservice-impl&revision=2015-05-17</capability>
</required-capabilities>
<configuration>
<name>binding-notification-broker</name>
</notification-service>
</module>
+ <!-- mappingservice.implementation module -->
+ <module>
+ <type
+ xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl">
+ prefix:lfm-mappingservice-impl
+ </type>
+ <name>lfm-mappingservice-default</name>
+
+ <rpc-registry>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+ <name>binding-rpc-broker</name>
+ </rpc-registry>
+
+ <data-broker>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+
+ <broker>
+ <type
+ xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+ <name>binding-osgi-broker</name>
+ </broker>
+ </module>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
<provider>/modules/module[type='pingpong-data-broker'][name='pingpong-data-broker']</provider>
</instance>
</service>
+
<!-- lfm mappingservice southbound -->
<service>
<type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice-sb:impl">prefix:lfm-mappingservice-sb</type>
<provider>/modules/module[type='lfm-mappingservice-sb-impl'][name='lfm-mappingservice-sb-impl-default']</provider>
</instance>
</service>
+ <!-- lfm mappingservice implementation -->
+ <service>
+ <type
+ xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:lfm-mappingservice:impl">prefix:lfm-mappingservice</type>
+ <instance>
+ <name>lfm-mappingservice</name>
+ <provider>/modules/module[type='lfm-mappingservice-impl'][name='lfm-mappingservice-default']
+ </provider>
+ </instance>
+ </service>
+
</services>
</data>