import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.NotificationService;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginTimer;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceReplyProcessor;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* <p>
public interface DeviceContext extends AutoCloseable,
DeviceReplyProcessor,
PortNumberCache,
+ TxFacade,
XidSequencer {
void setStatisticsRpcEnabled(boolean isStatisticsRpcEnabled);
*/
ListenableFuture<Void> onDeviceLostClusterLeadership();
- /**
- * Method creates put operation using provided data in underlying transaction chain.
- */
- <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store, final InstanceIdentifier<T> path, final T data) throws Exception;
-
- /**
- * Method creates delete operation for provided path in underlying transaction chain.
- */
- <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path) throws Exception;
-
- /**
- * Method submits Transaction to DataStore.
- * @return transaction is submitted successfully
- */
- boolean submitTransaction();
-
/**
* Method has to close TxManager ASAP we are notified about Closed Connection
* @return sync. future for Slave and MD-SAL completition for Master
*/
ListenableFuture<Void> shuttingDownDataStoreTransactions();
-
- /**
- * Method exposes transaction created for device
- * represented by this context. This read only transaction has a fresh dataStore snapshot.
- * There is a possibility to get different data set from DataStore
- * as write transaction in this context.
- * @return readOnlyTransaction - Don't forget to close it after finish reading
- */
- ReadOnlyTransaction getReadTransaction();
-
-
/**
* Method provides current devices connection context.
*
--- /dev/null
+/*
+ * Copyright (c) 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.openflowplugin.api.openflow.device;
+
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Handles operations with transactions
+ */
+public interface TxFacade {
+
+ /**
+ * Method creates put operation using provided data in underlying transaction chain.
+ */
+ <T extends DataObject> void writeToTransaction(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
+ final T data) throws Exception;
+
+ /**
+ * Method creates delete operation for provided path in underlying transaction chain.
+ */
+ <T extends DataObject> void addDeleteToTxChain(final LogicalDatastoreType store, final InstanceIdentifier<T> path) throws Exception;
+
+ /**
+ * Method submits Transaction to DataStore.
+ * @return transaction is submitted successfully
+ */
+ boolean submitTransaction();
+
+ /**
+ * Method exposes transaction created for device
+ * represented by this context. This read only transaction has a fresh dataStore snapshot.
+ * There is a possibility to get different data set from DataStore
+ * as write transaction in this context.
+ * @return readOnlyTransaction - Don't forget to close it after finish reading
+ */
+ ReadOnlyTransaction getReadTransaction();
+}
@Override
protected final FutureCallback<OfHeader> createCallback(final RequestContext<List<MultipartReply>> context, final Class<?> requestType) {
- return new MultipartRequestOnTheFlyCallback(context, requestType, getDeviceContext(), getEventIdentifier());
+ return new MultipartRequestOnTheFlyCallback(context, requestType,
+ getDeviceContext().getMessageSpy(), getEventIdentifier(), getDeviceContext().getDeviceState(),
+ getDeviceContext().getDeviceFlowRegistry(), getDeviceContext());
}
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collections;
import java.util.List;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.impl.statistics.SinglePurposeMultipartReplyTranslator;
final class MultipartRequestOnTheFlyCallback extends AbstractRequestCallback<List<MultipartReply>> {
private static final Logger LOG = LoggerFactory.getLogger(MultipartRequestOnTheFlyCallback.class);
- private final DeviceContext deviceContext;
private static final SinglePurposeMultipartReplyTranslator MULTIPART_REPLY_TRANSLATOR = new SinglePurposeMultipartReplyTranslator();
+ private final DeviceState deviceState;
+ private final DeviceFlowRegistry registry;
private boolean virgin = true;
private boolean finished = false;
private final EventIdentifier doneEventIdentifier;
+ private final TxFacade txFacade;
public MultipartRequestOnTheFlyCallback(final RequestContext<List<MultipartReply>> context,
final Class<?> requestType,
- final DeviceContext deviceContext,
- final EventIdentifier eventIdentifier) {
- super(context, requestType, deviceContext.getMessageSpy(), eventIdentifier);
- this.deviceContext = deviceContext;
+ final MessageSpy messageSpy,
+ final EventIdentifier eventIdentifier,
+ final DeviceState deviceState,
+ final DeviceFlowRegistry registry,
+ final TxFacade txFacade) {
+ super(context, requestType, messageSpy, eventIdentifier);
+
+ this.deviceState = deviceState;
+ this.registry = registry;
+ this.txFacade = txFacade;
+
//TODO: this is focused on flow stats only - need more general approach if used for more than flow stats
- doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceContext.getPrimaryConnectionContext().getNodeId().toString());
+ doneEventIdentifier = new EventIdentifier(MultipartType.OFPMPFLOW.name(), deviceState.getNodeId().toString());
}
public EventIdentifier getDoneEventIdentifier() {
final MultipartReply multipartReply = (MultipartReply) result;
final MultipartReply singleReply = multipartReply;
- final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(deviceContext, singleReply);
+ final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
+ deviceState.getFeatures().getDatapathId(), deviceState.getFeatures().getVersion(), singleReply);
final Iterable<? extends DataObject> allMultipartData = multipartDataList;
//TODO: following part is focused on flow stats only - need more general approach if used for more than flow stats
ListenableFuture<Void> future;
if (virgin) {
- future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext);
+ future = StatisticsGatheringUtils.deleteAllKnownFlows(deviceState, registry, txFacade);
virgin = false;
} else {
future = Futures.immediateFuture(null);
@Override
public Void apply(final Void input) {
- StatisticsGatheringUtils.writeFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData,deviceContext);
+ StatisticsGatheringUtils.writeFlowStatistics((Iterable<FlowsStatisticsUpdate>) allMultipartData,
+ deviceState, registry, txFacade);
if (!multipartReply.getFlags().isOFPMPFREQMORE()) {
endCollecting();
final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.<MultipartReply>emptyList()).build();
spyMessage(MessageSpy.STATISTIC_GROUP.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
setResult(rpcResult);
- deviceContext.submitTransaction();
+ txFacade.submitTransaction();
finished = true;
}
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesConvertor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTableInput> implements SalTableService {
private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalTableServiceImpl.class);
+ private final TxFacade txFacade;
+ private final NodeId nodeId;
- public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ public SalTableServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+ final NodeId nodeId) {
super(requestContextStack, deviceContext);
+ this.txFacade = deviceContext;
+ this.nodeId = nodeId;
}
@Override
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeatures = convertToSalTableFeatures(multipartReplies);
- final DeviceContext deviceContext = getDeviceContext();
final InstanceIdentifier<FlowCapableNode> flowCapableNodeII = InstanceIdentifier.create(Nodes.class)
.child(Node.class, new NodeKey(getNodeId())).augmentation(FlowCapableNode.class);
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures tableFeatureData : salTableFeatures) {
final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures, TableFeaturesKey> tableFeaturesII = flowCapableNodeII
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures.class,
new TableFeaturesKey(tableId));
- deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
+ txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, tableFeaturesII,
tableFeatureData);
}
- deviceContext.submitTransaction();
+
+ txFacade.submitTransaction();
}
protected static List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(
private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
- public List<DataObject> translate(final DeviceContext deviceContext, final OfHeader msg) {
+ public List<DataObject> translate(final BigInteger datapathId, final short version, final OfHeader msg) {
List<DataObject> listDataObject = new ArrayList<>();
- OpenflowVersion ofVersion = OpenflowVersion.get(deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
+ OpenflowVersion ofVersion = OpenflowVersion.get(version);
- final FeaturesReply features = deviceContext.getPrimaryConnectionContext().getFeatures();
if (msg instanceof MultipartReplyMessage) {
MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
- NodeId node = SinglePurposeMultipartReplyTranslator.nodeIdFromDatapathId(features.getDatapathId());
+ NodeId node = SinglePurposeMultipartReplyTranslator.nodeIdFromDatapathId(datapathId);
switch (mpReply.getType()) {
case OFPMPFLOW: {
FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder();
message.setTransactionId(generateTransactionId(mpReply.getXid()));
MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
- message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(), features.getDatapathId(), ofVersion));
+ message.setFlowAndStatisticsMapList(flowStatsConvertor.toSALFlowStatsList(replyBody.getFlowStats(), datapathId, ofVersion));
listDataObject.add(message.build());
return listDataObject;
NodeConnectorStatisticsAndPortNumberMapBuilder statsBuilder =
new NodeConnectorStatisticsAndPortNumberMapBuilder();
statsBuilder.setNodeConnectorId(
- InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(),
+ InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId,
portStats.getPortNo(), ofVersion));
BytesBuilder bytesBuilder = new BytesBuilder();
QueueIdAndStatisticsMapBuilder statsBuilder =
new QueueIdAndStatisticsMapBuilder();
statsBuilder.setNodeConnectorId(
- InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(),
+ InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId,
queueStats.getPortNo(), ofVersion));
statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
statsBuilder.setDuration(durationBuilder.build());
statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
- statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(),
+ statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId,
queueStats.getPortNo(), ofVersion));
statsMap.add(statsBuilder.build());
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
+import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
import org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.StatisticsGatherer;
try {
for (final MultipartReply singleReply : rpcResult.getResult()) {
- final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(deviceContext, singleReply);
+ final List<? extends DataObject> multipartDataList = MULTIPART_REPLY_TRANSLATOR.translate(
+ deviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ deviceContext.getPrimaryConnectionContext().getFeatures().getVersion(), singleReply);
multipartData = multipartDataList.get(0);
allMultipartData = Iterables.concat(allMultipartData, multipartDataList);
}
}
private static void processMeterConfigStatsUpdated(final Iterable<MeterConfigStatsUpdated> data, final DeviceContext deviceContext) throws Exception {
- final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
+ final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
deleteAllKnownMeters(deviceContext, fNodeIdent);
for (final MeterConfigStatsUpdated meterConfigStatsUpdated : data) {
for (final MeterConfigStats meterConfigStats : meterConfigStatsUpdated.getMeterConfigStats()) {
private static ListenableFuture<Boolean> processFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
final DeviceContext deviceContext, final EventIdentifier eventIdentifier) {
- final ListenableFuture<Void> deleFuture = deleteAllKnownFlows(deviceContext);
+ final ListenableFuture<Void> deleFuture = deleteAllKnownFlows(deviceContext.getDeviceState(),
+ deviceContext.getDeviceFlowRegistry(), deviceContext);
return Futures.transform(deleFuture, new Function<Void, Boolean>() {
@Override
public Boolean apply(final Void input) {
- writeFlowStatistics(data, deviceContext);
+ writeFlowStatistics(data, deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(),
+ deviceContext);
deviceContext.submitTransaction();
EventsTimeCounter.markEnd(eventIdentifier);
return Boolean.TRUE;
});
}
- public static void writeFlowStatistics(final Iterable<FlowsStatisticsUpdate> data, final DeviceContext deviceContext) {
- final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
+ public static void writeFlowStatistics(final Iterable<FlowsStatisticsUpdate> data,
+ final DeviceState deviceState,
+ final DeviceFlowRegistry registry,
+ final TxFacade txFacade) {
+ final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceState);
try {
for (final FlowsStatisticsUpdate flowsStatistics : data) {
for (final FlowAndStatisticsMapList flowStat : flowsStatistics.getFlowAndStatisticsMapList()) {
final short tableId = flowStat.getTableId();
final FlowRegistryKey flowRegistryKey = FlowRegistryKeyFactory.create(flowBuilder.build());
- final FlowId flowId = deviceContext.getDeviceFlowRegistry().storeIfNecessary(flowRegistryKey, tableId);
+ final FlowId flowId = registry.storeIfNecessary(flowRegistryKey, tableId);
final FlowKey flowKey = new FlowKey(flowId);
flowBuilder.setKey(flowKey);
final TableKey tableKey = new TableKey(tableId);
final InstanceIdentifier<Flow> flowIdent = fNodeIdent.child(Table.class, tableKey).child(Flow.class, flowKey);
- deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
+ txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, flowIdent, flowBuilder.build());
}
}
} catch (Exception e) {
return flowStatisticsDataBld;
}
- public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceContext deviceContext) {
+ public static ListenableFuture<Void> deleteAllKnownFlows(final DeviceState deviceState,
+ final DeviceFlowRegistry registry,
+ final TxFacade txFacade) {
/* DeviceState.deviceSynchronized is a marker for actual phase - false means initPhase, true means noInitPhase */
- if (deviceContext.getDeviceState().deviceSynchronized()) {
- final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
- final ReadOnlyTransaction readTx = deviceContext.getReadTransaction();
+ if (deviceState.deviceSynchronized()) {
+ final InstanceIdentifier<FlowCapableNode> flowCapableNodePath = assembleFlowCapableNodeInstanceIdentifier(deviceState);
+ final ReadOnlyTransaction readTx = txFacade.getReadTransaction();
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowCapableNodeFuture = readTx.read(
LogicalDatastoreType.OPERATIONAL, flowCapableNodePath);
for (final Table tableData : flowCapNodeOpt.get().getTable()) {
final Table table = new TableBuilder(tableData).setFlow(Collections.<Flow>emptyList()).build();
final InstanceIdentifier<Table> iiToTable = flowCapableNodePath.child(Table.class, tableData.getKey());
- deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
+ txFacade.writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToTable, table);
}
}
- deviceContext.getDeviceFlowRegistry().removeMarked();
+ registry.removeMarked();
readTx.close();
return Futures.immediateFuture(null);
}
}
private static void processFlowTableStatistics(final Iterable<FlowTableStatisticsUpdate> data, final DeviceContext deviceContext) throws Exception {
- final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
+ final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
for (final FlowTableStatisticsUpdate flowTableStatisticsUpdate : data) {
for (final FlowTableAndStatisticsMap tableStat : flowTableStatisticsUpdate.getFlowTableAndStatisticsMap()) {
private static void processMetersStatistics(final Iterable<MeterStatisticsUpdated> data,
final DeviceContext deviceContext) throws Exception {
- final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
+ final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
for (final MeterStatisticsUpdated meterStatisticsUpdated : data) {
for (final MeterStats mStat : meterStatisticsUpdated.getMeterStats()) {
final MeterStatistics stats = new MeterStatisticsBuilder(mStat).build();
}
private static void processGroupStatistics(final Iterable<GroupStatisticsUpdated> data, final DeviceContext deviceContext) throws Exception {
- final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext);
+ final InstanceIdentifier<FlowCapableNode> fNodeIdent = assembleFlowCapableNodeInstanceIdentifier(deviceContext.getDeviceState());
for (final GroupStatisticsUpdated groupStatistics : data) {
for (final GroupStats groupStats : groupStatistics.getGroupStats()) {
deviceContext.submitTransaction();
}
- private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceContext deviceContext) {
- return deviceContext.getDeviceState().getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
+ private static InstanceIdentifier<FlowCapableNode> assembleFlowCapableNodeInstanceIdentifier(final DeviceState deviceState) {
+ return deviceState.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
}
/**
rpcContext.registerRpcServiceImplementation(FlowCapableTransactionService.class, flowCapableTransactionService);
rpcContext.registerRpcServiceImplementation(SalMeterService.class, salMeterService);
rpcContext.registerRpcServiceImplementation(SalGroupService.class, salGroupService);
- rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext));
+ rpcContext.registerRpcServiceImplementation(SalTableService.class, new SalTableServiceImpl(rpcContext, deviceContext, deviceContext.getPrimaryConnectionContext().getNodeId()));
rpcContext.registerRpcServiceImplementation(SalPortService.class, new SalPortServiceImpl(rpcContext, deviceContext));
rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext));
rpcContext.registerRpcServiceImplementation(NodeConfigService.class, new NodeConfigServiceImpl(rpcContext, deviceContext));
when(mockedFeaturesReply.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
when(mocketGetFeaturesOutput.getTables()).thenReturn(tableId);
+ when(mocketGetFeaturesOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+ when(mocketGetFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimaryConnection);
when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_PATH);
when(mockedDeviceState.getFeatures()).thenReturn(mocketGetFeaturesOutput);
when(mockedDeviceState.deviceSynchronized()).thenReturn(true);
+ when(mockedDeviceState.getNodeId()).thenReturn(mockedNodeId);
+
when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(mockedFlowRegistry);
//NOOP
}
};
- multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class, mockedDeviceContext, dummyEventIdentifier);
+ multipartRequestOnTheFlyCallback = new MultipartRequestOnTheFlyCallback(dummyRequestContext, String.class,
+ mockedDeviceContext.getMessageSpy(),dummyEventIdentifier, mockedDeviceContext.getDeviceState(),
+ mockedDeviceContext.getDeviceFlowRegistry(), mockedDeviceContext);
}
.when(mockedOutboundQueue).commitEntry(
Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
- salTableService = new SalTableServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+ salTableService = new SalTableServiceImpl(mockedRequestContextStack, mockedDeviceContext,
+ mockedDeviceContext.getPrimaryConnectionContext().getNodeId());
}
@Test
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyFlow(), MultipartType.OFPMPFLOW);
- List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(mockedDeviceContext, multipartReplyMessage);
+ List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getVersion(),
+ multipartReplyMessage);
DataObject dataObject = validateOutput(result);
assertTrue(dataObject instanceof FlowsStatisticsUpdate);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyAggregate(), MultipartType.OFPMPAGGREGATE);
- List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(mockedDeviceContext, multipartReplyMessage);
+ List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getVersion(),
+ multipartReplyMessage);
DataObject dataObject = validateOutput(result);
assertTrue(dataObject instanceof AggregateFlowStatisticsUpdate);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyPortStats(), MultipartType.OFPMPPORTSTATS);
OpenflowPortsUtil.init();
- List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(mockedDeviceContext, multipartReplyMessage);
+ List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getVersion(),
+ multipartReplyMessage);
DataObject dataObject = validateOutput(result);
assertTrue(dataObject instanceof NodeConnectorStatisticsUpdate);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyGroup(), MultipartType.OFPMPGROUP);
- List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(mockedDeviceContext, multipartReplyMessage);
+ List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getVersion(),
+ multipartReplyMessage);
DataObject dataObject = validateOutput(result);
assertTrue(dataObject instanceof GroupStatisticsUpdated);
MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyGroupDesc(), MultipartType.OFPMPGROUPDESC);
- List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(mockedDeviceContext, multipartReplyMessage);
+ List<DataObject> result = singlePurposeMultipartReplyTranslator.translate(
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getDatapathId(),
+ mockedDeviceContext.getPrimaryConnectionContext().getFeatures().getVersion(),
+ multipartReplyMessage);
DataObject dataObject = validateOutput(result);
assertTrue(dataObject instanceof GroupDescStatsUpdated);
final ArgumentCaptor<InstanceIdentifier> flowPath = ArgumentCaptor.forClass(InstanceIdentifier.class);
final ArgumentCaptor<Flow> flow = ArgumentCaptor.forClass(Flow.class);
- StatisticsGatheringUtils.writeFlowStatistics(prepareFlowStatisticsData(), deviceContext);
+ StatisticsGatheringUtils.writeFlowStatistics(prepareFlowStatisticsData(),
+ deviceContext.getDeviceState(), deviceContext.getDeviceFlowRegistry(), deviceContext);
Mockito.verify(deviceContext).writeToTransaction(
dataStoreType.capture(), flowPath.capture(), flow.capture());
@Test
public void testDeleteAllKnownFlowsNotSync() throws Exception {
when(deviceState.deviceSynchronized()).thenReturn(false);
- StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext);
+ StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
+ deviceContext.getDeviceFlowRegistry(), deviceContext);
Mockito.verifyNoMoreInteractions(deviceFlowRegistry);
}
final KeyedInstanceIdentifier<Table, TableKey> tablePath = deviceState.getNodeInstanceIdentifier()
.augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tableId));
- StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext);
+ StatisticsGatheringUtils.deleteAllKnownFlows(deviceContext.getDeviceState(),
+ deviceContext.getDeviceFlowRegistry(), deviceContext);
verify(deviceContext).writeToTransaction(
LogicalDatastoreType.OPERATIONAL,
protected void setup() {
statisticsGatheringService = new StatisticsGatheringOnTheFlyService(mockedRequestContextStack, mockedDeviceContext);
Mockito.doReturn(NODE_ID).when(mockedPrimConnectionContext).getNodeId();
+ Mockito.when(mockedDeviceContext.getDeviceState().getNodeId()).thenReturn(NODE_ID);
}
@Test