<artifactId>yang-common</artifactId>
<version>${yangtools.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-broker-impl</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.sonatype.plugins</groupId>
<artifactId>munge-maven-plugin</artifactId>
<type>jar</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <!-- version>4.8.1</version -->
+ <version>[4.8.1, 4.11]</version>
+ <!-- version>4.11</version -->
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
import org.opendaylight.sfc.provider.bootstrap.SfcProviderBootstrapRestAPI;
import org.opendaylight.sfc.provider.logback.SfcProviderLogbackLoader;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionService;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainService;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sn.rev140701.ServiceNodeService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+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.PortNumber;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
scheduledExecutorService.schedule
(SfcProviderBootstrapRestAPI.getPutBootstrapData(emptyObjArray, emptyClassArray), 15,
TimeUnit.SECONDS);
+
+ scheduledExecutorService.shutdown();
+
+
LOG.info("SFC provider (instance {}) initialized.", ret);
return ret;
}
public static final InstanceIdentifier<ServiceFunctionTypes> sftIID =
InstanceIdentifier.builder(ServiceFunctionTypes.class).build();
- protected ExecutorService executor;
+ public ExecutorService executor;
protected DataBroker dataProvider;
private static OpendaylightSfc opendaylightSfcObj;
this.dataProvider = salDataProvider;
}
- public AsyncDataBroker getDataProvider(AsyncDataBroker salDataProvider) {
+ public DataBroker getDataProvider() {
return this.dataProvider;
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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.sfc.provider;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+
+/**
+ * <p/>
+ *
+ * @version 0.1
+ * @since 2014-06-30
+ */
+public abstract class SfcProviderAbstractAPI implements Callable<Object> {
+
+ protected static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
+ protected String methodName = null;
+ protected Object[] parameters;
+ protected Class[] parameterTypes;
+ protected DataBroker dataBroker;
+
+ SfcProviderAbstractAPI(Object[] params, String m) {
+ this.methodName = m;
+ this.parameters = new Object[params.length];
+ this.parameterTypes = new Class[params.length];
+ this.parameters = Arrays.copyOf(params, params.length);
+ this.dataBroker = odlSfc.getDataProvider();
+
+ for (int i = 0; i < params.length; i++) {
+ this.parameterTypes[i] = params[i].getClass();
+ }
+ }
+
+ SfcProviderAbstractAPI(Object[] params, Class[] paramsTypes, String m) {
+ this.methodName = m;
+ this.parameters = new Object[params.length];
+ this.parameterTypes = new Class[params.length];
+ this.parameters = Arrays.copyOf(params, params.length);
+ this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
+ this.dataBroker = odlSfc.getDataProvider();
+ }
+
+ @Override
+ public final Object call() {
+ Object result = null;
+ if (methodName != null) {
+ Class<?> c = this.getClass();
+ Method method;
+ try {
+ method = c.getDeclaredMethod(methodName, parameterTypes);
+ result = method.invoke(this, parameters);
+ } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+}
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.sal.common.util.Rpcs;
+import org.opendaylight.sfc.provider.util.SfcSftMapper;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.*;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.concurrent.ExecutionException;
/**
*
* <p>
* @version 0.1
* @since 2014-06-30
*/
-public class SfcProviderServiceChainAPI implements Runnable {
+public class SfcProviderServiceChainAPI extends SfcProviderAbstractAPI {
- private ServiceFunctionChain serviceFunctionChain;
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceChainAPI.class);
- private static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
- private String methodName = null;
- private Object[] parameters;
- private Class[] parameterTypes;
-
- SfcProviderServiceChainAPI (Object[] params, String m) {
- int i = 0;
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- for (Object obj : parameters) {
- this.parameterTypes[i] = obj.getClass();
- i++;
- }
+ SfcProviderServiceChainAPI(Object[] params, String m) {
+ super(params, m);
+ }
+
+ SfcProviderServiceChainAPI(Object[] params, Class[] paramsTypes, String m) {
+ super(params, paramsTypes, m);
+ }
+
+ public static SfcProviderServiceChainAPI getPut(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "putServiceFunctionChain");
+ }
+
+ public static SfcProviderServiceChainAPI getRead(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "readServiceFunctionChain");
+ }
+
+ public static SfcProviderServiceChainAPI getDelete(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "deleteServiceFunctionChain");
+ }
+
+ public static SfcProviderServiceChainAPI getPutAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "putAllServiceFunctionChains");
+ }
+
+ public static SfcProviderServiceChainAPI getReadAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "readAllServiceFunctionChains");
}
- SfcProviderServiceChainAPI (Object[] params, Class[] paramsTypes, String m) {
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
+ public static SfcProviderServiceChainAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceChainAPI(params, paramsTypes, "deleteAllServiceFunctionChains");
}
public static SfcProviderServiceChainAPI getAddChainToChainState (Object[] params, Class[] paramsTypes) {
return new SfcProviderServiceChainAPI(params, paramsTypes, "addChainToChainState");
}
- @SuppressWarnings("unused")
- private void addChainToChainState (ServiceFunctionChain serviceFunctionChain) {
+ protected boolean putServiceFunctionChain(ServiceFunctionChain sfc) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionChain> sfcEntryIID = InstanceIdentifier.builder(ServiceFunctionChains.class).
+ child(ServiceFunctionChain.class, sfc.getKey()).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sfcEntryIID, sfc, true);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctionChain readServiceFunctionChain(String serviceFunctionChainName) {
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionChain sfc = null;
+ InstanceIdentifier<ServiceFunctionChain> sfcIID;
+ ServiceFunctionChainKey serviceFunctionChainKey = new ServiceFunctionChainKey(serviceFunctionChainName);
+ sfcIID = InstanceIdentifier.builder(ServiceFunctionChains.class)
+ .child(ServiceFunctionChain.class, serviceFunctionChainKey).build();
+
+ if (dataBroker != null) {
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<ServiceFunctionChain> serviceFunctionChainDataObject = null;
+ try {
+ serviceFunctionChainDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfcIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionChainDataObject != null
+ && serviceFunctionChainDataObject.isPresent()) {
+ sfc = serviceFunctionChainDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfc;
+ }
+
+ protected boolean deleteServiceFunctionChain(String serviceFunctionChainName) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionChainKey serviceFunctionChainKey = new ServiceFunctionChainKey(serviceFunctionChainName);
+ InstanceIdentifier<ServiceFunctionChain> sfcEntryIID = InstanceIdentifier.builder(ServiceFunctionChains.class)
+ .child(ServiceFunctionChain.class, serviceFunctionChainKey).toInstance();
+
+ if (dataBroker != null) {
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfcEntryIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected boolean putAllServiceFunctionChains(ServiceFunctionChains sfcs) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionChains> sfcsIID = InstanceIdentifier.builder(ServiceFunctionChains.class).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, sfcsIID, sfcs);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctionChains readAllServiceFunctionChains() {
+ ServiceFunctionChains sfcs = null;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ InstanceIdentifier<ServiceFunctionChains> sfcsIID = InstanceIdentifier.builder(ServiceFunctionChains.class).toInstance();
+
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunctionChains> serviceFunctionChainsDataObject = null;
+ try {
+ serviceFunctionChainsDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfcsIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionChainsDataObject != null
+ && serviceFunctionChainsDataObject.isPresent()) {
+ sfcs = serviceFunctionChainsDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfcs;
+ }
+
+ protected boolean deleteAllServiceFunctionChains() {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunctionChains> sfcsIID = InstanceIdentifier.builder(ServiceFunctionChains.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfcsIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected void addChainToChainState (ServiceFunctionChain serviceFunctionChain) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
ServiceFunctionChainStateKey serviceFunctionChainStateKey = new ServiceFunctionChainStateKey(serviceFunctionChain.getName());
}
-
- public static ServiceFunctionChain readServiceFunctionChain(String serviceFunctionChainName) {
- LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
- InstanceIdentifier<ServiceFunctionChain> sfcIID;
- ServiceFunctionChainKey serviceFunctionChainKey = new ServiceFunctionChainKey(serviceFunctionChainName);
- sfcIID = InstanceIdentifier.builder(ServiceFunctionChains.class)
- .child(ServiceFunctionChain.class, serviceFunctionChainKey).build();
-
- ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
- Optional<ServiceFunctionChain> serviceFunctionChainObject = null;
- try {
- serviceFunctionChainObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfcIID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
-
- if (serviceFunctionChainObject.get() instanceof ServiceFunctionChain) {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return serviceFunctionChainObject.get();
- } else {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
-
private InstanceIdentifier<SfcServiceFunction> getServiceFunctionIIDFromChain (ServiceFunctionChain sfc, ServiceFunction sf) {
SfcServiceFunctionKey serviceFunctionKey = new SfcServiceFunctionKey(sf.getName());
InstanceIdentifier<SfcServiceFunction> sfIID = InstanceIdentifier.builder(ServiceFunctionChains.class)
}
}
- @Override
- public void run() {
- if (methodName != null) {
- Class<?> c = this.getClass();
- Method method;
- try {
- method = c.getDeclaredMethod(methodName, parameterTypes);
- method.invoke(this, parameters);
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-
- }
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* This class has the APIs to operate on the ServiceFunction
* datastore.
- *
+ * <p/>
* It is normally called from onDataChanged() through a executor
* service. We need to use an executor service because we can not
* operate on a datastore while on onDataChanged() context.
- * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
*
- *
- * <p>
* @version 0.1
- * @since 2014-06-30
+ * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
+ * <p/>
+ * <p/>
+ * <p/>
+ * @since 2014-06-30
*/
-public class SfcProviderServiceForwarderAPI implements Runnable {
+public class SfcProviderServiceForwarderAPI extends SfcProviderAbstractAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceForwarderAPI.class);
- private static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
- private String methodName = null;
- private Object[] parameters;
- private Class[] parameterTypes;
-
-
- SfcProviderServiceForwarderAPI (Object[] params, String m) {
- int i = 0;
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- for (Object obj : parameters) {
- this.parameterTypes[i] = obj.getClass();
- i++;
+
+ SfcProviderServiceForwarderAPI(Object[] params, String m) {
+ super(params, m);
+ }
+
+ SfcProviderServiceForwarderAPI(Object[] params, Class[] paramsTypes, String m) {
+ super(params, paramsTypes, m);
+ }
+
+
+ public static SfcProviderServiceForwarderAPI getPut(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "putServiceFunctionForwarder");
+ }
+
+ public static SfcProviderServiceForwarderAPI getRead(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "readServiceFunctionForwarder");
+ }
+
+ public static SfcProviderServiceForwarderAPI getDelete(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteServiceFunctionForwarder");
+ }
+
+ public static SfcProviderServiceForwarderAPI getPutAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "putAllServiceFunctionForwarders");
+ }
+
+ public static SfcProviderServiceForwarderAPI getReadAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "readAllServiceFunctionForwarders");
+ }
+
+ public static SfcProviderServiceForwarderAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteAllServiceFunctionForwarders");
+ }
+
+ public static SfcProviderServiceForwarderAPI getDeleteServiceFunctionFromForwarder(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteServiceFunctionFromForwarder");
+ }
+
+ public static SfcProviderServiceForwarderAPI getCreateServiceForwarderAPI(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "createServiceFunctionForwarder");
+ }
+
+ public static SfcProviderServiceForwarderAPI getUpdateServiceForwarderAPI(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceForwarderAPI(params, paramsTypes, "updateServiceFunctionForwarder");
+ }
+
+ /*
+ public static ServiceFunctionForwarder readServiceFunctionForwarder(String name) {
+ LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionForwarderKey serviceFunctionForwarderKey =
+ new ServiceFunctionForwarderKey(name);
+ InstanceIdentifier<ServiceFunctionForwarder> sffIID;
+ sffIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
+ .child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey)
+ .build();
+
+ ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
+ Optional<ServiceFunctionForwarder> serviceFunctionForwarderObject = null;
+ try {
+ serviceFunctionForwarderObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sffIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
}
+ if (serviceFunctionForwarderObject != null &&
+ (serviceFunctionForwarderObject.get() instanceof ServiceFunctionForwarder)) {
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return serviceFunctionForwarderObject.get();
+ } else {
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return null;
+ }
}
+ */
+
+ public static void addPathIdtoServiceFunctionForwarder(ServiceFunctionPath serviceFunctionPath) throws ExecutionException, InterruptedException {
+ LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
+
+ InstanceIdentifier<ServiceFunctionForwarders> sffsIID;
+ ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder = new ServiceFunctionForwardersBuilder();
+ ArrayList<ServiceFunctionForwarder> serviceFunctionForwarderList = new ArrayList<>();
+ List<SfpServiceFunction> sfpServiceFunctionArrayList = serviceFunctionPath.getSfpServiceFunction();
+
+ for (SfpServiceFunction sfpServiceFunction : sfpServiceFunctionArrayList) {
+
+ ServiceFunctionForwarderKey serviceFunctionForwarderKey =
+ new ServiceFunctionForwarderKey(sfpServiceFunction.getServiceFunctionForwarder());
+ ServiceFunctionForwarder serviceFunctionForwarder =
+ (ServiceFunctionForwarder) odlSfc.executor.submit(SfcProviderServiceForwarderAPI.getRead(
+ new Object[]{sfpServiceFunction.getServiceFunctionForwarder()},
+ new Class[]{String.class})).get();
+ ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder();
+ if (serviceFunctionForwarder != null) {
+ //serviceFunctionForwarderBuilder.setPathId(serviceFunctionPath.getPathId());
+ serviceFunctionForwarderBuilder.setName(sfpServiceFunction.getServiceFunctionForwarder());
+ serviceFunctionForwarderBuilder.setSffDataPlaneLocator(serviceFunctionForwarder.getSffDataPlaneLocator());
+ serviceFunctionForwarderBuilder.setServiceFunctionDictionary(serviceFunctionForwarder.getServiceFunctionDictionary());
+ serviceFunctionForwarderBuilder.setKey(serviceFunctionForwarderKey);
+
+ } else {
+ LOG.error("Failed to read Service Function Forwarder from data store");
+ continue;
+ }
+ serviceFunctionForwarderList.add(serviceFunctionForwarderBuilder.build());
+ }
+
+ serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
+ sffsIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class).build();
+
+ WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sffsIID, serviceFunctionForwardersBuilder.build(), true);
+ writeTx.commit();
+
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+
+ //serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
- SfcProviderServiceForwarderAPI (Object[] params, Class[] paramsTypes, String m) {
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
}
+ // TODO: need to check for sff-data-plane-locator
+ /*
+ * This method checks if a SFF is complete and can be sent to southbound devices
+ */
+ public static boolean checkServiceFunctionForwarder(ServiceFunctionForwarder serviceFunctionForwarder) {
+ if ((serviceFunctionForwarder.getName() != null) &&
+ (serviceFunctionForwarder.getServiceFunctionDictionary() != null)) {
+ return true;
+ } else {
+ return false;
+ }
- public static SfcProviderServiceForwarderAPI getDeleteServiceFunctionFromForwarder(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI (params, paramsTypes, "deleteServiceFunctionFromForwarder");
}
- public static SfcProviderServiceForwarderAPI getCreateServiceForwarderAPI (Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI (params, paramsTypes, "createServiceFunctionForwarder");
+ protected boolean putServiceFunctionForwarder(ServiceFunctionForwarder sff) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionForwarder> sffEntryIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class).
+ child(ServiceFunctionForwarder.class, sff.getKey()).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sffEntryIID, sff, true);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
}
- public static SfcProviderServiceForwarderAPI getUpdateServiceForwarderAPI (Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI (params, paramsTypes, "updateServiceFunctionForwarder");
+ protected ServiceFunctionForwarder readServiceFunctionForwarder(String serviceFunctionForwarderName) {
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionForwarder sff = null;
+ InstanceIdentifier<ServiceFunctionForwarder> sffIID;
+ ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(serviceFunctionForwarderName);
+ sffIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
+ .child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey).build();
+
+ if (dataBroker != null) {
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<ServiceFunctionForwarder> serviceFunctionForwarderDataObject = null;
+ try {
+ serviceFunctionForwarderDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sffIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionForwarderDataObject != null
+ && serviceFunctionForwarderDataObject.isPresent()) {
+ sff = serviceFunctionForwarderDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sff;
}
+ protected boolean deleteServiceFunctionForwarder(String serviceFunctionForwarderName) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(serviceFunctionForwarderName);
+ InstanceIdentifier<ServiceFunctionForwarder> sffEntryIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class).
+ child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey).toInstance();
- public void createServiceFunctionForwarder (ServiceFunction serviceFunction) {
+ if (dataBroker != null) {
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sffEntryIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected boolean putAllServiceFunctionForwarders(ServiceFunctionForwarders sffs) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
+ InstanceIdentifier.builder(ServiceFunctionForwarders.class).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, sffsIID, sffs);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctionForwarders readAllServiceFunctionForwarders() {
+ ServiceFunctionForwarders sffs = null;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
+ InstanceIdentifier.builder(ServiceFunctionForwarders.class).toInstance();
+
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunctionForwarders> serviceFunctionForwardersDataObject = null;
+ try {
+ serviceFunctionForwardersDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sffsIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionForwardersDataObject != null
+ && serviceFunctionForwardersDataObject.isPresent()) {
+ sffs = serviceFunctionForwardersDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sffs;
+ }
+
+ protected boolean deleteAllServiceFunctionForwarders() {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
+ InstanceIdentifier.builder(ServiceFunctionForwarders.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sffsIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ public void createServiceFunctionForwarder(ServiceFunction serviceFunction) {
LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
InstanceIdentifier<ServiceFunctionForwarder> sffIID;
serviceFunctionForwarderBuilder.setServiceFunctionDictionary(serviceFunctionDictionaryList);
LOG.debug("\n########## Creating Forwarder: {} Service Function: {} "
- ,serviceFunctionForwarderName, serviceFunction.getName());
+ , serviceFunctionForwarderName, serviceFunction.getName());
WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.CONFIGURATION,
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
- public void deleteServiceFunctionFromForwarder (ServiceFunction serviceFunction) {
+ public void deleteServiceFunctionFromForwarder(ServiceFunction serviceFunction) {
LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
String serviceFunctionForwarderName = serviceFunction.getSfDataPlaneLocator().
getServiceFunctionForwarder();
writeTx.commit();
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
+
@SuppressWarnings("unused")
- public void updateServiceFunctionForwarder (ServiceFunction serviceFunction) {
+ public void updateServiceFunctionForwarder(ServiceFunction serviceFunction) {
LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
deleteServiceFunctionFromForwarder(serviceFunction);
createServiceFunctionForwarder(serviceFunction);
}
+
@SuppressWarnings("unused")
- public void createServiceFunctionForwarders (ServiceFunctionChains serviceFunctionchains) {
+ public void createServiceFunctionForwarders(ServiceFunctionChains serviceFunctionchains) {
LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
InstanceIdentifier<ServiceFunctionForwarders> sffIID;
// Iterate thorough all Service Functions in a single chain
List<SfcServiceFunction> sfcServiceFunctionList = serviceFunctionChain.getSfcServiceFunction();
- for (SfcServiceFunction sfcServiceFunction :sfcServiceFunctionList) {
+ for (SfcServiceFunction sfcServiceFunction : sfcServiceFunctionList) {
- // Read all data of a single Service Service
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(sfcServiceFunction.getName());
+ // Read a single Service Function
+ ServiceFunction serviceFunction = (ServiceFunction) SfcProviderServiceFunctionAPI
+ .getRead(
+ new Object[]{sfcServiceFunction.getName()}, new Class[]{String.class}).call();
// Build a single service function forwarder
String serviceFunctionForwarderName = serviceFunction.getSfDataPlaneLocator().
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
+
@SuppressWarnings("unused")
- public void deleteServiceFunctionForwarderfromSF (ServiceFunction serviceFunction) {
+ public void deleteServiceFunctionForwarderfromSF(ServiceFunction serviceFunction) {
/*
* TODO: We assume that if a ServiceFunction exists it belongs to a ServiceFunctionForwarder
new ServiceFunctionDictionaryKey(serviceFunction.getName());
sffIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
.child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey)
- .child(ServiceFunctionDictionary.class, serviceFunctionDictionaryKey )
+ .child(ServiceFunctionDictionary.class, serviceFunctionDictionaryKey)
.build();
LOG.debug("\n########## Deleting Forwarder: {} Service Function: {} "
- ,serviceFunctionForwarderName, serviceFunction.getName());
+ , serviceFunctionForwarderName, serviceFunction.getName());
WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION,
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
- @SuppressWarnings("unused")
- public static ServiceFunctionForwarder readServiceFunctionForwarder(String name) {
- LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
- ServiceFunctionForwarderKey serviceFunctionForwarderKey =
- new ServiceFunctionForwarderKey(name);
- InstanceIdentifier<ServiceFunctionForwarder> sffIID;
- sffIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
- .child(ServiceFunctionForwarder.class, serviceFunctionForwarderKey)
- .build();
-
- ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
- Optional<ServiceFunctionForwarder> serviceFunctionForwarderObject = null;
- try {
- serviceFunctionForwarderObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sffIID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
-
- if (serviceFunctionForwarderObject != null &&
- (serviceFunctionForwarderObject.get() instanceof ServiceFunctionForwarder)) {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return serviceFunctionForwarderObject.get();
- } else {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
-
- public static void addPathIdtoServiceFunctionForwarder(ServiceFunctionPath serviceFunctionPath) {
- LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
-
- InstanceIdentifier<ServiceFunctionForwarders> sffsIID;
- ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder = new ServiceFunctionForwardersBuilder();
- ArrayList<ServiceFunctionForwarder> serviceFunctionForwarderList = new ArrayList<>();
- List<SfpServiceFunction> sfpServiceFunctionArrayList = serviceFunctionPath.getSfpServiceFunction();
-
- for (SfpServiceFunction sfpServiceFunction : sfpServiceFunctionArrayList) {
-
- ServiceFunctionForwarderKey serviceFunctionForwarderKey =
- new ServiceFunctionForwarderKey(sfpServiceFunction.getServiceFunctionForwarder());
- ServiceFunctionForwarder serviceFunctionForwarder = readServiceFunctionForwarder (sfpServiceFunction.getServiceFunctionForwarder());
- ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder();
- if (serviceFunctionForwarder != null) {
- //serviceFunctionForwarderBuilder.setPathId(serviceFunctionPath.getPathId());
- serviceFunctionForwarderBuilder.setName(sfpServiceFunction.getServiceFunctionForwarder());
- serviceFunctionForwarderBuilder.setSffDataPlaneLocator(serviceFunctionForwarder.getSffDataPlaneLocator());
- serviceFunctionForwarderBuilder.setServiceFunctionDictionary(serviceFunctionForwarder.getServiceFunctionDictionary());
- serviceFunctionForwarderBuilder.setKey(serviceFunctionForwarderKey);
-
- } else {
- LOG.error("Failed to read Service Function Forwarder from data store");
- continue;
- }
- serviceFunctionForwarderList.add(serviceFunctionForwarderBuilder.build());
- }
-
- serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
- sffsIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class).build();
-
- WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
- writeTx.merge(LogicalDatastoreType.CONFIGURATION,
- sffsIID, serviceFunctionForwardersBuilder.build(), true);
- writeTx.commit();
-
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
-
- //serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
-
- }
-
- // TODO: need to check for sff-data-plane-locator
- /*
- * This method checks if a SFF is complete and can be sent to southbound devices
- */
- public static boolean checkServiceFunctionForwarder (ServiceFunctionForwarder serviceFunctionForwarder) {
- if ((serviceFunctionForwarder.getName() != null) &&
- (serviceFunctionForwarder.getServiceFunctionDictionary() != null)) {
- return true;
- } else {
- return false;
- }
-
- }
-
- @Override
- public void run() {
- if (methodName != null) {
- Class<?> c = this.getClass();
- Method method;
- try {
- method = c.getDeclaredMethod(methodName, parameterTypes);
- method.invoke(this, parameters);
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
-
- }
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* This class has the APIs to operate on the ServiceFunction
* datastore.
- *
+ * <p/>
* It is normally called from onDataChanged() through a executor
* service. We need to use an executor service because we can not
* operate on a datastore while on onDataChanged() context.
- * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
- *
*
- * <p>
* @version 0.1
- * @since 2014-06-30
+ * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
+ * @since 2014-06-30
*/
-public class SfcProviderServiceFunctionAPI implements Runnable {
+public class SfcProviderServiceFunctionAPI extends SfcProviderAbstractAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceFunctionAPI.class);
- private static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
- private String methodName = null;
- private Object[] parameters;
- private Class[] parameterTypes;
- SfcProviderServiceFunctionAPI (Object[] params, Class[] paramsTypes, String m) {
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
+ SfcProviderServiceFunctionAPI(Object[] params, String m) {
+ super(params, m);
}
- public static SfcProviderServiceFunctionAPI getDeleteServicePathFromServiceFunctionState (Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI (params, paramsTypes, "deleteServicePathFromServiceFunctionState");
+ SfcProviderServiceFunctionAPI(Object[] params, Class[] paramsTypes, String m) {
+ super(params, paramsTypes, m);
}
- public static ServiceFunction readServiceFunction(String serviceFunctionName) {
- LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
- InstanceIdentifier<ServiceFunction> sfIID;
- ServiceFunctionKey serviceFunctionKey = new ServiceFunctionKey(serviceFunctionName);
- sfIID = InstanceIdentifier.builder(ServiceFunctions.class)
- .child(ServiceFunction.class, serviceFunctionKey).build();
-
- ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
- Optional<ServiceFunction> serviceFunctiondataObject = null;
- try {
- serviceFunctiondataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfIID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- if (serviceFunctiondataObject != null &&
- (serviceFunctiondataObject.get() instanceof ServiceFunction)) {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return serviceFunctiondataObject.get();
- } else {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
+ public static SfcProviderServiceFunctionAPI getDeleteServicePathFromServiceFunctionState(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteServicePathFromServiceFunctionState");
}
- /*
- * When a Service Path is deleted directly (not as a consequence of deleting a SF), we need
- * to remove its reference from all the ServiceFunction states.
- */
- @SuppressWarnings("unused")
- public void deleteServicePathFromServiceFunctionState (ServiceFunctionPath serviceFunctionPath) {
+ public static SfcProviderServiceFunctionAPI getPut(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "putServiceFunction");
+ }
- List<SfpServiceFunction> sfpServiceFunctionList = serviceFunctionPath.getSfpServiceFunction();
- for (SfpServiceFunction sfpServiceFunction : sfpServiceFunctionList) {
- String serviceFunctionName = sfpServiceFunction.getName();
- ServiceFunctionState serviceFunctionState = readServiceFunctionState(serviceFunctionName);
- ServiceFunctionStateKey serviceFunctionStateKey = new ServiceFunctionStateKey(serviceFunctionName);
- InstanceIdentifier<ServiceFunctionState> sfStateIID =
- InstanceIdentifier.builder(ServiceFunctionsState.class)
- .child(ServiceFunctionState.class, serviceFunctionStateKey)
- .build();
+ public static SfcProviderServiceFunctionAPI getRead(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readServiceFunction");
+ }
- List<String> sfServiceFunctionPathList = serviceFunctionState.getSfServiceFunctionPath();
- List<String> newPathList = new ArrayList<>();
- newPathList.addAll(sfServiceFunctionPathList);
- newPathList.remove(serviceFunctionPath.getName());
- ServiceFunctionStateBuilder serviceFunctionStateBuilder = new ServiceFunctionStateBuilder();
- serviceFunctionStateBuilder.setName(serviceFunctionName);
- serviceFunctionStateBuilder.setSfServiceFunctionPath(newPathList);
+ public static SfcProviderServiceFunctionAPI getDelete(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteServiceFunction");
+ }
+ public static SfcProviderServiceFunctionAPI getPutAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "putAllServiceFunctions");
+ }
- ReadWriteTransaction writeTx = odlSfc.dataProvider.newReadWriteTransaction();
- writeTx.put(LogicalDatastoreType.CONFIGURATION, sfStateIID, serviceFunctionStateBuilder.build(), true);
- writeTx.commit();
- }
+ public static SfcProviderServiceFunctionAPI getReadAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readAllServiceFunctions");
}
+ public static SfcProviderServiceFunctionAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteAllServiceFunctions");
+ }
- public static ServiceFunctionState readServiceFunctionState (String serviceFunctionName) {
+ public static ServiceFunctionState readServiceFunctionState(String serviceFunctionName) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
ServiceFunctionState serviceFunctionState;
}
}
- public static void deleteServiceFunctionState (String serviceFunctionName) {
+ public static void deleteServiceFunctionState(String serviceFunctionName) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
/*
* We add the path name to the operational store of each SF in the path.
*/
- public static void addPathToServiceFunctionState (ServiceFunctionPath serviceFunctionPath) {
+ public static void addPathToServiceFunctionState(ServiceFunctionPath serviceFunctionPath) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
}
}
- @Override
- public void run() {
- if (methodName != null) {
- Class<?> c = this.getClass();
- Method method;
+ protected static boolean putServiceFunction(ServiceFunction sf) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class).
+ child(ServiceFunction.class, sf.getKey()).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION,
+ sfEntryIID, sf, true);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected static boolean mergeServiceFunction(ServiceFunction sf) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class).
+ child(ServiceFunction.class, sf.getKey()).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sfEntryIID, sf, true);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunction readServiceFunction(String serviceFunctionName) {
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunction sf = null;
+ InstanceIdentifier<ServiceFunction> sfIID;
+ ServiceFunctionKey serviceFunctionKey = new ServiceFunctionKey(serviceFunctionName);
+ sfIID = InstanceIdentifier.builder(ServiceFunctions.class)
+ .child(ServiceFunction.class, serviceFunctionKey).build();
+
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunction> serviceFunctionDataObject = null;
+ try {
+ serviceFunctionDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionDataObject != null
+ && serviceFunctionDataObject.isPresent()) {
+ sf = serviceFunctionDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sf;
+ }
+
+ protected boolean deleteServiceFunction(String serviceFunctionName) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionKey serviceFunctionKey = new ServiceFunctionKey(serviceFunctionName);
+ InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class)
+ .child(ServiceFunction.class, serviceFunctionKey).toInstance();
+
+ if (odlSfc.getDataProvider() != null) {
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfEntryIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected boolean putAllServiceFunctions(ServiceFunctions sfs) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, sfsIID, sfs);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctions readAllServiceFunctions() {
+ ServiceFunctions sfs = null;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).toInstance();
+
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunctions> serviceFunctionsDataObject = null;
try {
- method = c.getDeclaredMethod(methodName, parameterTypes);
- method.invoke(this, parameters);
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
+ serviceFunctionsDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfsIID).get();
+ } catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
+ if (serviceFunctionsDataObject != null
+ && serviceFunctionsDataObject.isPresent()) {
+ sfs = serviceFunctionsDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfs;
+ }
+
+ protected boolean deleteAllServiceFunctions() {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfsIID);
+ writeTx.commit();
+
+ ret = true;
}
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ /*
+ * When a Service Path is deleted directly (not as a consequence of deleting a SF), we need
+ * to remove its reference from all the ServiceFunction states.
+ */
+ @SuppressWarnings("unused")
+ public void deleteServicePathFromServiceFunctionState(ServiceFunctionPath serviceFunctionPath) {
+
+ List<SfpServiceFunction> sfpServiceFunctionList = serviceFunctionPath.getSfpServiceFunction();
+ for (SfpServiceFunction sfpServiceFunction : sfpServiceFunctionList) {
+ String serviceFunctionName = sfpServiceFunction.getName();
+ ServiceFunctionState serviceFunctionState = readServiceFunctionState(serviceFunctionName);
+ ServiceFunctionStateKey serviceFunctionStateKey = new ServiceFunctionStateKey(serviceFunctionName);
+ InstanceIdentifier<ServiceFunctionState> sfStateIID =
+ InstanceIdentifier.builder(ServiceFunctionsState.class)
+ .child(ServiceFunctionState.class, serviceFunctionStateKey)
+ .build();
+ List<String> sfServiceFunctionPathList = serviceFunctionState.getSfServiceFunctionPath();
+ List<String> newPathList = new ArrayList<>();
+ newPathList.addAll(sfServiceFunctionPathList);
+ newPathList.remove(serviceFunctionPath.getName());
+ ServiceFunctionStateBuilder serviceFunctionStateBuilder = new ServiceFunctionStateBuilder();
+ serviceFunctionStateBuilder.setName(serviceFunctionName);
+ serviceFunctionStateBuilder.setSfServiceFunctionPath(newPathList);
+
+
+ ReadWriteTransaction writeTx = odlSfc.dataProvider.newReadWriteTransaction();
+ writeTx.put(LogicalDatastoreType.CONFIGURATION, sfStateIID, serviceFunctionStateBuilder.build(), true);
+ writeTx.commit();
+ }
}
+
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
/**
* This class has the APIs to operate on the ServiceFunctionPath
* datastore.
- *
+ * <p/>
* It is normally called from onDataChanged() through a executor
* service. We need to use an executor service because we can not
* operate on a datastore while on onDataChanged() context.
- * @see org.opendaylight.sfc.provider.SfcProviderSfpEntryDataListener
*
- *
- * <p>
* @version 0.1
+ * @see org.opendaylight.sfc.provider.SfcProviderSfpEntryDataListener
+ * <p/>
+ * <p/>
+ * <p/>
* @since 2014-06-30
*/
-public class SfcProviderServicePathAPI implements Runnable {
+public class SfcProviderServicePathAPI extends SfcProviderAbstractAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServicePathAPI.class);
- private static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
- private String methodName = null;
- private Object[] parameters;
- private Class[] parameterTypes;
private static AtomicInteger numCreatedPath = new AtomicInteger(0);
SfcProviderServicePathAPI (Object[] params, String m) {
- int i = 0;
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- for (Object obj : parameters) {
- this.parameterTypes[i] = obj.getClass();
- i++;
+ super(params, m);
}
+ SfcProviderServicePathAPI(Object[] params, Class[] paramsTypes, String m) {
+ super(params, paramsTypes, m);
+ }
+
+ public static SfcProviderServicePathAPI getPut(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "putServiceFunctionPath");
+ }
+
+ public static SfcProviderServicePathAPI getRead(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "readServiceFunctionPath");
+ }
+
+ public static SfcProviderServicePathAPI getDelete(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "deleteServiceFunctionPath");
+ }
+
+ public static SfcProviderServicePathAPI getPutAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "putAllServiceFunctionPaths");
+ }
+
+ public static SfcProviderServicePathAPI getReadAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "readAllServiceFunctionPaths");
}
- SfcProviderServicePathAPI (Object[] params, Class[] paramsTypes, String m) {
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
+ public static SfcProviderServicePathAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServicePathAPI(params, paramsTypes, "deleteAllServiceFunctionPaths");
}
public static SfcProviderServicePathAPI getDeleteServicePathContainingFunction (Object[] params, Class[] paramsTypes) {
return new SfcProviderServicePathAPI(params, paramsTypes, "updateServicePathContainingFunction");
}
+ public static int numCreatedPathGetValue() {
+ return numCreatedPath.get();
+ }
public int numCreatedPathIncrementGet() {
return numCreatedPath.incrementAndGet();
return numCreatedPath.decrementAndGet();
}
- public static int numCreatedPathGetValue() {
- return numCreatedPath.get();
+ protected boolean putServiceFunctionPath(ServiceFunctionPath sfp) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionPath> sfpEntryIID = InstanceIdentifier.builder(ServiceFunctionPaths.class).
+ child(ServiceFunctionPath.class, sfp.getKey()).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sfpEntryIID, sfp, true);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctionPath readServiceFunctionPath(String serviceFunctionPathName) {
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionPath sfp = null;
+ InstanceIdentifier<ServiceFunctionPath> sfpIID;
+ ServiceFunctionPathKey serviceFunctionPathKey = new ServiceFunctionPathKey(serviceFunctionPathName);
+ sfpIID = InstanceIdentifier.builder(ServiceFunctionPaths.class)
+ .child(ServiceFunctionPath.class, serviceFunctionPathKey).build();
+
+ if (dataBroker != null) {
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<ServiceFunctionPath> serviceFunctionPathDataObject = null;
+ try {
+ serviceFunctionPathDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfpIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionPathDataObject != null
+ && serviceFunctionPathDataObject.isPresent()) {
+ sfp = serviceFunctionPathDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfp;
+ }
+
+ protected boolean deleteServiceFunctionPath(String serviceFunctionPathName) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionPathKey serviceFunctionPathKey = new ServiceFunctionPathKey(serviceFunctionPathName);
+ InstanceIdentifier<ServiceFunctionPath> sfpEntryIID = InstanceIdentifier.builder(ServiceFunctionPaths.class)
+ .child(ServiceFunctionPath.class, serviceFunctionPathKey).toInstance();
+
+ if (dataBroker != null) {
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfpEntryIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected boolean putAllServiceFunctionPaths(ServiceFunctionPaths sfps) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
+
+ InstanceIdentifier<ServiceFunctionPaths> sfpsIID = InstanceIdentifier.builder(ServiceFunctionPaths.class).toInstance();
+
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, sfpsIID, sfps);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
+
+ protected ServiceFunctionPaths readAllServiceFunctionPaths() {
+ ServiceFunctionPaths sfps = null;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ InstanceIdentifier<ServiceFunctionPaths> sfpsIID = InstanceIdentifier.builder(ServiceFunctionPaths.class).toInstance();
+
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunctionPaths> serviceFunctionPathsDataObject = null;
+ try {
+ serviceFunctionPathsDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfpsIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionPathsDataObject != null
+ && serviceFunctionPathsDataObject.isPresent()) {
+ sfps = serviceFunctionPathsDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfps;
+ }
+
+ protected boolean deleteAllServiceFunctionPaths() {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
+
+ InstanceIdentifier<ServiceFunctionPaths> sfpsIID = InstanceIdentifier.builder(ServiceFunctionPaths.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sfpsIID);
+ writeTx.commit();
+
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
}
/* Today A Service Function Chain modification is catastrophic. We delete all Paths
private void deleteServicePathInstantiatedFromChain (ServiceFunctionPath serviceFunctionPath) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
- ServiceFunctionChain serviceFunctionChain;
+ ServiceFunctionChain serviceFunctionChain = null;
String serviceChainName = serviceFunctionPath.getServiceChainName();
- if ((serviceChainName == null) || ((serviceFunctionChain = SfcProviderServiceChainAPI
- .readServiceFunctionChain(serviceChainName)) == null)) {
+ try {
+ serviceFunctionChain = serviceChainName != null ?
+ (ServiceFunctionChain) odlSfc.executor
+ .submit(SfcProviderServiceChainAPI.getRead(
+ new Object[]{serviceChainName},
+ new Class[]{String.class})).get()
+ : null;
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionChain == null) {
LOG.error("\n########## ServiceFunctionChain name for Path {} not provided",
serviceFunctionPath.getName());
return;
long pathId;
int pos_index = 0;
int service_index;
- ServiceFunctionChain serviceFunctionChain;
+ ServiceFunctionChain serviceFunctionChain = null;
+ serviceFunctionChain = null;
String serviceFunctionChainName = serviceFunctionPath.getServiceChainName();
- if ((serviceFunctionChainName == null) || ((serviceFunctionChain = SfcProviderServiceChainAPI
- .readServiceFunctionChain(serviceFunctionChainName)) == null)) {
+ try {
+ serviceFunctionChain = serviceFunctionChainName != null ?
+ (ServiceFunctionChain) odlSfc.executor
+ .submit(SfcProviderServiceChainAPI.getRead(
+ new Object[]{serviceFunctionChainName},
+ new Class[]{String.class})).get()
+ : null;
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionChain == null) {
LOG.error("\n########## ServiceFunctionChain name for Path {} not provided",
serviceFunctionPath.getName());
return;
* we do not hit NULL Pointer exceptions
*/
- ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.getServiceFunctionTypeList(sfcServiceFunction.getType());
+ ServiceFunctionType serviceFunctionType = null;
+ try {
+ serviceFunctionType = (ServiceFunctionType) odlSfc.executor.submit(SfcProviderServiceTypeAPI.getRead(
+ new Object[]{sfcServiceFunction.getType()}, new Class[]{String.class})).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
if (serviceFunctionType != null) {
List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
if (!sftServiceFunctionNameList.isEmpty()) {
for (SftServiceFunctionName sftServiceFunctionName : sftServiceFunctionNameList) {
// TODO: API to select suitable Service Function
String serviceFunctionName = sftServiceFunctionName.getName();
- ServiceFunction serviceFunction;
- if ((serviceFunctionName != null) && ((
- serviceFunction = SfcProviderServiceFunctionAPI
- .readServiceFunction(serviceFunctionName)) != null)) {
-
+ ServiceFunction serviceFunction = null;
+ try {
+ serviceFunction =
+ (ServiceFunction) odlSfc.executor.submit(SfcProviderServiceFunctionAPI
+ .getRead(new Object[]{serviceFunctionName}, new Class[]{String.class})).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunction != null) {
sfpServiceFunctionBuilder.setName(serviceFunctionName)
.setServiceIndex((short)service_index)
.setServiceFunctionForwarder(serviceFunction.getSfDataPlaneLocator()
}
+ /*
private void deleteServiceFunctionPathEntry (ServiceFunctionChain serviceFunctionChain) {
LOG.info("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
LOG.info("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
+ */
- public static ServiceFunctionPath readServiceFunctionPath (String path) {
- LOG.info("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
- ServiceFunctionPathKey serviceFuntionPathKey = new ServiceFunctionPathKey(path);
- InstanceIdentifier<ServiceFunctionPath> sfpIID;
- sfpIID = InstanceIdentifier.builder(ServiceFunctionPaths.class)
- .child(ServiceFunctionPath.class, serviceFuntionPathKey)
- .build();
-
- ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
- Optional<ServiceFunctionPath> serviceFunctionPathObject = null;
- try {
- serviceFunctionPathObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sfpIID).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
-
- if (serviceFunctionPathObject != null &&
- (serviceFunctionPathObject.get() instanceof ServiceFunctionPath)) {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return serviceFunctionPathObject.get();
- } else {
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
- return null;
- }
- }
/*
* We iterate through all service paths that use this service function and remove them.
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
- @Override
- public void run() {
- if (methodName != null) {
- Class<?> c = this.getClass();
- Method method;
- try {
- method = c.getDeclaredMethod(methodName, parameterTypes);
- method.invoke(this, parameters);
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- e.printStackTrace();
}
- }
-
- }
-}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
import java.util.concurrent.ExecutionException;
/**
* This class has the APIs to operate on the ServiceFunctionType
* datastore.
- *
+ * <p/>
* It is normally called from onDataChanged() through a executor
* service. We need to use an executor service because we can not
* operate on a datastore while on onDataChanged() context.
- * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
*
- *
- * <p>
* @version 0.1
- * @since 2014-06-30
+ * @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
+ * <p/>
+ * <p/>
+ * <p/>
+ * @since 2014-06-30
*/
-public class SfcProviderServiceTypeAPI implements Runnable {
+public class SfcProviderServiceTypeAPI extends SfcProviderAbstractAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceTypeAPI.class);
- private static final OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
- private String methodName = null;
- private Class[] parameterTypes;
- Object[] parameters;
-
- SfcProviderServiceTypeAPI (Object[] params, String m) {
- int i = 0;
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- for (Object obj : parameters) {
- this.parameterTypes[i] = obj.getClass();
- i++;
- }
+ SfcProviderServiceTypeAPI(Object[] params, String m) {
+ super(params, m);
+ }
+
+ SfcProviderServiceTypeAPI(Object[] params, Class[] paramsTypes, String m) {
+ super(params, paramsTypes, m);
+ }
+
+ public static SfcProviderServiceTypeAPI getPut(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "putServiceFunctionType");
+ }
+
+ public static SfcProviderServiceTypeAPI getRead(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "readServiceFunctionType");
+ }
+
+ public static SfcProviderServiceTypeAPI getDelete(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteServiceFunctionType");
+ }
+
+ public static SfcProviderServiceTypeAPI getPutAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "putAllServiceFunctionTypes");
}
- SfcProviderServiceTypeAPI (Object[] params, Class[] paramsTypes, String m) {
- this.methodName = m;
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- this.parameters = Arrays.copyOf(params, params.length);
- this.parameterTypes = Arrays.copyOf(paramsTypes, paramsTypes.length);
+ public static SfcProviderServiceTypeAPI getReadAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "readAllServiceFunctionTypes");
}
- public static SfcProviderServiceTypeAPI getCreateServiceFunctionToServiceType(Object[] params, Class[] paramsTypes) {
+ public static SfcProviderServiceTypeAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
+ return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteAllServiceFunctionTypes");
+ }
+
+ public static SfcProviderServiceTypeAPI getCreateServiceFunctionToServiceType(Object[] params, Class[] paramsTypes) {
return new SfcProviderServiceTypeAPI(params, paramsTypes, "createServiceFunctionTypeEntry");
}
- public static SfcProviderServiceTypeAPI getDeleteServiceFunctionFromServiceType (Object[] params, Class[] paramsTypes) {
+ public static SfcProviderServiceTypeAPI getDeleteServiceFunctionFromServiceType(Object[] params, Class[] paramsTypes) {
return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteServiceFunctionTypeEntry");
}
+ protected boolean putServiceFunctionType(ServiceFunctionType sft) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
- public void createServiceFunctionTypeEntry (ServiceFunction serviceFunction) {
+ InstanceIdentifier<ServiceFunctionType> sftEntryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
+ .child(ServiceFunctionType.class, sft.getKey()).toInstance();
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sftEntryIID, sft, true);
+ writeTx.commit();
- LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
- String sfkey = serviceFunction.getType();
- ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(sfkey);
+ protected ServiceFunctionType readServiceFunctionType(String serviceFunctionTypeName) {
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionType sft = null;
+ InstanceIdentifier<ServiceFunctionType> sftIID;
+ ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(serviceFunctionTypeName);
+ sftIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
+ .child(ServiceFunctionType.class, serviceFunctionTypeKey).build();
- //Build the instance identifier all the way down to the bottom child
+ if (dataBroker != null) {
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<ServiceFunctionType> serviceFunctionChainDataObject = null;
+ try {
+ serviceFunctionChainDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sftIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionChainDataObject != null
+ && serviceFunctionChainDataObject.isPresent()) {
+ sft = serviceFunctionChainDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sft;
+ }
- SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(serviceFunction.getName());
+ protected boolean deleteServiceFunctionType(String serviceFunctionTypeName) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(serviceFunctionTypeName);
+ InstanceIdentifier<ServiceFunctionType> sftEntryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
+ .child(ServiceFunctionType.class, serviceFunctionTypeKey).toInstance();
- InstanceIdentifier<SftServiceFunctionName> sftentryIID;
- sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
- .child(ServiceFunctionType.class, serviceFunctionTypeKey)
- .child(SftServiceFunctionName.class,sftServiceFunctionNameKey).build();
+ if (dataBroker != null) {
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sftEntryIID);
+ writeTx.commit();
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
+ }
- // Create a item in the list keyed by service function name
- SftServiceFunctionNameBuilder sftServiceFunctionNameBuilder = new SftServiceFunctionNameBuilder();
- sftServiceFunctionNameBuilder = sftServiceFunctionNameBuilder.setName(serviceFunction.getName());
- SftServiceFunctionName sftServiceFunctionName = sftServiceFunctionNameBuilder.build();
+ protected boolean putAllServiceFunctionTypes(ServiceFunctionTypes sfts) {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (dataBroker != null) {
- WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
- writeTx.merge(LogicalDatastoreType.CONFIGURATION,
- sftentryIID, sftServiceFunctionName, true);
- writeTx.commit();
+ InstanceIdentifier<ServiceFunctionTypes> sftsIID = InstanceIdentifier.builder(ServiceFunctionTypes.class).toInstance();
- LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION, sftsIID, sfts);
+ writeTx.commit();
+ ret = true;
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
}
- public void deleteServiceFunctionTypeEntry (ServiceFunction serviceFunction) {
+ protected ServiceFunctionTypes readAllServiceFunctionTypes() {
+ ServiceFunctionTypes sfts = null;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ InstanceIdentifier<ServiceFunctionTypes> sftsIID = InstanceIdentifier.builder(ServiceFunctionTypes.class).toInstance();
- LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
- String sfkey = serviceFunction.getType();
- ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(sfkey);
+ if (odlSfc.getDataProvider() != null) {
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
+ Optional<ServiceFunctionTypes> serviceFunctionTypesDataObject = null;
+ try {
+ serviceFunctionTypesDataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, sftsIID).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
+ if (serviceFunctionTypesDataObject != null
+ && serviceFunctionTypesDataObject.isPresent()) {
+ sfts = serviceFunctionTypesDataObject.get();
+ }
+ }
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return sfts;
+ }
- //Build the instance identifier all the way down to the bottom child
- InstanceIdentifier<SftServiceFunctionName> sftentryIID;
- SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(serviceFunction.getName());
- sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class).
- child(ServiceFunctionType.class, serviceFunctionTypeKey)
- .child(SftServiceFunctionName.class,sftServiceFunctionNameKey).build();
+ protected boolean deleteAllServiceFunctionTypes() {
+ boolean ret = false;
+ LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
+ if (odlSfc.getDataProvider() != null) {
- WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
- writeTx.delete(LogicalDatastoreType.CONFIGURATION,
- sftentryIID);
- writeTx.commit();
+ InstanceIdentifier<ServiceFunctionTypes> sftsIID = InstanceIdentifier.builder(ServiceFunctionTypes.class).toInstance();
+
+ WriteTransaction writeTx = odlSfc.getDataProvider().newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION, sftsIID);
+ writeTx.commit();
+ ret = true;
+ }
LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+ return ret;
}
- public static ServiceFunctionType getServiceFunctionTypeList (String type) {
+ /*
+ public static ServiceFunctionType getServiceFunctionTypeList(String typeName) {
LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
InstanceIdentifier<ServiceFunctionType> sftListIID;
ServiceFunctionTypeKey serviceFunctionTypeKey;
- serviceFunctionTypeKey = new ServiceFunctionTypeKey(type);
+ serviceFunctionTypeKey = new ServiceFunctionTypeKey(typeName);
- /*
- * We iterate thorough the list of service function types and for each one we get a suitable
- * Service Function
- */
sftListIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
.child(ServiceFunctionType.class, serviceFunctionTypeKey).build();
return null;
}
}
+ */
- @Override
- public void run() {
- if (methodName != null) {
- Class<?> c = this.getClass();
- Method method;
- try {
- method = c.getDeclaredMethod(methodName, parameterTypes);
- method.invoke(this, parameters);
- } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- e.printStackTrace();
- }
- }
+ public void createServiceFunctionTypeEntry(ServiceFunction serviceFunction) {
+
+ LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
+ String sfkey = serviceFunction.getType();
+ ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(sfkey);
+
+ //Build the instance identifier all the way down to the bottom child
+
+ SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(serviceFunction.getName());
+
+ InstanceIdentifier<SftServiceFunctionName> sftentryIID;
+ sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
+ .child(ServiceFunctionType.class, serviceFunctionTypeKey)
+ .child(SftServiceFunctionName.class, sftServiceFunctionNameKey).build();
+
+
+ // Create a item in the list keyed by service function name
+ SftServiceFunctionNameBuilder sftServiceFunctionNameBuilder = new SftServiceFunctionNameBuilder();
+ sftServiceFunctionNameBuilder = sftServiceFunctionNameBuilder.setName(serviceFunction.getName());
+ SftServiceFunctionName sftServiceFunctionName = sftServiceFunctionNameBuilder.build();
+
+ WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.CONFIGURATION,
+ sftentryIID, sftServiceFunctionName, true);
+ writeTx.commit();
+
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
+
+ }
+
+ public void deleteServiceFunctionTypeEntry(ServiceFunction serviceFunction) {
+
+ LOG.debug("\n########## Start: {}", Thread.currentThread().getStackTrace()[1]);
+ String sfkey = serviceFunction.getType();
+ ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(sfkey);
+
+ //Build the instance identifier all the way down to the bottom child
+ InstanceIdentifier<SftServiceFunctionName> sftentryIID;
+ SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(serviceFunction.getName());
+ sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class)
+ .child(ServiceFunctionType.class, serviceFunctionTypeKey)
+ .child(SftServiceFunctionName.class, sftServiceFunctionNameKey).build();
+
+ WriteTransaction writeTx = odlSfc.dataProvider.newWriteOnlyTransaction();
+ writeTx.delete(LogicalDatastoreType.CONFIGURATION,
+ sftentryIID);
+ writeTx.commit();
+
+ LOG.debug("\n########## Stop: {}", Thread.currentThread().getStackTrace()[1]);
}
+
}
Object[] serviceTypeObj = {originalServiceFunction};
Class[] serviceTypeClass = {ServiceFunction.class};
- odlSfc.executor.execute(SfcProviderServiceTypeAPI
+ odlSfc.executor.submit(SfcProviderServiceTypeAPI
.getDeleteServiceFunctionFromServiceType(serviceTypeObj, serviceTypeClass));
//Object[] sfParams = {originalServiceFunction};
Object[] functionParams = {originalServiceFunction};
Class[] functionParamsTypes = {ServiceFunction.class};
- odlSfc.executor.execute(SfcProviderServicePathAPI
+ odlSfc.executor.submit(SfcProviderServicePathAPI
.getDeleteServicePathContainingFunction(functionParams, functionParamsTypes));
}
}
Object[] serviceTypeObj = {createdServiceFunction};
Class[] serviceTypeClass = {ServiceFunction.class};
- odlSfc.executor.execute(SfcProviderServiceTypeAPI
+ odlSfc.executor.submit(SfcProviderServiceTypeAPI
.getCreateServiceFunctionToServiceType(serviceTypeObj, serviceTypeClass));
//Object[] sfParams = {createdServiceFunction};
ServiceFunction updatedServiceFunction = (ServiceFunction) entry.getValue();
Object[] serviceTypeObj = {updatedServiceFunction};
Class[] serviceTypeClass = {ServiceFunction.class};
- odlSfc.executor.execute(SfcProviderServiceTypeAPI
+ odlSfc.executor.submit(SfcProviderServiceTypeAPI
.getCreateServiceFunctionToServiceType(serviceTypeObj, serviceTypeClass));
Object[] sfParams = {updatedServiceFunction};
//odlSfc.executor.execute(SfcProviderServiceForwarderAPI
// .getUpdateServiceForwarderAPI(sfParams, sfParamsTypes ));
- odlSfc.executor.execute(SfcProviderServicePathAPI
+ odlSfc.executor.submit(SfcProviderServicePathAPI
.getUpdateServicePathContainingFunction(sfParams, sfParamsTypes));
}
}
LOG.debug("\n########## Created ServiceFunctionChain name: {}", createdServiceFunctionChain.getName());
Object[] serviceChainObj = {createdServiceFunctionChain};
Class[] serviceChainClass = {ServiceFunctionChain.class};
- odlSfc.executor.execute(SfcProviderServiceChainAPI
+ odlSfc.executor.submit(SfcProviderServiceChainAPI
.getAddChainToChainState(serviceChainObj, serviceChainClass));
List<SfcServiceFunction> SfcServiceFunctionList = createdServiceFunctionChain.getSfcServiceFunction();
for (SfcServiceFunction sfcServiceFunction : SfcServiceFunctionList) {
LOG.debug("\n########## Created ServiceFunctionChain name: {}", createdServiceFunctionPath.getName());
Object[] servicePathObj = {createdServiceFunctionPath};
Class[] servicePathClass = {ServiceFunctionPath.class};
- odlSfc.executor.execute(SfcProviderServicePathAPI
+ odlSfc.executor.submit(SfcProviderServicePathAPI
.getCreateServicePathAPI(servicePathObj, servicePathClass));
}
}
updatedServiceFunctionPath.getName());
Object[] servicePathObj = {updatedServiceFunctionPath};
Class[] servicePathClass = {ServiceFunctionPath.class};
- odlSfc.executor.execute(SfcProviderServicePathAPI
+ odlSfc.executor.submit(SfcProviderServicePathAPI
.getUpdateServicePathAPI(servicePathObj, servicePathClass));
}
}
Object[] serviceTypeObj = {originalServiceFunctionPath};
Class[] serviceTypeClass = {ServiceFunctionPath.class};
- odlSfc.executor.execute(SfcProviderServiceFunctionAPI
+ odlSfc.executor.submit(SfcProviderServiceFunctionAPI
.getDeleteServicePathFromServiceFunctionState(serviceTypeObj, serviceTypeClass));
}
}
-package org.opendaylight.sfc.provider;
+package org.opendaylight.sfc.provider.util;
import com.google.common.base.Optional;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.sfc.provider.OpendaylightSfc;
+import org.opendaylight.sfc.provider.SfcProviderServiceFunctionAPI;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sn.rev140701.ServiceNodes;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sn.rev140701.service.nodes.ServiceNode;
/**
* This class maps service function types to service node mappers
*
- * @see org.opendaylight.sfc.provider.SfcSnMapper
+ * @see SfcSnMapper
* <p>
* @version 0.1
public void update() {
if (odlSfc != null) {
- ReadOnlyTransaction readTx = odlSfc.dataProvider.newReadOnlyTransaction();
+ ReadOnlyTransaction readTx = odlSfc.getDataProvider().newReadOnlyTransaction();
Optional<ServiceNodes> dataObject = null;
try {
dataObject = readTx.read(LogicalDatastoreType.CONFIGURATION, OpendaylightSfc.snIID).get();
for(ServiceNode sn : snList){
List<String> sfNameList = sn.getServiceFunction();
for(String sfName : sfNameList){
- ServiceFunction sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
+ ServiceFunction sf = null;
+ try {
+ sf = (ServiceFunction) odlSfc.executor.submit(SfcProviderServiceFunctionAPI.getRead(
+ new Object[]{sfName}, new Class[]{String.class})).get();
+ } catch (InterruptedException | ExecutionException e) {
+ e.printStackTrace();
+ }
if ( sf != null) {
this.add(sf.getType(), sn.getName(), sf);
} else {
-package org.opendaylight.sfc.provider;
+package org.opendaylight.sfc.provider.util;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;