package org.opendaylight.sfc.sfc_netconf.provider.listener;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
-import org.opendaylight.sfc.sfc_netconf.provider.api.SfcProviderSfDescriptionMonitorAPI;
import org.opendaylight.sfc.sfc_netconf.provider.api.SfcNetconfServiceForwarderAPI;
import org.opendaylight.sfc.sfc_netconf.provider.api.SfcNetconfServiceFunctionAPI;
+import org.opendaylight.sfc.sfc_netconf.provider.api.SfcProviderSfDescriptionMonitorAPI;
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.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.TcpProxy;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rev141201.service.functions.state.service.function.state.sfc.sf.desc.mon.DescriptionInfo;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rev141201.service.functions.state.service.function.state.sfc.sf.desc.mon.MonitoringInfo;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.TcpProxy;
-import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-
public class SfcNetconfNodeDataListener extends SfcNetconfAbstractDataListener {
private static final Logger LOG = LoggerFactory.getLogger(SfcNetconfNodeDataListener.class);
private static HashMap<String, Class<? extends ServiceFunctionTypeIdentity>> sftMap = new HashMap<String, Class<? extends ServiceFunctionTypeIdentity>>() {{
break;
}
ServiceFunction sf = SfcNetconfServiceFunctionAPI.buildServiceFunctionFromNetconf(nodeName, descInfo.getDataPlaneIp(), descInfo.getDataPlanePort(), sfType);
- if (SfcProviderServiceFunctionAPI.putServiceFunctionExecutor(sf)) {
+ if (SfcProviderServiceFunctionAPI.putServiceFunction(sf)) {
LOG.info("Successfully created SF from Netconf node {}", nodeName);
SfcNetconfServiceFunctionAPI.putServiceFunctionDescription(descInfo, nodeName);
MonitoringInfo monInfo = SfcNetconfServiceFunctionAPI.getServiceFunctionMonitor(nodeName);
thread.start();
} else { //SFF
ServiceFunctionForwarder sff = SfcNetconfServiceForwarderAPI.buildServiceForwarderFromNetconf(nodeName, nnode);
- if (SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(sff)) {
+ if (SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff)) {
LOG.info("Successfully created SFF from Netconf node {}", nodeName);
} else {
LOG.error("Failed to create SFF from Netconf node {}", nodeName);
// Note that device could jump back and forth between connected and connecting for various reasons:
// disconnect from remote device, network connectivity loss etc.
LOG.info("Netconf device disconnected, deleting SFF {}", nodeName);
- if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderExecutor(nodeName)) {
+ if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarder(nodeName)) {
LOG.info("SFF {} deleted successfully", nodeName);
} else {
LOG.error("Failed to delete SFF {}", nodeName);
case UnableToConnect: {
// Its over for the device, no more reconnects
LOG.info("Unable to connected to Netconf device, deleting SFF {}", nodeName);
- if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderExecutor(nodeName)) {
+ if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarder(nodeName)) {
LOG.info("SFF {} deleted successfully", nodeName);
} else {
LOG.error("Failed to delete SFF {}", nodeName);
package org.opendaylight.sfc.sfc_netconf.provider.api;
-import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
-import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-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.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
+import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsState;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.state.ServiceFunctionState;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.state.ServiceFunctionStateBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.state.ServiceFunctionStateKey;
+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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rev141201.ServiceFunctionState1;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rev141201.ServiceFunctionState1Builder;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rev141201.service.functions.state.service.function.state.SfcSfDescMon;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.sf.desc.mon.rpt.rev141105.sf.monitoring.info.resource.utilization.sf.ports.bandwidth.utilization.PortBandwidthUtilizationKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-
-import static org.junit.Assert.*;
-
public class SfcNetconfServiceFunctionAPITest extends AbstractDataBrokerTest {
- private ExecutorService executor;
private final OpendaylightSfc opendaylightSfc = new OpendaylightSfc();
private static final String IP_MGMT_ADDRESS = "192.168.1.2";
private static final int DP_PORT = 6633;
private static final String SF_STATE_NAME = "dummySFS";
@Before
- public void before() throws InterruptedException {
+ public void before() {
DataBroker dataBroker = getDataBroker();
opendaylightSfc.setDataProvider(dataBroker);
- executor = opendaylightSfc.getExecutor();
- }
-
- @After
- public void after() throws InterruptedException {
}
- public void testCreateReadServiceFunctionDescription() throws ExecutionException, InterruptedException {
+ public void testCreateReadServiceFunctionDescription() {
ServiceFunctionStateKey serviceFunctionStateKey =
new ServiceFunctionStateKey("unittest-fw-1");
SfcSfDescMon sfDescMon;
SfcProviderServiceFunctionAPI.putServiceFunctionState(serviceFunctionState);
SfcSfDescMon readSfcSfDescMon =
- SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor("unittest-fw-1");
+ SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor("unittest-fw-1");
Long numPorts = 1L;
assertNotNull("Must be not null", readSfcSfDescMon);
assertEquals("Must be equal", cap, readSfcSfDescMon.getDescriptionInfo().getCapabilities());
}
@Test
- public void testCreateReadServiceFunctionMonitor() throws ExecutionException, InterruptedException {
+ public void testCreateReadServiceFunctionMonitor() {
SfcSfDescMon sfDescMon;
ServiceFunctionStateKey serviceFunctionStateKey =
.addAugmentation(ServiceFunctionState1.class,sfState1).build();
SfcProviderServiceFunctionAPI.putServiceFunctionState(serviceFunctionState);
SfcSfDescMon readSfcSfDescMon =
- SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor("unittest-fw-2");
+ SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor("unittest-fw-2");
assertNotNull("Must be not null", readSfcSfDescMon);
assertEquals("Must be equal", resrcUtil, readSfcSfDescMon.getMonitoringInfo().getResourceUtilization());
assertTrue("Must be true", readSfcSfDescMon.getMonitoringInfo().isLiveness());
RpcResult <CreateRenderedPathOutput> rpcResult;
String retRspName = null;
- createdServiceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPathExecutor
+ createdServiceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath
(createRenderedPathInput.getParentServiceFunctionPath());
if (createdServiceFunctionPath != null) {
rpcResult = RpcResultBuilder.success(createRenderedPathOutputBuilder.build()).build();
if ((createdServiceFunctionPath.getClassifier() != null) &&
- SfcProviderServiceClassifierAPI.readServiceClassifierExecutor
+ SfcProviderServiceClassifierAPI.readServiceClassifier
(createdServiceFunctionPath.getClassifier()) != null) {
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState
(createdServiceFunctionPath.getClassifier(), renderedServicePath.getName());
} else {
LOG.warn("Classifier not provided or does not exist");
SfcProviderRenderedPathAPI.setSymmetricPathId(renderedServicePath, revRenderedServicePath.getPathId());
if ((createdServiceFunctionPath.getSymmetricClassifier() != null) &&
SfcProviderServiceClassifierAPI
- .readServiceClassifierExecutor
+ .readServiceClassifier
(createdServiceFunctionPath.getSymmetricClassifier()) != null) {
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState
(createdServiceFunctionPath.getSymmetricClassifier(), revRenderedServicePath.getName());
} else {
RpcResultBuilder<DeleteRenderedPathOutput> rpcResultBuilder;
// If a RSP is deleted we delete both SF and SFF operational states.
SfcProviderServiceForwarderAPI
- .deletePathFromServiceForwarderStateExecutor(input.getName());
+ .deletePathFromServiceForwarderState(input.getName());
SfcProviderServiceFunctionAPI
- .deleteServicePathFromServiceFunctionStateExecutor(input.getName());
+ .deleteServicePathFromServiceFunctionState(input.getName());
- ret = SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(input.getName());
+ ret = SfcProviderRenderedPathAPI.deleteRenderedServicePath(input.getName());
DeleteRenderedPathOutputBuilder deleteRenderedPathOutputBuilder = new DeleteRenderedPathOutputBuilder();
deleteRenderedPathOutputBuilder.setResult(ret);
if (ret) {
if ((createdServiceFunctionClassifier.getAccessList() != null) && !createdServiceFunctionClassifier.getAccessList().isEmpty()) {
//call executor to write <ACL, Classifier> entry into ACL operational store
- SfcProviderAclAPI.addClassifierToAccessListStateExecutor(createdServiceFunctionClassifier.getAccessList(),
+ SfcProviderAclAPI.addClassifierToAccessListState(createdServiceFunctionClassifier.getAccessList(),
createdServiceFunctionClassifier.getName());
}
}
if (!updatedServiceFunctionClassifier.getAccessList().isEmpty()) {
//call executor to write <ACL, Classifier> entry into ACL operational store
- SfcProviderAclAPI.addClassifierToAccessListStateExecutor(updatedServiceFunctionClassifier.getAccessList(),
+ SfcProviderAclAPI.addClassifierToAccessListState(updatedServiceFunctionClassifier.getAccessList(),
updatedServiceFunctionClassifier.getName());
}
// if Access List is empty string, Classifier should be not more linked to the origin Access List
else {
//call executor to delete <ACL, Classifier> entry from ACL operational store
- SfcProviderAclAPI.deleteClassifierFromAccessListStateExecutor(originalServiceFunctionClassifier.getAccessList(),
+ SfcProviderAclAPI.deleteClassifierFromAccessListState(originalServiceFunctionClassifier.getAccessList(),
originalServiceFunctionClassifier.getName());
}
}
if ((deletedServiceFunctionClassifier.getAccessList() != null) && !deletedServiceFunctionClassifier.getAccessList().isEmpty()) {
//call executor to delete <ACL, Classifier> entry from ACL operational store
- SfcProviderAclAPI.deleteClassifierFromAccessListStateExecutor(deletedServiceFunctionClassifier.getAccessList(),
+ SfcProviderAclAPI.deleteClassifierFromAccessListState(deletedServiceFunctionClassifier.getAccessList(),
deletedServiceFunctionClassifier.getName());
}
}
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
public class SfcProviderSfEntryDataListener implements DataChangeListener {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderSfEntryDataListener.class);
- private OpendaylightSfc odlSfc = OpendaylightSfc.getOpendaylightSfcObj();
/**
* This method is called whenever there is change in a SF. Before doing any changes
if (entry.getValue() instanceof ServiceFunction) {
ServiceFunction createdServiceFunction = (ServiceFunction) entry.getValue();
- if (!SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(createdServiceFunction)) {
+ if (!SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(createdServiceFunction)) {
LOG.error("Failed to create service function type: {}", createdServiceFunction.getType());
}
}
ServiceFunction originalServiceFunction = (ServiceFunction) dataObject;
if (!SfcProviderServiceTypeAPI
- .deleteServiceFunctionTypeEntryExecutor(originalServiceFunction)) {
+ .deleteServiceFunctionTypeEntry(originalServiceFunction)) {
LOG.error("Failed to delete Service Function Type for SF: {}",
originalServiceFunction.getName());
}
*/
String sfName = originalServiceFunction.getName();
List<String> rspList =
- SfcProviderServiceFunctionAPI.readServiceFunctionStateAsStringListExecutor(sfName);
+ SfcProviderServiceFunctionAPI.readServiceFunctionStateAsStringList(sfName);
if ((rspList != null) && (!rspList.isEmpty())) {
- if (SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
+ if (SfcProviderServiceFunctionAPI.deleteServiceFunctionState(sfName)) {
} else {
LOG.error("{}: Failed to delete SF {} operational state",
Thread.currentThread().getStackTrace()[1], sfName);
}
- SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspList);
+ SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(rspList);
- SfcProviderRenderedPathAPI.deleteRenderedServicePathsExecutor(rspList);
+ SfcProviderRenderedPathAPI.deleteRenderedServicePaths(rspList);
}
}
}
&& (!(dataCreatedObject.containsKey(entry.getKey())))) {
DataObject dataObject = dataOriginalDataObject.get(entry.getKey());
ServiceFunction originalServiceFunction = (ServiceFunction) dataObject;
- Object[] serviceFunctionObj = {originalServiceFunction};
- Class[] serviceFunctionClass = {ServiceFunction.class};
-
ServiceFunction updatedServiceFunction = (ServiceFunction) entry.getValue();
// We only update SF type entry if type has changed
if (!updatedServiceFunction.getType().equals(originalServiceFunction.getType())) {
-
// We remove the original SF from SF type list
- Future future = odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI
- .getDeleteServiceFunctionFromServiceType(serviceFunctionObj, serviceFunctionClass));
- try {
- LOG.debug("getDeleteServiceFunctionFromServiceType returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ....", e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
+ SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntry(originalServiceFunction);
// We create a independent entry
- serviceFunctionObj[0] = updatedServiceFunction;
- serviceFunctionClass[0] = ServiceFunction.class;
- odlSfc.getExecutor().submit(SfcProviderServiceTypeAPI
- .getCreateServiceFunctionTypeEntry(serviceFunctionObj, serviceFunctionClass));
+ SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(updatedServiceFunction);
}
/*
*/
String sfName = originalServiceFunction.getName();
List<SfServicePath> sfServicePathList =
- SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(sfName);
+ SfcProviderServiceFunctionAPI.readServiceFunctionState(sfName);
List<String> rspList = new ArrayList<>();
if ((sfServicePathList != null) && (!sfServicePathList.isEmpty())) {
- if (!SfcProviderServiceFunctionAPI.deleteServiceFunctionStateExecutor(sfName)) {
+ if (!SfcProviderServiceFunctionAPI.deleteServiceFunctionState(sfName)) {
LOG.error("{}: Failed to delete SF {} operational state",
Thread.currentThread().getStackTrace()[1], sfName);
}
for (SfServicePath sfServicePath : sfServicePathList) {
String rspName = sfServicePath.getName();
- SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspName);
+ SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(rspName);
rspList.add(rspName);
}
- SfcProviderRenderedPathAPI.deleteRenderedServicePathsExecutor(rspList);
+ SfcProviderRenderedPathAPI.deleteRenderedServicePaths(rspList);
}
/*
* We do not update the SFF dictionary. Since the user configured it in the
String sffName = serviceFunctionForwarder.getName();
List<String> rspList = new ArrayList<>();
List<SffServicePath> sffServicePathList =
- SfcProviderServiceForwarderAPI.readSffStateExecutor(sffName);
+ SfcProviderServiceForwarderAPI.readSffState(sffName);
if ((sffServicePathList != null) && !sffServicePathList.isEmpty()) {
- if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderStateExecutor(sffName)) {
+ if (SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderState(sffName)) {
} else {
LOG.error("{}: Failed to delete SFF {} operational state",
for (SffServicePath sffServicePath : sffServicePathList) {
String rspName = sffServicePath.getName();
SfcProviderServiceFunctionAPI
- .deleteServicePathFromServiceFunctionStateExecutor(rspName);
+ .deleteServicePathFromServiceFunctionState(rspName);
rspList.add(rspName);
}
- SfcProviderRenderedPathAPI.deleteRenderedServicePathsExecutor(rspList);
+ SfcProviderRenderedPathAPI.deleteRenderedServicePaths(rspList);
}
}
}
String sffName = serviceFunctionForwarder.getName();
LOG.debug("{}: SFF {} update", Thread.currentThread().getStackTrace()[1], sffName);
List<SffServicePath> sffServicePathList =
- SfcProviderServiceForwarderAPI.readSffStateExecutor(sffName);
+ SfcProviderServiceForwarderAPI.readSffState(sffName);
List<String> rspList = new ArrayList<>();
if ((sffServicePathList != null) && !sffServicePathList.isEmpty()) {
- if (!SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderStateExecutor(sffName)) {
+ if (!SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderState(sffName)) {
LOG.error("{}: Failed to delete SFF {} operational state",
Thread.currentThread().getStackTrace()[1], sffName);
}
for (SffServicePath sffServicePath : sffServicePathList) {
String rspName = sffServicePath.getName();
SfcProviderServiceFunctionAPI
- .deleteServicePathFromServiceFunctionStateExecutor(rspName);
+ .deleteServicePathFromServiceFunctionState(rspName);
rspList.add(rspName);
}
- SfcProviderRenderedPathAPI.deleteRenderedServicePathsExecutor(rspList);
+ SfcProviderRenderedPathAPI.deleteRenderedServicePaths(rspList);
}
}
package org.opendaylight.sfc.provider;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.sfc.provider.api.*;
+import org.opendaylight.sfc.provider.api.SfcConcurrencyAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderScheduleTypeAPI;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypes;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerType;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-
public class SfcProviderSfstEntryDataListener implements DataChangeListener {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderSfstEntryDataListener.class);
(ServiceFunctionSchedulerType) entry.getValue();
LOG.debug("\n########## createdServiceFunctionSchedulerType {} {}",
createdServiceFunctionSchedulerType.getType(), createdServiceFunctionSchedulerType.getName());
- try {
- if (createdServiceFunctionSchedulerType.isEnabled() == true) {
- isCreateTrue = true;
-
- Object[] sfstObj = {};
- Class[] sfstClass = {};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI = SfcProviderScheduleTypeAPI
- .getReadAll(sfstObj, sfstClass);
- Future future = odlSfc.getExecutor().submit(sfcProviderScheduleTypeAPI);
- if(future.get()!=null) {
- ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes =
- (ServiceFunctionSchedulerTypes)future.get();
- List<ServiceFunctionSchedulerType> sfScheduleTypeList =
- serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
- for (ServiceFunctionSchedulerType sfst : sfScheduleTypeList) {
- if (sfst.isEnabled() == true) {
- if (!(sfst.getType().equals(createdServiceFunctionSchedulerType.getType()))) {
- ServiceFunctionSchedulerType sfstUpdate = new ServiceFunctionSchedulerTypeBuilder()
- .setName(sfst.getName())
- .setType(sfst.getType())
- .setEnabled(false).build();
-
- Object[] sfstObjUpdate = {sfstUpdate};
- Class[] sfstClassUpdate = {ServiceFunctionSchedulerType.class};
- future = odlSfc.getExecutor().submit(SfcProviderScheduleTypeAPI
- .getPut(sfstObjUpdate, sfstClassUpdate));
- break;
- }
+ if (createdServiceFunctionSchedulerType.isEnabled() == true) {
+ isCreateTrue = true;
+ ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes = SfcProviderScheduleTypeAPI
+ .readAllServiceFunctionScheduleTypes();
+ if(serviceFunctionSchedulerTypes != null) {
+ List<ServiceFunctionSchedulerType> sfScheduleTypeList =
+ serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
+ for (ServiceFunctionSchedulerType sfst : sfScheduleTypeList) {
+ if (sfst.isEnabled() == true) {
+ if (!(sfst.getType().equals(createdServiceFunctionSchedulerType.getType()))) {
+ ServiceFunctionSchedulerType sfstUpdate = new ServiceFunctionSchedulerTypeBuilder()
+ .setName(sfst.getName())
+ .setType(sfst.getType())
+ .setEnabled(false).build();
+
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstUpdate);
+ break;
}
}
}
}
- } catch (InterruptedException e) {
- LOG.warn("failed to ....", e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ....", e);
}
}
}
LOG.debug("\n########## updatedServiceFunctionSchedulerType {} {}",
updatedServiceFunctionSchedulerType.getType(), updatedServiceFunctionSchedulerType.getName());
- try {
- if (isCreateTrue==false) {
- if (updatedServiceFunctionSchedulerType.isEnabled() == true) {
- Object[] sfstObj = {};
- Class[] sfstClass = {};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI = SfcProviderScheduleTypeAPI
- .getReadAll(sfstObj, sfstClass);
- Future future = odlSfc.getExecutor().submit(sfcProviderScheduleTypeAPI);
- if(future.get()!=null) {
- ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes =
- (ServiceFunctionSchedulerTypes)future.get();
- List<ServiceFunctionSchedulerType> sfScheduleTypeList =
- serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
- for (ServiceFunctionSchedulerType sfst : sfScheduleTypeList) {
- if (sfst.isEnabled() == true) {
- if (!(sfst.getType().equals(updatedServiceFunctionSchedulerType.getType()))) {
- ServiceFunctionSchedulerType sfstUpdate = new ServiceFunctionSchedulerTypeBuilder()
- .setName(sfst.getName())
- .setType(sfst.getType())
- .setEnabled(false).build();
-
- Object[] serviceFunctionSchedulerTypeObj = {sfstUpdate};
- Class[] serviceFunctionSchedulerTypeClass = {ServiceFunctionSchedulerType.class};
- future = odlSfc.getExecutor().submit(SfcProviderScheduleTypeAPI
- .getPut(serviceFunctionSchedulerTypeObj, serviceFunctionSchedulerTypeClass));
- break;
-
- }
+ if (isCreateTrue==false) {
+ if (updatedServiceFunctionSchedulerType.isEnabled() == true) {
+ ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes = SfcProviderScheduleTypeAPI
+ .readAllServiceFunctionScheduleTypes();
+ if(serviceFunctionSchedulerTypes != null) {
+ List<ServiceFunctionSchedulerType> sfScheduleTypeList =
+ serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
+ for (ServiceFunctionSchedulerType sfst : sfScheduleTypeList) {
+ if (sfst.isEnabled() == true) {
+ if (!(sfst.getType().equals(updatedServiceFunctionSchedulerType.getType()))) {
+ ServiceFunctionSchedulerType sfstUpdate = new ServiceFunctionSchedulerTypeBuilder()
+ .setName(sfst.getName())
+ .setType(sfst.getType())
+ .setEnabled(false).build();
+
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstUpdate);
+ break;
+
}
}
}
}
- } else if (isCreateTrue==true) {
- isCreateTrue=false;
}
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
+ } else if (isCreateTrue==true) {
+ isCreateTrue=false;
}
}
}
+++ /dev/null
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.sfc.provider;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Created by repenno on 11/29/14.
- */
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD) //can use in method only.
-public @interface SfcReflection {
-
- //should ignore this test?
- public boolean enabled() default true;
-}
+++ /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.api;
-
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
-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.Callable;
-
-/**
- * <p>
- *
- * @version 0.1
- * @since 2014-06-30
- */
-public abstract class SfcProviderAbstractAPI implements Callable<Object> {
-
- protected static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- private static final Logger LOG = LoggerFactory.getLogger
- (SfcProviderAbstractAPI.class);
- private String methodName = null;
- private Object[] parameters;
- private Class[] parameterTypes;
- protected DataBroker dataBroker;
-
- public String getMethodName()
- {
- return methodName;
- }
-
- public void setMethodName(String methodName)
- {
- this.methodName = methodName;
- }
-
- public Object[] getParameters()
- {
- return parameters;
- }
-
- public void setParameters(Object[] parameters)
- {
- this.parameters = Arrays.copyOf(parameters, parameters.length);
- }
-
- public Class[] getParameterTypes()
- {
- return parameterTypes;
- }
-
- public void setParameterTypes(Class[] parameterTypes)
- {
- this.parameterTypes = Arrays.copyOf(parameterTypes,
- parameterTypes.length);
- }
-
- public DataBroker getDataBroker()
- {
- return dataBroker;
- }
-
- public void setDataBroker(DataBroker dataBroker)
- {
- this.dataBroker = dataBroker;
- }
-
- SfcProviderAbstractAPI(Object[] params, String m) {
- setMethodName(m);
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- setParameters(params);
- setDataBroker(ODL_SFC.getDataProvider());
-
- for (int i = 0; i < params.length; i++) {
- this.parameterTypes[i] = params[i].getClass();
- }
- }
-
- protected SfcProviderAbstractAPI(Object[] params, Class[] paramsTypes, String m) {
- setMethodName(m);
- this.parameters = new Object[params.length];
- this.parameterTypes = new Class[params.length];
- setParameters(params);
- setParameterTypes(paramsTypes);
- setDataBroker(ODL_SFC.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 e) {
- LOG.error("Illegal Access, method: {}, message: {}", methodName, e.getMessage());
- } catch (InvocationTargetException e) {
- LOG.error("Invocation exception {}, message: {}", methodName, e.getMessage());
- } catch (NoSuchMethodException e) {
- LOG.error("Could not find method {} in class", methodName);
- }
- }
- return result;
- }
-
-}
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.SfcReflection;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessListsState;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
/**
* This class has the APIs to operate on the ACL
* <p>
* @since 2014-11-04
*/
-public class SfcProviderAclAPI extends SfcProviderAbstractAPI {
+public class SfcProviderAclAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderAclAPI.class);
- private static final String FAILED_TO_STR = "failed to ...";
-
- SfcProviderAclAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderAclAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- public static SfcProviderAclAPI getReadAccessList(Object[] params, Class[] paramsTypes) {
- return new SfcProviderAclAPI(params, paramsTypes, "readAccessList");
- }
-
- public static SfcProviderAclAPI getReadAccessListState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderAclAPI(params, paramsTypes, "readAccessListState");
- }
-
- public static SfcProviderAclAPI getAddClassifierToAccessListStateExecutor(Object[] params, Class[] paramsTypes) {
- return new SfcProviderAclAPI(params, paramsTypes, "addClassifierToAccessListState");
- }
-
- public static SfcProviderAclAPI getDeleteClassifierFromAccessListStateExecutor(Object[] params, Class[] paramsTypes) {
- return new SfcProviderAclAPI(params, paramsTypes, "deleteClassifierFromAccessListState");
- }
/**
* This method reads a Access List from DataStore
* @param accessListName Access List name
* @return ACL object or null if not found
*/
- @SuppressWarnings("unused")
- @SfcReflection
- protected Acl readAccessList(String accessListName) {
+ public static Acl readAccessList(String accessListName) {
printTraceStart(LOG);
Acl acl;
InstanceIdentifier<Acl> aclIID;
}
- /**
- * Wrapper API to read access list from Datastore
- * <p>
- * @param accessListName Access List name
- * @return an Acl object, null otherwise
- */
- public static Acl readAccessListExecutor(String accessListName) {
-
- printTraceStart(LOG);
- Acl ret = null;
- Object[] functionParamsObj = {accessListName};
- Class[] functionParamsClass = {String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderAclAPI
- .getReadAccessList(functionParamsObj, functionParamsClass));
- try {
- ret = (Acl) future.get();
- LOG.debug("getReadAccessList: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method reads a Access List state from Operational DataStore
* <p>
* @param accessListName Access List name
* @return ACL state object or null if not found
*/
- @SuppressWarnings("unused")
- @SfcReflection
- protected AccessListState readAccessListState(String accessListName) {
+ public static AccessListState readAccessListState(String accessListName) {
printTraceStart(LOG);
AccessListState aclState;
InstanceIdentifier<AccessListState> aclStateIID;
}
- /**
- * Wrapper API to read access list state from Operational Datastore
- * <p>
- * @param accessListName Access List name
- * @return an AccessListState object that is a list of all classifiers using
- * this access list, null otherwise
- */
- public static AccessListState readAccessListStateExecutor(String accessListName) {
-
- printTraceStart(LOG);
- AccessListState ret = null;
- Object[] functionParamsObj = {accessListName};
- Class[] functionParamsClass = {String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderAclAPI
- .getReadAccessListState(functionParamsObj, functionParamsClass));
- try {
- ret = (AccessListState) future.get();
- LOG.debug("getReadAccessListState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Adds Classifier to Access List state
* <p>
* @param serviceClassifierName Service Classifier name
* @return true if success.
*/
- @SuppressWarnings("unused")
public static boolean addClassifierToAccessListState (String accessListName, String serviceClassifierName) {
printTraceStart(LOG);
return ret;
}
- /**
- * Wrapper API used to add Classifier to Access List state
- * <p>
- * @param accessListName Service Function Classifier name
- * @param serviceClassifierName Rendered Path name
- * @return true if success.
- */
- @SuppressWarnings("unused")
- public static boolean addClassifierToAccessListStateExecutor (String accessListName, String serviceClassifierName) {
-
- printTraceStart(LOG);
- boolean ret = true;
- Object[] functionParams = {accessListName, serviceClassifierName};
- Class[] functionParamsTypes = {String.class, String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderAclAPI
- .getAddClassifierToAccessListStateExecutor(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddClassifierToAccessListStateExecutor returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Deletes Classifier from Access List state
* <p>
* @param serviceClassifierName Service Classifier name
* @return true if success.
*/
- @SuppressWarnings("unused")
public static boolean deleteClassifierFromAccessListState (String accessListName, String serviceClassifierName) {
printTraceStart(LOG);
printTraceStop(LOG);
return ret;
}
-
- /**
- * Wrapper API used to delete Classifier from Access List state
- * <p>
- * @param accessListName Service Function Classifier name
- * @param serviceClassifierName Rendered Path name
- * @return true if success.
- */
- @SuppressWarnings("unused")
- public static boolean deleteClassifierFromAccessListStateExecutor (String accessListName, String serviceClassifierName) {
-
- printTraceStart(LOG);
- boolean ret = true;
- Object[] functionParams = {accessListName, serviceClassifierName};
- Class[] functionParamsTypes = {String.class, String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderAclAPI
- .getDeleteClassifierFromAccessListStateExecutor(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteClassifierFromAccessListStateExecutor returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- }
- printTraceStop(LOG);
- return ret;
- }
}
import java.util.Comparator;
import java.util.List;
import java.util.ListIterator;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicInteger;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
-import org.opendaylight.sfc.provider.SfcReflection;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
* <p>
* @since 2014-11-04
*/
-public class SfcProviderRenderedPathAPI extends SfcProviderAbstractAPI {
+public class SfcProviderRenderedPathAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderRenderedPathAPI.class);
- private static final String FAILED_TO_STR = "failed to ...";
private static final int MAX_STARTING_INDEX = 255;
private static AtomicInteger numCreatedPath = new AtomicInteger(0);
- private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
private static SfcServiceFunctionSchedulerAPI defaultScheduler;
static final Comparator<SfcServiceFunction> SF_ORDER = new Comparator<SfcServiceFunction>() {
try {
serviceFunctionSchedulerType =
- SfcProviderScheduleTypeAPI.readEnabledServiceFunctionScheduleTypeEntryExecutor().getType();
+ SfcProviderScheduleTypeAPI.readEnabledServiceFunctionScheduleTypeEntry().getType();
} catch (Exception e) {
serviceFunctionSchedulerType = Random.class;
}
LOG.info("Selected SF Schdedule Type: {}", serviceFunctionSchedulerType);
}
- @SuppressWarnings("unused")
public static int numCreatedPathGetValue() {
return numCreatedPath.get();
}
return numCreatedPath.incrementAndGet();
}
- @SuppressWarnings("unused")
public int numCreatedPathDecrementGet() {
return numCreatedPath.decrementAndGet();
}
- SfcProviderRenderedPathAPI(Object[] params, String m) {
- super(params, m);
- // initDefaultServiceFunctionScheduler();
- }
-
- SfcProviderRenderedPathAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- // initDefaultServiceFunctionScheduler();
- }
-
- public static SfcProviderRenderedPathAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "readRenderedServicePath");
- }
-
- public static SfcProviderRenderedPathAPI getReadRenderedServicePath(Object[] params, Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "readRenderedServicePath");
- }
-
- public static SfcProviderRenderedPathAPI getCreateRenderedServicePathEntryAPI(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "createRenderedServicePathEntry");
- }
-
- public static SfcProviderRenderedPathAPI getCreateReverseRenderedServicePathEntryAPI(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "createReverseRenderedServicePathEntry");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderRenderedPathAPI getDeleteRenderedServicePath(Object[] params, Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "deleteRenderedServicePath");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderRenderedPathAPI getDeleteRenderedServicePaths(Object[] params, Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "deleteRenderedServicePaths");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderRenderedPathAPI getUpdateRenderedServicePathAPI(Object[] params, Class[] paramsTypes) {
- return new SfcProviderRenderedPathAPI(params, paramsTypes, "updateRenderedServicePathEntry");
- }
-
- @SuppressWarnings("unused")
- /*
- * protected void updateRenderedServicePathEntry (ServiceFunctionPath serviceFunctionPath) {
- * this.createRenderedServicePathEntry(serviceFunctionPath);
- * }
- */
-
- public static RenderedServicePath createRenderedServicePathEntryExecutor(ServiceFunctionPath serviceFunctionPath,
- CreateRenderedPathInput createRenderedPathInput, SfcServiceFunctionSchedulerAPI scheduler) {
- RenderedServicePath ret = null;
- Object[] servicePathObj = {serviceFunctionPath, createRenderedPathInput, scheduler};
- Class[] servicePathClass =
- {ServiceFunctionPath.class, CreateRenderedPathInput.class, SfcServiceFunctionSchedulerAPI.class};
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI =
- SfcProviderRenderedPathAPI.getCreateRenderedServicePathEntryAPI(servicePathObj, servicePathClass);
- Future futureCreateRSP = ODL_SFC.getExecutor().submit(sfcProviderRenderedPathAPI);
- try {
- ret = (RenderedServicePath) futureCreateRSP.get();
- LOG.debug("createRenderedServicePathEntryExecutor: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- return ret;
- }
-
- public static RenderedServicePath createReverseRenderedServicePathEntryExecutor(
- RenderedServicePath renderedServicePath) {
- RenderedServicePath ret = null;
- Object[] servicePathObj = {renderedServicePath};
- Class[] servicePathClass = {RenderedServicePath.class};
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = SfcProviderRenderedPathAPI
- .getCreateReverseRenderedServicePathEntryAPI(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderRenderedPathAPI);
- try {
- ret = (RenderedServicePath) future.get();
- LOG.debug("getCreateRenderedServicePathEntryAPI: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- return ret;
- }
-
/**
* Creates a RSP and all the associated operational state based on the
* given service function path and scheduler
}
// Create RSP
- if ((renderedServicePath = SfcProviderRenderedPathAPI.createRenderedServicePathEntryExecutor(
+ if ((renderedServicePath = SfcProviderRenderedPathAPI.createRenderedServicePathEntry(
createdServiceFunctionPath, createRenderedPathInput, scheduler)) != null) {
rspSuccessful = true;
// Add Path name to SFF operational state
if (rspSuccessful
- && SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(renderedServicePath)) {
+ && SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(renderedServicePath)) {
addPathToSffStateSuccessful = true;
} else {
if (renderedServicePath != null) {
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(renderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName());
}
}
// Add Path to SF operational state
if (addPathToSffStateSuccessful
- && SfcProviderServiceFunctionAPI.addPathToServiceFunctionStateExecutor(renderedServicePath)) {
+ && SfcProviderServiceFunctionAPI.addPathToServiceFunctionState(renderedServicePath)) {
addPathToSfStateSuccessful = true;
} else {
- SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(createdServiceFunctionPath);
+ SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(createdServiceFunctionPath);
if (renderedServicePath != null) {
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(renderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName());
}
}
// Add RSP to SFP operational state
- if (addPathToSfStateSuccessful && SfcProviderServicePathAPI.addRenderedPathToServicePathStateExecutor(
+ if (addPathToSfStateSuccessful && SfcProviderServicePathAPI.addRenderedPathToServicePathState(
createdServiceFunctionPath.getName(), renderedServicePath.getName())) {
addPathtoSfpStateSuccessful = true;
} else {
SfcProviderServiceFunctionAPI
- .deleteServicePathFromServiceFunctionStateExecutor(createdServiceFunctionPath.getName());
- SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(createdServiceFunctionPath);
+ .deleteServicePathFromServiceFunctionState(createdServiceFunctionPath.getName());
+ SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(createdServiceFunctionPath);
if (renderedServicePath != null) {
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(renderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName());
}
}
// Reverse Path
if ((revRenderedServicePath = SfcProviderRenderedPathAPI
- .createReverseRenderedServicePathEntryExecutor(renderedServicePath)) != null) {
+ .createReverseRenderedServicePathEntry(renderedServicePath)) != null) {
revRspSuccessful = true;
} else {
LOG.error("Could not create Reverse RSP {}", renderedServicePath.getName());
// Add Path name to SFF operational state
if (revRspSuccessful
- && SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(revRenderedServicePath)) {
+ && SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(revRenderedServicePath)) {
addRevPathToSffStateSuccessul = true;
} else {
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(revRenderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(revRenderedServicePath.getName());
}
// Add Path to SF operational state
if (addRevPathToSffStateSuccessul
- && SfcProviderServiceFunctionAPI.addPathToServiceFunctionStateExecutor(revRenderedServicePath)) {
+ && SfcProviderServiceFunctionAPI.addPathToServiceFunctionState(revRenderedServicePath)) {
addRevPathToSfStateSuccessul = true;
// Send to SB REST
*/
} else {
SfcProviderServiceForwarderAPI
- .deletePathFromServiceForwarderStateExecutor(revRenderedServicePath.getName());
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(revRenderedServicePath.getName());
+ .deletePathFromServiceForwarderState(revRenderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(revRenderedServicePath.getName());
}
// Add RSP to SFP operational state
- if (addRevPathToSfStateSuccessul && SfcProviderServicePathAPI.addRenderedPathToServicePathStateExecutor(
+ if (addRevPathToSfStateSuccessul && SfcProviderServicePathAPI.addRenderedPathToServicePathState(
renderedServicePath.getParentServiceFunctionPath(), revRenderedServicePath.getName())) {
addRevPathToSfpStateSuccessul = true;
} else {
SfcProviderServiceFunctionAPI
- .deleteServicePathFromServiceFunctionStateExecutor(revRenderedServicePath.getName());
+ .deleteServicePathFromServiceFunctionState(revRenderedServicePath.getName());
SfcProviderServiceForwarderAPI
- .deletePathFromServiceForwarderStateExecutor(revRenderedServicePath.getName());
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(revRenderedServicePath.getName());
+ .deletePathFromServiceForwarderState(revRenderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(revRenderedServicePath.getName());
}
return revRenderedServicePath;
* @param serviceIndex Starting index
* @return List of {@link RenderedServicePathHop}
*/
- protected List<RenderedServicePathHop> createRenderedServicePathHopList(List<String> serviceFunctionNameList,
+ protected static List<RenderedServicePathHop> createRenderedServicePathHopList(List<String> serviceFunctionNameList,
List<String> sfgNameList, int serviceIndex) {
List<RenderedServicePathHop> renderedServicePathHopArrayList = new ArrayList<>();
RenderedServicePathHopBuilder renderedServicePathHopBuilder = new RenderedServicePathHopBuilder();
if (sfgNameList != null) {
boolean loopBroken = false;
for (String sfgName : sfgNameList) {
- ServiceFunctionGroup sfg = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroupExecutor(sfgName);
+ ServiceFunctionGroup sfg = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(sfgName);
if (sfg == null) {
LOG.error("Could not find suitable SFG in data store by name: {}", sfgName);
loopBroken = true;
break;
}
ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI
- .readServiceFunctionExecutor(sfg.getSfcServiceFunction().get(0).getName());
+ .readServiceFunction(sfg.getSfcServiceFunction().get(0).getName());
if (serviceFunction == null) {
LOG.error("Could not find suitable SF in data store by name: {}",
sfg.getSfcServiceFunction().get(0).getName());
} else {
for (String serviceFunctionName : serviceFunctionNameList) {
ServiceFunction serviceFunction =
- SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(serviceFunctionName);
+ SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionName);
if (serviceFunction == null) {
LOG.error("Could not find suitable SF in data store by name: {}", serviceFunctionName);
return null;
return renderedServicePathHopArrayList;
}
- private void createSFHopBuilder(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
+ private static void createSFHopBuilder(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
short posIndex, String serviceFunctionName, ServiceFunction serviceFunction) {
createHopBuilderInternal(serviceIndex, renderedServicePathHopBuilder, posIndex, serviceFunction);
renderedServicePathHopBuilder.setServiceFunctionName(serviceFunctionName);
}
- private void createSFGHopBuilder(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
+ private static void createSFGHopBuilder(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
short posIndex, String serviceFunctionGroupName, ServiceFunction serviceFunction) {
createHopBuilderInternal(serviceIndex, renderedServicePathHopBuilder, posIndex, serviceFunction);
renderedServicePathHopBuilder.setServiceFunctionGroupName(serviceFunctionGroupName);
}
- private void createHopBuilderInternal(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
+ private static void createHopBuilderInternal(int serviceIndex, RenderedServicePathHopBuilder renderedServicePathHopBuilder,
short posIndex, ServiceFunction serviceFunction) {
String serviceFunctionForwarderName =
serviceFunction.getSfDataPlaneLocator().get(0).getServiceFunctionForwarder();
ServiceFunctionForwarder serviceFunctionForwarder =
- SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(serviceFunctionForwarderName);
+ SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(serviceFunctionForwarderName);
if (serviceFunctionForwarder != null && serviceFunctionForwarder.getSffDataPlaneLocator() != null
&& serviceFunctionForwarder.getSffDataPlaneLocator().get(0) != null) {
renderedServicePathHopBuilder
* @param scheduler SfcServiceFunctionSchedulerAPI object
* @return RenderedServicePath
*/
- protected RenderedServicePath createRenderedServicePathEntry(ServiceFunctionPath serviceFunctionPath,
+ protected static RenderedServicePath createRenderedServicePathEntry(ServiceFunctionPath serviceFunctionPath,
CreateRenderedPathInput createRenderedPathInput, SfcServiceFunctionSchedulerAPI scheduler) {
printTraceStart(LOG);
* @param renderedServicePath RSP object
* @return Nothing
*/
- @SfcReflection
- public RenderedServicePath createReverseRenderedServicePathEntry(RenderedServicePath renderedServicePath) {
+ public static RenderedServicePath createReverseRenderedServicePathEntry(RenderedServicePath renderedServicePath) {
RenderedServicePath ret = null;
String revPathName;
}
- @SuppressWarnings("unused")
- public static RenderedServicePath readRenderedServicePathExecutor(String rspName) {
-
- printTraceStart(LOG);
- RenderedServicePath ret = null;
-
- Object[] rspNameObj = {rspName};
- Class[] rspNameClass = {String.class};
-
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI =
- SfcProviderRenderedPathAPI.getReadRenderedServicePath(rspNameObj, rspNameClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderRenderedPathAPI);
- try {
- ret = (RenderedServicePath) future.get();
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- return ret;
- }
-
/**
* This function reads a RSP from the datastore
* <p>
* @param servicePaths SffServicePath object
* @return Nothing.
*/
- @SuppressWarnings("unused")
- @SfcReflection
public static boolean deleteRenderedServicePaths(List<String> servicePaths) {
printTraceStart(LOG);
return ret;
}
- /**
- * Wrapper API to deletes a list of Service Paths. It includes Executor creation
- * and response management
- * <p>
- *
- * @param servicePaths SffServicePath object
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static boolean deleteRenderedServicePathsExecutor(List<String> servicePaths) {
-
- printTraceStart(LOG);
- boolean ret = true;
-
- // SFF deletion is a critical event. If a SFF is deleted we delete all associated SFPs
- Object[] servicePathObj = {servicePaths};
- Class[] servicePathClass = {List.class};
-
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI =
- SfcProviderRenderedPathAPI.getDeleteRenderedServicePaths(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderRenderedPathAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteRenderedServicePaths: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- return ret;
- }
-
/**
* This method deletes a RSP from the datastore and frees the Path ID
* <p>
return ret;
}
- /**
- * This method is an executor wrapper around a method that
- * deletes a RSP from the datastore
- * <p>
- *
- * @param renderedServicePathName RSP name
- * @return Nothing.
- */
- public static boolean deleteRenderedServicePathExecutor(String renderedServicePathName) {
- boolean ret = false;
- printTraceStart(LOG);
- Object[] servicePathObj = {renderedServicePathName};
- Class[] servicePathClass = {String.class};
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI =
- SfcProviderRenderedPathAPI.getDeleteRenderedServicePath(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderRenderedPathAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteRenderedServicePath: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- if (!ret) {
- LOG.error("{}: Failed to delete RSP {}", Thread.currentThread().getStackTrace()[1],
- renderedServicePathName);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method provides all necessary information for a system to construct
* a NSH header and associated overlay packet to target the first
}
/* Read service chain sfcName if it exists */
- serviceFunctionChain = SfcProviderServiceChainAPI.readServiceFunctionChainExecutor(sfcName);
+ serviceFunctionChain = SfcProviderServiceChainAPI.readServiceFunctionChain(sfcName);
/* Create service chain sfcName if it doesn't exist */
if (serviceFunctionChain == null) {
ServiceFunctionChainBuilder sfcBuilder = new ServiceFunctionChainBuilder();
sfcBuilder.setName(sfcName).setSfcServiceFunction(sfcServiceFunctionArrayList);
serviceFunctionChain = sfcBuilder.build();
- ret = SfcProviderServiceChainAPI.putServiceFunctionChainExecutor(serviceFunctionChain);
+ ret = SfcProviderServiceChainAPI.putServiceFunctionChain(serviceFunctionChain);
if (ret == false) {
LOG.error("Failed to create ServiceFunctionChain: {}", sfcName);
return null;
}
/* Read ServiceFunctionPath pathName if it exists */
- ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPathExecutor(pathName);
+ ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(pathName);
/* Create ServiceFunctionPath pathName if it doesn't exist */
if (serviceFunctionPath == null) {
ServiceFunctionPathBuilder pathBuilder = new ServiceFunctionPathBuilder();
pathBuilder.setName(pathName).setServiceChainName(sfcName);
serviceFunctionPath = pathBuilder.build();
- ret = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath);
+ ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath);
if (ret == false) {
LOG.error("Failed to create ServiceFunctionPath: {}", pathName);
return null;
}
if ((serviceFunctionPath.getClassifier() != null) && SfcProviderServiceClassifierAPI
- .readServiceClassifierExecutor(serviceFunctionPath.getClassifier()) != null) {
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(
+ .readServiceClassifier(serviceFunctionPath.getClassifier()) != null) {
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState(
serviceFunctionPath.getClassifier(), renderedServicePath.getName());
} else {
LOG.warn("Classifier not provided or does not exist");
if (revRenderedServicePath == null) {
LOG.error("Failed to create symmetric RenderedServicePath for ServiceFunctionPath: {}", pathName);
} else if ((serviceFunctionPath.getSymmetricClassifier() != null) && SfcProviderServiceClassifierAPI
- .readServiceClassifierExecutor(serviceFunctionPath.getSymmetricClassifier()) != null) {
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(
+ .readServiceClassifier(serviceFunctionPath.getSymmetricClassifier()) != null) {
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState(
serviceFunctionPath.getSymmetricClassifier(), revRenderedServicePath.getName());
} else {
LOG.warn("Symmetric Classifier not provided or does not exist");
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypeIdentity;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypes;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerType;
* @version 0.1
* @since 2015-03-20
*/
-public class SfcProviderScheduleTypeAPI extends SfcProviderAbstractAPI {
+public class SfcProviderScheduleTypeAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderScheduleTypeAPI.class);
- private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- SfcProviderScheduleTypeAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderScheduleTypeAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- public static SfcProviderScheduleTypeAPI getPut(Object[] params, Class[] paramsTypes) {
- return new SfcProviderScheduleTypeAPI(params, paramsTypes, "putServiceFunctionScheduleType");
- }
-
- public static SfcProviderScheduleTypeAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderScheduleTypeAPI(params, paramsTypes, "readServiceFunctionScheduleType");
- }
-
- public static SfcProviderScheduleTypeAPI getDelete(Object[] params, Class[] paramsTypes) {
- return new SfcProviderScheduleTypeAPI(params, paramsTypes, "deleteServiceFunctionScheduleType");
- }
-
- public static SfcProviderScheduleTypeAPI getReadAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderScheduleTypeAPI(params, paramsTypes, "readAllServiceFunctionScheduleTypes");
- }
-
- /**
- * This method puts service function schedule type.
- *
- * @return True if ST was put, false otherwise
- */
- public static boolean putServiceFunctionScheduleTypeExecutor(
- ServiceFunctionSchedulerType serviceFunctionSchedulerType) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionSchedulerType};
- Class[] servicePathClass = {ServiceFunctionSchedulerType.class};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI =
- SfcProviderScheduleTypeAPI.getPut(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderScheduleTypeAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServiceFunctionState: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method deletes service function schedule type.
- *
- * @return True if ST was deleted, false otherwise
- */
- public static boolean deleteServiceFunctionScheduleTypeExecutor(
- Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerType) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionSchedulerType};
- Class[] servicePathClass = {serviceFunctionSchedulerType.getClass()};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI =
- SfcProviderScheduleTypeAPI.getDelete(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderScheduleTypeAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServiceFunctionState: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method reads service function schedule type.
- *
- * @return If ST was read successfully, returns that ST
- */
- public static ServiceFunctionSchedulerType readServiceFunctionScheduleTypeExecutor(
- Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerType) {
- printTraceStart(LOG);
+ public static ServiceFunctionSchedulerType readEnabledServiceFunctionScheduleTypeEntry() {
ServiceFunctionSchedulerType ret = null;
- Object[] servicePathObj = {serviceFunctionSchedulerType};
- Class[] servicePathClass = {serviceFunctionSchedulerType.getClass()};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI =
- SfcProviderScheduleTypeAPI.getRead(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderScheduleTypeAPI);
- try {
- ret = (ServiceFunctionSchedulerType) future.get();
- LOG.debug("getDeleteServiceFunctionState: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- public static ServiceFunctionSchedulerType readEnabledServiceFunctionScheduleTypeEntryExecutor() {
- ServiceFunctionSchedulerType ret = null;
- Object[] sfstObj = {};
- Class[] sfstClass = {};
-
printTraceStart(LOG);
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI =
- SfcProviderScheduleTypeAPI.getReadAll(sfstObj, sfstClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderScheduleTypeAPI);
- try {
- LOG.debug("getReadAll returns: {}", future.get());
- ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes = (ServiceFunctionSchedulerTypes) future.get();
- List<ServiceFunctionSchedulerType> sfScheduleTypeList =
- serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
- for (ServiceFunctionSchedulerType serviceFunctionSchedulerType : sfScheduleTypeList) {
- if (serviceFunctionSchedulerType.isEnabled()) {
- ret = serviceFunctionSchedulerType;
- break;
- }
+ ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes =
+ SfcProviderScheduleTypeAPI.readAllServiceFunctionScheduleTypes();
+ List<ServiceFunctionSchedulerType> sfScheduleTypeList =
+ serviceFunctionSchedulerTypes.getServiceFunctionSchedulerType();
+ for (ServiceFunctionSchedulerType serviceFunctionSchedulerType : sfScheduleTypeList) {
+ if (serviceFunctionSchedulerType.isEnabled()) {
+ ret = serviceFunctionSchedulerType;
+ break;
}
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
}
-
printTraceStop(LOG);
return ret;
}
- protected boolean putServiceFunctionScheduleType(ServiceFunctionSchedulerType serviceFunctionSchedulerType) {
+ public static boolean putServiceFunctionScheduleType(ServiceFunctionSchedulerType serviceFunctionSchedulerType) {
boolean ret;
printTraceStart(LOG);
return ret;
}
- protected boolean deleteServiceFunctionScheduleType(
+ public static boolean deleteServiceFunctionScheduleType(
Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerType) {
printTraceStart(LOG);
boolean ret = false;
return ret;
}
- protected ServiceFunctionSchedulerType readServiceFunctionScheduleType(
+ public static ServiceFunctionSchedulerType readServiceFunctionScheduleType(
Class<? extends ServiceFunctionSchedulerTypeIdentity> serviceFunctionSchedulerTypeIdentity) {
printTraceStart(LOG);
ServiceFunctionSchedulerType serviceFunctionSchedulerType;
return serviceFunctionSchedulerType;
}
- protected ServiceFunctionSchedulerTypes readAllServiceFunctionScheduleTypes() {
+ public static ServiceFunctionSchedulerTypes readAllServiceFunctionScheduleTypes() {
ServiceFunctionSchedulerTypes serviceFunctionSchedulerTypes;
printTraceStart(LOG);
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainsState;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
* @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
* @since 2014-06-30
*/
-public class SfcProviderServiceChainAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceChainAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceChainAPI.class);
- private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- private static final String FAILED_TO_STR = "failed to ...";
-
- 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");
- }
-
- public static SfcProviderServiceChainAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceChainAPI(params, paramsTypes, "deleteAllServiceFunctionChains");
- }
-
- public static SfcProviderServiceChainAPI getSfcRef(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceChainAPI(params, paramsTypes, "getServiceFunctionChainsRef");
- }
-
- public static SfcProviderServiceChainAPI getSfcStateRef(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceChainAPI(params, paramsTypes, "getServiceFunctionChainsStateRef");
- }
-
- /**
- * This method creates a service chain by Executor, it includes
- * Executor creation and response management.
- *
- * @param serviceFunctionChain a ServiceFunctionChain object
- * @return true if serviceFunctionChain was created, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean putServiceFunctionChainExecutor(ServiceFunctionChain serviceFunctionChain) {
- boolean ret = false;
- Object[] sfcParameters = {serviceFunctionChain};
- Class[] sfcParameterTypes = {ServiceFunctionChain.class};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServiceChainAPI.getPut(sfcParameters, sfcParameterTypes))
- .get();
- ret = (boolean) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
/**
* This method reads the service function chain specified by the given name from
return sfc;
}
- /**
- * This method reads the operational state for a service function.
- *
- * @param serviceFunctionName SF name
- * @return A ServiceFunctionState object that is a list of all paths using
- * this service function, null otherwise
- */
- public static ServiceFunctionChain readServiceFunctionChainExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- ServiceFunctionChain ret = null;
- Object[] servicePathObj = {serviceFunctionName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceChainAPI sfcProviderServiceChainAPI =
- SfcProviderServiceChainAPI.getRead(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceChainAPI);
- try {
- ret = (ServiceFunctionChain) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method deletes a single service path name from the Service Function
* Chain operational data store
* @return A ServiceFunctionState object that is a list of all paths using
* this service function, null otherwise
*/
- @SuppressWarnings("unused")
public static boolean deletePathFromServiceFunctionChainState(String serviceFunctionChainName,
String servicePathName) {
* @return A ServiceFunctionState object that is a list of all paths using
* this service function, null otherwise
*/
- @SuppressWarnings("unused")
public static boolean addPathToServiceFunctionChainState(String serviceFunctionChainName, String servicePathName) {
printTraceStart(LOG);
return ret;
}
- public static ServiceFunctionChains getServiceFunctionChainsRefExecutor() {
- printTraceStart(LOG);
- ServiceFunctionChains ret = null;
- Object[] servicePathObj = {};
- Class[] servicePathClass = {};
- SfcProviderServiceChainAPI sfcProviderServiceChainAPI =
- SfcProviderServiceChainAPI.getSfcRef(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceChainAPI);
- try {
- ret = (ServiceFunctionChains) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- public static ServiceFunctionChainsState getServiceFunctionChainsStateRefExecutor() {
- printTraceStart(LOG);
- ServiceFunctionChainsState ret = null;
- Object[] servicePathObj = {};
- Class[] servicePathClass = {};
- SfcProviderServiceChainAPI sfcProviderServiceChainAPI =
- SfcProviderServiceChainAPI.getSfcStateRef(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceChainAPI);
- try {
- ret = (ServiceFunctionChainsState) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method creates a SFC from the datastore.
*
* @param serviceFunctionChain SFC object
* @return true if SFC was created, false otherwise
*/
- protected boolean putServiceFunctionChain(ServiceFunctionChain serviceFunctionChain) {
+ public static boolean putServiceFunctionChain(ServiceFunctionChain serviceFunctionChain) {
boolean ret = false;
printTraceStart(LOG);
* @param serviceFunctionChainName SFC name
* @return true if SF was deleted, false otherwise
*/
- @SuppressWarnings("unused")
- protected boolean deleteServiceFunctionChain(String serviceFunctionChainName) {
+ protected static boolean deleteServiceFunctionChain(String serviceFunctionChainName) {
boolean ret = false;
printTraceStart(LOG);
ServiceFunctionChainKey serviceFunctionChainKey = new ServiceFunctionChainKey(serviceFunctionChainName);
* @return A ServiceFunctionState object that is a list of all paths using
* this service function, null otherwise
*/
- @SuppressWarnings("unused")
- protected boolean putAllServiceFunctionChains(ServiceFunctionChains sfcs) {
+ protected static boolean putAllServiceFunctionChains(ServiceFunctionChains sfcs) {
boolean ret = false;
printTraceStart(LOG);
*
* @return ServiceFunctionChains A object that contains all Service Functions Object
*/
- @SuppressWarnings("unused")
- protected ServiceFunctionChains readAllServiceFunctionChains() {
+ protected static ServiceFunctionChains readAllServiceFunctionChains() {
ServiceFunctionChains sfcs;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionChains> sfcsIID =
return ret;
}
- public ServiceFunctionChains getServiceFunctionChainsRef() {
+ public static ServiceFunctionChains getServiceFunctionChainsRef() {
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionChains> sfcsIID;
return sfc;
}
- protected ServiceFunctionChainsState getServiceFunctionChainsStateRef() {
+ protected static ServiceFunctionChainsState getServiceFunctionChainsStateRef() {
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionChainsState> sfcsIID;
package org.opendaylight.sfc.provider.api;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.SfcReflection;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.ServiceFunctionClassifiers;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.ServiceFunctionClassifiersState;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.ServiceFunctionClassifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-
/**
* This class has the APIs to operate on the Service Classifier datastore.
* <p>
* @since 2014-11-04
*/
-public class SfcProviderServiceClassifierAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceClassifierAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceClassifierAPI.class);
- private static final String FAILED_TO_STR = "failed to ...";
-
- SfcProviderServiceClassifierAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderServiceClassifierAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
-
- public static SfcProviderServiceClassifierAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceClassifierAPI(params, paramsTypes, "readServiceClassifier");
- }
-
- public static SfcProviderServiceClassifierAPI getAddRenderedPathToServiceClassifierStateExecutor
- (Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceClassifierAPI(params, paramsTypes, "addRenderedPathToServiceClassifierState");
- }
/**
* We iterate through all service paths that use this service function and if
* @param renderedPathName Rendered Path name
* @return Nothing.
*/
- @SuppressWarnings("unused")
- public static boolean addRenderedPathToServiceClassifierState (String serviceClassifierName, String renderedPathName) {
+ public static boolean addRenderedPathToServiceClassifierState(String serviceClassifierName, String renderedPathName) {
printTraceStart(LOG);
InstanceIdentifier<SclRenderedServicePath> sclIID;
return ret;
}
- /**
- * We iterate through all service paths that use this service function and if
- * necessary, remove them.
- * <p>
- * @param serviceClassifierName Service Function Classifier name
- * @param renderedPathName Rendered Path name
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static boolean addRenderedPathToServiceClassifierStateExecutor (String serviceClassifierName, String renderedPathName) {
-
- printTraceStart(LOG);
- boolean ret = true;
- Object[] functionParams = {serviceClassifierName, renderedPathName};
- Class[] functionParamsTypes = {String.class, String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceClassifierAPI
- .getAddRenderedPathToServiceClassifierStateExecutor(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddRenderedPathToServiceClassifierStateExecutor returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method reads a classifier from DataStore
* <p>
* @param serviceClassifierName Classifier name
* @return SF object or null if not found
*/
- @SuppressWarnings("unused")
- @SfcReflection
- protected ServiceFunctionClassifier readServiceClassifier(String serviceClassifierName) {
+ public static ServiceFunctionClassifier readServiceClassifier(String serviceClassifierName) {
printTraceStart(LOG);
ServiceFunctionClassifier scl;
InstanceIdentifier<ServiceFunctionClassifier> sclIID;
}
- /**
- * Wrapper API to reads a service function classifier from datastore
- * <p>
- * @param serviceClassifierName Service Classifier Name
- * @return A ServiceFunctionState object that is a list of all paths using
- * this service function, null otherwise
- */
- public static ServiceFunctionClassifier readServiceClassifierExecutor(String serviceClassifierName) {
-
- printTraceStart(LOG);
- ServiceFunctionClassifier ret = null;
- Object[] servicePathObj = {serviceClassifierName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceClassifierAPI sfcProviderServiceClassifierAPI = SfcProviderServiceClassifierAPI
- .getRead(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceClassifierAPI);
- try {
- ret = (ServiceFunctionClassifier) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
}
package org.opendaylight.sfc.provider.api;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
-import org.opendaylight.sfc.provider.SfcReflection;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+import com.google.common.base.Preconditions;
/**
* This class has the APIs to operate on the ServiceFunction
* <p>
* @since 2014-06-30
*/
-public class SfcProviderServiceForwarderAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceForwarderAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceForwarderAPI.class);
- private static final String FAILED_TO_STR = "failed to ...";
-
-
- 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 getReadSffState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "readSffState");
- }
- @SuppressWarnings("unused")
- public static SfcProviderServiceForwarderAPI getDelete(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteServiceFunctionForwarder");
- }
- @SuppressWarnings("unused")
- public static SfcProviderServiceForwarderAPI getPutAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "putAllServiceFunctionForwarders");
- }
- @SuppressWarnings("unused")
- 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");
- }
- @SuppressWarnings("unused")
- public static SfcProviderServiceForwarderAPI getDeleteServiceFunctionFromForwarder(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteServiceFunctionFromForwarder");
- }
- public static SfcProviderServiceForwarderAPI getCheckServiceForwarderAPI(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "checkServiceFunctionForwarder");
- }
- public static SfcProviderServiceForwarderAPI getUpdate(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "updateServiceFunctionForwarder");
- }
- public static SfcProviderServiceForwarderAPI getAddPathToServiceForwarderState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "addPathToServiceForwarderState");
- }
- public static SfcProviderServiceForwarderAPI getDeletePathFromServiceForwarderState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deletePathFromServiceForwarderState");
- }
- public static SfcProviderServiceForwarderAPI getDeletePathsUsedByServiceForwarder(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteRenderedPathsUsedByServiceForwarder");
- }
- public static SfcProviderServiceForwarderAPI getDeleteServiceFunctionForwarderState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteServiceFunctionForwarderState");
- }
- public static SfcProviderServiceForwarderAPI getDeleteSffDataPlaneLocator(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceForwarderAPI(params, paramsTypes, "deleteSffDataPlaneLocator");
- }
/**
* This method creates a SFF in the data store
* @param sff SFF object
* @return true if SFF was created, false otherwise
*/
- protected boolean putServiceFunctionForwarder(ServiceFunctionForwarder sff) {
+ public static boolean putServiceFunctionForwarder(ServiceFunctionForwarder sff) {
boolean ret;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionForwarder> sffEntryIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class).
return ret;
}
- /**
- * Creates a executor and calls appropriate function
- * to put SFF into DataStore
- *
- * <p>
- * @param serviceFunctionForwarder Service Function Forwarder Object
- * @return Nothing.
- */
- public static boolean putServiceFunctionForwarderExecutor(ServiceFunctionForwarder serviceFunctionForwarder) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionForwarder};
- Class[] servicePathClass = {ServiceFunctionForwarder.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getPut(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getPut: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* This method searches for a data plane locator of a given name within a SFF
* <p>
* @param sffLocatorName SffDataPlaneLocator name
* @return true if SffDataPlane locator was deleted, false otherwise
*/
- protected boolean deleteSffDataPlaneLocator(String sffName, String sffLocatorName) {
+ protected static boolean deleteSffDataPlaneLocator(String sffName, String sffLocatorName) {
boolean ret = false;
printTraceStart(LOG);
return ret;
}
- /**
- * Creates a executor and calls appropriate function
- * to delete SffDataPlaneLocator from SFF stored in configuraiton DataStore
- *
- * <p>
- * @param sffName SFF name
- * @param sffLocatorName SffDataPlaneLocator name
- * @return true if SffDataPlane locator was deleted, false otherwise
- */
- public static boolean deleteSffDataPlaneLocatorExecutor(String sffName, String sffLocatorName) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] methodObjects = {sffName, sffLocatorName};
- Class[] methodClasses = {String.class, String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeleteSffDataPlaneLocator(methodObjects, methodClasses);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteSffDataPlaneLocator: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method reads a SFF from the datastore
* <p>
* @param serviceFunctionForwarderName SFF name
* @return true if SF was deleted, false otherwise
*/
- protected boolean deleteServiceFunctionForwarder(String serviceFunctionForwarderName) {
+ public static boolean deleteServiceFunctionForwarder(String serviceFunctionForwarderName) {
boolean ret = false;
printTraceStart(LOG);
ServiceFunctionForwarderKey serviceFunctionForwarderKey = new ServiceFunctionForwarderKey(serviceFunctionForwarderName);
return ret;
}
- /**
- * Creates a executor and calls appropriate function
- * to delete SFF from DataStore
- *
- * <p>
- * @param serviceFunctionForwarderName Service Function Forwarder Name
- * @return Nothing.
- */
- public static boolean deleteServiceFunctionForwarderExecutor(String serviceFunctionForwarderName) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionForwarderName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDelete(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDelete: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Put all Service Function Forwarders in the data store
*
* <p>
* @return true is all SFFs were created, false otherwise
*/
- protected boolean putAllServiceFunctionForwarders(ServiceFunctionForwarders sffs) {
+ public static boolean putAllServiceFunctionForwarders(ServiceFunctionForwarders sffs) {
boolean ret;
printTraceStart(LOG);
return ret;
}
- /**
- * Creates a wrapper executor around a method to add a ServiceFunctionForwarder
- * object to into DataStore
- *
- * <p>
- * @param serviceFunctionForwarders Service Function Forwarders Object
- * @return Nothing.
- */
- public static boolean putAllServiceFunctionForwardersExecutor(ServiceFunctionForwarders serviceFunctionForwarders) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionForwarders};
- Class[] servicePathClass = {ServiceFunctionForwarders.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getPutAll(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("putAllServiceFunctionForwardersExecutor: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Read all Service Function Forwarders
* devices
* <p>
* @return ServiceFunctionForwarders object
*/
- protected ServiceFunctionForwarders readAllServiceFunctionForwarders() {
+ protected static ServiceFunctionForwarders readAllServiceFunctionForwarders() {
ServiceFunctionForwarders sffs;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
return sffs;
}
- /**
- * This method creates an executor and reads all the Service Function
- * Forwarders from SFC datastore
- * <p>
- * @return ServiceFunctionForwarders object including all Service Function
- * Forwarders
- */
- public static ServiceFunctionForwarders readAllServiceFunctionForwardersExecutor() {
- printTraceStart(LOG);
- ServiceFunctionForwarders ret = null;
- Object[] servicePathObj = {};
- Class[] servicePathClass = {};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getReadAll(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (ServiceFunctionForwarders) future.get();
- LOG.debug("getReadAll: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Delete All Service Function Forwarders in the data store
* devices
protected boolean deleteAllServiceFunctionForwarders() {
boolean ret = false;
printTraceStart(LOG);
- if (ODL_SFC.getDataProvider() != null) {
-
- InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
- InstanceIdentifier.builder(ServiceFunctionForwarders.class).build();
-
- if (SfcDataStoreAPI.deleteTransactionAPI(sffsIID, LogicalDatastoreType.CONFIGURATION)) {
- ret = true;
- }
+ InstanceIdentifier<ServiceFunctionForwarders> sffsIID =
+ InstanceIdentifier.builder(ServiceFunctionForwarders.class).build();
+ if (SfcDataStoreAPI.deleteTransactionAPI(sffsIID, LogicalDatastoreType.CONFIGURATION)) {
+ ret = true;
}
printTraceStop(LOG);
return ret;
* @param serviceFunctionForwarder ServiceFunctionForwarder object
* @return true if SFF was updated, false otherwise
*/
- public boolean updateServiceFunctionForwarder(ServiceFunctionForwarder serviceFunctionForwarder) {
+ public static boolean updateServiceFunctionForwarder(ServiceFunctionForwarder serviceFunctionForwarder) {
printTraceStart(LOG);
Preconditions.checkNotNull(serviceFunctionForwarder);
return ret;
}
- /**
- * Creates a executor and calls appropriate function to update
- * SFF configuration
- *
- * <p>
- * @param serviceFunctionForwarder Service Function Forwarder Object
- * @return true if SFF was updated, false otherwise.
- */
- public static boolean updateServiceFunctionForwarderExecutor(ServiceFunctionForwarder serviceFunctionForwarder) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] serviceForwarderObject = {serviceFunctionForwarder};
- Class[] serviceForwarderClass = {ServiceFunctionForwarder.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getUpdate(serviceForwarderObject, serviceForwarderClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getUpdate: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* We add the path name to the operational store of each SFF.
*
* @param pathName Service Function Path Object
* @return Nothing.
*/
- public boolean addPathToServiceForwarderState(String pathName) {
+ public static boolean addPathToServiceForwarderState(String pathName) {
printTraceStart(LOG);
* @param renderedServicePath RSP Object
* @return Nothing.
*/
- public boolean addPathToServiceForwarderState(RenderedServicePath renderedServicePath) {
+ public static boolean addPathToServiceForwarderState(RenderedServicePath renderedServicePath) {
printTraceStart(LOG);
return ret;
}
- /**
- * We add the path name to the operational store of each SFF.
- *
- * <p>
- * @param pathName Service Function Path Object
- * @return Nothing.
- */
- public static boolean addPathToServiceForwarderStateExecutor(String pathName) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {pathName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getAddPathToServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddPathToServiceForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * We add the path name to the operational store of each SFF.
- *
- * <p>
- * @param renderedServicePath RSP Object
- * @return Nothing.
- */
- public static boolean addPathToServiceForwarderStateExecutor(RenderedServicePath renderedServicePath) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {renderedServicePath};
- Class[] servicePathClass = {RenderedServicePath.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getAddPathToServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddPathToServiceForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* When a SFF is deleted we need to delete all SFPs from the
* associated SFF operational state
* @param serviceFunctionPath SFP object
* @return true if all paths were deleted, false otherwise.
*/
- @SuppressWarnings("unused")
- public boolean deletePathFromServiceForwarderState(ServiceFunctionPath serviceFunctionPath) {
+ public static boolean deletePathFromServiceForwarderState(ServiceFunctionPath serviceFunctionPath) {
printTraceStart(LOG);
return ret;
}
- /**
- * Creates a executor and calls appropriate function to to remove
- * SFF operational state for given Service Path
- *
- * <p>
- * @param serviceFunctionPath Service Function Path Object
- * @return Nothing.
- */
- public static boolean deletePathFromServiceForwarderStateExecutor(ServiceFunctionPath serviceFunctionPath) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {serviceFunctionPath};
- Class[] servicePathClass = {ServiceFunctionPath.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeletePathFromServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeletePathFromServiceForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * Creates a executor and calls appropriate function to to remove
- * the given list of service paths from SFF operational state
- *
- * <p>
- * @param servicePaths String List of Service Path names
- * @return True if paths were deleted, false otherwise
- */
- public static boolean deletePathFromServiceForwarderStateExecutor(List<String> servicePaths) {
-
- printTraceStart(LOG);
- boolean ret = false;
-
- Object[] servicePathObj = {servicePaths};
- Class[] servicePathClass = {List.class};
-
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeletePathFromServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeletePathFromServiceForwarderState: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- return ret;
- }
-
-
- /**
- * Creates a executor and calls appropriate function to to remove
- * SFF operational state for given Service Path
- *
- * <p>
- * @param rspName Service Function Path Object
- * @return Nothing.
- */
- public static boolean deletePathFromServiceForwarderStateExecutor(String rspName) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {rspName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeletePathFromServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeletePathFromServiceForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* When a SFF is deleted we need to delete all SFPs from the
* associated SFF operational state
* @param rspName SFP object
* @return true if all path was deleted, false otherwise.
*/
- @SuppressWarnings("unused")
- @SfcReflection
public static boolean deletePathFromServiceForwarderState(String rspName) {
printTraceStart(LOG);
return ret;
}
- /**
- * This method deletes the operational state for the given SFF name.
- * <p>
- * @param sffName SFF name
- * @return true if state was deletes, false otherwise
- */
- public static boolean deleteServiceFunctionForwarderStateExecutor(String sffName) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {sffName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeleteServiceFunctionForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServiceFunctionForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Returns the list of SFPs anchored by a SFF
*
return ret;
}
- /**
- * Wrapper API to read the list of SFPs anchored by the given SFF name. It
- * includes Executor creation and response management
- *
- * <p>
- * @param sffName SFF name
- * @return ServiceFunctionState.
- */
- public static List<SffServicePath> readSffStateExecutor(String sffName) {
- printTraceStart(LOG);
- List<SffServicePath> ret = null;
-
- // SFF deletion is a critical event. If a SFF is deleted we delete all associated SFPs
- Object[] serviceForwarderObj = {sffName};
- Class[] serviceForwarderClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getReadSffState(serviceForwarderObj, serviceForwarderClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (List<SffServicePath>) future.get();
- LOG.debug("getReadSffState: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- return ret;
- }
-
- /**
- * Wrapper API to read a SFF given the SFF name. It
- * includes Executor creation and response management
- *
- * <p>
- * @param sffName SFF name
- * @return ServiceFunctionForwarder.
- */
- public static ServiceFunctionForwarder readServiceFunctionForwarderExecutor(String sffName) {
- printTraceStart(LOG);
- ServiceFunctionForwarder ret = null;
-
- Object[] serviceFunctionForwarderObj = {sffName};
- Class[] serviceFunctionForwarderClass = {String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceFunctionForwarderAPI = SfcProviderServiceForwarderAPI
- .getRead(serviceFunctionForwarderObj, serviceFunctionForwarderClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionForwarderAPI);
- try {
- ret = (ServiceFunctionForwarder) future.get();
- LOG.debug("getReadServiceFunctionForwarder: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- return ret;
- }
-
/**
* Deletes all RSPs used by the given SFF object
*
* @param serviceFunctionForwarder SFF Object
* @return true if all RSPs were deleted, false otherwise
*/
- @SuppressWarnings("unused")
- @SfcReflection
public static boolean deleteRenderedPathsUsedByServiceForwarder(ServiceFunctionForwarder serviceFunctionForwarder) {
printTraceStart(LOG);
}
/**
- * Attaches the path name to the operational store of each SFF.
- *
- * <p>
- * @param sfpName SF name
- * @param sffName SFF name
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- @SfcReflection
- public static boolean deletePathFromServiceForwarderStateExecutor(String sfpName, String sffName) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {sfpName, sffName};
- Class[] servicePathClass = {String.class, String.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeletePathFromServiceForwarderState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeletePathFromServiceForwarderState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method deletes all RSPs used by the given SFF
- *
- * <p>
- * @param serviceFunctionForwarder SFF object
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static boolean deletePathsUsedByServiceForwarderExecutor(ServiceFunctionForwarder serviceFunctionForwarder) {
-
- printTraceStart(LOG);
- boolean ret = true;
-
- // SFF deletion is a critical event. If a SFF is deleted we delete all associated SFPs
- Object[] serviceForwarderObj = {serviceFunctionForwarder};
- Class[] serviceForwarderClass = {ServiceFunctionForwarder.class};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = SfcProviderServiceForwarderAPI
- .getDeletePathsUsedByServiceForwarder(serviceForwarderObj, serviceForwarderClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceForwarderAPI);
- try {
- ret = (boolean) future.get();
- LOG.info("getDeletePathsUsedByServiceForwarder: {}", ret);
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
* When a SFF is deleted we need to delete all SFPs from the
* associated SFF operational state
*
* @param sffName SFF name
* @return true if all paths were deleted, false otherwise.
*/
- @SuppressWarnings("unused")
- @SfcReflection
public static boolean deletePathFromServiceForwarderState(String rspName, String sffName) {
printTraceStart(LOG);
package org.opendaylight.sfc.provider.api;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
+import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
-import org.opendaylight.sfc.provider.SfcReflection;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
-import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-
/**
* This class has the APIs to operate on the ServiceFunction
* datastore.
* @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
* @since 2014-06-30
*/
-public class SfcProviderServiceFunctionAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceFunctionAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceFunctionAPI.class);
- SfcProviderServiceFunctionAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderServiceFunctionAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- public static SfcProviderServiceFunctionAPI getDeleteServicePathFromServiceFunctionState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteServicePathFromServiceFunctionState");
- }
- public static SfcProviderServiceFunctionAPI getPut(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "putServiceFunction");
- }
- public static SfcProviderServiceFunctionAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readServiceFunction");
- }
- public static SfcProviderServiceFunctionAPI getReadServiceFunctionState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readServiceFunctionState");
- }
- public static SfcProviderServiceFunctionAPI getReadServiceFunctionStateAsStringList(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readServiceFunctionStateAsStringList");
- }
- public static SfcProviderServiceFunctionAPI getDelete(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteServiceFunction");
- }
- public static SfcProviderServiceFunctionAPI getDeleteServiceFunctionState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "deleteServiceFunctionState");
- }
- public static SfcProviderServiceFunctionAPI getPutAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "putAllServiceFunctions");
- }
- 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 SfcProviderServiceFunctionAPI getAddPathToServiceFunctionState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "addPathToServiceFunctionState");
- }
- public static SfcProviderServiceFunctionAPI getReadServiceFunctionDescriptionMonitor(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readServiceFunctionDescriptionMonitor");
- }
- public static SfcProviderServiceFunctionAPI getReadAllServiceFunctionsState(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionAPI(params, paramsTypes, "readAllServiceFunctionStates");
- }
/**
* This method reads the operational state for a service function.
* <p>
return ret;
}
-
- /**
- * This method reads the operational state for a service function.
- * <p>
- * @param serviceFunctionName SF name
- * @return A ServiceFunctionState object that is a list of all paths using
- * this service function, null otherwise
- */
- public static List<SfServicePath> readServiceFunctionStateExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- List<SfServicePath> ret = null;
- Object[] serviceFunctionObj = {serviceFunctionName};
- Class[] serviceFunctionClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getReadServiceFunctionState(serviceFunctionObj, serviceFunctionClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (List<SfServicePath>) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method reads the operational state for a service function.
* <p>
}
- /**
- * This method reads the operational state for a service function as a
- * string list of service function paths
- * <p>
- * @param serviceFunctionName SF name
- * @return A string list of service function paths
- */
- public static List<String> readServiceFunctionStateAsStringListExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- List<String> ret = null;
- Object[] serviceFunctionNameObj = {serviceFunctionName};
- Class[] serviceFunctionNameClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getReadServiceFunctionStateAsStringList(serviceFunctionNameObj, serviceFunctionNameClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (List<String>) future.get();
- LOG.debug("getReadServiceFunctionStateAsStringList: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method reads the operational state for a service function.
* <p>
return ret;
}
- /**
- * This method reads the operational state for a service function.
- * <p>
- * @param serviceFunctionName SF name
- * @return service function description and monitor information
- * null otherwise
- */
- public static SfcSfDescMon readServiceFunctionDescriptionMonitorExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- SfcSfDescMon ret = null;
- Object[] serviceFunctionNameObj = {serviceFunctionName};
- Class[] serviceFunctionNameClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getReadServiceFunctionDescriptionMonitor(serviceFunctionNameObj, serviceFunctionNameClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (SfcSfDescMon) future.get();
- LOG.debug("getReadServiceFunctionDescriptionMonitor: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
protected ServiceFunctionsState readAllServiceFunctionStates() {
ServiceFunctionsState sfsState = null;
printTraceStart(LOG);
return sfsState;
}
- /**
- * This method deletes the operational state for a service function.
- * <p>
- * @param serviceFunctionName SF name
- * @return True if SF state was deleted, false otherwise
- */
- public static boolean deleteServiceFunctionStateExecutor(String serviceFunctionName) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] serviceFunctionNameObj = {serviceFunctionName};
- Class[] serviceFunctionNameClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getDeleteServiceFunctionState(serviceFunctionNameObj, serviceFunctionNameClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method deletes the operational state for a service function.
* <p>
* @return A ServiceFunctionState object that is a list of all paths using
* this service function, null otherwise
*/
- @SuppressWarnings("unused")
public static boolean deleteServiceFunctionState(String serviceFunctionName) {
printTraceStart(LOG);
boolean ret = false;
* @param pathName SFP name
* @return true if SFP was added, false otherwise
*/
- @SuppressWarnings("unused")
public static boolean addPathToServiceFunctionState(String pathName) {
boolean ret = false;
* @param renderedServicePath RSP object
* @return true if SFP was added, false otherwise
*/
- @SuppressWarnings("unused")
public static boolean addPathToServiceFunctionState(RenderedServicePath renderedServicePath) {
boolean ret = false;
- /**
- * This method adds a RSP name to the corresponding SF operational state.
- * <p>
- * @param pathName RSP name
- * @return true if RSP name was added, false otherwise
- */
- public static boolean addPathToServiceFunctionStateExecutor(String pathName) {
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] servicePathObj = {pathName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getAddPathToServiceFunctionState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddPathToServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method adds a SFP name to the corresponding SF operational state.
- * <p>
- * @param renderedServicePath RSP object
- * @return true if SFP was added, false otherwise
- */
- public static boolean addPathToServiceFunctionStateExecutor(RenderedServicePath renderedServicePath) {
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] servicePathObj = {renderedServicePath};
- Class[] servicePathClass = {RenderedServicePath.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getAddPathToServiceFunctionState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddPathToServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* This method puts a SF to data store.
* <p>
return ret;
}
- /**
- * Wrapper executor method adds a SF to the data store.
- * <p>
- * @param sf Service Function
- * @return true if SF was added, false otherwise
- */
- public static boolean putServiceFunctionExecutor(ServiceFunction sf) {
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] serviceFunctionObj = {sf};
- Class[] serviceFunctionClass = {ServiceFunction.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getPut(serviceFunctionObj, serviceFunctionClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("putServiceFunctionExecutor: {}", ret);
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Add ServiceFunctionState to datastore
* <p>
return ret;
}
- @SuppressWarnings("unused")
protected static boolean mergeServiceFunction(ServiceFunction sf) {
boolean ret;
printTraceStart(LOG);
* @param serviceFunctionName SF name
* @return SF object or null if not found
*/
- @SuppressWarnings("unused")
- @SfcReflection
- protected ServiceFunction readServiceFunction(String serviceFunctionName) {
+ public static ServiceFunction readServiceFunction(String serviceFunctionName) {
printTraceStart(LOG);
ServiceFunction sf;
InstanceIdentifier<ServiceFunction> sfIID;
return sf;
}
- /**
- * This method reads the operational state for a service function.
- * <p>
- * @param serviceFunctionName SF name
- * @return A ServiceFunctionState object that is a list of all paths using
- * this service function, null otherwise
- */
- public static ServiceFunction readServiceFunctionExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- ServiceFunction ret = null;
- Object[] serviceFunctionObj = {serviceFunctionName};
- Class[] serviceFunctionClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getRead(serviceFunctionObj, serviceFunctionClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (ServiceFunction) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* This method deletes a SF from the datastore
* <p>
* @param serviceFunctionName SF name
* @return true if SF was deleted, false otherwise
*/
- @SuppressWarnings("unused")
- protected boolean deleteServiceFunction(String serviceFunctionName) {
+ public static boolean deleteServiceFunction(String serviceFunctionName) {
boolean ret = false;
printTraceStart(LOG);
ServiceFunctionKey serviceFunctionKey = new ServiceFunctionKey(serviceFunctionName);
return ret;
}
- /**
- * This method deletes a SF from the datastore
- * <p>
- * @param serviceFunctionName SF name
- * @return true if SF was deleted, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean deleteServiceFunctionExecutor(String serviceFunctionName) {
- boolean ret = false;
- printTraceStart(LOG);
- Object[] servicePathObj = {serviceFunctionName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getDelete(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* This method adds a ServiceFunctions Object (collection of SFs) to the data store
*
* @param sfs Object holding ServiceFunctions
* @return true is ServiceFunctions added to the datatore, false otherwise
*/
- @SuppressWarnings("unused")
- @SfcReflection
- protected boolean putAllServiceFunctions(ServiceFunctions sfs) {
+ public static boolean putAllServiceFunctions(ServiceFunctions sfs) {
boolean ret = false;
printTraceStart(LOG);
//InstanceIdentifier<ServiceFunctions> sfsIID = InstanceIdentifier.builder(ServiceFunctions.class).build();
return ret;
}
- /**
- * This method creates an executor wrapper that adds the ServiceFunctions to
- * the datastore
- *
- * <p>
- * @param serviceFunctions Object holding ServiceFunctions
- * @return true is ServiceFunctions added to the datatore, false otherwise
- */
- public static boolean putAllServiceFunctionsExecutor(ServiceFunctions serviceFunctions) {
- printTraceStart(LOG);
- boolean ret = false;
- Object[] serviceFunctionsObj = {serviceFunctions};
- Class[] serviceFunctionsClass = {ServiceFunctions.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getPutAll(serviceFunctionsObj, serviceFunctionsClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getPutAll: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
- protected ServiceFunctions readAllServiceFunctions() {
+ protected static ServiceFunctions readAllServiceFunctions() {
ServiceFunctions sfs = null;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctions> sfsIID =
return sfs;
}
- /**
- * This method creates an executor and reads all the Service Functions
- * from SFC datastore
- * <p>
- * @return ServiceFunctions object including all Service Functions
- */
- public static ServiceFunctions readAllServiceFunctionsExecutor() {
- printTraceStart(LOG);
- ServiceFunctions ret = null;
- Object[] serviceFunctionsObj = {};
- Class[] serviceFunctionsClass = {};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getReadAll(serviceFunctionsObj, serviceFunctionsClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (ServiceFunctions) future.get();
- LOG.debug("getReadAll: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
protected boolean deleteAllServiceFunctions() {
boolean ret = false;
printTraceStart(LOG);
return ret;
}
- /**
- * Wrapper API to delete the given service path name from the all Service Functions
- * that are used by the associated path. It includes Executes creation and response
- * management.
- * <p>
- * @param serviceFunctionPath SFP object
- * @return true if SF was deleted, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean deleteServicePathFromServiceFunctionStateExecutor(ServiceFunctionPath serviceFunctionPath) {
-
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] servicePathObj = {serviceFunctionPath};
- Class[] servicePathClass = {ServiceFunctionPath.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getDeleteServicePathFromServiceFunctionState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServicePathFromServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * Wrapper API to delete the given service path name from the all Service Functions
- * that are used by the associated path. It includes Executes creation and response
- * management.
- *
- * <p>
- * @param rspList List of service path names
- * @return true if SF was deleted, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean deleteServicePathFromServiceFunctionStateExecutor(List<String> rspList) {
-
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] servicePathObj = {rspList};
- Class[] servicePathClass = {List.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getDeleteServicePathFromServiceFunctionState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServicePathFromServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
/**
* Delete the given service path name from the all Service Functions that are used by
* the associated path
* @param serviceFunctionPath RSP object
* @return true if SF was deleted, false otherwise
*/
- @SuppressWarnings("unused")
- @SfcReflection
- public boolean deleteServicePathFromServiceFunctionState(ServiceFunctionPath serviceFunctionPath) {
+ public static boolean deleteServicePathFromServiceFunctionState(ServiceFunctionPath serviceFunctionPath) {
boolean ret = true;
RenderedServicePath renderedServicePath = SfcProviderRenderedPathAPI.readRenderedServicePath(serviceFunctionPath.getName());
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.
- * <p>
- * @param sfpName RSP List
- * @return true if SF was deleted, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean deleteServicePathFromServiceFunctionStateExecutor(String sfpName) {
-
- boolean ret = false;
- printTraceStart(LOG);
-
- Object[] servicePathObj = {sfpName};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceFunctionAPI sfcProviderServiceFunctionAPI = SfcProviderServiceFunctionAPI
- .getDeleteServicePathFromServiceFunctionState(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServicePathFromServiceFunctionState: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This method removes the given Service Path from the all SF operational
* states that use it.
* @param sfpName SFP name
* @return true if SF was deleted, false otherwise
*/
- @SuppressWarnings("unused")
- public boolean deleteServicePathFromServiceFunctionState(String sfpName) {
+ public static boolean deleteServicePathFromServiceFunctionState(String sfpName) {
printTraceStart(LOG);
boolean ret = true;
* @param sfName SF name
* @return true if SF was deleted, false otherwise
*/
- @SuppressWarnings("unused")
- @SfcReflection
public static boolean deleteServicePathFromServiceFunctionState(String rspName, String sfName) {
boolean ret;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
* <p>
* @since 2015-02-14
*/
-public class SfcProviderServiceFunctionGroupAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceFunctionGroupAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceFunctionGroupAPI.class);
- SfcProviderServiceFunctionGroupAPI(Object[] params, String m) {
- super(params, m);
- }
-
- @SuppressWarnings("rawtypes")
- SfcProviderServiceFunctionGroupAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getPut(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "putServiceFunctionGroup");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "readServiceFunctionGroup");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getByType(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "getServiceFunctionGroupByType");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getDelete(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "deleteServiceFunctionGroup");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getAddSF(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "addServiceFunctionToGroup");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAPI getRemoveSF(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAPI(params, paramsTypes, "removeServiceFunctionFromGroup");
- }
-
- public static ServiceFunctionGroup getServiceFunctionGroupbyTypeExecutor(
- Class<? extends ServiceFunctionTypeIdentity> sft) {
-
- printTraceStart(LOG);
- ServiceFunctionGroup ret = null;
- Object[] servicePathObj = {sft.getName()};
- Class[] servicePathClass = {String.class};
- SfcProviderServiceFunctionGroupAPI sfcProviderServiceFunctionGroupAPI =
- SfcProviderServiceFunctionGroupAPI.getByType(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionGroupAPI);
- try {
- ret = (ServiceFunctionGroup) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * Puts a SFG in the datastore
- * <p>
- *
- * @param sfg the ServiceFunctionGroup to put
- * @return boolean success or failure
- */
- public static boolean putServiceFunctionGroupExecutor(ServiceFunctionGroup sfg) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] servicePathObj = {sfg};
- Class[] servicePathClass = {ServiceFunctionGroup.class};
- SfcProviderServiceFunctionGroupAPI sfcProviderServiceFunctionGroupAPI =
- SfcProviderServiceFunctionGroupAPI.getPut(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceFunctionGroupAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method reads the service function group corresponding to the name.
- *
- * @param serviceFunctionGroupName SFG name
- * @return service function group corresponding to the name
- */
- @SuppressWarnings("rawtypes")
- public static ServiceFunctionGroup readServiceFunctionGroupExecutor(String serviceFunctionGroupName) {
-
- printTraceStart(LOG);
- ServiceFunctionGroup ret = null;
- Object[] sfgObj = {serviceFunctionGroupName};
- Class[] sfgClass = {String.class};
- SfcProviderServiceFunctionGroupAPI sfgAPI = SfcProviderServiceFunctionGroupAPI.getRead(sfgObj, sfgClass);
- Future future = ODL_SFC.getExecutor().submit(sfgAPI);
- try {
- ret = (ServiceFunctionGroup) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
public static List<String> getSfgNameList(ServiceFunctionChain serviceFunctionChain) {
List<String> ret = new ArrayList<>();
List<SfcServiceFunction> sfcServiceFunction = serviceFunctionChain.getSfcServiceFunction();
if (sfcServiceFunction != null) {
for (SfcServiceFunction sf : sfcServiceFunction) {
ServiceFunctionGroup sfg =
- SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupbyTypeExecutor(sf.getType());
+ SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupByType(sf.getType());
LOG.debug("look for service function group of type {} and found {}", sf.getType(), sfg);
if (sfg != null) {
ret.add(sfg.getName());
* @param serviceFunctionGroupName name
* @return ServiceFunctionGroup object or null if not found
*/
- protected ServiceFunctionGroup readServiceFunctionGroup(String serviceFunctionGroupName) {
+ public static ServiceFunctionGroup readServiceFunctionGroup(String serviceFunctionGroupName) {
printTraceStart(LOG);
ServiceFunctionGroup sfg;
InstanceIdentifier<ServiceFunctionGroup> sfgIID;
* @param serviceFunctionType function type
* @return ServiceFunctionGroup object or null if not found
*/
- protected ServiceFunctionGroup getServiceFunctionGroupByType(String serviceFunctionType) {
+ protected static ServiceFunctionGroup getServiceFunctionGroupByType(Class<? extends ServiceFunctionTypeIdentity> serviceFunctionType) {
printTraceStart(LOG);
ServiceFunctionGroup sfg = null;
InstanceIdentifier<ServiceFunctionGroups> sfgIID;
if (sfgs != null) {
for (ServiceFunctionGroup element : sfgs.getServiceFunctionGroup()) {
- if (element.getType().getName().equals(serviceFunctionType)) {
+ if (element.getType().equals(serviceFunctionType)) {
sfg = element;
LOG.debug("found group " + sfg + " that matches type " + serviceFunctionType);
break;
* @param sfg the ServiceFunctionGroup to put
* @return boolean success or failure
*/
- protected boolean putServiceFunctionGroup(ServiceFunctionGroup sfg) {
+ public static boolean putServiceFunctionGroup(ServiceFunctionGroup sfg) {
boolean ret;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionGroup> sfgEntryIID = InstanceIdentifier.builder(ServiceFunctionGroups.class)
* @param serviceFunctionGroupName SFG name
* @return boolean success of failure
*/
- protected boolean deleteServiceFunctionGroup(String serviceFunctionGroupName) {
+ protected static boolean deleteServiceFunctionGroup(String serviceFunctionGroupName) {
boolean ret = false;
printTraceStart(LOG);
ServiceFunctionGroupKey serviceFunctionGroupKey = new ServiceFunctionGroupKey(serviceFunctionGroupName);
* @param serviceFunctionName name of SF to add
* @return boolean success of failure
*/
- protected boolean addServiceFunctionToGroup(String serviceFunctionGroupName, String serviceFunctionName) {
+ protected static boolean addServiceFunctionToGroup(String serviceFunctionGroupName, String serviceFunctionName) {
boolean ret = false;
printTraceStart(LOG);
* @param serviceFunctionName name of SF to remove
* @return boolean success of failure
*/
- protected boolean removeServiceFunctionFromGroup(String serviceFunctionGroupName, String serviceFunctionName) {
+ protected static boolean removeServiceFunctionFromGroup(String serviceFunctionGroupName, String serviceFunctionName) {
boolean ret = false;
printTraceStart(LOG);
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfg.alg.rev150214.ServiceFunctionGroupAlgorithms;
* @version 0.1 <p>
* @since 2015-02-14
*/
-public class SfcProviderServiceFunctionGroupAlgAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceFunctionGroupAlgAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceFunctionGroupAlgAPI.class);
private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- SfcProviderServiceFunctionGroupAlgAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderServiceFunctionGroupAlgAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAlgAPI getPut(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAlgAPI(params, paramsTypes, "putServiceFunctionGroupAlgorithm");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAlgAPI getRead(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAlgAPI(params, paramsTypes, "readServiceFunctionGroupAlgorithm");
- }
-
- @SuppressWarnings("rawtypes")
- public static SfcProviderServiceFunctionGroupAlgAPI getDelete(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionGroupAlgAPI(params, paramsTypes, "deleteServiceFunctionGroupAlgorithm");
- }
-
/**
* Reads a SFG Algorithm from the datastore <p>
* @param serviceFunctionGroupAlgorithmName name
* @return ServiceFunctionGroupAlgorithm object or null if not found
*/
- protected ServiceFunctionGroupAlgorithm readServiceFunctionGroupAlgorithm(String serviceFunctionGroupAlgorithmName) {
+ protected static ServiceFunctionGroupAlgorithm readServiceFunctionGroupAlgorithm(String serviceFunctionGroupAlgorithmName) {
printTraceStart(LOG);
ServiceFunctionGroupAlgorithm sfgAlg;
InstanceIdentifier<ServiceFunctionGroupAlgorithm> sfgAlgIID;
* @param sfgAlg the ServiceFunctionGroupAlgorithm to put
* @return boolean success or failure
*/
- protected boolean putServiceFunctionGroupAlgorithm(ServiceFunctionGroupAlgorithm sfgAlg) {
+ protected static boolean putServiceFunctionGroupAlgorithm(ServiceFunctionGroupAlgorithm sfgAlg) {
boolean ret;
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionGroupAlgorithm> sfgAlgEntryIID = InstanceIdentifier.builder(ServiceFunctionGroupAlgorithms.class).child(ServiceFunctionGroupAlgorithm.class, sfgAlg.getKey()).toInstance();
* @param serviceFunctionGroupAlgorithmName SFG Algorithm name
* @return boolean success of failure
*/
- protected boolean deleteServiceFunctionGroupAlgorithm(String serviceFunctionGroupAlgorithmName) {
+ protected static boolean deleteServiceFunctionGroupAlgorithm(String serviceFunctionGroupAlgorithmName) {
boolean ret = false;
printTraceStart(LOG);
ServiceFunctionGroupAlgorithmKey serviceFunctionGroupAlgorithmKey = new ServiceFunctionGroupAlgorithmKey(serviceFunctionGroupAlgorithmName);
return ret;
}
- @SuppressWarnings("rawtypes")
public static ServiceFunctionGroupAlgorithm readServiceFunctionGroupAlg(String serviceFunctionGroupAlgName) {
-
printTraceStart(LOG);
- ServiceFunctionGroupAlgorithm ret = null;
- Object[] sfgObj = { serviceFunctionGroupAlgName};
- Class[] sfgClass = { String.class };
- SfcProviderServiceFunctionGroupAlgAPI sfgAPI = SfcProviderServiceFunctionGroupAlgAPI.getRead(sfgObj, sfgClass);
- Future future = ODL_SFC.getExecutor().submit(sfgAPI);
- try {
- ret = (ServiceFunctionGroupAlgorithm) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ....", e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ....", e);
- } catch (Exception e) {
- LOG.error("Unexpected exception", e);
- }
+ ServiceFunctionGroupAlgorithm ret =
+ SfcProviderServiceFunctionGroupAlgAPI.readServiceFunctionGroupAlgorithm(serviceFunctionGroupAlgName);
+ LOG.debug("getRead: {}", ret);
printTraceStop(LOG);
return ret;
}
package org.opendaylight.sfc.provider.api;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStart;
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.SfcReflection;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.md.rev140701.ServiceFunctionMetadata;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.md.rev140701.service.function.metadata.ContextMetadata;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.md.rev140701.service.function.metadata.ContextMetadataKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.md.rev140701.service.function.metadata.VariableMetadata;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.md.rev140701.service.function.metadata.VariableMetadataKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
* @since 2015-10-10
*/
-public class SfcProviderServiceFunctionMetadataAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceFunctionMetadataAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceFunctionMetadataAPI.class);
- private static final String FAILED_TO_STR = "failed to ...";
-
- SfcProviderServiceFunctionMetadataAPI(Object[] params, String m) {
- super(params, m);
- }
-
- SfcProviderServiceFunctionMetadataAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- public static SfcProviderServiceFunctionMetadataAPI getPutContextMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "putContextMetadata");
- }
-
- public static SfcProviderServiceFunctionMetadataAPI getReadContextMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "readContextMetadata");
- }
-
- public static SfcProviderServiceFunctionMetadataAPI getDeleteContextMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "deleteContextMetadata");
- }
-
- public static SfcProviderServiceFunctionMetadataAPI getPutVariableMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "putVariableMetadata");
- }
- public static SfcProviderServiceFunctionMetadataAPI getReadVariableMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "readVariableMetadata");
- }
-
-
- public static SfcProviderServiceFunctionMetadataAPI getDeleteVariableMetadata(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceFunctionMetadataAPI(params, paramsTypes, "deleteVariableMetadata");
- }
-
- @SuppressWarnings("unused")
- @SfcReflection
- protected boolean putContextMetadata(ContextMetadata md) {
+ protected static boolean putContextMetadata(ContextMetadata md) {
boolean ret = false;
InstanceIdentifier<ContextMetadata> mdIID;
return ret;
}
- public static boolean putContextMetadataExecutor(ContextMetadata md) {
- boolean ret = false;
- Object[] functionParamsObj = {md};
- Class[] functionParamsClass = {ContextMetadata.class};
-
- printTraceStart(LOG);
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getPutContextMetadata(functionParamsObj, functionParamsClass));
- try {
- ret = (boolean) future.get();
- LOG.debug("getPutContextMetadata: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
- @SfcReflection
- protected ContextMetadata readContextMetadata(String mdName) {
+ protected static ContextMetadata readContextMetadata(String mdName) {
printTraceStart(LOG);
ContextMetadata md;
InstanceIdentifier<ContextMetadata> mdIID;
return md;
}
- public static ContextMetadata readContextMetadataExecutor(String mdName) {
- printTraceStart(LOG);
- ContextMetadata ret = null;
- Object[] functionParamsObj = {mdName};
- Class[] functionParamsClass = {String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getReadContextMetadata(functionParamsObj, functionParamsClass));
- try {
- ret = (ContextMetadata) future.get();
- LOG.debug("getReadContextMetadata: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
public static boolean deleteContextMetadata (String mdName) {
boolean ret = false;
printTraceStart(LOG);
return ret;
}
- @SuppressWarnings("unused")
- public static boolean deleteContextMetadataExecutor (String mdName) {
- boolean ret = false;
- Object[] functionParams = {mdName};
- Class[] functionParamsTypes = {String.class};
-
- printTraceStart(LOG);
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getDeleteContextMetadata(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteContextMetadata returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
- @SfcReflection
- protected boolean putVariableMetadata(VariableMetadata md) {
+ protected static boolean putVariableMetadata(VariableMetadata md) {
boolean ret = false;
InstanceIdentifier<VariableMetadata> mdIID;
return ret;
}
- public static boolean putVariableMetadataExecutor(VariableMetadata md) {
- boolean ret = false;
- Object[] functionParamsObj = {md};
- Class[] functionParamsClass = {VariableMetadata.class};
-
- printTraceStart(LOG);
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getPutVariableMetadata(functionParamsObj, functionParamsClass));
- try {
- ret = (boolean) future.get();
- LOG.debug("getPutVariableMetadata: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
- @SfcReflection
- protected VariableMetadata readVariableMetadata(String mdName) {
+ protected static VariableMetadata readVariableMetadata(String mdName) {
VariableMetadata md;
InstanceIdentifier<VariableMetadata> mdIID;
return md;
}
- public static VariableMetadata readVariableMetadataExecutor(String mdName) {
- VariableMetadata ret = null;
- Object[] functionParamsObj = {mdName};
- Class[] functionParamsClass = {String.class};
-
- printTraceStart(LOG);
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getReadVariableMetadata(functionParamsObj, functionParamsClass));
- try {
- ret = (VariableMetadata) future.get();
- LOG.debug("getReadVariableMetadata: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn("failed to ...." , e);
- } catch (ExecutionException e) {
- LOG.warn("failed to ...." , e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
-
@SuppressWarnings("unused")
public static boolean deleteVariableMetadata (String mdName) {
boolean ret = false;
printTraceStop(LOG);
return ret;
}
-
- @SuppressWarnings("unused")
- public static boolean deleteVariableMetadataExecutor (String mdName) {
- boolean ret = false;
- Object[] functionParams = {mdName};
- Class[] functionParamsTypes = {String.class};
-
- printTraceStart(LOG);
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServiceFunctionMetadataAPI
- .getDeleteVariableMetadata(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteVariableMetadata returns: {}", future.get());
- } catch (InterruptedException e) {
- LOG.warn(FAILED_TO_STR , e);
- } catch (ExecutionException e) {
- LOG.warn(FAILED_TO_STR , e);
- }
- printTraceStop(LOG);
- return ret;
- }
}
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
-import org.opendaylight.sfc.provider.SfcReflection;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
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.state.service.function.state.SfServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
* @version 0.1
* @since 2014-06-30
*/
-public class SfcProviderServicePathAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServicePathAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServicePathAPI.class);
- private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- private static final String FAILED_TO_STR = "failed to ...";
-
- SfcProviderServicePathAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderServicePathAPI getPut(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "putServiceFunctionPath");
- }
-
- @SuppressWarnings("unused")
- 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");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderServicePathAPI getPutAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "putAllServiceFunctionPaths");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderServicePathAPI getReadAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "readAllServiceFunctionPaths");
- }
-
- @SuppressWarnings("unused")
- 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, "deleteServicePathContainingFunction");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderServicePathAPI getDeleteServicePathInstantiatedFromChain(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "deleteServicePathInstantiatedFromChain");
- }
-
- public static SfcProviderServicePathAPI getCreateServicePathAPI(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "createServiceFunctionPathEntry");
- }
-
- @SuppressWarnings("unused")
- public static SfcProviderServicePathAPI getUpdateServicePathInstantiatedFromChain(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "updateServicePathInstantiatedFromChain");
- }
-
- public static SfcProviderServicePathAPI getUpdateServicePathContainingFunction(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "updateServicePathContainingFunction");
- }
-
- public static SfcProviderServicePathAPI getCheckServicePathAPI(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "checkServiceFunctionPath");
- }
-
- public static SfcProviderServicePathAPI getAddRenderedPathToServicePathStateExecutor(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "addRenderedPathToServicePathState");
- }
-
- public static SfcProviderServicePathAPI getDeleteServicePathStateExecutor(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "deleteServicePathState");
- }
-
- public static SfcProviderServicePathAPI getReadServicePathStateExecutor(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServicePathAPI(params, paramsTypes, "readServicePathState");
- }
/**
* This function checks if the Service Path has any constraints
* @param servicePathName Service Path Name
* @return List of RSP name objects
*/
- @SuppressWarnings("unused")
- protected static List<SfpRenderedServicePath> readServicePathState(String servicePathName) {
+ public static List<SfpRenderedServicePath> readServicePathState(String servicePathName) {
printTraceStart(LOG);
InstanceIdentifier<ServiceFunctionPathState> sfpIID;
return ret;
}
- /**
- * Wrapper API to read the Service Function Path operational state
- *
- * @param servicePathName Service Path Name
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static List<SfpRenderedServicePath> readServicePathStateExecutor(String servicePathName) {
-
- printTraceStart(LOG);
- List<SfpRenderedServicePath> ret = null;
-
- Object[] servicePathObj = {servicePathName};
- Class[] servicePathClass = {String.class};
-
- SfcProviderServicePathAPI sfcProviderServicePathAPI =
- SfcProviderServicePathAPI.getReadServicePathStateExecutor(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServicePathAPI);
- try {
- ret = (List<SfpRenderedServicePath>) future.get();
- LOG.debug("getReadServicePathStateExecutor: {}", ret);
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* Wrapper API to delete the Service Function Path operational state
*
* @param servicePathName Service Path Name
* @return Nothing.
*/
- @SuppressWarnings("unused")
protected static boolean deleteServicePathState(String servicePathName) {
printTraceStart(LOG);
return ret;
}
- /**
- * Wrapper API to delete the Service Function Path operational state
- *
- * @param servicePathName Service Path Name
- * @return Nothing.
- */
- @SfcReflection
- @SuppressWarnings("unused")
- public static boolean deleteServicePathStateExecutor(String servicePathName) {
-
- printTraceStart(LOG);
- boolean ret = true;
-
- Object[] servicePathObj = {servicePathName};
- Class[] servicePathClass = {String.class};
-
- SfcProviderServicePathAPI sfcProviderServicePathAPI =
- SfcProviderServicePathAPI.getDeleteServicePathStateExecutor(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServicePathAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServicePathStateExecutor: {}", ret);
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* We iterate through all service paths that use this service function and if
* necessary, remove them.
* @param renderedPathName Rendered Path name
* @return Nothing.
*/
- @SfcReflection
- @SuppressWarnings("unused")
public static boolean addRenderedPathToServicePathState(String servicePathName, String renderedPathName) {
printTraceStart(LOG);
return ret;
}
- /**
- * We iterate through all service paths that use this service function and if
- * necessary, remove them.
- *
- * @param servicePathName Service Function Path name
- * @param renderedPathName Rendered Path name
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static boolean addRenderedPathToServicePathStateExecutor(String servicePathName, String renderedPathName) {
-
- printTraceStart(LOG);
- boolean ret = true;
- Object[] functionParams = {servicePathName, renderedPathName};
- Class[] functionParamsTypes = {String.class, String.class};
- Future future = ODL_SFC.getExecutor().submit(SfcProviderServicePathAPI
- .getAddRenderedPathToServicePathStateExecutor(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getAddRenderedPathToServicePathStateExecutor returns: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method creates a ServiceFunctionPath by Executor, it includes
- * Executor creation and response management
- *
- * @param sfp a ServiceFunctionPath object
- * @return true if sfp is created, false otherwise
- */
- @SuppressWarnings("unused")
- public static boolean putServiceFunctionPathExecutor(ServiceFunctionPath sfp) {
- boolean ret = false;
- Object[] sfcParameters = {sfp};
- Class[] sfcParameterTypes = {ServiceFunctionPath.class};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getPut(sfcParameters, sfcParameterTypes))
- .get();
- ret = (boolean) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This function reads a SFP from the datastore
*
return sfp;
}
- /**
- * This method reads the operational state for a service function.
- *
- * @param serviceFunctionName SF name
- * @return A ServiceFunctionState object that is a list of all paths using
- * this service function, null otherwise
- */
- public static ServiceFunctionPath readServiceFunctionPathExecutor(String serviceFunctionName) {
-
- printTraceStart(LOG);
- ServiceFunctionPath ret = null;
- Object[] servicePathObj = {serviceFunctionName};
- Class[] servicePathClass = {String.class};
- SfcProviderServicePathAPI sfcProviderServicePathAPI =
- SfcProviderServicePathAPI.getRead(servicePathObj, servicePathClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServicePathAPI);
- try {
- ret = (ServiceFunctionPath) future.get();
- LOG.debug("readServiceFunctionPathExecutor: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
/**
* This function deletes a SFP from the datastore
*
return ret;
}
- /**
- * This function deletes a SFP from the datastore
- *
- * @param serviceFunctionPathName SFP name
- * @return Nothing.
- */
- public static boolean deleteServiceFunctionPathExecutor(String serviceFunctionPathName) {
- boolean ret = false;
- Object[] sfcParameters = {serviceFunctionPathName};
- Class[] sfcParameterTypes = {String.class};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getDelete(sfcParameters, sfcParameterTypes))
- .get();
- ret = (boolean) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This function put service function paths to the datastore
- *
- * @param serviceFunctionPaths SFP name
- * @return Nothing.
- */
- public static boolean putServiceFunctionPathsExecutor(ServiceFunctionPaths serviceFunctionPaths) {
- boolean ret = false;
- Object[] sfcParameters = {serviceFunctionPaths};
- Class[] sfcParameterTypes = {ServiceFunctionPaths.class};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getPutAll(sfcParameters, sfcParameterTypes))
- .get();
- ret = (boolean) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
public static ServiceFunctionPaths readAllServiceFunctionPaths() {
ServiceFunctionPaths sfps;
printTraceStart(LOG);
return sfps;
}
- /**
- * This function read service function paths from the datastore
- *
- * @return Nothing.
- */
- public static ServiceFunctionPaths readAllServiceFunctionPathsExecutor() {
- ServiceFunctionPaths ret = null;
- Object[] sfcParameters = {};
- Class[] sfcParameterTypes = {};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getReadAll(sfcParameters, sfcParameterTypes))
- .get();
- ret = (ServiceFunctionPaths) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This function read service function paths from the datastore
- *
- * @return Nothing.
- */
- public static boolean deleteAllServiceFunctionPathsExecutor() {
- boolean ret = false;
- Object[] sfcParameters = {};
- Class[] sfcParameterTypes = {};
-
- printTraceStart(LOG);
- try {
- Object result = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getDeleteAll(sfcParameters, sfcParameterTypes))
- .get();
- ret = (boolean) result;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * Check a SFF for consistency after datastore creation
- *
- * @param serviceFunctionPath SFP object
- * @param operation HttpMethod
- * @return Nothing
- */
- // calls non-existing method
- public static boolean checkServiceFunctionPathExecutor(ServiceFunctionPath serviceFunctionPath, String operation) {
-
- printTraceStart(LOG);
- boolean ret = false;
-
- // Send to SB REST
- RenderedServicePath renderedServicePath =
- SfcProviderRenderedPathAPI.readRenderedServicePath(serviceFunctionPath.getName());
- if (renderedServicePath == null) {
- LOG.error("Failed to find RSP: {}", serviceFunctionPath.getName());
- return false;
- }
- Object[] renderedPathObj = {renderedServicePath, operation};
- Class[] renderedPathClass = {RenderedServicePath.class, String.class};
- Future future = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getCheckServicePathAPI(renderedPathObj, renderedPathClass));
- try {
- ret = (boolean) future.get();
- LOG.debug("getCheckServicePathAPI returns: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * Check a SFF for consistency after datastore creation
- *
- * @param renderedServicePath RSP object
- * @param operation HttpMethod
- * @return Nothing
- */
- // calls non-existing method
- public static boolean checkServiceFunctionPathExecutor(RenderedServicePath renderedServicePath, String operation) {
-
- printTraceStart(LOG);
- boolean ret = false;
-
- Object[] renderedPathObj = {renderedServicePath, operation};
- Class[] renderedPathClass = {RenderedServicePath.class, String.class};
- Future future = ODL_SFC.getExecutor()
- .submit(SfcProviderServicePathAPI.getCheckServicePathAPI(renderedPathObj, renderedPathClass));
- try {
- ret = (boolean) future.get();
- LOG.debug("getCheckServicePathAPI returns: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * We iterate through all service paths that use this service function and if
- * necessary, remove them.
- *
- * @param serviceFunction Service Function Object
- * @return Nothing.
- */
- @SuppressWarnings("unused")
- public static boolean deleteServicePathContainingFunctionExecutor(ServiceFunction serviceFunction) {
-
- printTraceStart(LOG);
- boolean ret = true;
- Object[] functionParams = {serviceFunction};
- Class[] functionParamsTypes = {ServiceFunction.class};
- Future future = ODL_SFC.getExecutor().submit(
- SfcProviderServicePathAPI.getDeleteServicePathContainingFunction(functionParams, functionParamsTypes));
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServicePathContainingFunction returns: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- @SuppressWarnings("unused")
- protected boolean putServiceFunctionPath(ServiceFunctionPath sfp) {
+ public static boolean putServiceFunctionPath(ServiceFunctionPath sfp) {
boolean ret = false;
printTraceStart(LOG);
return ret;
}
- @SuppressWarnings("unused")
- protected boolean putAllServiceFunctionPaths(ServiceFunctionPaths sfps) {
+ protected static boolean putAllServiceFunctionPaths(ServiceFunctionPaths sfps) {
boolean ret = false;
printTraceStart(LOG);
return ret;
}
- @SuppressWarnings("unused")
- protected boolean deleteAllServiceFunctionPaths() {
+ protected static boolean deleteAllServiceFunctionPaths() {
boolean ret = false;
printTraceStart(LOG);
* @param serviceFunction Service Function Object
* @return Nothing.
*/
- @SuppressWarnings("unused")
- @SfcReflection
- public boolean deleteServicePathContainingFunction(ServiceFunction serviceFunction) {
+ public static boolean deleteServicePathContainingFunction(ServiceFunction serviceFunction) {
printTraceStart(LOG);
boolean ret = true;
import static org.opendaylight.sfc.provider.SfcProviderDebug.printTraceStop;
import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.OpendaylightSfc;
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.sft.rev140701.ServiceFunctionTypeIdentity;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypes;
* @see org.opendaylight.sfc.provider.SfcProviderSfEntryDataListener
* @since 2014-06-30
*/
-public class SfcProviderServiceTypeAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceTypeAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceTypeAPI.class);
- private static final OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- private static final String FAILED_TO_STR = "failed to ...";
-
- 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");
- }
-
- public static SfcProviderServiceTypeAPI getReadAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceTypeAPI(params, paramsTypes, "readAllServiceFunctionTypes");
- }
-
- public static SfcProviderServiceTypeAPI getDeleteAll(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteAllServiceFunctionTypes");
- }
-
- public static SfcProviderServiceTypeAPI getCreateServiceFunctionTypeEntry(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceTypeAPI(params, paramsTypes, "createServiceFunctionTypeEntry");
- }
-
- public static SfcProviderServiceTypeAPI getDeleteServiceFunctionTypeEntry(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteServiceFunctionTypeEntry");
- }
-
- public static SfcProviderServiceTypeAPI getDeleteServiceFunctionFromServiceType(Object[] params,
- Class[] paramsTypes) {
- return new SfcProviderServiceTypeAPI(params, paramsTypes, "deleteServiceFunctionTypeEntry");
- }
-
- public static boolean putServiceFunctionTypeExecutor(ServiceFunctionType sft) {
-
- printTraceStart(LOG);
- boolean ret = false;
- Object[] serviceTypeObj = {sft};
- Class[] serviceTypeClass = {ServiceFunctionType.class};
- SfcProviderServiceTypeAPI sfcProviderServiceTypeAPI =
- SfcProviderServiceTypeAPI.getPut(serviceTypeObj, serviceTypeClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceTypeAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- /**
- * This method reads the operational state for a service function.
- *
- * @param serviceFunctionTypeIdentity SF name
- * @return A ServiceFunctionType object
- */
- public static ServiceFunctionType readServiceFunctionTypeExecutor(
- Class<? extends ServiceFunctionTypeIdentity> serviceFunctionTypeIdentity) {
-
- printTraceStart(LOG);
- ServiceFunctionType ret = null;
- Object[] serviceTypeObj = {serviceFunctionTypeIdentity};
- Class[] serviceTypeClass = {Class.class};
- SfcProviderServiceTypeAPI sfcProviderServiceTypeAPI =
- SfcProviderServiceTypeAPI.getRead(serviceTypeObj, serviceTypeClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceTypeAPI);
- try {
- ret = (ServiceFunctionType) future.get();
- LOG.debug("getRead: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("failed to ....", e);
- }
- printTraceStop(LOG);
- return ret;
- }
-
- public static boolean deleteServiceFunctionTypeEntryExecutor(ServiceFunction serviceFunction) {
- boolean ret = false;
- Object[] serviceTypeObj = {serviceFunction};
- Class[] serviceTypeClass = {ServiceFunction.class};
- SfcProviderServiceTypeAPI sfcProviderServiceTypeAPI =
- SfcProviderServiceTypeAPI.getDeleteServiceFunctionTypeEntry(serviceTypeObj, serviceTypeClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceTypeAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("getDeleteServiceFunctionTypeEntry: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- return ret;
- }
-
- /**
- * Wrapper method that creates an executor that will execute a method to add a
- * SFType to the datatore
- *
- * @param serviceFunction Service Function Object
- * @return Nothing.
- */
- public static boolean createServiceFunctionTypeEntryExecutor(ServiceFunction serviceFunction) {
- boolean ret = false;
- Object[] serviceTypeObj = {serviceFunction};
- Class[] serviceTypeClass = {ServiceFunction.class};
- SfcProviderServiceTypeAPI sfcProviderServiceTypeAPI =
- SfcProviderServiceTypeAPI.getCreateServiceFunctionTypeEntry(serviceTypeObj, serviceTypeClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderServiceTypeAPI);
- try {
- ret = (boolean) future.get();
- LOG.debug("createServiceFunctionTypeEntryExecutor: {}", future.get());
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn(FAILED_TO_STR, e);
- }
- return ret;
- }
/**
* This method creates a Service function Type entry from a Service
return ret;
}
- protected boolean putServiceFunctionType(ServiceFunctionType sft) {
+ public static boolean putServiceFunctionType(ServiceFunctionType sft) {
boolean ret;
printTraceStart(LOG);
sfName = curSftServiceFunctionName.getName();
/* Check next one if curSftServiceFunctionName doesn't exist */
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfName);
+ ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
if (serviceFunction == null) {
LOG.error("ServiceFunction {} doesn't exist", sfName);
continue;
}
/* Read ServiceFunctionMonitor information */
- SfcSfDescMon sfcSfDescMon = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor(sfName);
+ SfcSfDescMon sfcSfDescMon = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor(sfName);
if (sfcSfDescMon == null) {
sftServiceFunctionName = sfName;
LOG.error("Read monitor information from Data Store failed! serviceFunction: {}", sfName);
*/
ServiceFunctionType serviceFunctionType;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(sfcServiceFunction.getType());
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType());
if (serviceFunctionType != null) {
List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
if (!sftServiceFunctionNameList.isEmpty()) {
while (maxTries > 0) {
serviceFunctionName = sftServiceFunctionNameList.get(start).getName();
- serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(serviceFunctionName);
+ serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionName);
if (serviceFunction != null) {
break;
} else {
*/
ServiceFunctionType serviceFunctionType;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(sfcServiceFunction.getType());
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType());
if (serviceFunctionType != null) {
List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
if (!sftServiceFunctionNameList.isEmpty()) {
* we do not hit NULL Pointer exceptions
*/
ServiceFunctionType serviceFunctionType;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(sfcServiceFunction.getType());
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType());
if (serviceFunctionType != null) {
List<SftServiceFunctionName> sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
if (!sftServiceFunctionNameList.isEmpty()) {
String toSffName;
/* Add all the ServiceFunction nodes */
- ServiceFunctions sfs = SfcProviderServiceFunctionAPI.readAllServiceFunctionsExecutor();
+ ServiceFunctions sfs = SfcProviderServiceFunctionAPI.readAllServiceFunctions();
List<ServiceFunction> serviceFunctionList = sfs.getServiceFunction();
for (ServiceFunction serviceFunction : serviceFunctionList) {
sfName = serviceFunction.getName();
LOG.debug("Add ServiceFunction: {}", sfName);
}
- ServiceFunctionForwarders sffs = SfcProviderServiceForwarderAPI.readAllServiceFunctionForwardersExecutor();
+ ServiceFunctionForwarders sffs = SfcProviderServiceForwarderAPI.readAllServiceFunctionForwarders();
List<ServiceFunctionForwarder> serviceFunctionForwarderList = sffs.getServiceFunctionForwarder();
/* Add edges and node for every ServiceFunctionForwarder */
}
ServiceFunctionType serviceFunctionType =
- SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(sfcServiceFunction.getType());
+ SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType());
if (serviceFunctionType != null) {
List<SftServiceFunctionName> sftServiceFunctionNameList =
serviceFunctionType.getSftServiceFunctionName();
package org.opendaylight.sfc.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.api.*;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.*;
+import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPITest;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionGroupAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceTypeAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathOutput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.DeleteRenderedPathInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.DeleteRenderedPathInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.DeleteRenderedPathOutput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRenderedServicePathFirstHopInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRenderedServicePathFirstHopInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRenderedServicePathFirstHopOutput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRspFirstHopBySftListInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRspFirstHopBySftListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.ReadRspFirstHopBySftListOutput;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.ServiceFunctionClassifiers;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.state.ServiceFunctionClassifierStateKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.state.service.function.classifier.state.SclRenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.state.service.function.classifier.state.SclRenderedServicePathKey;
-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.PutServiceFunctionInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.PutServiceFunctionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ReadServiceFunctionInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ReadServiceFunctionInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ReadServiceFunctionOutput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.function.entry.SfDataPlaneLocatorKey;
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.sf.rev140701.service.functions.state.service.function.state.SfServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.InstantiateServiceFunctionChainInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.PutServiceFunctionChainsInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.PutServiceFunctionChainsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainsBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.service.function.path.state.SfpRenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.service.function.types.ServiceFunctionTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.service.function.types.ServiceFunctionTypeKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.service.function.types.service.function.type.SftServiceFunctionName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.junit.Assert.*;
-
public class SfcProviderRpcTest extends AbstractDataStoreManager {
private final String[] sffNames = {"sff1", "sff2", "sff3", "sff4"};
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
LOG.debug("call createServiceFunctionTypeEntryExecutor for {}", serviceFunction.getName());
assertTrue("Must be true", ret);
}
.setSymmetric(true).setClassifier(SFP_NAME).setSymmetricClassifier(SFP_NAME);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- boolean ret = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath);
+ boolean ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath);
assertTrue("Must be true", ret);
}
init();
ServiceFunctionPath serviceFunctionPath =
- SfcProviderServicePathAPI.readServiceFunctionPathExecutor(SFP_NAME);
+ SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME);
assertNotNull("Must be not null", serviceFunctionPath);
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
serviceFunctionPath, createRenderedPathInput);
//check if SFF oper contains RSP
- List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffStateExecutor(SFF_NAMES[1]);
+ List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(SFF_NAMES[1]);
assertNotNull("Must be not null", sffServicePathList);
assertEquals(sffServicePathList.get(0).getName(), RSP_NAME);
//check if SF oper contains RSP
- List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor("unittest-fw-1");
+ List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState("unittest-fw-1");
assertEquals(sfServicePathList.get(0).getName(), RSP_NAME);
//check if SFP oper contains RSP
- List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathStateExecutor(SFP_NAME);
+ List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathState(SFP_NAME);
assertEquals(sfpRenderedServicePathList.get(0).getName(), RSP_NAME);
SfcProviderRpc sfcProviderRpc = new SfcProviderRpc();
init();
ServiceFunctionPath serviceFunctionPath =
- SfcProviderServicePathAPI.readServiceFunctionPathExecutor(SFP_NAME);
+ SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME);
assertNotNull("Must be not null", serviceFunctionPath);
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
serviceFunctionPath, createRenderedPathInput);
//check if SFF oper contains RSP
- List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffStateExecutor(SFF_NAMES[1]);
+ List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(SFF_NAMES[1]);
assertNotNull("Must be not null", sffServicePathList);
assertEquals(sffServicePathList.get(0).getName(), RSP_NAME);
//check if SF oper contains RSP
- List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor("unittest-fw-1");
+ List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState("unittest-fw-1");
assertEquals(sfServicePathList.get(0).getName(), RSP_NAME);
//check if SFP oper contains RSP
- List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathStateExecutor(SFP_NAME);
+ List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathState(SFP_NAME);
assertEquals(sfpRenderedServicePathList.get(0).getName(), RSP_NAME);
SfcProviderRpc sfcProviderRpc = new SfcProviderRpc();
ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceType))
.setSftServiceFunctionName(sftServiceFunctionNames);
- return SfcProviderServiceTypeAPI.putServiceFunctionTypeExecutor(serviceFunctionTypeBuilder.build());
+ return SfcProviderServiceTypeAPI.putServiceFunctionType(serviceFunctionTypeBuilder.build());
}
/*
serviceFunctionForwarderBuilder.setName(forwarderName)
.setKey(new ServiceFunctionForwarderKey(forwarderName))
.setSffDataPlaneLocator(sffDataPlaneLocator);
- return SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(serviceFunctionForwarderBuilder.build());
+ return SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(serviceFunctionForwarderBuilder.build());
}
/*
.setSfDataPlaneLocator(sfDataPlaneLocator)
.setType(functionType);
- return SfcProviderServiceFunctionAPI.putServiceFunctionExecutor(serviceFunctionBuilder.build());
+ return SfcProviderServiceFunctionAPI.putServiceFunction(serviceFunctionBuilder.build());
}
/*
.setSfcServiceFunction(sfcServiceFunctionList)
.setType(groupType);
- return SfcProviderServiceFunctionGroupAPI.putServiceFunctionGroupExecutor(serviceFunctionGroupBuilder.build());
+ return SfcProviderServiceFunctionGroupAPI.putServiceFunctionGroup(serviceFunctionGroupBuilder.build());
}
/*
for (String sfName : sfNames) {
sfcSfgServiceFunctionBuilder.setName(sfName)
.setKey(new SfcServiceFunctionKey(sfName))
- .setType(SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfName).getType());
+ .setType(SfcProviderServiceFunctionAPI.readServiceFunction(sfName).getType());
sfcSfgServiceFunctionList.add(sfcSfgServiceFunctionBuilder.build());
}
.setKey(new ServiceFunctionChainKey(chainName))
.setSfcServiceFunction(sfcSfgServiceFunctionList);
- return SfcProviderServiceChainAPI.putServiceFunctionChainExecutor(serviceFunctionChainBuilder.build());
+ return SfcProviderServiceChainAPI.putServiceFunctionChain(serviceFunctionChainBuilder.build());
}
/*
.setClassifier(classifierName)
.setSymmetricClassifier(classifierRevName)
.setSymmetric(symmetric);
- return SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPathBuilder.build());
+ return SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPathBuilder.build());
}
/*
package org.opendaylight.sfc.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.api.*;
+import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceTypeAPI;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.service.function.types.service.function.type.SftServiceFunctionName;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
/**
ServiceFunction originalServiceFunction = build_service_function();
InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class).
child(ServiceFunction.class, originalServiceFunction.getKey()).build();
- assertTrue(SfcProviderServiceFunctionAPI.putServiceFunctionExecutor(originalServiceFunction));
+ assertTrue(SfcProviderServiceFunctionAPI.putServiceFunction(originalServiceFunction));
/* Since there is no listener we need to create a Service Function Type Entry */
assertTrue(SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(originalServiceFunction));
//Clean-up
assertTrue(SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntry(updatedServiceFunction));
- assertTrue(SfcProviderServiceFunctionAPI.deleteServiceFunctionExecutor(originalServiceFunction.getName()));
+ assertTrue(SfcProviderServiceFunctionAPI.deleteServiceFunction(originalServiceFunction.getName()));
Thread.sleep(500);
assertNull(SfcProviderServiceTypeAPI.readServiceFunctionTypeEntry(originalServiceFunction));
// Prepare to remove the first SF used by the RSP.
String sfName = renderedServicePath.getRenderedServicePathHop().get(0).getServiceFunctionName();
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfName);
+ ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
assertNotNull(serviceFunction);
// Now we prepare to remove the entry through the listener
sfEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(500);
- assertNull(SfcProviderRenderedPathAPI.readRenderedServicePathExecutor(renderedServicePath.getName()));
+ assertNull(SfcProviderRenderedPathAPI.readRenderedServicePath(renderedServicePath.getName()));
List<String> sfpNameList = SfcProviderServiceFunctionAPI.
readServiceFunctionStateAsStringList(serviceFunction.getName());
if (sfpNameList != null) {
// Prepare to update the first SF used by the RSP.
String sfName = renderedServicePath.getRenderedServicePathHop().get(0).getServiceFunctionName();
- ServiceFunction originalServiceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfName);
+ ServiceFunction originalServiceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
assertNotNull(originalServiceFunction);
// Now we prepare the updated data. We change mgmt address and type
//Clean-up
assertTrue(SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntry(updatedServiceFunction));
- assertNull(SfcProviderRenderedPathAPI.readRenderedServicePathExecutor(renderedServicePath.getName()));
+ assertNull(SfcProviderRenderedPathAPI.readRenderedServicePath(renderedServicePath.getName()));
List<String> sfpNameList = SfcProviderServiceFunctionAPI.
readServiceFunctionStateAsStringList(originalServiceFunction.getName());
if (sfpNameList != null) {
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- assertTrue(SfcProviderServiceFunctionAPI.putAllServiceFunctionsExecutor(sfsBuilder.build()));
+ assertTrue(SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build()));
//executor.submit(SfcProviderServiceFunctionAPI.getPutAll(new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
Thread.sleep(1000); // Wait they are really created
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- assertTrue(SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction));
+ assertTrue(SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction));
}
// Create Service Function Forwarders
ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder = new ServiceFunctionForwardersBuilder();
serviceFunctionForwardersBuilder.setServiceFunctionForwarder(sffList);
assertTrue(SfcProviderServiceForwarderAPI.
- putAllServiceFunctionForwardersExecutor(serviceFunctionForwardersBuilder.build()));
+ putAllServiceFunctionForwarders(serviceFunctionForwardersBuilder.build()));
//Create Service Function Chain
ServiceFunctionChainKey sfcKey = new ServiceFunctionChainKey(SFC_NAME);
// Object[] parameters = {sfcBuilder.build()};
// Class[] parameterTypes = {ServiceFunctionChain.class};
- assertTrue(SfcProviderServiceChainAPI.putServiceFunctionChainExecutor(sfcBuilder.build()));
+ assertTrue(SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build()));
// executor.submit(SfcProviderServiceChainAPI
// .getPut(parameters, parameterTypes)).get();
Thread.sleep(1000); // Wait SFC is really crated
// ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
ServiceFunctionChain readServiceFunctionChain =
- SfcProviderServiceChainAPI.readServiceFunctionChainExecutor(SFC_NAME);
+ SfcProviderServiceChainAPI.readServiceFunctionChain(SFC_NAME);
assertNotNull(readServiceFunctionChain);
.setSymmetric(true);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- assertTrue(SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath));
+ assertTrue(SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath));
// assertTrue("Must be true", ret);
Thread.sleep(1000); // Wait they are really created
package org.opendaylight.sfc.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.api.*;
+import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderServiceTypeAPI;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.state.service.function.forwarder.state.SffServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
-
/**
* SfcProviderSfEntryDataListener Tester.
String sffName = renderedServicePath.getRenderedServicePathHop().get(0).getServiceFunctionForwarder();
LOG.info("sffNme: {}", sffName);
ServiceFunctionForwarder serviceFunctionForwarder = SfcProviderServiceForwarderAPI.
- readServiceFunctionForwarderExecutor(sffName);
+ readServiceFunctionForwarder(sffName);
assertNotNull(serviceFunctionForwarder);
// Now we prepare to remove the entry through the listener
sffEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(2000);
// Verify that RSP was removed
- assertNull(SfcProviderRenderedPathAPI.readRenderedServicePathExecutor(renderedServicePath.getName()));
+ assertNull(SfcProviderRenderedPathAPI.readRenderedServicePath(renderedServicePath.getName()));
// Verify that State was removed
- List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffStateExecutor(sffName);
+ List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(sffName);
assertNull(sffServicePathList);
/* for (SffServicePath sffServicePath : sffServicePathList) {
assertNotEquals(sffServicePath.getName(), renderedServicePath.getName());
// Prepare to remove the first SF used by the RSP.
String sffName = renderedServicePath.getRenderedServicePathHop().get(0).getServiceFunctionForwarder();
ServiceFunctionForwarder serviceFunctionForwarder = SfcProviderServiceForwarderAPI.
- readServiceFunctionForwarderExecutor(sffName);
+ readServiceFunctionForwarder(sffName);
assertNotNull(serviceFunctionForwarder);
// Now we prepare the updated data. We change mgmt address and type
*/
sffEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(500);
- assertNull(SfcProviderRenderedPathAPI.readRenderedServicePathExecutor(renderedServicePath.getName()));
+ assertNull(SfcProviderRenderedPathAPI.readRenderedServicePath(renderedServicePath.getName()));
// Verify that State was removed
- List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffStateExecutor(sffName);
+ List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(sffName);
assertNull(sffServicePathList);
/* for (SffServicePath sffServicePath : sffServicePathList) {
assertNotEquals(sffServicePath.getName(), renderedServicePath.getName());
.setServiceNode(null) // for consistency only; we are going to get rid of ServiceNodes in the future
.build();
- assertTrue(SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(sff));
+ assertTrue(SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff));
return sff;
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- assertTrue(SfcProviderServiceFunctionAPI.putAllServiceFunctionsExecutor(sfsBuilder.build()));
+ assertTrue(SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build()));
//executor.submit(SfcProviderServiceFunctionAPI.getPutAll(new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
Thread.sleep(1000); // Wait they are really created
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- assertTrue(SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction));
+ assertTrue(SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction));
}
// Create Service Function Forwarders
ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder = new ServiceFunctionForwardersBuilder();
serviceFunctionForwardersBuilder.setServiceFunctionForwarder(sffList);
assertTrue(SfcProviderServiceForwarderAPI.
- putAllServiceFunctionForwardersExecutor(serviceFunctionForwardersBuilder.build()));
+ putAllServiceFunctionForwarders(serviceFunctionForwardersBuilder.build()));
//Create Service Function Chain
ServiceFunctionChainKey sfcKey = new ServiceFunctionChainKey(SFC_NAME);
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(true);
- assertTrue(SfcProviderServiceChainAPI.putServiceFunctionChainExecutor(sfcBuilder.build()));
+ assertTrue(SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build()));
Thread.sleep(1000); // Wait SFC is really crated
ServiceFunctionChain readServiceFunctionChain =
- SfcProviderServiceChainAPI.readServiceFunctionChainExecutor(SFC_NAME);
+ SfcProviderServiceChainAPI.readServiceFunctionChain(SFC_NAME);
assertNotNull(readServiceFunctionChain);
.setSymmetric(true);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- assertTrue(SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath));
+ assertTrue(SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath));
Thread.sleep(1000); // Wait they are really created
package org.opendaylight.sfc.provider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.sfc.provider.api.*;
-import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypes;
+import org.opendaylight.sfc.provider.api.SfcDataStoreAPI;
+import org.opendaylight.sfc.provider.api.SfcProviderScheduleTypeAPI;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.LoadBalance;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.Random;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.RoundRobin;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypes;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerType;
-import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeKey;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeBuilder;
-import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.Random;
-import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.RoundRobin;
-import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.LoadBalance;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.concurrent.Future;
-import java.util.*;
-
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.when;
ServiceFunctionSchedulerType serviceFunctionSchedulerType = build_service_function_scheduler_type();
- assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType));
+ assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(serviceFunctionSchedulerType));
InstanceIdentifier<ServiceFunctionSchedulerType> sfstEntryIID = InstanceIdentifier.builder(ServiceFunctionSchedulerTypes.class).
child(ServiceFunctionSchedulerType.class, serviceFunctionSchedulerType.getKey()).build();
sfstEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(500);
- ServiceFunctionSchedulerType sfst = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType.getType());
+ ServiceFunctionSchedulerType sfst = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleType(serviceFunctionSchedulerType.getType());
assertNotNull(sfst);
assertEquals(serviceFunctionSchedulerType, sfst);
Thread.sleep(500);
//Clean-up
- assertTrue(SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType.getType()));
+ assertTrue(SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleType(serviceFunctionSchedulerType.getType()));
Thread.sleep(500);
}
sfstEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(500);
- assertNull(SfcProviderScheduleTypeAPI.readServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType.getType()));
+ assertNull(SfcProviderScheduleTypeAPI.readServiceFunctionScheduleType(serviceFunctionSchedulerType.getType()));
}
/**
InstanceIdentifier<ServiceFunctionSchedulerType> sfstEntryIID = InstanceIdentifier.builder(ServiceFunctionSchedulerTypes.class).
child(ServiceFunctionSchedulerType.class, serviceFunctionSchedulerType.getKey()).build();
- assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType));
+ assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(serviceFunctionSchedulerType));
originalData.put(sfstEntryIID, serviceFunctionSchedulerType);
updatedServiceFunctionSchedulerTypeBuilder.setName(SchedulerTypeName);
ServiceFunctionSchedulerType updatedServiceFunctionSchedulerType = updatedServiceFunctionSchedulerTypeBuilder.build();
- assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleTypeExecutor(updatedServiceFunctionSchedulerType));
+ assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(updatedServiceFunctionSchedulerType));
updatedData.put(sfstEntryIID, updatedServiceFunctionSchedulerType);
when(dataChangeEvent.getUpdatedData()).thenReturn(updatedData);
*/
sfstEntryDataListener.onDataChanged(dataChangeEvent);
Thread.sleep(500);
- ServiceFunctionSchedulerType sfst = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleTypeExecutor(updatedServiceFunctionSchedulerType.getType());
+ ServiceFunctionSchedulerType sfst = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleType(updatedServiceFunctionSchedulerType.getType());
assertNotNull(sfst);
assertEquals(updatedServiceFunctionSchedulerType.getName(), sfst.getName());
//Clean-up
- assertTrue(SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType.getType()));
+ assertTrue(SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleType(serviceFunctionSchedulerType.getType()));
Thread.sleep(500);
}
ServiceFunctionSchedulerType serviceFunctionSchedulerType = sfstBuilder.build();
- assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerType));
+ assertTrue(SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(serviceFunctionSchedulerType));
InstanceIdentifier<ServiceFunctionSchedulerType> sfstEntryIID = InstanceIdentifier.builder(ServiceFunctionSchedulerTypes.class).
child(ServiceFunctionSchedulerType.class, serviceFunctionSchedulerType.getKey()).build();
public int countNumOfEnabledAlgorithmType() throws Exception {
int count = 0;
- OpendaylightSfc ODL_SFC = OpendaylightSfc.getOpendaylightSfcObj();
- Object[] serviceScheduleTypeObj = {};
- Class[] serviceScheduleTypeClass = {};
- SfcProviderScheduleTypeAPI sfcProviderScheduleTypeAPI = SfcProviderScheduleTypeAPI
- .getReadAll(serviceScheduleTypeObj, serviceScheduleTypeClass);
- Future future = ODL_SFC.getExecutor().submit(sfcProviderScheduleTypeAPI);
-
- ServiceFunctionSchedulerTypes sfsts = (ServiceFunctionSchedulerTypes) future.get();
+ ServiceFunctionSchedulerTypes sfsts = SfcProviderScheduleTypeAPI.readAllServiceFunctionScheduleTypes();
List<ServiceFunctionSchedulerType> sfstList = sfsts.getServiceFunctionSchedulerType();
for (ServiceFunctionSchedulerType sfst: sfstList) {
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
/**
* Wrapper around DataStore APIs. These methods take care of retries and callbacks
* automatically.
//auxiliary method
- protected void init() throws ExecutionException, InterruptedException {
+ protected void init() {
// Create Service Functions
final IpAddress[] ipMgmtAddress = new IpAddress[sfNames.length];
final IpAddress[] locatorIpAddress = new IpAddress[sfNames.length];
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll(new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
- Thread.sleep(1000); // Wait they are really created
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
LOG.debug("call createServiceFunctionTypeEntryExecutor for {}", serviceFunction.getName());
assertTrue("Must be true", ret);
}
.setConnectedSffDictionary(sffDictionaryList)
.setServiceNode(null);
ServiceFunctionForwarder sff = sffBuilder.build();
- executor.submit(SfcProviderServiceForwarderAPI.getPut(new Object[]{sff}, new Class[]{ServiceFunctionForwarder.class})).get();
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
}
//Create Service Function Chain
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(true);
- Object[] parameters = {sfcBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
- Thread.sleep(1000); // Wait SFC is really crated
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build());
//Check if Service Function Chain was created
- Object[] parameters2 = {SFC_NAME};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(SFC_NAME);
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfcServiceFunctionList);
.setSymmetric(true);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- boolean ret = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath);
+ boolean ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath);
assertTrue("Must be true", ret);
-
- Thread.sleep(1000); // Wait they are really created
}
}
setOdlSfc();
}
- @Test
- //tes SfcProviderAclAPI constructor
- public void constructorTest() {
- String methodName = "test string";
- Object[] params = {methodName};
- SfcProviderAclAPI sfcProviderAclAPI = new SfcProviderAclAPI(params, methodName);
-
- assertNotNull("Must not be null", sfcProviderAclAPI);
- assertEquals("Must be equal", sfcProviderAclAPI.getMethodName(), methodName);
- assertEquals("Must be equal", sfcProviderAclAPI.getParameters().getClass(), Object[].class);
- }
-
@Test
//read existing access list from data store
public void testReadAccessList() throws Exception {
assertTrue("must be true", transactionSuccessful);
//read access list from data store
- Acl accessList = SfcProviderAclAPI.readAccessListExecutor(ACL_NAME);
+ Acl accessList = SfcProviderAclAPI.readAccessList(ACL_NAME);
assertNotNull("Must not be null", accessList);
assertNotNull("Must not be null", accessList.getAccessListEntries());
assertTrue("must be true", transactionSuccessful);
//read access list state from data store
- AccessListState accessListState = SfcProviderAclAPI.readAccessListStateExecutor(ACL_STATE_NAME);
+ AccessListState accessListState = SfcProviderAclAPI.readAccessListState(ACL_STATE_NAME);
assertNotNull("Must not be null", accessListState);
assertEquals("Must be equal", accessListState.getAclName(), ACL_STATE_NAME);
public void testAddAndDeleteClassifier() throws Exception {
//add classifier
- boolean result = SfcProviderAclAPI.addClassifierToAccessListStateExecutor(ACL_NAME, CLASSIFIER_NAME);
+ boolean result = SfcProviderAclAPI.addClassifierToAccessListState(ACL_NAME, CLASSIFIER_NAME);
assertTrue("Must be true", result);
//delete classifier
- result = SfcProviderAclAPI.deleteClassifierFromAccessListStateExecutor(ACL_NAME, CLASSIFIER_NAME);
+ result = SfcProviderAclAPI.deleteClassifierFromAccessListState(ACL_NAME, CLASSIFIER_NAME);
assertTrue("Must be true", result);
}
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.path.first.hop.info.RenderedServicePathFirstHop;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.state.service.function.path.state.SfpRenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mpls;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
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.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.*;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.LoadBalance;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.Random;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.RoundRobin;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ServiceFunctionSchedulerTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.ShortestPath;
import org.powermock.reflect.Whitebox;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcProviderRenderedPathAPITest extends AbstractSfcRendererServicePathAPITest {
@Test
}
@Test
- public void testReadRenderedServicePathFirstHop() throws ExecutionException, InterruptedException {
+ public void testReadRenderedServicePathFirstHop() {
super.init();
- ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPathExecutor(SFP_NAME);
+ ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME);
assertNotNull("Must be not null", serviceFunctionPath);
/* Create RenderedServicePath and reverse RenderedServicePath */
assertEquals("Must be equal", firstHop.getPort(), new PortNumber(PORT[0]));
assertEquals("Must be equal", lastHop.getIp(), new IpAddress(new Ipv4Address(SFF_LOCATOR_IP[SFF_LOCATOR_IP.length - 1])));
assertEquals("Must be equal", lastHop.getPort(), new PortNumber(PORT[PORT.length - 1]));
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(renderedServicePath.getName());
- SfcProviderRenderedPathAPI.deleteRenderedServicePathExecutor(revRenderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(renderedServicePath.getName());
+ SfcProviderRenderedPathAPI.deleteRenderedServicePath(revRenderedServicePath.getName());
}
@Test
- public void testReadRspFirstHopBySftList() throws ExecutionException, InterruptedException {
+ public void testReadRspFirstHopBySftList() {
init();
List<Class<? extends ServiceFunctionTypeIdentity>> sftList = new ArrayList<>();
}
@Test
- public void testCreateRenderedServicePathHopList() throws ExecutionException, InterruptedException {
+ public void testCreateRenderedServicePathHopList() {
init();
final String[] tmpSfNames = {"unittest-fw-1", "unittest-dpi-1", "unittest-napt-1"};
List<String> sfNameList = Arrays.asList(tmpSfNames);
final int startingIndex = 255;
- Object[] parameters = {};
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI(parameters, null);
+ SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI();
List<RenderedServicePathHop> rspHopList;
}
@Test
- public void testCreateRenderedServicePathAndState() throws ExecutionException, InterruptedException {
+ public void testCreateRenderedServicePathAndState() {
init();
ServiceFunctionPath serviceFunctionPath =
- SfcProviderServicePathAPI.readServiceFunctionPathExecutor(SFP_NAME);
+ SfcProviderServicePathAPI.readServiceFunctionPath(SFP_NAME);
assertNotNull("Must be not null", serviceFunctionPath);
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
serviceFunctionPath, createRenderedPathInputBuilder.build());
//check if SFF oper contains RSP
- List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffStateExecutor(SFF_NAMES[1]);
+ List<SffServicePath> sffServicePathList = SfcProviderServiceForwarderAPI.readSffState(SFF_NAMES[1]);
assertNotNull("Must be not null", sffServicePathList);
assertEquals(sffServicePathList.get(0).getName(), RSP_NAME);
//check if SF oper contains RSP
- List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor("unittest-fw-1");
+ List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState("unittest-fw-1");
assertEquals(sfServicePathList.get(0).getName(), RSP_NAME);
//check if SFP oper contains RSP
- List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathStateExecutor(SFP_NAME);
+ List<SfpRenderedServicePath> sfpRenderedServicePathList = SfcProviderServicePathAPI.readServicePathState(SFP_NAME);
assertEquals(sfpRenderedServicePathList.get(0).getName(), RSP_NAME);
}
Object[] params = new Object[0];
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder();
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI(params, null);
+ SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI();
RenderedServicePath testRenderedServicePath;
serviceFunctionPathBuilder.setServiceChainName(null);
Object[] params = new Object[0];
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder();
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI(params, null);
+ SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI();
SfcServiceFunctionSchedulerAPI testScheduler = new SfcServiceFunctionRandomSchedulerAPI();
RenderedServicePath testRenderedServicePath;
Object[] params = new Object[0];
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder();
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI(params, null);
+ SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI();
SfcServiceFunctionSchedulerAPI testScheduler = new SfcServiceFunctionRandomSchedulerAPI();
RenderedServicePath testRenderedServicePath;
Object[] params = new Object[0];
CreateRenderedPathInputBuilder createRenderedPathInputBuilder = new CreateRenderedPathInputBuilder();
ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder();
- SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI(params, null);
+ SfcProviderRenderedPathAPI sfcProviderRenderedPathAPI = new SfcProviderRenderedPathAPI();
SfcServiceFunctionSchedulerAPI testScheduler = new SfcServiceFunctionRandomSchedulerAPI();
RenderedServicePath testRenderedServicePath;
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeBuilder;
import org.opendaylight.yang.gen.v1.urn.intel.params.xml.ns.yang.sfc.sfst.rev150312.service.function.scheduler.types.ServiceFunctionSchedulerTypeKey;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcProviderScheduleTypeAPITest extends AbstractDataStoreManager {
@Before
setOdlSfc();
}
- /* Cannot pass at the moment, will fix later on
- * Error log:
- * ERROR o.o.s.p.api.SfcProviderAbstractAPI - Could not find method readServiceFunctionScheduleType in class
-
@Test
- public void testCreateReadScheduleType() throws ExecutionException, InterruptedException {
- String name = "random-01";
- Class<? extends ServiceFunctionSchedulerTypeIdentity> type = Random.class;
- ServiceFunctionSchedulerTypeKey key = new ServiceFunctionSchedulerTypeKey(type);
-
- ServiceFunctionSchedulerTypeBuilder sfstBuilder = new ServiceFunctionSchedulerTypeBuilder();
- sfstBuilder.setName(name).setType(type).setKey(key).setEnabled(true);
-
- Object[] parameters = {sfstBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionSchedulerType.class};
-
- try {
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters, parameterTypes)).get();
- } catch (ExecutionException ee) {
- assertEquals("Must be equal", 0, 1);
- } catch (InterruptedException ie) {
- assertEquals("Must be equal", 0, 1);
- }
-
- Object[] parameters2 = {type};
- Class[] parameterTypes2 = {ServiceFunctionSchedulerTypeIdentity.class};
- try {
- Object result = executor.submit(SfcProviderScheduleTypeAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionSchedulerType sfst2 = (ServiceFunctionSchedulerType) result;
-
- assertNotNull("Must be not null", sfst2);
- assertEquals("Must be equal", sfst2.getName(), name);
- assertEquals("Must be equal", sfst2.getType(), type);
- assertEquals("Must be equal", sfst2.isEnabled(), true);
- } catch (ExecutionException ee) {
- assertEquals("Must be equal", 0, 1);
- } catch (InterruptedException ie) {
- assertEquals("Must be equal", 0, 1);
- }
- }
-
- @Test
- public void testCreateDeleteScheduleType() throws ExecutionException, InterruptedException {
- String name = "random-01";
- Class<? extends ServiceFunctionSchedulerTypeIdentity> type = Random.class;
- ServiceFunctionSchedulerTypeKey key = new ServiceFunctionSchedulerTypeKey(type);
-
- ServiceFunctionSchedulerTypeBuilder sfstBuilder = new ServiceFunctionSchedulerTypeBuilder();
- sfstBuilder.setName(name).setType(type).setKey(key).setEnabled(true);
-
- Object[] parameters = {sfstBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionSchedulerType.class};
-
- try {
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters, parameterTypes)).get();
- } catch (ExecutionException ee) {
- assertEquals("Must be equal", 0, 1);
- } catch (InterruptedException ie) {
- assertEquals("Must be equal", 0, 1);
- }
-
- Object[] parameters2 = {type};
- Class[] parameterTypes2 = {ServiceFunctionSchedulerTypeIdentity.class};
- try {
- Object result = executor.submit(SfcProviderScheduleTypeAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionSchedulerType sfst2 = (ServiceFunctionSchedulerType) result;
- assertNotNull("Must be not null", sfst2);
-
- result = executor.submit(SfcProviderScheduleTypeAPI
- .getDelete(parameters2, parameterTypes2)).get();
- result = executor.submit(SfcProviderScheduleTypeAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionSchedulerType sfst3 = (ServiceFunctionSchedulerType) result;
- assertNull("Must be null", sfst3);
- } catch (ExecutionException ee) {
- assertEquals("Must be equal", 0, 1);
- } catch (InterruptedException ie) {
- assertEquals("Must be equal", 0, 1);
- }
- }
- */
-
- @Test
- public void testCreateReadAllScheduleTypes() throws ExecutionException, InterruptedException {
+ public void testCreateReadAllScheduleTypes() {
String name1 = "random-01";
Class<? extends ServiceFunctionSchedulerTypeIdentity> type1 = Random.class;
ServiceFunctionSchedulerTypeKey key1 = new ServiceFunctionSchedulerTypeKey(type1);
ServiceFunctionSchedulerTypeBuilder sfstBuilder2 = new ServiceFunctionSchedulerTypeBuilder();
sfstBuilder2.setName(name2).setType(type2).setKey(key2).setEnabled(false);
- Object[] parameters1 = {sfstBuilder1.build()};
- Object[] parameters2 = {sfstBuilder2.build()};
- Class[] parameterTypes = {ServiceFunctionSchedulerType.class};
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstBuilder1.build());
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstBuilder2.build());
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters1, parameterTypes)).get();
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters2, parameterTypes)).get();
-
- Object[] parameters = {};
- Class[] parameterTypes2 = {};
-
- Object result = executor.submit(SfcProviderScheduleTypeAPI
- .getReadAll(parameters, parameterTypes2)).get();
- ServiceFunctionSchedulerTypes sfsts = (ServiceFunctionSchedulerTypes) result;
+ ServiceFunctionSchedulerTypes sfsts = SfcProviderScheduleTypeAPI.readAllServiceFunctionScheduleTypes();
List<ServiceFunctionSchedulerType> sfstList = sfsts.getServiceFunctionSchedulerType();
assertEquals("Must be equal", sfstList.size(), 2);
}
@Test
- public void testCreateReadEnabledScheduleTypeEntryExecutor() throws ExecutionException, InterruptedException {
+ public void testCreateReadEnabledScheduleTypeEntryExecutor() {
String name1 = "random-01";
Class<? extends ServiceFunctionSchedulerTypeIdentity> type1 = Random.class;
ServiceFunctionSchedulerTypeKey key1 = new ServiceFunctionSchedulerTypeKey(type1);
ServiceFunctionSchedulerTypeBuilder sfstBuilder2 = new ServiceFunctionSchedulerTypeBuilder();
sfstBuilder2.setName(name2).setType(type2).setKey(key2).setEnabled(false);
- Object[] parameters1 = {sfstBuilder1.build()};
- Object[] parameters2 = {sfstBuilder2.build()};
- Class[] parameterTypes = {ServiceFunctionSchedulerType.class};
-
-
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters1, parameterTypes)).get();
- executor.submit(SfcProviderScheduleTypeAPI
- .getPut(parameters2, parameterTypes)).get();
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstBuilder1.build());
+ SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(sfstBuilder2.build());
- Object result = SfcProviderScheduleTypeAPI.readEnabledServiceFunctionScheduleTypeEntryExecutor();
+ Object result = SfcProviderScheduleTypeAPI.readEnabledServiceFunctionScheduleTypeEntry();
ServiceFunctionSchedulerType sfst = (ServiceFunctionSchedulerType) result;
assertNotNull("Must be not null", sfst);
.setType(RoundRobin.class);
//write service function scheduler type
- boolean transactionSuccessful = SfcProviderScheduleTypeAPI.putServiceFunctionScheduleTypeExecutor(serviceFunctionSchedulerTypeBuilder.build());
+ boolean transactionSuccessful = SfcProviderScheduleTypeAPI.putServiceFunctionScheduleType(serviceFunctionSchedulerTypeBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//read written service function scheduler type
- ServiceFunctionSchedulerType serviceFunctionSchedulerType = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleTypeExecutor(RoundRobin.class);
+ ServiceFunctionSchedulerType serviceFunctionSchedulerType = SfcProviderScheduleTypeAPI.readServiceFunctionScheduleType(RoundRobin.class);
assertNotNull("Must not be null", serviceFunctionSchedulerType);
assertEquals("Must be equal", serviceFunctionSchedulerType.getName(), "SFST");
assertEquals("Must be equal", serviceFunctionSchedulerType.getType(), RoundRobin.class);
assertTrue("Must be equal", serviceFunctionSchedulerType.isEnabled());
//remove service function scheduler type
- transactionSuccessful = SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleTypeExecutor(RoundRobin.class);
+ transactionSuccessful = SfcProviderScheduleTypeAPI.deleteServiceFunctionScheduleType(RoundRobin.class);
assertTrue("Must be true", transactionSuccessful);
}
}
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chains.state.service.function.chain.state.SfcServicePathKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcProviderServiceChainAPITest extends AbstractDataStoreManager {
public static final String[] LOCATOR_IP_ADDRESS =
}
@Test
- public void testCreateReadServiceFunctionChain() throws ExecutionException, InterruptedException {
+ public void testCreateReadServiceFunctionChain() {
String name = "unittest-chain-1";
ServiceFunctionChainKey key = new ServiceFunctionChainKey(name);
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(false);
- Object[] parameters = {sfcBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build());
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(name);
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfcServiceFunctionList);
}
@Test
- public void testDeleteServiceFunctionChain() throws ExecutionException, InterruptedException {
+ public void testDeleteServiceFunctionChain() {
String name = "unittest-chain-2";
ServiceFunctionChainKey key = new ServiceFunctionChainKey(name);
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(false);
- Object[] parameters = {sfcBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
-
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build());
+ ServiceFunctionChain result = SfcProviderServiceChainAPI.readServiceFunctionChain(name);
assertNotNull("Must be not null", result);
- assertTrue("Must be ServiceFunctionChain", result instanceof ServiceFunctionChain);
-
- executor.submit(SfcProviderServiceChainAPI
- .getDelete(parameters2, parameterTypes2)).get();
-
- result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
+ SfcProviderServiceChainAPI.deleteServiceFunctionChain(name);
+ result = SfcProviderServiceChainAPI.readServiceFunctionChain(name);
assertNull("Must be null", result);
}
@Test
- public void testCreateReadServiceFunctionChains() throws ExecutionException, InterruptedException {
+ public void testCreateReadServiceFunctionChains() {
List<SfcServiceFunction> sfcAllServiceFunctionList = new ArrayList<>();
ServiceFunctionChainsBuilder sfcsBuilder = new ServiceFunctionChainsBuilder();
sfcsBuilder.setServiceFunctionChain(sfcList);
-
- executor.submit(SfcProviderServiceChainAPI
- .getPutAll(
- new Object[]{sfcsBuilder.build()}, new Class[]{ServiceFunctionChains.class})).get();
+ SfcProviderServiceChainAPI.putAllServiceFunctionChains(sfcsBuilder.build());
final int INDEX_TO_READ = 1;
- Object[] parameters2 = {sfcName.get(INDEX_TO_READ)};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(sfcName.get(INDEX_TO_READ));
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2, sfcArray[INDEX_TO_READ]);
@Test
public void testReadAllServiceFunctionChains() {
- Object[] params = {"hello"};
- SfcProviderServiceChainAPILocal sfcProviderServiceChainAPILocal = new SfcProviderServiceChainAPILocal(params);
-
ServiceFunctionChainBuilder serviceFunctionChainBuilder = new ServiceFunctionChainBuilder();
ServiceFunctionChain serviceFunctionChain = serviceFunctionChainBuilder.setName("SFC1").setKey(new ServiceFunctionChainKey("SFC1")).build();
SfcDataStoreAPI.writePutTransactionAPI(sfcsIID, serviceFunctionChains, LogicalDatastoreType.CONFIGURATION);
- ServiceFunctionChains returnedSfc = sfcProviderServiceChainAPILocal.readAllServiceFunctionChains();
+ ServiceFunctionChains returnedSfc = SfcProviderServiceChainAPI.readAllServiceFunctionChains();
assertNotNull("Returned variable is missing.", returnedSfc);
}
assertTrue("Must be true", transactionSuccessful);
//get service function chains
- ServiceFunctionChains serviceFunctionChains = SfcProviderServiceChainAPI.getServiceFunctionChainsRefExecutor();
+ ServiceFunctionChains serviceFunctionChains = SfcProviderServiceChainAPI.getServiceFunctionChainsRef();
assertNotNull("Must not be null", serviceFunctionChains);
assertEquals("Must be equal", serviceFunctionChains.getServiceFunctionChain().get(0).getName(), "SFC1");
assertEquals("Must be equal", serviceFunctionChains.getServiceFunctionChain().get(0).getSfcServiceFunction().get(0).getName(), "SFF1");
assertTrue("Must be true", transactionSuccessful);
//get data
- ServiceFunctionChainsState serviceFunctionChainsState = SfcProviderServiceChainAPI.getServiceFunctionChainsStateRefExecutor();
+ ServiceFunctionChainsState serviceFunctionChainsState = SfcProviderServiceChainAPI.getServiceFunctionChainsStateRef();
assertNotNull("Must not be null", serviceFunctionChainsState);
assertEquals("Must be equal", serviceFunctionChainsState.getServiceFunctionChainState().get(0).getName(), "SFC1");
assertEquals("Must be equal", serviceFunctionChainsState.getServiceFunctionChainState().get(0).getSfcServicePath().get(0).getName(), "SP1");
assertTrue("Must be true", transactionSuccessful);
}
- private class SfcProviderServiceChainAPILocal extends SfcProviderServiceChainAPI {
-
- SfcProviderServiceChainAPILocal(Object[] params) {
- super(params, "m");
- }
- }
}
package org.opendaylight.sfc.provider.api;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertArrayEquals;
import java.util.ArrayList;
import java.util.List;
assertClsfStateDoesNotExist(clsfName);
assertTrue("Failed to update clsf state.",
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(clsfName, rspName1));
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState(clsfName, rspName1));
readAndAssertClsfState(clsfName, rspName1);
// update classifier state with another rendered service path
assertTrue("Failed to update clsf state.",
- SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierStateExecutor(clsfName, rspName2));
+ SfcProviderServiceClassifierAPI.addRenderedPathToServiceClassifierState(clsfName, rspName2));
readAndAssertClsfState(clsfName, rspName2);
}
}
private static void assertClassifierDoesNotExists(String clsfName) {
- ServiceFunctionClassifier clsf = SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(clsfName);
+ ServiceFunctionClassifier clsf = SfcProviderServiceClassifierAPI.readServiceClassifier(clsfName);
assertNull("Unexpected classifier found.", clsf);
}
private static void readAndAssertClassifier(ServiceFunctionClassifier expectedClsf) {
- ServiceFunctionClassifier clsf = SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(expectedClsf.getName());
+ ServiceFunctionClassifier clsf = SfcProviderServiceClassifierAPI.readServiceClassifier(expectedClsf.getName());
assertNotNull("Classifier not found.", clsf);
assertEquals(expectedClsf.getName(), clsf.getName());
assertEquals(expectedClsf.getKey().getName(), clsf.getKey().getName());
assertEquals(expectedClsf.getSclServiceFunctionForwarder(), clsf.getSclServiceFunctionForwarder());
}
- @SuppressWarnings("rawtypes")
- @Test
- public void getReadTest() throws Exception {
- Object[] params = {"funcParam0", "funcParam1"};
- Class[] paramTypes = {String.class, String.class};
- SfcProviderServiceClassifierAPI api = SfcProviderServiceClassifierAPI.getRead(params, paramTypes);
- assertApiInitialization(api, params, paramTypes);
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void getAddRenderedPathToServiceClassifierStateExecutorTest() throws Exception {
- Object[] params = {"funcParam0", "funcParam1"};
- Class[] paramTypes = {String.class, String.class};
- SfcProviderServiceClassifierAPI api = SfcProviderServiceClassifierAPI.getAddRenderedPathToServiceClassifierStateExecutor(params, paramTypes);
- assertApiInitialization(api, params, paramTypes);
- }
-
- @SuppressWarnings("rawtypes")
- private void assertApiInitialization(SfcProviderServiceClassifierAPI api,
- Object[] expectedParams, Class[] expectedParamTypes) {
- assertArrayEquals(expectedParams, api.getParameters());
- assertArrayEquals(expectedParamTypes, api.getParameterTypes());
- assertFalse(api.getMethodName().isEmpty());
- }
}
\ No newline at end of file
package org.opendaylight.sfc.provider.api;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
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 java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.hamcrest.CoreMatchers.hasItem;
-import static org.junit.Assert.*;
-
/**
* Tests for dictionary operations on SFFs
*/
}
@Test
- public void testUpdateDictionary() throws ExecutionException, InterruptedException {
+ public void testUpdateDictionary() {
String name = sffName[0];
.setServiceNode(null) // for consistency only; we are going to get rid of ServiceNodes in the future
.build();
- Object[] parameters = {sff};
- Class[] parameterTypes = {ServiceFunctionForwarder.class};
-
- executor.submit(SfcProviderServiceForwarderAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceForwarderAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionForwarder sff2 = (ServiceFunctionForwarder) result;
-
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
+ ServiceFunctionForwarder sff2 = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(name);
assertNotNull("Must be not null", sff2);
assertEquals("Must be equal", sff2.getSffDataPlaneLocator(), locatorList);
assertThat("Must contain first dictionary entry", sff2.getServiceFunctionDictionary(), hasItem(firstDictEntry));
sff2.getServiceFunctionDictionary().add(newDictEntry);
dictionary.add(newDictEntry);
- Object[] parameters3 = {sff};
- Class[] parameterTypes3 = {ServiceFunctionForwarder.class};
-
- executor.submit(SfcProviderServiceForwarderAPI
- .getPut(parameters3, parameterTypes3)).get();
-
- Object[] parameters4 = {name};
- Class[] parameterTypes4 = {String.class};
- Object result4 = executor.submit(SfcProviderServiceForwarderAPI
- .getRead(parameters4, parameterTypes4)).get();
- ServiceFunctionForwarder sff4 = (ServiceFunctionForwarder) result4;
-
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
+ ServiceFunctionForwarder sff4 = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(name);
assertNotNull("Must be not null", sff4);
assertThat("Must contain first dictionary entry", sff4.getServiceFunctionDictionary(), hasItem(firstDictEntry));
assertThat("Must contain new dictionary entry", sff4.getServiceFunctionDictionary(), hasItem(newDictEntry));
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
/**
* Tests for simple data store operations on SFFs (i.e. Service Functions are created first)
*/
private static final String[] SF_ABSTRACT_NAMES = {"firewall", "dpi", "napt", "http-header-enrichment", "qos"};
private static final String SFC_NAME = "unittest-chain-1";
private static final String SFP_NAME = "unittest-sfp-1";
- private static final String RSP_NAME = "unittest-rsp-1";
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceChainAPITest.class);
private static final String[] sfNames = {"unittest-fw-1", "unittest-dpi-1", "unittest-napt-1", "unittest-http-header-enrichment-1", "unittest-qos-1"};
private final String[] SFF_NAMES = {"SFF1", "SFF2", "SFF3", "SFF4", "SFF5"};
private List<ServiceFunction> sfList = new ArrayList<>();
@Before
- public void before() throws ExecutionException, InterruptedException {
+ public void before() {
setOdlSfc();
// Create Service Functions
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll(new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
- Thread.sleep(1000); // Wait they are really created
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
LOG.debug("call createServiceFunctionTypeEntryExecutor for {}", serviceFunction.getName());
assertTrue("Must be true", ret);
}
.setConnectedSffDictionary(sffDictionaryList)
.setServiceNode(null);
ServiceFunctionForwarder sff = sffBuilder.build();
- executor.submit(SfcProviderServiceForwarderAPI.getPut(new Object[]{sff}, new Class[]{ServiceFunctionForwarder.class})).get();
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
}
//Create Service Function Chain
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(true);
- Object[] parameters = {sfcBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
- Thread.sleep(1000); // Wait SFC is really crated
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build());
//Check if Service Function Chain was created
- Object[] parameters2 = {SFC_NAME};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(SFC_NAME);
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfcServiceFunctionList);
.setSymmetric(true);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- boolean ret = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath);
+ boolean ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath);
assertTrue("Must be true", ret);
- Thread.sleep(1000); // Wait they are really created
}
@Test
- public void testCreateReadUpdateServiceFunctionForwarder() throws ExecutionException, InterruptedException {
+ public void testCreateReadUpdateServiceFunctionForwarder() {
String name = sffName[0];
.setServiceNode(null) // for consistency only; we are going to get rid of ServiceNodes in the future
.build();
- Object[] parameters = {sff};
- Class[] parameterTypes = {ServiceFunctionForwarder.class};
-
- executor.submit(SfcProviderServiceForwarderAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceForwarderAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionForwarder sff2 = (ServiceFunctionForwarder) result;
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
+ ServiceFunctionForwarder sff2 = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(name);
assertNotNull("Must be not null", sff2);
assertEquals("Must be equal", sff2.getSffDataPlaneLocator(), locatorList);
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.HttpHeaderEnrichment;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Napt44;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Qos;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
/**
* Tests for simple datastore operations on SFFs (i.e. Service Functions are created first)
*/
private static final String[] SF_ABSTRACT_NAMES = {"firewall", "dpi", "napt", "http-header-enrichment", "qos"};
private static final String SFC_NAME = "unittest-chain-1";
private static final String SFP_NAME = "unittest-sfp-1";
- private static final String RSP_NAME = "unittest-rsp-1";
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceChainAPITest.class);
private static final String[] sfNames = {"unittest-fw-1", "unittest-dpi-1", "unittest-napt-1", "unittest-http-header-enrichment-1", "unittest-qos-1"};
private final String[] SFF_NAMES = {"SFF1", "SFF2", "SFF3", "SFF4", "SFF5"};
private List<ServiceFunction> sfList = new ArrayList<>();
@Before
- public void before() throws ExecutionException, InterruptedException {
+ public void before() {
setOdlSfc();
// Create Service Functions
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll(new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
- Thread.sleep(1000); // Wait they are really created
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
// Create ServiceFunctionTypeEntry for all ServiceFunctions
for (ServiceFunction serviceFunction : sfList) {
- boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
LOG.debug("call createServiceFunctionTypeEntryExecutor for {}", serviceFunction.getName());
assertTrue("Must be true", ret);
}
.setConnectedSffDictionary(sffDictionaryList)
.setServiceNode(null);
ServiceFunctionForwarder sff = sffBuilder.build();
- executor.submit(SfcProviderServiceForwarderAPI.getPut(new Object[]{sff}, new Class[]{ServiceFunctionForwarder.class})).get();
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
}
//Create Service Function Chain
.setSfcServiceFunction(sfcServiceFunctionList)
.setSymmetric(true);
- Object[] parameters = {sfcBuilder.build()};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
- Thread.sleep(1000); // Wait SFC is really crated
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfcBuilder.build());
//Check if Service Function Chain was created
- Object[] parameters2 = {SFC_NAME};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(SFC_NAME);
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfcServiceFunctionList);
.setSymmetric(true);
ServiceFunctionPath serviceFunctionPath = pathBuilder.build();
assertNotNull("Must be not null", serviceFunctionPath);
- boolean ret = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPath);
+ boolean ret = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPath);
assertTrue("Must be true", ret);
-
- Thread.sleep(1000); // Wait they are really created
}
@Test
- public void testCreateReadUpdateServiceFunctionForwarder() throws ExecutionException, InterruptedException {
+ public void testCreateReadUpdateServiceFunctionForwarder() {
String name = sffName[0];
.setServiceNode(null) // for consistency only; we are going to get rid of ServiceNodes in the future
.build();
- Object[] parameters = {sff};
- Class[] parameterTypes = {ServiceFunctionForwarder.class};
-
- executor.submit(SfcProviderServiceForwarderAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceForwarderAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionForwarder sff2 = (ServiceFunctionForwarder) result;
-
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
+ ServiceFunctionForwarder sff2 = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(name);
assertNotNull("Must be not null", sff2);
assertEquals("Must be equal", sff2.getSffDataPlaneLocator(), locatorList);
assertEquals("Must be equal", sff2.getServiceFunctionDictionary(), dictionary);
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
/**
* Tests for simple datastore operations on SFFs (i.e. Service Functions are created first)
*/
public class SfcProviderServiceForwarderAPISimpleTest extends AbstractDataStoreManager {
- private final Object[] params = {"hello"};
private final ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder();
private final RenderedServicePathHopBuilder renderedServicePathHopBuilder = new RenderedServicePathHopBuilder();
private final RenderedServicePathHop renderedServicePathHop = renderedServicePathHopBuilder.setKey(new RenderedServicePathHopKey((short) 3))
.setServiceFunctionForwarder("SFF1").build();
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPILocal(params);
+ SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPI();
ServiceFunctionForwarder sff;
- private ServiceFunctionPathBuilder pathBuilder = new ServiceFunctionPathBuilder();
@Before
public void before() {
}
@Test
- public void testCreateReadUpdateServiceFunctionForwarder() throws ExecutionException, InterruptedException {
+ public void testCreateReadUpdateServiceFunctionForwarder() {
String name = "SFF1";
String[] sfNames = {"unittest-fw-1", "unittest-dpi-1", "unittest-napt-1", "unittest-http-header-enrichment-1", "unittest-qos-1"};
IpAddress[] ipMgmtAddress = new IpAddress[sfNames.length];
.setServiceNode(null) // for consistency only; we are going to get rid of ServiceNodes in the future
.build();
- Object[] parameters = {sff};
- Class[] parameterTypes = {ServiceFunctionForwarder.class};
-
- executor.submit(SfcProviderServiceForwarderAPI
- .getPut(parameters, parameterTypes)).get();
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceForwarderAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionForwarder sff2 = (ServiceFunctionForwarder) result;
+ ServiceFunctionForwarder sff2 = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(name);
assertNotNull("Must be not null", sff2);
assertEquals("Must be equal", sff2.getSffDataPlaneLocator(), locatorList);
serviceFunctionForwarderBuilder.setName(sff)
.setKey(new ServiceFunctionForwarderKey(sff));
- boolean transactionSuccessful = SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(serviceFunctionForwarderBuilder.build());
+ boolean transactionSuccessful = SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(serviceFunctionForwarderBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//create list of path for testing purposes
sffServicePathTestList.add(createRenderedServicePath(rsp + 4, sff, (short) 4));
//add two paths to service function forwarder state via rsp objects
- transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(sffServicePathTestList.get(0));
+ transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(sffServicePathTestList.get(0));
assertTrue("Must be true", transactionSuccessful);
- transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(sffServicePathTestList.get(1));
+ transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(sffServicePathTestList.get(1));
assertTrue("Must be true", transactionSuccessful);
//add another two paths to service function forwarder state via rsp name
- transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(sffServicePathTestList.get(2).getName());
+ transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(sffServicePathTestList.get(2).getName());
assertTrue("Must be true", transactionSuccessful);
- transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(sffServicePathTestList.get(3).getName());
+ transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(sffServicePathTestList.get(3).getName());
assertTrue("Must be true", transactionSuccessful);
//read service function forwarder state from data store, it should return list of all four paths
- List<SffServicePath> sffServicePaths = SfcProviderServiceForwarderAPI.readSffStateExecutor(sff);
+ List<SffServicePath> sffServicePaths = SfcProviderServiceForwarderAPI.readSffState(sff);
assertNotNull("Must be not null", sffServicePaths);
assertEquals("Must be equal", sffServicePaths.size(), 4);
//remove path 1 via service path object
ServiceFunctionPathBuilder serviceFunctionPathBuilder = new ServiceFunctionPathBuilder();
serviceFunctionPathBuilder.setName("rsp1");
- transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(serviceFunctionPathBuilder.build());
+ transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(serviceFunctionPathBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//remove path 2 via rendered service path name
- transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor("rsp2");
+ transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState("rsp2");
assertTrue("Must be true", transactionSuccessful);
//remove paths 3 & 4 via list of rendered service path names
List<String> rspNames = new ArrayList<>();
rspNames.add("rsp3");
rspNames.add("rsp4");
- transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderStateExecutor(rspNames);
+ transactionSuccessful = SfcProviderServiceForwarderAPI.deletePathFromServiceForwarderState(rspNames);
assertTrue("Must be true", transactionSuccessful);
//read service function forwarder state from data store, paths are removed, should return null
- sffServicePaths = SfcProviderServiceForwarderAPI.readSffStateExecutor(sff);
+ sffServicePaths = SfcProviderServiceForwarderAPI.readSffState(sff);
assertNull("Must be null", sffServicePaths);
//remove written forwarder
- transactionSuccessful = SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderExecutor(sff);
+ transactionSuccessful = SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarder(sff);
assertTrue("Must be true", transactionSuccessful);
}
sffBuilder.setName("SFF1")
.setKey(new ServiceFunctionForwarderKey("SFF1"));
ServiceFunctionForwarder sff = sffBuilder.build();
- assertTrue(SfcProviderServiceForwarderAPI.updateServiceFunctionForwarderExecutor(sff));
+ assertTrue(SfcProviderServiceForwarderAPI.updateServiceFunctionForwarder(sff));
}
/*
.setKey(new ServiceFunctionForwarderKey(sffName));
ServiceFunctionForwarder serviceFunctionForwarder = serviceFunctionForwarderBuilder.build();
- boolean transactionSuccessful = SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(serviceFunctionForwarder);
+ boolean transactionSuccessful = SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(serviceFunctionForwarder);
assertTrue("Must be true", transactionSuccessful);
//create rendered service path and add it to service function forwarder state
- transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderStateExecutor(createRenderedServicePath(sffPath, sffName, (short) 1));
+ transactionSuccessful = SfcProviderServiceForwarderAPI.addPathToServiceForwarderState(createRenderedServicePath(sffPath, sffName, (short) 1));
assertTrue("Must be true", transactionSuccessful);
//check if rendered service path exists
sffBuilder.setName("SFF1")
.setKey(new ServiceFunctionForwarderKey("SFF1"));
ServiceFunctionForwarder sff = sffBuilder.build();
- assertTrue(SfcProviderServiceForwarderAPI.putServiceFunctionForwarderExecutor(sff));
+ assertTrue(SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff));
}
@Test
SfcDataStoreAPI.writePutTransactionAPI(sffDataPlaneLocatorIID, sffDataPlaneLocator, LogicalDatastoreType.CONFIGURATION);
- Object[] params = {"hello"};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPILocal(params);
-
+ SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPI();
assertTrue(sfcProviderServiceForwarderAPI.deleteSffDataPlaneLocator("SFF1", "SFFLoc1"));
}
SfcDataStoreAPI.writePutTransactionAPI(sffDataPlaneLocatorIID, sffDataPlaneLocator, LogicalDatastoreType.CONFIGURATION);
- assertTrue(SfcProviderServiceForwarderAPI.deleteSffDataPlaneLocatorExecutor("SFF1", "SFFLoc1"));
+ assertTrue(SfcProviderServiceForwarderAPI.deleteSffDataPlaneLocator("SFF1", "SFFLoc1"));
}
@Test
public void testDeleteServiceFunctionForwarder() {
- Object[] params = {"hello"};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPILocal(params);
-
+ SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPI();
assertTrue(sfcProviderServiceForwarderAPI.deleteServiceFunctionForwarder("SFF1"));
}
@Test
public void testDeleteServiceFunctionForwarderExecutor() {
- assertTrue(SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarderExecutor("SFF1"));
+ assertTrue(SfcProviderServiceForwarderAPI.deleteServiceFunctionForwarder("SFF1"));
}
@Test
serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
ServiceFunctionForwarders sffs = serviceFunctionForwardersBuilder.build();
- Object[] params = {"hello"};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPILocal(params);
-
+ SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPI();
assertTrue(sfcProviderServiceForwarderAPI.putAllServiceFunctionForwarders(sffs));
}
SfcDataStoreAPI.writePutTransactionAPI(sffIID, serviceFunctionDictionary, LogicalDatastoreType.CONFIGURATION);
- Object[] params = {"hello"};
- SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPILocal(params);
+ SfcProviderServiceForwarderAPI sfcProviderServiceForwarderAPI = new SfcProviderServiceForwarderAPI();
assertTrue(sfcProviderServiceForwarderAPI.deleteServiceFunctionFromForwarder(serviceFunction));
}
return renderedServicePathBuilder.build();
}
- private class SfcProviderServiceForwarderAPILocal extends SfcProviderServiceForwarderAPI {
-
- SfcProviderServiceForwarderAPILocal(Object[] params) {
- super(params, "m");
- }
- }
}
}
@Test
- public void testCreateReadServiceFunction() throws ExecutionException, InterruptedException {
+ public void testCreateReadServiceFunction() {
String name = "unittest-fw-1";
Class<? extends ServiceFunctionTypeIdentity> type = Firewall.class;
.setIpMgmtAddress(ipMgmtAddress)
.setSfDataPlaneLocator(dataPlaneLocatorList);
- Object[] parameters = {sfBuilder.build()};
- Class[] parameterTypes = {ServiceFunction.class};
-
- executor.submit(SfcProviderServiceFunctionAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunction sf2 = (ServiceFunction) result;
+ SfcProviderServiceFunctionAPI.putServiceFunction(sfBuilder.build());
+ ServiceFunction sf2 = SfcProviderServiceFunctionAPI.readServiceFunction(name);
assertNotNull("Must be not null", sf2);
assertEquals("Must be equal", sf2.getIpMgmtAddress(), ipMgmtAddress);
}
@Test
- public void testDeleteServiceFunction() throws ExecutionException, InterruptedException {
+ public void testDeleteServiceFunction() {
String name = "unittest-fw-1";
Class<? extends ServiceFunctionTypeIdentity> type = Firewall.class;
.setIpMgmtAddress(ipMgmtAddress)
.setSfDataPlaneLocator(dataPlaneLocatorList);
- Object[] parameters = {sfBuilder.build()};
- Class[] parameterTypes = {ServiceFunction.class};
-
- executor.submit(SfcProviderServiceFunctionAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {name};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
+ SfcProviderServiceFunctionAPI.putServiceFunction(sfBuilder.build());
+ assertNotNull("Must be not null", SfcProviderServiceFunctionAPI.readServiceFunction(name));
- assertNotNull("Must be not null", result);
- assertTrue("Must be ServiceFunction", result instanceof ServiceFunction);
-
- executor.submit(SfcProviderServiceFunctionAPI
- .getDelete(parameters2, parameterTypes2)).get();
- result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
-
- assertNull("Must be null", result);
+ SfcProviderServiceFunctionAPI.deleteServiceFunction(name);
+ assertNull("Must be null", SfcProviderServiceFunctionAPI.readServiceFunction(name));
}
@Test
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(list);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll
- (new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
-
-
- Object[] parameters2 = {sfName[1]};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunction sf2 = (ServiceFunction) result;
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
+ ServiceFunction sf2 = SfcProviderServiceFunctionAPI.readServiceFunction(sfName[1]);
assertNotNull("Must be not null", sf2);
assertEquals("Must be equal", sf2.getIpMgmtAddress(), ipMgmtAddress[1]);
assertTrue("Must be true", transactionSuccessful);
//read service function with its name and return it
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(SF_NAME);
+ ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(SF_NAME);
assertNotNull("Must be not null", serviceFunction);
assertEquals("Must be equal", serviceFunction.getIpMgmtAddress().getIpv4Address().getValue(), IP_MGMT_ADDRESS[1]);
//read service function state with its name
//list of SfServicePath will be returned
- List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionStateExecutor(SF_STATE_NAME);
+ List<SfServicePath> sfServicePathList = SfcProviderServiceFunctionAPI.readServiceFunctionState(SF_STATE_NAME);
assertNotNull("Must not be null", sfServicePathList);
assertEquals("Must be equal", sfServicePathList.get(0).getName(), SF_SERVICE_PATH);
//read service function state with its name
//list of Strings representing paths will be returned
- List<String> rspList = SfcProviderServiceFunctionAPI.readServiceFunctionStateAsStringListExecutor(SF_STATE_NAME);
+ List<String> rspList = SfcProviderServiceFunctionAPI.readServiceFunctionStateAsStringList(SF_STATE_NAME);
assertNotNull("Must not be null", rspList);
assertEquals("Must be equal", rspList.get(0), SF_SERVICE_PATH);
assertTrue("Must be true", transactionSuccessful);
//read all service functions from data store
- ServiceFunctions serviceFunctionsResult = SfcProviderServiceFunctionAPI.readAllServiceFunctionsExecutor();
+ ServiceFunctions serviceFunctionsResult = SfcProviderServiceFunctionAPI.readAllServiceFunctions();
assertNotNull("Must not be null", serviceFunctionsResult);
assertEquals("Must be equal", serviceFunctionsResult.getServiceFunction().get(0).getName(), SF_NAME);
assertTrue("Must be true", transactionSuccessful);
//add this path to service function, a name of service path is used
- boolean result = SfcProviderServiceFunctionAPI.addPathToServiceFunctionStateExecutor(RSP_NAME + 1);
+ boolean result = SfcProviderServiceFunctionAPI.addPathToServiceFunctionState(RSP_NAME + 1);
assertTrue("Must be true", result);
RenderedServicePath renderedServicePath = (RenderedServicePath) writeReturnPath(RSP_NAME + 2, SF_NAME + 2, false);
//add this path to service function, an object of service path is used
- result = SfcProviderServiceFunctionAPI.addPathToServiceFunctionStateExecutor(renderedServicePath);
+ result = SfcProviderServiceFunctionAPI.addPathToServiceFunctionState(renderedServicePath);
assertTrue("Must be true", result);
serviceFunctionPathBuilder.setName(RSP_NAME + 1);
//delete both paths; first through created path object, second through path name
- result = SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionStateExecutor(serviceFunctionPathBuilder.build());
+ result = SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionState(serviceFunctionPathBuilder.build());
assertTrue("Must be true", result);
- result = SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionStateExecutor(RSP_NAME + 2);
+ result = SfcProviderServiceFunctionAPI.deleteServicePathFromServiceFunctionState(RSP_NAME + 2);
assertTrue("Must be true", result);
}
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcProviderServiceFunctionGroupAPITest extends AbstractDataStoreManager {
private static final String ALGORITHM = "algorithm";
}
@Test
- public void testPutReadDeleteServiceFunctionGroupAlgorithm() throws ExecutionException, InterruptedException {
+ public void testPutReadDeleteServiceFunctionGroupAlgorithm() {
// Create:
String sfgAlgName = "testServiceFunctionGroupAlgorithm";
ServiceFunctionGroupAlgorithm sfgAlg = SimpleTestEntityBuilder.buildServiceFunctionGroupAlgorithm(sfgAlgName);
// Put:
- Object[] params = {sfgAlg};
- Class[] paramsTypes = {ServiceFunctionGroupAlgorithm.class};
- executor.submit(SfcProviderServiceFunctionGroupAlgAPI.getPut(params, paramsTypes)).get();
+ SfcProviderServiceFunctionGroupAlgAPI.putServiceFunctionGroupAlgorithm(sfgAlg);
// Read:
- Object[] params2 = {sfgAlgName};
- Class[] paramsTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionGroupAlgAPI.getRead(params2, paramsTypes2)).get();
- ServiceFunctionGroupAlgorithm sfgAlg2 = (ServiceFunctionGroupAlgorithm) result;
+ ServiceFunctionGroupAlgorithm sfgAlg2 = SfcProviderServiceFunctionGroupAlgAPI.readServiceFunctionGroupAlg(sfgAlgName);
assertNotNull("Must be not null", sfgAlg2);
assertEquals("Must be equal", sfgAlg2.getName(), sfgAlgName);
// Delete:
- executor.submit(SfcProviderServiceFunctionGroupAlgAPI.getDelete(params2, paramsTypes2));
- Thread.sleep(1000);
- result = executor.submit(SfcProviderServiceFunctionGroupAlgAPI.getRead(params2, paramsTypes2)).get();
- sfgAlg2 = (ServiceFunctionGroupAlgorithm) result;
-
+ SfcProviderServiceFunctionGroupAlgAPI.deleteServiceFunctionGroupAlgorithm(sfgAlgName);
+ sfgAlg2 = SfcProviderServiceFunctionGroupAlgAPI.readServiceFunctionGroupAlgorithm(sfgAlgName);
assertNull("Must be null", sfgAlg2); // TODO: test passes locally but fails on Jenkins
}
@Test
- public void testPutReadDeleteServiceFunctionGroup() throws ExecutionException, InterruptedException {
+ public void testPutReadDeleteServiceFunctionGroup() {
// Create:
String sfgName = "testServiceFunctionGroup";
ServiceFunctionGroup sfg = SimpleTestEntityBuilder.buildServiceFunctionGroup(sfgName, sfgAlgName);
// Put:
- Object[] params = {sfg};
- Class[] paramsTypes = {ServiceFunctionGroup.class};
- executor.submit(SfcProviderServiceFunctionGroupAPI.getPut(params, paramsTypes)).get();
+ SfcProviderServiceFunctionGroupAPI.putServiceFunctionGroup(sfg);
// Read:
- Object[] params2 = {sfgName};
- Class[] paramsTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionGroupAPI.getRead(params2, paramsTypes2)).get();
- ServiceFunctionGroup sfg2 = (ServiceFunctionGroup) result;
+ ServiceFunctionGroup sfg2 = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(sfgName);
assertNotNull("Must be not null", sfg2);
assertEquals("Must be equal", sfg2.getName(), sfgName);
assertEquals("Must be equal", sfg2.getAlgorithm(), sfgAlgName);
// Delete:
- executor.submit(SfcProviderServiceFunctionGroupAPI.getDelete(params2, paramsTypes2));
- Thread.sleep(1000);
- result = executor.submit(SfcProviderServiceFunctionGroupAPI.getRead(params2, paramsTypes2)).get();
- sfg2 = (ServiceFunctionGroup) result;
+ SfcProviderServiceFunctionGroupAPI.deleteServiceFunctionGroup(sfgName);
+ sfg2 = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(sfgName);
- assertNull("Must be null", sfg2); // TODO: test passes locally but fails on Jenkins
+ assertNull("Must be null", sfg2);
}
@Test
@Ignore
- public void testAddRemoveFunctionFromServiceFunctionGroup() throws ExecutionException, InterruptedException {
+ public void testAddRemoveFunctionFromServiceFunctionGroup() {
// Create:
String sfgName = "testServiceFunctionGroup";
// Add Service Function:
ServiceFunction sf = sfList.get(0);
- Object[] params = {sfg.getName(), sf.getName()};
- Class[] paramsTypes = {String.class, String.class};
- executor.submit(SfcProviderServiceFunctionGroupAPI.getAddSF(params, paramsTypes)).get();
-
+ SfcProviderServiceFunctionGroupAPI.addServiceFunctionToGroup(sfg.getName(), sf.getName());
assertNotNull("Must be not null", sfg.getSfcServiceFunction().get(0));
// Delete Service Function:
- executor.submit(SfcProviderServiceFunctionGroupAPI.getDelete(params, paramsTypes));
+ SfcProviderServiceFunctionGroupAPI.removeServiceFunctionFromGroup(sfg.getName(), sf.getName());
assertNull("Must be null", sfg.getSfcServiceFunction().get(0));
}
assertTrue("Must be true", transactionSuccessful);
//get service function by type
- ServiceFunctionGroup serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupbyTypeExecutor(Firewall.class);
+ ServiceFunctionGroup serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupByType(Firewall.class);
assertNotNull("Must be not null", serviceFunctionGroup);
assertEquals("Must be equal", serviceFunctionGroup.getIpMgmtAddress().getIpv4Address().getValue(), IP_V4_ADDRESS);
assertEquals("Must be equal", serviceFunctionGroup.getType(), Firewall.class);
- serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupbyTypeExecutor(Dpi.class);
+ serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupByType(Dpi.class);
assertNotNull("Must be not null", serviceFunctionGroup);
assertEquals("Must be equal", serviceFunctionGroup.getIpMgmtAddress().getIpv6Address().getValue(), IP_V6_ADDRESS);
assertEquals("Must be equal", serviceFunctionGroup.getType(), Dpi.class);
//get service function group by name
- serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroupExecutor(SFG_NAME + 1);
+ serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(SFG_NAME + 1);
assertNotNull("Must be not null", serviceFunctionGroup);
assertEquals("Must be equal", serviceFunctionGroup.getName(), SFG_NAME + 1);
assertEquals("Must be equal", serviceFunctionGroup.getIpMgmtAddress().getIpv4Address().getValue(), IP_V4_ADDRESS);
assertEquals("Must be equal", serviceFunctionGroup.getType(), Firewall.class);
- serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroupExecutor(SFG_NAME + 2);
+ serviceFunctionGroup = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(SFG_NAME + 2);
assertNotNull("Must be not null", serviceFunctionGroup);
assertEquals("Must be equal", serviceFunctionGroup.getName(), SFG_NAME + 2);
.setContextHeader4(4L);
//write service function metadata
- boolean transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.putContextMetadataExecutor(contextMetadataBuilder.build());
+ boolean transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.putContextMetadata(contextMetadataBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//read service function metadata
- ContextMetadata contextMetadata = SfcProviderServiceFunctionMetadataAPI.readContextMetadataExecutor("CMD");
+ ContextMetadata contextMetadata = SfcProviderServiceFunctionMetadataAPI.readContextMetadata("CMD");
assertNotNull("Must not be null", contextMetadata);
assertEquals("Must be equal", contextMetadata.getName(), "CMD");
assertEquals("Must be equal", contextMetadata.getContextHeader1(), (Object)1L);
assertEquals("Must be equal", contextMetadata.getContextHeader4(), (Object)4L);
//remove service function metadata
- transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.deleteContextMetadataExecutor("CMD");
+ transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.deleteContextMetadata("CMD");
assertTrue("Must be true", transactionSuccessful);
}
.setTlvMetadata(tlvList);
//write service function metadata
- boolean transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.putVariableMetadataExecutor(variableMetadataBuilder.build());
+ boolean transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.putVariableMetadata(variableMetadataBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//read service function metadata
- VariableMetadata variableMetadata = SfcProviderServiceFunctionMetadataAPI.readVariableMetadataExecutor("VMD");
+ VariableMetadata variableMetadata = SfcProviderServiceFunctionMetadataAPI.readVariableMetadata("VMD");
assertNotNull("Must not be null", variableMetadata);
assertNotNull("Must not be null", variableMetadata.getTlvMetadata());
assertEquals("Must be equal", variableMetadata.getTlvMetadata().size(), 1);
assertEquals("Must be equal", variableMetadata.getTlvMetadata().get(0).getTlvData(), "123456");
//remove service function metadata
- transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.deleteVariableMetadataExecutor("VMD");
+ transactionSuccessful = SfcProviderServiceFunctionMetadataAPI.deleteVariableMetadata("VMD");
assertTrue("Must be true", transactionSuccessful);
}
}
public class SfcProviderServicePathAPITest extends AbstractDataStoreManager {
- private List<ServiceFunction> sfList = new ArrayList<>();
-
@Before
public void before() {
setOdlSfc();
assertTrue("Must be true", transactionSuccessful);
//read service path state
- List<SfpRenderedServicePath> sfpList = SfcProviderServicePathAPI.readServicePathStateExecutor(sfpKey);
+ List<SfpRenderedServicePath> sfpList = SfcProviderServicePathAPI.readServicePathState(sfpKey);
assertNotNull("Must not be null", sfpList);
assertEquals("Must be equal", sfpList.get(0).getName(), rspKey);
//delete service path state
- transactionSuccessful = SfcProviderServicePathAPI.deleteServicePathStateExecutor(sfpKey);
+ transactionSuccessful = SfcProviderServicePathAPI.deleteServicePathState(sfpKey);
assertTrue("Must be true", transactionSuccessful);
//try to read again, must be null
- sfpList = SfcProviderServicePathAPI.readServicePathStateExecutor(sfpKey);
+ sfpList = SfcProviderServicePathAPI.readServicePathState(sfpKey);
assertNull("Must be null", sfpList);
}
serviceFunctionPathStateBuilder.setName(sfpKey)
.setKey(new ServiceFunctionPathStateKey(sfpKey));
- boolean transactionSuccessful = SfcProviderServicePathAPI.addRenderedPathToServicePathStateExecutor(serviceFunctionPathStateBuilder.build().getName(), rspKey);
+ boolean transactionSuccessful = SfcProviderServicePathAPI.addRenderedPathToServicePathState(serviceFunctionPathStateBuilder.build().getName(), rspKey);
assertTrue("Must be true", transactionSuccessful);
//check if path is already added
.setKey(new ServiceFunctionPathKey(sfpName))
.setClassifier(testClassifier);
- boolean transactionSuccessful = SfcProviderServicePathAPI.putServiceFunctionPathExecutor(serviceFunctionPathBuilder.build());
+ boolean transactionSuccessful = SfcProviderServicePathAPI.putServiceFunctionPath(serviceFunctionPathBuilder.build());
assertTrue("Must be true", transactionSuccessful);
//read service function path
- ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPathExecutor(sfpName);
+ ServiceFunctionPath serviceFunctionPath = SfcProviderServicePathAPI.readServiceFunctionPath(sfpName);
assertNotNull("Must not be null", serviceFunctionPath);
assertEquals("Must be equal", serviceFunctionPath.getClassifier(), testClassifier);
//delete service function path
- transactionSuccessful = SfcProviderServicePathAPI.deleteServiceFunctionPathExecutor(sfpName);
+ transactionSuccessful = SfcProviderServicePathAPI.deleteServiceFunctionPath(sfpName);
assertTrue("Must be true", transactionSuccessful);
}
ServiceFunctionPaths writtenPaths = serviceFunctionPathsBuilder.build();
//put all paths
- boolean transactionSuccessful = SfcProviderServicePathAPI.putServiceFunctionPathsExecutor(writtenPaths);
+ boolean transactionSuccessful = SfcProviderServicePathAPI.putAllServiceFunctionPaths(writtenPaths);
assertTrue("Must be true", transactionSuccessful);
//read all paths
- ServiceFunctionPaths getPaths = SfcProviderServicePathAPI.readAllServiceFunctionPathsExecutor();
+ ServiceFunctionPaths getPaths = SfcProviderServicePathAPI.readAllServiceFunctionPaths();
assertNotNull("Must not be null", getPaths);
assertTrue("Must be true", getPaths.equals(writtenPaths));
- transactionSuccessful = SfcProviderServicePathAPI.deleteAllServiceFunctionPathsExecutor();
+ transactionSuccessful = SfcProviderServicePathAPI.deleteAllServiceFunctionPaths();
assertTrue("Must be true", transactionSuccessful);
}
assertTrue("Must be true", transactionSuccessful);
//delete path
- transactionSuccessful = SfcProviderServicePathAPI.deleteServicePathContainingFunctionExecutor(serviceFunction);
+ transactionSuccessful = SfcProviderServicePathAPI.deleteServicePathContainingFunction(serviceFunction);
assertTrue("Must be true", transactionSuccessful);
}
}
public class SfcProviderServiceTypeAPITest extends AbstractDataStoreManager{
- SfcProviderServiceTypeAPILocal sfcProviderServiceTypeAPILocal;
+ SfcProviderServiceTypeAPI sfcProviderServiceTypeAPILocal;
@Before
public void before() {
setOdlSfc();
- Object[] params = {"hello"};
- sfcProviderServiceTypeAPILocal = new SfcProviderServiceTypeAPILocal(params);
- }
-
- @Test
- public void testGetPut(){
- ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
-
- Class serviceFunctionTypeIdentity = Firewall.class;
- serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceFunctionTypeIdentity)).setType(serviceFunctionTypeIdentity);
- ServiceFunctionType serviceFunctionType = serviceFunctionTypeBuilder.build();
- Object[] serviceTypeObj = {serviceFunctionType};
- Class[] serviceTypeClass = {Firewall.class};
- SfcProviderServiceTypeAPI sfcProviderServiceTypeAPI = SfcProviderServiceTypeAPI.getPut(serviceTypeObj, serviceTypeClass);
- assertNotNull(sfcProviderServiceTypeAPI);
- assertEquals("Incorrectly returned value of SfcProviderServiceTypeAPI.", "putServiceFunctionType", sfcProviderServiceTypeAPI.getMethodName());
+ sfcProviderServiceTypeAPILocal = new SfcProviderServiceTypeAPI();
}
@Test
public void testPutServiceFunctionType() throws Exception{
ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
- Class serviceFunctionTypeIdentity = Firewall.class;
+ Class<Firewall> serviceFunctionTypeIdentity = Firewall.class;
serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceFunctionTypeIdentity)).setType(serviceFunctionTypeIdentity);
ServiceFunctionType serviceFunctionType = serviceFunctionTypeBuilder.build();
SfcDataStoreAPI.writePutTransactionAPI(sftentryIID, sftServiceFunctionName, LogicalDatastoreType.CONFIGURATION);
- assertTrue(SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntryExecutor(serviceFunction));
+ assertTrue(SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntry(serviceFunction));
assertNull(SfcDataStoreAPI.readTransactionAPI(sftentryIID, LogicalDatastoreType.CONFIGURATION));
}
ServiceFunctionTypesBuilder serviceFunctionTypesBuilder = new ServiceFunctionTypesBuilder();
List<ServiceFunctionType> serviceFunctionTypeList = new ArrayList<>();
ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
- Class serviceFunctionTypeIdentity = Firewall.class;
+ Class<Firewall> serviceFunctionTypeIdentity = Firewall.class;
serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceFunctionTypeIdentity)).setType(serviceFunctionTypeIdentity);
ServiceFunctionType serviceFunctionType = serviceFunctionTypeBuilder.build();
serviceFunctionTypeList.add(serviceFunctionType);
ServiceFunctionTypesBuilder serviceFunctionTypesBuilder = new ServiceFunctionTypesBuilder();
List<ServiceFunctionType> serviceFunctionTypeList = new ArrayList<>();
ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
- Class serviceFunctionTypeIdentity = Firewall.class;
+ Class<Firewall> serviceFunctionTypeIdentity = Firewall.class;
serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceFunctionTypeIdentity)).setType(serviceFunctionTypeIdentity);
ServiceFunctionType serviceFunctionType = serviceFunctionTypeBuilder.build();
serviceFunctionTypeList.add(serviceFunctionType);
ServiceFunctionTypesBuilder serviceFunctionTypesBuilder = new ServiceFunctionTypesBuilder();
List<ServiceFunctionType> serviceFunctionTypeList = new ArrayList<>();
ServiceFunctionTypeBuilder serviceFunctionTypeBuilder = new ServiceFunctionTypeBuilder();
- Class serviceFunctionTypeIdentity = Firewall.class;
+ Class<Firewall> serviceFunctionTypeIdentity = Firewall.class;
serviceFunctionTypeBuilder.setKey(new ServiceFunctionTypeKey(serviceFunctionTypeIdentity)).setType(serviceFunctionTypeIdentity);
ServiceFunctionType serviceFunctionType = serviceFunctionTypeBuilder.build();
serviceFunctionTypeList.add(serviceFunctionType);
assertNull("Variable has not been set correctly.", outputSFTypes);
}
- private class SfcProviderServiceTypeAPILocal extends SfcProviderServiceTypeAPI{
-
- SfcProviderServiceTypeAPILocal(Object[] params) {
- super(params, "m");
- }
- }
}
\ No newline at end of file
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.functions.ServiceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
public class SfcServiceFunctionLoadBalanceSchedulerAPITest extends AbstractDataStoreManager {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceChainAPITest.class);
private SfcServiceFunctionSchedulerAPI scheduler;
@Before
- public void before() throws ExecutionException, InterruptedException {
+ public void before() {
setOdlSfc();
scheduler = new SfcServiceFunctionLoadBalanceSchedulerAPI();
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll
- (new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
//Wait a while in order to ensure they are really created
- Thread.sleep(1000);
for (ServiceFunction serviceFunction : sfList) {
- SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
}
/* Ensure all the ServiceFunctions in sfList are indeed created */
maxTries = 10;
ServiceFunction sf2 = null;
while (maxTries > 0) {
- Object[] parameters2 = {serviceFunction.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
- sf2 = (ServiceFunction) result;
+ sf2 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunction.getName());
maxTries--;
if (sf2 != null) {
break;
}
- Thread.sleep(1000);
}
LOG.debug("SfcServiceFunctionLoadBalanceSchedulerAPITest: getRead ServiceFunction {} {} times: {}", serviceFunction.getName(), 10 - maxTries, (sf2 == null) ? "Failed" : "Successful");
}
}
@Test
- public void testServiceFunctionLoadBalanceScheduler() throws ExecutionException, InterruptedException {
- Object[] sfcParameters = {sfChain};
- Class[] sfcParameterTypes = {ServiceFunctionChain.class};
- executor.submit(SfcProviderServiceChainAPI
- .getPut(sfcParameters, sfcParameterTypes)).get();
-
- Object[] parameters2 = {sfChain.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ public void testServiceFunctionLoadBalanceScheduler() {
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfChain);
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(sfChain.getName());
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfChain.getSfcServiceFunction());
ServiceFunctionType serviceFunctionType;
List<SftServiceFunctionName> sftServiceFunctionNameList;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Firewall.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Firewall.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Dpi.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Dpi.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Napt44.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Napt44.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
int serviceIndex = 255;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Firewall.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Firewall.class);
List<SftServiceFunctionName> sftFirewallList = serviceFunctionType.getSftServiceFunctionName();
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Dpi.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Dpi.class);
List<SftServiceFunctionName> sftDpiList = serviceFunctionType.getSftServiceFunctionName();
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Napt44.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Napt44.class);
List<SftServiceFunctionName> sftNapt44List = serviceFunctionType.getSftServiceFunctionName();
List<String> serviceFunctionNameArrayList = scheduler.scheduleServiceFunctions(sfChain, serviceIndex, sfPath);
for (int i = 0; i < 3; i++) {
String sfFWName = sftFirewallList.get(i).getName();
- java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor(sfFWName)
+ java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor(sfFWName)
.getMonitoringInfo()
.getResourceUtilization()
.getCPUUtilization();
for (int i = 0; i < 3; i++) {
String sfDPIName = sftDpiList.get(i).getName();
- java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor(sfDPIName)
+ java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor(sfDPIName)
.getMonitoringInfo()
.getResourceUtilization()
.getCPUUtilization();
for (int i = 0; i < 3; i++) {
String sfNATName = sftNapt44List.get(i).getName();
- java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitorExecutor(sfNATName)
+ java.lang.Long cPUUtilization = SfcProviderServiceFunctionAPI.readServiceFunctionDescriptionMonitor(sfNATName)
.getMonitoringInfo()
.getResourceUtilization()
.getCPUUtilization();
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.functions.ServiceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcServiceFunctionSchedulerAPITest extends AbstractDataStoreManager {
private static final Logger LOG = LoggerFactory.getLogger(SfcServiceFunctionSchedulerAPITest.class);
private ServiceFunctionPath sfPath;
@Before
- public void before() throws ExecutionException, InterruptedException, IllegalAccessException {
+ public void before() throws Exception {
setOdlSfc();
int maxTries = 10;
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll
- (new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
- Thread.sleep(1000); //Wait they are really created
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
for (ServiceFunction serviceFunction : sfList) {
- SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
}
- Object[] sfcParameters = {sfChain};
- Class[] sfcParameterTypes = {ServiceFunctionChain.class};
- executor.submit(SfcProviderServiceChainAPI
- .getPut(sfcParameters, sfcParameterTypes)).get();
- Thread.sleep(1000); //Wait it is really created
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfChain);
}
@Test
- public void testBasicEnvSetup() throws ExecutionException, InterruptedException {
+ public void testBasicEnvSetup() {
int maxTries;
for (ServiceFunction serviceFunction : sfList) {
maxTries = 10;
ServiceFunction sf2 = null;
while (maxTries > 0) {
- Object[] parameters2 = {serviceFunction.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
- sf2 = (ServiceFunction) result;
+ sf2 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunction.getName());
maxTries--;
if (sf2 != null) {
break;
}
- Thread.sleep(1000);
}
LOG.debug("SfcServiceFunctionSchedulerAPITest: getRead ServiceFunction {} {} times: {}", serviceFunction.getName(), 10 - maxTries, (sf2 != null) ? "Successful" : "Failed");
assertNotNull("Must be not null", sf2);
assertEquals("Must be equal", sf2.getType(), serviceFunction.getType());
}
- Object[] parameters2 = {sfChain.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ SfcProviderServiceFunctionAPI.readServiceFunction(sfChain.getName());
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(sfChain.getName());
assertNotNull("Must be not null", sfc2);
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfChain.getSfcServiceFunction());
ServiceFunctionType serviceFunctionType;
List<SftServiceFunctionName> sftServiceFunctionNameList;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Firewall.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Firewall.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
for (SftServiceFunctionName sftServiceFunctionName : sftServiceFunctionNameList) {
}
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Dpi.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Dpi.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Napt44.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Napt44.class);
sftServiceFunctionNameList = serviceFunctionType.getSftServiceFunctionName();
assertNotNull("Must be not null", sftServiceFunctionNameList);
assertEquals("Must be equal", sftServiceFunctionNameList.size(), 3);
}
@Test
- public void testServiceFunctionRandomScheduler() throws ExecutionException, InterruptedException {
+ public void testServiceFunctionRandomScheduler() {
int serviceIndex = 255;
SfcServiceFunctionSchedulerAPI scheduler = new SfcServiceFunctionRandomSchedulerAPI();
List<String> serviceFunctionNameArrayList =
assertNotNull("Must be not null", serviceFunctionNameArrayList);
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(serviceFunctionNameArrayList.get(0));
+ ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionNameArrayList.get(0));
assertNotNull("Must be not null", serviceFunction);
assertEquals("Must be equal", serviceFunction.getType(), Firewall.class);
assertNotEquals("Must be not equal", serviceFunction.getType(), Dpi.class);
serviceFunction = SfcProviderServiceFunctionAPI
- .readServiceFunctionExecutor(serviceFunctionNameArrayList.get(1));
+ .readServiceFunction(serviceFunctionNameArrayList.get(1));
assertEquals("Must be equal", serviceFunction.getType(), Dpi.class);
assertNotEquals("Must be not equal", serviceFunction.getType(), Napt44.class);
serviceFunction = SfcProviderServiceFunctionAPI
- .readServiceFunctionExecutor(serviceFunctionNameArrayList.get(2));
+ .readServiceFunction(serviceFunctionNameArrayList.get(2));
assertEquals("Must be equal", serviceFunction.getType(), Napt44.class);
assertNotEquals("Must be not equal", serviceFunction.getType(), Firewall.class);
}
@Test
- public void testServiceFunctionRoundRobinScheduler() throws ExecutionException, InterruptedException {
+ public void testServiceFunctionRoundRobinScheduler() {
int serviceIndex = 255;
SfcServiceFunctionSchedulerAPI scheduler = new SfcServiceFunctionRoundRobinSchedulerAPI();
List<String> serviceFunctionNameArrayList;
ServiceFunctionType serviceFunctionType;
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Firewall.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Firewall.class);
List<SftServiceFunctionName> sftFirewallList = serviceFunctionType.getSftServiceFunctionName();
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Dpi.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Dpi.class);
List<SftServiceFunctionName> sftDpiList = serviceFunctionType.getSftServiceFunctionName();
- serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(Napt44.class);
+ serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(Napt44.class);
List<SftServiceFunctionName> sftNapt44List = serviceFunctionType.getSftServiceFunctionName();
/* First round */
assertEquals("Must be equal", serviceFunctionNameArrayList.get(1), sftDpiList.get(0).getName());
assertEquals("Must be equal", serviceFunctionNameArrayList.get(2), sftNapt44List.get(0).getName());
- Class scheduleType = scheduler.getSfcServiceFunctionSchedulerType();
+ Class<?> scheduleType = scheduler.getSfcServiceFunctionSchedulerType();
assertNotNull("Must be not null", scheduleType);
assertEquals("Must be equal", scheduleType.getSimpleName(), RoundRobin.class.getSimpleName());
package org.opendaylight.sfc.provider.api;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.sfc.provider.AbstractDataStoreManager;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
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.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderKey;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.*;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ConnectedSffDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorKey;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocator;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-import static org.junit.Assert.*;
-
public class SfcServiceFunctionShortestPathSchedulerAPITest extends AbstractDataStoreManager {
private static final Logger LOG = LoggerFactory.getLogger(SfcServiceFunctionShortestPathSchedulerAPITest.class);
private SfcServiceFunctionShortestPathSchedulerAPI scheduler;
@Before
- public void before() throws ExecutionException, InterruptedException {
+ public void before() {
setOdlSfc();
scheduler = new SfcServiceFunctionShortestPathSchedulerAPI();
/* Must create ServiceFunctionType first */
for (ServiceFunction serviceFunction : sfList) {
- boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntryExecutor(serviceFunction);
+ boolean ret = SfcProviderServiceTypeAPI.createServiceFunctionTypeEntry(serviceFunction);
LOG.debug("call createServiceFunctionTypeEntryExecutor for {}", serviceFunction.getName());
assertTrue("Must be true", ret);
}
ServiceFunctionsBuilder sfsBuilder = new ServiceFunctionsBuilder();
sfsBuilder.setServiceFunction(sfList);
- executor.submit(SfcProviderServiceFunctionAPI.getPutAll
- (new Object[]{sfsBuilder.build()}, new Class[]{ServiceFunctions.class})).get();
- Thread.sleep(1000); // Wait they are really created
+ SfcProviderServiceFunctionAPI.putAllServiceFunctions(sfsBuilder.build());
String sfcName = "ShortestPath-unittest-chain-1";
List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>();
.setConnectedSffDictionary(sffDictionaryList)
.setServiceNode(null);
ServiceFunctionForwarder sff = sffBuilder.build();
- executor.submit(SfcProviderServiceForwarderAPI.getPut(new Object[]{sff}, new Class[]{ServiceFunctionForwarder.class})).get();
+ SfcProviderServiceForwarderAPI.putServiceFunctionForwarder(sff);
}
- Thread.sleep(1000); // Wait they are really created
}
@Test
- public void testSfcServiceFunctionShortestPathScheduler() throws ExecutionException, InterruptedException {
+ public void testSfcServiceFunctionShortestPathScheduler() {
int maxTries;
for (ServiceFunction serviceFunction : sfList) {
maxTries = 10;
ServiceFunction sf2 = null;
while (maxTries > 0) {
- Object[] parameters2 = {serviceFunction.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parameters2, parameterTypes2)).get();
- sf2 = (ServiceFunction) result;
+ sf2 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunction.getName());
maxTries--;
if (sf2 != null) {
break;
}
- Thread.sleep(1000);
}
LOG.debug("SfcServiceFunctionShortestPathSchedulerAPITest: getRead ServiceFunction {} {} times: {}", serviceFunction.getName(), 10 - maxTries, (sf2 != null) ? "Successful" : "Failed");
assertNotNull("Must be not null", sf2);
assertEquals("Must be equal", sf2.getType(), serviceFunction.getType());
}
- Object[] parameters = {sfChain};
- Class[] parameterTypes = {ServiceFunctionChain.class};
-
- executor.submit(SfcProviderServiceChainAPI
- .getPut(parameters, parameterTypes)).get();
-
- Object[] parameters2 = {sfChain.getName()};
- Class[] parameterTypes2 = {String.class};
- Object result = executor.submit(SfcProviderServiceChainAPI
- .getRead(parameters2, parameterTypes2)).get();
- ServiceFunctionChain sfc2 = (ServiceFunctionChain) result;
+ SfcProviderServiceChainAPI.putServiceFunctionChain(sfChain);
+ ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(sfChain.getName());
assertNotNull("Must be not null", sfc2);
assertNotNull("Must be not null", sfChain.getSfcServiceFunction());
assertEquals("Must be equal", sfc2.getSfcServiceFunction(), sfChain.getSfcServiceFunction());
for (SfcServiceFunction sfcServiceFunction : sfChain.getSfcServiceFunction()) {
LOG.debug("sfcServiceFunction.name = {}", sfcServiceFunction.getName());
- ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionTypeExecutor(sfcServiceFunction.getType());
+ ServiceFunctionType serviceFunctionType = SfcProviderServiceTypeAPI.readServiceFunctionType(sfcServiceFunction.getType());
assertNotNull("Must be not null", serviceFunctionType);
}
List<String> serviceFunctionNameArrayList = scheduler.scheduleServiceFunctions(sfChain, serviceIndex, sfPath);
assertNotNull("Must be not null", serviceFunctionNameArrayList);
- Object[] parametersHop = {serviceFunctionNameArrayList.get(0)};
- Class[] parameterTypesHop = {String.class};
- Object resultHop = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parametersHop, parameterTypesHop)).get();
- ServiceFunction sfHop0 = (ServiceFunction) resultHop;
-
- Object[] parametersHop1 = {serviceFunctionNameArrayList.get(1)};
- Class[] parameterTypesHop1 = {String.class};
- Object resultHop1 = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parametersHop1, parameterTypesHop1)).get();
- ServiceFunction sfHop1 = (ServiceFunction) resultHop1;
-
- Object[] parametersHop2 = {serviceFunctionNameArrayList.get(2)};
- Class[] parameterTypesHop2 = {String.class};
- Object resultHop2 = executor.submit(SfcProviderServiceFunctionAPI
- .getRead(parametersHop2, parameterTypesHop2)).get();
- ServiceFunction sfHop2 = (ServiceFunction) resultHop2;
+ ServiceFunction sfHop0 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionNameArrayList.get(0));
+ ServiceFunction sfHop1 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionNameArrayList.get(1));
+ ServiceFunction sfHop2 = SfcProviderServiceFunctionAPI.readServiceFunction(serviceFunctionNameArrayList.get(2));
assertNotNull("Must be not null", sfHop0);
assertNotNull("Must be not null", sfHop1);
LOG.debug("\nCreated Service Classifier Name: {}", createdServiceClassifier.getName());
if (createdServiceClassifier.getAccessList() != null && !createdServiceClassifier.getAccessList().isEmpty()) {
- Acl accessList = SfcProviderAclAPI.readAccessListExecutor(createdServiceClassifier.getAccessList());
+ Acl accessList = SfcProviderAclAPI.readAccessList(createdServiceClassifier.getAccessList());
Runnable task = new SbRestAclTask(RestOperation.POST, accessList,
createdServiceClassifier.getSclServiceFunctionForwarder(), opendaylightSfc.getExecutor());
LOG.debug("\nModified Service Classifier Name: {}", updatedServiceClassifier.getName());
if (updatedServiceClassifier.getAccessList() != null && !updatedServiceClassifier.getAccessList().isEmpty()) {
- Acl accessList = SfcProviderAclAPI.readAccessListExecutor(updatedServiceClassifier.getAccessList());
+ Acl accessList = SfcProviderAclAPI.readAccessList(updatedServiceClassifier.getAccessList());
Runnable task = new SbRestAclTask(RestOperation.PUT, accessList,
updatedServiceClassifier.getSclServiceFunctionForwarder(), opendaylightSfc.getExecutor());
//rest uri list should be created from Classifier SFFs. Classifier will be taken from ACL operational data store <ACL, Classifier>
//this prevents from looping through all classifiers and looking from ACL.
- AccessListState accessListState = SfcProviderAclAPI.readAccessListStateExecutor(accessListName);
+ AccessListState accessListState = SfcProviderAclAPI.readAccessListState(accessListName);
if (accessListState != null) {
List<AclServiceFunctionClassifier> serviceClassifierList = accessListState.getAclServiceFunctionClassifier();
if (serviceClassifierList != null) {
for (AclServiceFunctionClassifier aclServiceClassifier : serviceClassifierList) {
ServiceFunctionClassifier serviceClassifier =
- SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(aclServiceClassifier.getName());
+ SfcProviderServiceClassifierAPI.readServiceClassifier(aclServiceClassifier.getName());
if (serviceClassifier != null) {
List<SclServiceFunctionForwarder> sclServiceForwarderList = serviceClassifier.getSclServiceFunctionForwarder();
if (sclServiceForwarderList != null && accessListName != null && !accessListName.isEmpty()) {
for (SclServiceFunctionForwarder sclServiceForwarder : sclServiceForwarderList) {
ServiceFunctionForwarder serviceForwarder =
- SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(sclServiceForwarder.getName());
+ SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sclServiceForwarder.getName());
if (serviceForwarder != null && serviceForwarder.getRestUri() != null &&
!serviceForwarder.getRestUri().getValue().isEmpty()) {
for (RenderedServicePathHop hop : hopList) {
ServiceFunctionForwarder sff =
SfcProviderServiceForwarderAPI
- .readServiceFunctionForwarderExecutor(hop.getServiceFunctionForwarder());
+ .readServiceFunctionForwarder(hop.getServiceFunctionForwarder());
if (sff != null && sff.getRestUri() != null) {
String restUri = sff.getRestUri().getValue() + RSP_REST_URI + obj.getName();
this.restUriList.add(restUri);
this.restUriList = new ArrayList<>();
- if(SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(obj.getName())!=null) {
- ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(obj.getName());
+ if(SfcProviderServiceFunctionAPI.readServiceFunction(obj.getName())!=null) {
+ ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(obj.getName());
if (serviceFunction.getRestUri() != null) {
String restUri = serviceFunction.getRestUri().getValue() + SFSTATE_REST_URI + obj.getName();
this.restUriList.add(restUri);
public void init() {
executorService = Executors.newFixedThreadPool(10);
- PowerMockito.stub(PowerMockito.method(SfcProviderAclAPI.class, "readAccessListStateExecutor", String.class))
+ PowerMockito.stub(PowerMockito.method(SfcProviderAclAPI.class, "readAccessListState", String.class))
.toReturn(this.buildAccessListState());
- PowerMockito.stub(PowerMockito.method(SfcProviderServiceClassifierAPI.class, "readServiceClassifierExecutor",
+ PowerMockito.stub(PowerMockito.method(SfcProviderServiceClassifierAPI.class, "readServiceClassifier",
String.class))
.toReturn(this.buildServiceFunctionClassifier());
PowerMockito.stub(PowerMockito.method(SfcProviderServiceForwarderAPI.class,
- "readServiceFunctionForwarderExecutor", String.class))
+ "readServiceFunctionForwarder", String.class))
.toReturn(this.buildServiceFunctionForwarder());
}
@Test
public void testSbRestAclTaskEmpty() throws IOException {
PowerMockito.mockStatic(SfcProviderServiceForwarderAPI.class);
- Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(SFF_NAME))
+ Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(SFF_NAME))
.thenReturn(new ServiceFunctionForwarderBuilder().build());
SbRestAclTask sbRestAclTask = new SbRestAclTask(RestOperation.PUT, this.buildAccessList(), executorService);
executorService = Executors.newFixedThreadPool(10);
PowerMockito.mockStatic(SfcProviderServiceForwarderAPI.class);
- Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(SFF_NAME))
+ Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(SFF_NAME))
.thenReturn(this.buildServiceFunctionForwarder());
}
@Test
public void testSbRestRspTaskEmpty() throws IOException {
PowerMockito.mockStatic(SfcProviderServiceForwarderAPI.class);
- Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(SFF_NAME))
+ Mockito.when(SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(SFF_NAME))
.thenReturn(new ServiceFunctionForwarderBuilder().build());
SbRestRspTask sbRestRspTask =
public void init() {
executorService = Executors.newFixedThreadPool(10);
PowerMockito.mockStatic(SfcProviderServiceFunctionAPI.class);
- Mockito.when(SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(SFSTATE_NAME))
+ Mockito.when(SfcProviderServiceFunctionAPI.readServiceFunction(SFSTATE_NAME))
.thenReturn(this.buildServiceFunction());
}
SbRestSfstateTask sbRestSfstateTask =
new SbRestSfstateTask(RestOperation.PUT, new ServiceFunctionStateBuilder().build(), executorService);
PowerMockito.mockStatic(SfcProviderServiceFunctionAPI.class);
- Mockito.when(SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(SFSTATE_NAME))
+ Mockito.when(SfcProviderServiceFunctionAPI.readServiceFunction(SFSTATE_NAME))
.thenReturn(new ServiceFunctionBuilder().build());
JsonNode jsonObject = mapper.readTree(sbRestSfstateTask.jsonObject);
String classifierName = serviceFunctionPath.getClassifier();
Acl acl = null;
if(classifierName != null) {
- ServiceFunctionClassifier classifier = SfcProviderServiceClassifierAPI.readServiceClassifierExecutor(classifierName);
+ ServiceFunctionClassifier classifier = SfcProviderServiceClassifierAPI.readServiceClassifier(classifierName);
String aclName = classifier.getAccessList();
- acl = SfcProviderAclAPI.readAccessListExecutor(aclName);
+ acl = SfcProviderAclAPI.readAccessList(aclName);
}
return acl;
}
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.sfc.provider.OpendaylightSfc;
-import org.opendaylight.sfc.provider.api.SfcProviderAbstractAPI;
import org.opendaylight.sfc.sfc_lisp.provider.LispUpdater;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SfcProviderServiceLispAPI extends SfcProviderAbstractAPI {
+public class SfcProviderServiceLispAPI {
private static final Logger LOG = LoggerFactory.getLogger(SfcProviderServiceLispAPI.class);
- public SfcProviderServiceLispAPI(Object[] params, Class[] paramsTypes, String m) {
- super(params, paramsTypes, m);
- }
-
- public static SfcProviderServiceLispAPI getUpdateServiceFunction(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceLispAPI(params, paramsTypes, "updateServiceFunction");
- }
-
- public static SfcProviderServiceLispAPI getUpdateServiceFunctionForwarder(Object[] params, Class[] paramsTypes) {
- return new SfcProviderServiceLispAPI(params, paramsTypes, "updateServiceFunctionForwarder");
- }
-
public static void lispUpdateServiceFunction(ServiceFunction sf) {
LOG.debug("\n####### Start: {}", Thread.currentThread().getStackTrace()[1]);
if (OpendaylightSfc.getOpendaylightSfcObj().getDataProvider() != null) {
InstanceIdentifier<ServiceFunction> sfEntryIID = InstanceIdentifier.builder(ServiceFunctions.class)
.child(ServiceFunction.class, sf.getKey()).toInstance();
- WriteTransaction writeTx = ODL_SFC.getDataProvider().newWriteOnlyTransaction();
+ WriteTransaction writeTx = OpendaylightSfc.getOpendaylightSfcObj().getDataProvider().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, sfEntryIID, sf, true);
writeTx.commit();
InstanceIdentifier<ServiceFunctionForwarder> sffEntryIID = InstanceIdentifier.builder(ServiceFunctionForwarders.class)
.child(ServiceFunctionForwarder.class, sff.getKey()).toInstance();
- WriteTransaction writeTx = ODL_SFC.getDataProvider().newWriteOnlyTransaction();
+ WriteTransaction writeTx = OpendaylightSfc.getOpendaylightSfcObj().getDataProvider().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.CONFIGURATION, sffEntryIID, sff, true);
writeTx.commit();
if( entry.getValue() instanceof ServiceFunction) {
ServiceFunction createdServiceFunction = (ServiceFunction) entry.getValue();
- Object[] serviceTypeObj = { createdServiceFunction };
- Class[] serviceTypeClass = { ServiceFunction.class };
-
if (lispUpdater.containsLispAddress(createdServiceFunction)) {
- OpendaylightSfc.getOpendaylightSfcObj().getExecutor().submit(SfcProviderServiceLispAPI.getUpdateServiceFunction(serviceTypeObj, serviceTypeClass));
+ SfcProviderServiceLispAPI.lispUpdateServiceFunction(createdServiceFunction);
}
}
List<ServiceFunctionForwarder> serviceFunctionForwarderList = updatedServiceFunctionForwarders.getServiceFunctionForwarder();
for (ServiceFunctionForwarder serviceFunctionForwarder : serviceFunctionForwarderList) {
if (lispUpdater.containsLispAddress(serviceFunctionForwarder)) {
- Object[] serviceFunctionForwarderObj = { serviceFunctionForwarder };
- Class[] serviceFunctionForwarderClass = { ServiceFunctionForwarder.class };
- OpendaylightSfc.getOpendaylightSfcObj().getExecutor().submit(SfcProviderServiceLispAPI.getUpdateServiceFunction(serviceFunctionForwarderObj,
- serviceFunctionForwarderClass));
+ SfcProviderServiceLispAPI.lispUpdateServiceFunctionForwarder(serviceFunctionForwarder);
}
-
}
}
}
ServiceFunction sf = rspContext.serviceFunctions.get(sfName);
if(sf == null) {
- sf = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfName);
+ sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfName);
if(sf != null) {
rspContext.serviceFunctions.put(sfName, sf);
}
ServiceFunctionForwarder sff = rspContext.serviceFunctionFowarders.get(sffName);
if(sff == null) {
- sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(sffName);
+ sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sffName);
if(sff != null) {
sff = SfcOvsUtil.augmentSffWithOpenFlowNodeId(sff);
rspContext.serviceFunctionFowarders.put(sffName, sff);
ServiceFunctionGroup sfg = rspContext.serviceFunctionGroups.get(sfgName);
if (sfg == null) {
- sfg = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroupExecutor(sfgName);
+ sfg = SfcProviderServiceFunctionGroupAPI.readServiceFunctionGroup(sfgName);
if (sfg != null) {
rspContext.serviceFunctionGroups.put(sfgName, sfg);
}
private void buildGroup(ServiceFunctionGroup sfg, boolean isAdd) {
try {
List<SfcServiceFunction> sfs = sfg.getSfcServiceFunction();
- ServiceFunction sf = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfs.get(0).getName());
+ ServiceFunction sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfs.get(0).getName());
// assuming all SF's have the same SFF
// should use the ovs id
String sffName = sf.getSfDataPlaneLocator().get(0).getServiceFunctionForwarder();
List<GroupBucketInfo> bucketsInfo = new ArrayList<GroupBucketInfo>();
- ServiceFunctionForwarder sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(sffName);
+ ServiceFunctionForwarder sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sffName);
int index = 0;
for (SfcServiceFunction sfcServiceFunction : sfg.getSfcServiceFunction()) {
- sf = SfcProviderServiceFunctionAPI.readServiceFunctionExecutor(sfcServiceFunction.getName());
+ sf = SfcProviderServiceFunctionAPI.readServiceFunction(sfcServiceFunction.getName());
ServiceFunctionDictionary sffSfDict =
sfcL2ProviderUtils.getSffSfDictionary(sff, sfcServiceFunction.getName());
String outPort = sfcL2ProviderUtils.getDictPortInfoPort(sffSfDict);
}
private String getSffOpenFlowNodeName(final String sffName) {
- ServiceFunctionForwarder sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarderExecutor(sffName);
+ ServiceFunctionForwarder sff = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sffName);
return sfcL2ProviderUtils.getSffOpenFlowNodeName(sff);
}
}