*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.base.Preconditions;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
-final class AggregateFlowsInTableService extends AbstractSimpleService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> {
- public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput.class);
+public final class AggregateFlowsInTableService extends AbstractCompatibleStatService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput,
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, AggregateFlowStatisticsUpdate> {
+
+ public AggregateFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.build();
}
+
+ @Override
+ public GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public AggregateFlowStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ final int mpSize = result.size();
+ Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+ TranslatorLibrary translatorLibrary = getDeviceContext().oook();
+ MultipartReply mpReply = result.get(0);
+ final TranslatorKey translatorKey = new TranslatorKey(mpReply.getVersion(), MultipartReplyAggregateCase.class.getName());
+ final MessageTranslator<MultipartReply, AggregatedFlowStatistics> messageTranslator = translatorLibrary.lookupTranslator(translatorKey);
+
+ final AggregatedFlowStatistics flowStatistics = messageTranslator.translate(mpReply, getDeviceContext(), null);
+ final AggregateFlowStatisticsUpdateBuilder notification = new AggregateFlowStatisticsUpdateBuilder(flowStatistics)
+ .setId(getDeviceContext().getDeviceState().getNodeId())
+ .setMoreReplies(Boolean.FALSE)
+ .setTransactionId(emulatedTxId);
+
+ return notification.build();
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-final class AllFlowsInAllTablesService extends AbstractSimpleService<GetAllFlowsStatisticsFromAllFlowTablesInput, GetAllFlowsStatisticsFromAllFlowTablesOutput> {
+public final class AllFlowsInAllTablesService extends AbstractCompatibleStatService<GetAllFlowsStatisticsFromAllFlowTablesInput,
+ GetAllFlowsStatisticsFromAllFlowTablesOutput, FlowsStatisticsUpdate> {
private final MultipartRequestFlowCase flowCase;
- AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllFlowsStatisticsFromAllFlowTablesOutput.class);
+ public AllFlowsInAllTablesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
final MultipartRequestFlowCaseBuilder multipartRequestFlowCaseBuilder = new MultipartRequestFlowCaseBuilder();
final MultipartRequestFlowBuilder mprFlowRequestBuilder = new MultipartRequestFlowBuilder();
return mprInput.build();
}
+
+ @Override
+ public GetAllFlowsStatisticsFromAllFlowTablesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.base.Function;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
-public class AllFlowsInTableService extends AbstractSimpleService<GetAllFlowStatisticsFromFlowTableInput, GetAllFlowStatisticsFromFlowTableOutput> {
+public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAllFlowStatisticsFromFlowTableInput,
+ GetAllFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
- public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllFlowStatisticsFromFlowTableOutput.class);
+ private Function<? super RpcResult<List<MultipartReply>>, FlowsStatisticsUpdate> transformer;
+
+ public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.build();
}
+
+ @Override
+ public GetAllFlowStatisticsFromFlowTableOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllFlowStatisticsFromFlowTableOutputBuilder()
+ .setTransactionId(emulatedTxId)
+ .build();
+ }
+
+ @Override
+ public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> mpResult, TransactionId emulatedTxId) {
+ return FlowStatisticsToNotificationTransformer.transformToNotification(mpResult, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Group;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
-final class AllGroupsStatsService extends AbstractSimpleService<GetAllGroupStatisticsInput, GetAllGroupStatisticsOutput> {
+final class AllGroupsStatsService extends
+ AbstractCompatibleStatService<GetAllGroupStatisticsInput, GetAllGroupStatisticsOutput, GroupStatisticsUpdated> {
+
private static final MultipartRequestGroupCase GROUP_CASE;
static {
GROUP_CASE = caseBuilder.build();
}
- AllGroupsStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllGroupStatisticsOutput.class);
+
+ public AllGroupsStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
+
@Override
protected OfHeader buildRequest(final Xid xid, final GetAllGroupStatisticsInput input) {
// Create multipart request header
// Send the request, no cookies associated, use any connection
return mprInput.build();
}
+
+ @Override
+ public GetAllGroupStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllGroupStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.MeterStatsResponseConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterConfigStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterConfigCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.config._case.MultipartRequestMeterConfigBuilder;
-final class AllMeterConfigStatsService extends AbstractSimpleService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput> {
+final class AllMeterConfigStatsService
+ extends AbstractCompatibleStatService<GetAllMeterConfigStatisticsInput, GetAllMeterConfigStatisticsOutput, MeterConfigStatsUpdated> {
+
private static final MultipartRequestMeterConfigCase METER_CONFIG_CASE;
+ private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
+
static {
MultipartRequestMeterConfigCaseBuilder caseBuilder =
METER_CONFIG_CASE = caseBuilder.build();
}
- AllMeterConfigStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllMeterConfigStatisticsOutput.class);
+ public AllMeterConfigStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
.createMultipartHeader(MultipartType.OFPMPMETERCONFIG, xid.getValue(), getVersion());
return mprInput.setMultipartRequestBody(METER_CONFIG_CASE).build();
}
+
+ @Override
+ public GetAllMeterConfigStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllMeterConfigStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public MeterConfigStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ MeterConfigStatsUpdatedBuilder message = new MeterConfigStatsUpdatedBuilder();
+ message.setId(getDeviceContext().getDeviceState().getNodeId());
+ message.setMoreReplies(Boolean.FALSE);
+ message.setTransactionId(emulatedTxId);
+
+ message.setMeterConfigStats(new ArrayList<MeterConfigStats>());
+ for (MultipartReply mpReply : result) {
+ MultipartReplyMeterConfigCase caseBody = (MultipartReplyMeterConfigCase) mpReply.getMultipartReplyBody();
+ MultipartReplyMeterConfig replyBody = caseBody.getMultipartReplyMeterConfig();
+ message.getMeterConfigStats().addAll(meterStatsConvertor.toSALMeterConfigList(replyBody.getMeterConfig()));
+
+ }
+
+ return message.build();
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowjava.protocol.api.util.BinContent;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Meter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
-final class AllMeterStatsService extends AbstractSimpleService<GetAllMeterStatisticsInput, GetAllMeterStatisticsOutput> {
+final class AllMeterStatsService
+ extends AbstractCompatibleStatService<GetAllMeterStatisticsInput, GetAllMeterStatisticsOutput, MeterStatisticsUpdated> {
private static final MultipartRequestMeterCase METER_CASE;
static {
METER_CASE = caseBuilder.build();
}
- AllMeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllMeterStatisticsOutput.class);
+ public AllMeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.setMultipartRequestBody(METER_CASE).build();
}
+
+ @Override
+ public GetAllMeterStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllMeterStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.NodeConnectorStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
+
+final class AllPortStatsService
+ extends AbstractCompatibleStatService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput, NodeConnectorStatisticsUpdate> {
-final class AllPortStatsService extends AbstractSimpleService<GetAllNodeConnectorsStatisticsInput, GetAllNodeConnectorsStatisticsOutput> {
private static final MultipartRequestPortStatsCase PORT_STATS_CASE;
static {
PORT_STATS_CASE = caseBuilder.build();
}
- AllPortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllNodeConnectorsStatisticsOutput.class);
+ public AllPortStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(PORT_STATS_CASE);
return mprInput.build();
}
+
+ @Override
+ public GetAllNodeConnectorsStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllNodeConnectorsStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
+
+final class AllQueuesAllPortsService
+ extends AbstractCompatibleStatService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput, QueueStatisticsUpdate> {
-final class AllQueuesAllPortsService extends AbstractSimpleService<GetAllQueuesStatisticsFromAllPortsInput, GetAllQueuesStatisticsFromAllPortsOutput> {
private static final MultipartRequestQueueCase QUEUE_CASE;
static {
QUEUE_CASE = caseBuilder.build();
}
- AllQueuesAllPortsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromAllPortsOutput.class);
+ public AllQueuesAllPortsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(QUEUE_CASE);
return mprInput.build();
}
+
+ @Override
+ public GetAllQueuesStatisticsFromAllPortsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllQueuesStatisticsFromAllPortsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-final class AllQueuesOnePortService extends AbstractSimpleService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput> {
- AllQueuesOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetAllQueuesStatisticsFromGivenPortOutput.class);
+final class AllQueuesOnePortService
+ extends AbstractCompatibleStatService<GetAllQueuesStatisticsFromGivenPortInput, GetAllQueuesStatisticsFromGivenPortOutput, QueueStatisticsUpdate> {
+
+ public AllQueuesOnePortService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.build();
}
+ @Override
+ public GetAllQueuesStatisticsFromGivenPortOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetAllQueuesStatisticsFromGivenPortOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.FlowStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchReactor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-final class FlowsInTableService extends AbstractSimpleService<GetFlowStatisticsFromFlowTableInput, GetFlowStatisticsFromFlowTableOutput> {
- FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetFlowStatisticsFromFlowTableOutput.class);
+public final class FlowsInTableService extends AbstractCompatibleStatService<GetFlowStatisticsFromFlowTableInput,
+ GetFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
+
+ public FlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.build();
}
+
+ @Override
+ public GetFlowStatisticsFromFlowTableOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetFlowStatisticsFromFlowTableOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public FlowsStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return FlowStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.GroupStatsResponseConvertor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder;
-final class GroupDescriptionService extends AbstractSimpleService<GetGroupDescriptionInput, GetGroupDescriptionOutput> {
+final class GroupDescriptionService
+ extends AbstractCompatibleStatService<GetGroupDescriptionInput, GetGroupDescriptionOutput, GroupDescStatsUpdated> {
private static final MultipartRequestGroupDescCase GROUP_DESC_CASE = new MultipartRequestGroupDescCaseBuilder().build();
+ private final GroupStatsResponseConvertor groupStatsResponseConvertor;
- GroupDescriptionService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetGroupDescriptionOutput.class);
+ public GroupDescriptionService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
+ groupStatsResponseConvertor = new GroupStatsResponseConvertor();
}
@Override
mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
return mprInput.build();
}
+
+ @Override
+ public GetGroupDescriptionOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetGroupDescriptionOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
+ notification.setId(getDeviceContext().getDeviceState().getNodeId());
+ notification.setMoreReplies(Boolean.FALSE);
+ notification.setTransactionId(emulatedTxId);
+
+ notification.setGroupDescStats(new ArrayList<GroupDescStats>());
+ for (MultipartReply mpReply : result) {
+ MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
+ MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
+ notification.getGroupDescStats().addAll(
+ groupStatsResponseConvertor.toSALGroupDescStatsList(replyBody.getGroupDesc(), getOfVersion()));
+ }
+
+ return notification.build();
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Chaining;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.ChainingChecks;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupAll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupFf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupIndirect;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupSelect;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder;
-final class GroupFeaturesService extends AbstractSimpleService<GetGroupFeaturesInput, GetGroupFeaturesOutput> {
+final class GroupFeaturesService
+ extends AbstractCompatibleStatService<GetGroupFeaturesInput, GetGroupFeaturesOutput, GroupFeaturesUpdated> {
+
private static final MultipartRequestGroupFeaturesCase GROUP_FEAT_CASE =
new MultipartRequestGroupFeaturesCaseBuilder().build();
- GroupFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetGroupFeaturesOutput.class);
+ public GroupFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(GROUP_FEAT_CASE);
return mprInput.build();
}
+
+ @Override
+ public GetGroupFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetGroupFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public GroupFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ final int mpSize = result.size();
+ Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+ GroupFeaturesUpdatedBuilder notification = new GroupFeaturesUpdatedBuilder();
+ notification.setId(getDeviceContext().getDeviceState().getNodeId());
+ notification.setMoreReplies(Boolean.FALSE);
+ notification.setTransactionId(emulatedTxId);
+
+ MultipartReplyGroupFeaturesCase caseBody = (MultipartReplyGroupFeaturesCase) result.get(0).getMultipartReplyBody();
+ MultipartReplyGroupFeatures replyBody = caseBody.getMultipartReplyGroupFeatures();
+
+ notification.setGroupTypesSupported(extractSupportedGroupTypes(replyBody.getTypes()));
+ notification.setMaxGroups(replyBody.getMaxGroups());
+ notification.setGroupCapabilitiesSupported(extractSupportedCapabilities(replyBody.getCapabilities()));
+ notification.setActions(extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
+
+ return notification.build();
+ }
+
+ @VisibleForTesting
+ static List<Class<? extends GroupCapability>> extractSupportedCapabilities(GroupCapabilities capabilities) {
+ List<Class<? extends GroupCapability>> supportedCapabilities = new ArrayList<>();
+
+ if (capabilities.isOFPGFCCHAINING()) {
+ supportedCapabilities.add(Chaining.class);
+ }
+ if (capabilities.isOFPGFCCHAININGCHECKS()) {
+ supportedCapabilities.add(ChainingChecks.class);
+ }
+ if (capabilities.isOFPGFCSELECTLIVENESS()) {
+ supportedCapabilities.add(SelectLiveness.class);
+ }
+ if (capabilities.isOFPGFCSELECTWEIGHT()) {
+ supportedCapabilities.add(SelectWeight.class);
+ }
+ return supportedCapabilities;
+ }
+
+ @VisibleForTesting
+ static List<Class<? extends GroupType>> extractSupportedGroupTypes(GroupTypes types) {
+ List<Class<? extends GroupType>> supportedGroups = new ArrayList<>();
+
+ if (types.isOFPGTALL()) {
+ supportedGroups.add(GroupAll.class);
+ }
+ if (types.isOFPGTSELECT()) {
+ supportedGroups.add(GroupSelect.class);
+ }
+ if (types.isOFPGTINDIRECT()) {
+ supportedGroups.add(GroupIndirect.class);
+ }
+ if (types.isOFPGTFF()) {
+ supportedGroups.add(GroupFf.class);
+ }
+ return supportedGroups;
+ }
+
+ @VisibleForTesting
+ static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
+ List<Long> supportActionByGroups = new ArrayList<>();
+ for (ActionType supportedActions : actionsSupported) {
+ long supportActionBitmap = 0;
+ supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1 << 0) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
+ supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
+ supportActionByGroups.add(Long.valueOf(supportActionBitmap));
+ }
+ return supportActionByGroups;
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.GroupStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group._case.MultipartRequestGroupBuilder;
-final class GroupStatsService extends AbstractSimpleService<GetGroupStatisticsInput, GetGroupStatisticsOutput> {
- GroupStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetGroupStatisticsOutput.class);
+final class GroupStatsService
+ extends AbstractCompatibleStatService<GetGroupStatisticsInput, GetGroupStatisticsOutput, GroupStatisticsUpdated> {
+
+ public GroupStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(caseBuilder.build());
return mprInput.build();
}
+
+ @Override
+ public GetGroupStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetGroupStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public GroupStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return GroupStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDrop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBandDscpRemark;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBurst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder;
-final class MeterFeaturesService extends AbstractSimpleService<GetMeterFeaturesInput, GetMeterFeaturesOutput> {
+final class MeterFeaturesService
+ extends AbstractCompatibleStatService<GetMeterFeaturesInput, GetMeterFeaturesOutput, MeterFeaturesUpdated> {
private static final MultipartRequestMeterFeaturesCase METER_FEATURES_CASE = new MultipartRequestMeterFeaturesCaseBuilder().build();
- protected MeterFeaturesService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetMeterFeaturesOutput.class);
+ public MeterFeaturesService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(METER_FEATURES_CASE);
return mprInput.build();
}
+
+ @Override
+ public GetMeterFeaturesOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetMeterFeaturesOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ final int mpSize = result.size();
+ Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
+
+ MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
+ notification.setId(getDeviceContext().getDeviceState().getNodeId());
+ notification.setMoreReplies(Boolean.FALSE);
+ notification.setTransactionId(emulatedTxId);
+
+ MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
+ MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
+ notification.setMaxBands(replyBody.getMaxBands());
+ notification.setMaxColor(replyBody.getMaxColor());
+ notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
+ notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
+ notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
+
+ return notification.build();
+ }
+
+ @VisibleForTesting
+ protected List<Class<? extends MeterBand>> extractSupportedMeterBand(MultipartReplyMeterFeatures replyBody, MeterBandTypeBitmap bandTypes) {
+ List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
+ if (bandTypes.isOFPMBTDROP()) {
+ supportedMeterBand.add(MeterBandDrop.class);
+ }
+ if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
+ supportedMeterBand.add(MeterBandDscpRemark.class);
+ }
+ return supportedMeterBand;
+ }
+
+ @VisibleForTesting
+ protected static List<Class<? extends MeterCapability>> extractMeterCapabilities(MeterFlags capabilities) {
+ List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
+
+ if (capabilities.isOFPMFBURST()) {
+ supportedCapabilities.add(MeterBurst.class);
+ }
+ if (capabilities.isOFPMFKBPS()) {
+ supportedCapabilities.add(MeterKbps.class);
+ }
+ if (capabilities.isOFPMFPKTPS()) {
+ supportedCapabilities.add(MeterPktps.class);
+ }
+ if (capabilities.isOFPMFSTATS()) {
+ supportedCapabilities.add(MeterStats.class);
+ }
+ return supportedCapabilities;
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.MeterStatisticsToNotificationTransformer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterStatisticsUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter._case.MultipartRequestMeterBuilder;
-final class MeterStatsService extends AbstractSimpleService<GetMeterStatisticsInput, GetMeterStatisticsOutput> {
+final class MeterStatsService
+ extends AbstractCompatibleStatService<GetMeterStatisticsInput, GetMeterStatisticsOutput, MeterStatisticsUpdated> {
- MeterStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetMeterStatisticsOutput.class);
+ public MeterStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(caseBuilder.build());
return mprInput.build();
}
+
+ @Override
+ public GetMeterStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetMeterStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public MeterStatisticsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return MeterStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.QueueStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdate;
-final class OneQueueOnePortService extends AbstractSimpleService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput> {
- OneQueueOnePortService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetQueueStatisticsFromGivenPortOutput.class);
+final class OneQueueOnePortService
+ extends AbstractCompatibleStatService<GetQueueStatisticsFromGivenPortInput, GetQueueStatisticsFromGivenPortOutput, QueueStatisticsUpdate> {
+
+ public OneQueueOnePortService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
mprInput.setMultipartRequestBody(caseBuilder.build());
return mprInput.build();
}
+
+ @Override
+ public GetQueueStatisticsFromGivenPortOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetQueueStatisticsFromGivenPortOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public QueueStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return QueueStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.api.openflow.statistics.compatibility.Delegator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
/**
* @author joe
*/
-public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService {
+public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService, Delegator<OpendaylightFlowStatisticsService> {
+
private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
public RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> apply(final RpcResult<List<MultipartReply>> input) {
final DeviceContext deviceContext = matchingFlowsInTable.getDeviceContext();
TranslatorLibrary translatorLibrary = deviceContext.oook();
- RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
+ final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult;
if (input.isSuccessful()) {
MultipartReply reply = input.getResult().get(0);
final TranslatorKey translatorKey = new TranslatorKey(reply.getVersion(), MultipartReplyAggregateCase.class.getName());
}
};
- private final AggregateFlowsInTableService aggregateFlowsInTable;
private final MatchingFlowsInTableService matchingFlowsInTable;
- private final AllFlowsInAllTablesService allFlowsInAllTables;
- private final AllFlowsInTableService allFlowsInTable;
- private final FlowsInTableService flowsInTable;
+ private OpendaylightFlowStatisticsService delegate;
public OpendaylightFlowStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext);
- allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext);
- allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext);
- flowsInTable = new FlowsInTableService(requestContextStack, deviceContext);
matchingFlowsInTable = new MatchingFlowsInTableService(requestContextStack, deviceContext);
}
@Override
+ public void setDelegate(OpendaylightFlowStatisticsService delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
+ @Override
+ @Deprecated
public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
- return aggregateFlowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
@Override
return Futures.transform(matchingFlowsInTable.handleServiceCall(input), matchingConvertor);
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
final GetAllFlowStatisticsFromFlowTableInput input) {
- return allFlowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAllFlowStatisticsFromFlowTable(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
- return allFlowsInAllTables.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getAllFlowsStatisticsFromAllFlowTables(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
+ /**
+ * @deprecated provided for Be-release as backward compatibility relic
+ */
@Override
+ @Deprecated
public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
final GetFlowStatisticsFromFlowTableInput input) {
- return flowsInTable.handleServiceCall(input);
+ if (delegate != null) {
+ return delegate.getFlowStatisticsFromFlowTable(input);
+ } else {
+ throw new IllegalAccessError("no delegate available - service is currently out of order");
+ }
}
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.FlowTableStatisticsUpdateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
import org.opendaylight.yangtools.yang.common.RpcResult;
-public final class OpendaylightFlowTableStatisticsServiceImpl extends AbstractSimpleService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput> implements
+public final class OpendaylightFlowTableStatisticsServiceImpl extends
+ AbstractCompatibleStatService<GetFlowTablesStatisticsInput, GetFlowTablesStatisticsOutput, FlowTableStatisticsUpdate> implements
OpendaylightFlowTableStatisticsService {
- public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetFlowTablesStatisticsOutput.class);
+ private final NotificationPublishService notificationPublishService;
+
+ public OpendaylightFlowTableStatisticsServiceImpl(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed,
+ final NotificationPublishService notificationPublishService) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
+ this.notificationPublishService = notificationPublishService;
}
@Override
public Future<RpcResult<GetFlowTablesStatisticsOutput>> getFlowTablesStatistics(
final GetFlowTablesStatisticsInput input) {
- return handleServiceCall(input);
+ return handleAndNotify(input, notificationPublishService);
}
@Override
return mprInput.build();
}
+
+ @Override
+ public GetFlowTablesStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetFlowTablesStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public FlowTableStatisticsUpdate transformToNotification(List<MultipartReply> mpReplyList, TransactionId emulatedTxId) {
+ FlowTableStatisticsUpdateBuilder notification = new FlowTableStatisticsUpdateBuilder();
+ notification.setId(getDeviceContext().getDeviceState().getNodeId());
+ notification.setMoreReplies(Boolean.FALSE);
+ notification.setTransactionId(emulatedTxId);
+
+ final List<FlowTableAndStatisticsMap> salFlowStats = new ArrayList<>();
+ notification.setFlowTableAndStatisticsMap(salFlowStats);
+ for (MultipartReply mpReply : mpReplyList) {
+ MultipartReplyTableCase caseBody = (MultipartReplyTableCase) mpReply.getMultipartReplyBody();
+ MultipartReplyTable replyBody = caseBody.getMultipartReplyTable();
+ List<TableStats> swTablesStats = replyBody.getTableStats();
+
+ for (TableStats swTableStats : swTablesStats) {
+ FlowTableAndStatisticsMapBuilder statisticsBuilder = new FlowTableAndStatisticsMapBuilder();
+ statisticsBuilder.setActiveFlows(new Counter32(swTableStats.getActiveCount()));
+ statisticsBuilder.setPacketsLookedUp(new Counter64(swTableStats.getLookupCount()));
+ statisticsBuilder.setPacketsMatched(new Counter64(swTableStats.getMatchedCount()));
+ statisticsBuilder.setTableId(new TableId(swTableStats.getTableId()));
+ salFlowStats.add(statisticsBuilder.build());
+ }
+ }
+
+ return notification.build();
+ }
}
package org.opendaylight.openflowplugin.impl.statistics.services;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInput;
private final GroupDescriptionService groupDesc;
private final GroupFeaturesService groupFeat;
private final GroupStatsService groupStats;
+ private final NotificationPublishService notificationPublishService;
- public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- allGroups = new AllGroupsStatsService(requestContextStack, deviceContext);
- groupDesc = new GroupDescriptionService(requestContextStack, deviceContext);
- groupFeat = new GroupFeaturesService(requestContextStack, deviceContext);
- groupStats = new GroupStatsService(requestContextStack, deviceContext);
+ public OpendaylightGroupStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed,
+ final NotificationPublishService notificationPublishService) {
+ this.notificationPublishService = notificationPublishService;
+ allGroups = new AllGroupsStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+ groupDesc = new GroupDescriptionService(requestContextStack, deviceContext, compatibilityXidSeed);
+ groupFeat = new GroupFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
+ groupStats = new GroupStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
public Future<RpcResult<GetAllGroupStatisticsOutput>> getAllGroupStatistics(final GetAllGroupStatisticsInput input) {
- return allGroups.handleServiceCall(input);
+ return allGroups.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetGroupDescriptionOutput>> getGroupDescription(final GetGroupDescriptionInput input) {
- return groupDesc.handleServiceCall(input);
+ return groupDesc.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetGroupFeaturesOutput>> getGroupFeatures(final GetGroupFeaturesInput input) {
- return groupFeat.handleServiceCall(input);
+ return groupFeat.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetGroupStatisticsOutput>> getGroupStatistics(final GetGroupStatisticsInput input) {
- return groupStats.handleServiceCall(input);
+ return groupStats.handleAndNotify(input, notificationPublishService);
}
}
package org.opendaylight.openflowplugin.impl.statistics.services;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInput;
private final AllMeterStatsService allMeterStats;
private final MeterFeaturesService meterFeatures;
private final MeterStatsService meterStats;
+ private final NotificationPublishService notificationPublishService;
- public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext);
- allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext);
- meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext);
- meterStats = new MeterStatsService(requestContextStack, deviceContext);
+ public OpendaylightMeterStatisticsServiceImpl(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed,
+ final NotificationPublishService notificationPublishService) {
+ this.notificationPublishService = notificationPublishService;
+
+ allMeterConfig = new AllMeterConfigStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+ allMeterStats = new AllMeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+ meterFeatures = new MeterFeaturesService(requestContextStack, deviceContext, compatibilityXidSeed);
+ meterStats = new MeterStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
public Future<RpcResult<GetAllMeterConfigStatisticsOutput>> getAllMeterConfigStatistics(
final GetAllMeterConfigStatisticsInput input) {
- return allMeterConfig.handleServiceCall(input);
+ return allMeterConfig.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetAllMeterStatisticsOutput>> getAllMeterStatistics(final GetAllMeterStatisticsInput input) {
- return allMeterStats.handleServiceCall(input);
+ return allMeterStats.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetMeterFeaturesOutput>> getMeterFeatures(final GetMeterFeaturesInput input) {
- return meterFeatures.handleServiceCall(input);
+ return meterFeatures.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetMeterStatisticsOutput>> getMeterStatistics(final GetMeterStatisticsInput input) {
- return meterStats.handleServiceCall(input);
+ return meterStats.handleAndNotify(input, notificationPublishService);
}
}
package org.opendaylight.openflowplugin.impl.statistics.services;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInput;
public class OpendaylightPortStatisticsServiceImpl implements OpendaylightPortStatisticsService {
private final AllPortStatsService allPortStats;
private final PortStatsService portStats;
+ private final NotificationPublishService notificationPublishService;
- public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- allPortStats = new AllPortStatsService(requestContextStack, deviceContext);
- portStats = new PortStatsService(requestContextStack, deviceContext);
+ public OpendaylightPortStatisticsServiceImpl(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed,
+ final NotificationPublishService notificationPublishService) {
+ this.notificationPublishService = notificationPublishService;
+ allPortStats = new AllPortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
+ portStats = new PortStatsService(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
public Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> getAllNodeConnectorsStatistics(
final GetAllNodeConnectorsStatisticsInput input) {
- return allPortStats.handleServiceCall(input);
+ return allPortStats.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetNodeConnectorStatisticsOutput>> getNodeConnectorStatistics(
final GetNodeConnectorStatisticsInput input) {
- return portStats.handleServiceCall(input);
+ return portStats.handleAndNotify(input, notificationPublishService);
}
}
package org.opendaylight.openflowplugin.impl.statistics.services;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInput;
private final AllQueuesAllPortsService allQueuesAllPorts;
private final AllQueuesOnePortService allQueuesOnePort;
private final OneQueueOnePortService oneQueueOnePort;
+ private final NotificationPublishService notificationPublishService;
- public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext);
- allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext);
- oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext);
+ public OpendaylightQueueStatisticsServiceImpl(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final AtomicLong compatibilityXidSeed,
+ final NotificationPublishService notificationPublishService) {
+ this.notificationPublishService = notificationPublishService;
+ allQueuesAllPorts = new AllQueuesAllPortsService(requestContextStack, deviceContext, compatibilityXidSeed);
+ allQueuesOnePort = new AllQueuesOnePortService(requestContextStack, deviceContext, compatibilityXidSeed);
+ oneQueueOnePort = new OneQueueOnePortService(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
public Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> getAllQueuesStatisticsFromAllPorts(
final GetAllQueuesStatisticsFromAllPortsInput input) {
- return allQueuesAllPorts.handleServiceCall(input);
+ return allQueuesAllPorts.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> getAllQueuesStatisticsFromGivenPort(
final GetAllQueuesStatisticsFromGivenPortInput input) {
- return allQueuesOnePort.handleServiceCall(input);
+ return allQueuesOnePort.handleAndNotify(input, notificationPublishService);
}
@Override
public Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> getQueueStatisticsFromGivenPort(
final GetQueueStatisticsFromGivenPortInput input) {
- return oneQueueOnePort.handleServiceCall(input);
+ return oneQueueOnePort.handleAndNotify(input, notificationPublishService);
}
}
*/
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.impl.services.AbstractSimpleService;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.NodeConnectorStatisticsToNotificationTransformer;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsUpdate;
-final class PortStatsService extends AbstractSimpleService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput> {
+final class PortStatsService
+ extends AbstractCompatibleStatService<GetNodeConnectorStatisticsInput, GetNodeConnectorStatisticsOutput, NodeConnectorStatisticsUpdate> {
- protected PortStatsService(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
- super(requestContextStack, deviceContext, GetNodeConnectorStatisticsOutput.class);
+ public PortStatsService(RequestContextStack requestContextStack, DeviceContext deviceContext, AtomicLong compatibilityXidSeed) {
+ super(requestContextStack, deviceContext, compatibilityXidSeed);
}
@Override
return mprInput.build();
}
+
+ @Override
+ public GetNodeConnectorStatisticsOutput buildTxCapableResult(TransactionId emulatedTxId) {
+ return new GetNodeConnectorStatisticsOutputBuilder().setTransactionId(emulatedTxId).build();
+ }
+
+ @Override
+ public NodeConnectorStatisticsUpdate transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
+ return NodeConnectorStatisticsToNotificationTransformer.transformToNotification(result, getDeviceContext(), getOfVersion(), emulatedTxId);
+ }
}
final TransactionId emulatedTxId) {
final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
+ notification.setId(deviceContext.getDeviceState().getNodeId());
notification.setFlowAndStatisticsMapList(statsList);
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
--- /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.impl.statistics.services.compatibility;
+
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService;
+import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInAllTablesService;
+import org.opendaylight.openflowplugin.impl.statistics.services.AllFlowsInTableService;
+import org.opendaylight.openflowplugin.impl.statistics.services.FlowsInTableService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author joe
+ */
+public class OpendaylightFlowStatisticsServiceDelegateImpl implements OpendaylightFlowStatisticsService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceDelegateImpl.class);
+
+ private final AggregateFlowsInTableService aggregateFlowsInTable;
+ private final AllFlowsInAllTablesService allFlowsInAllTables;
+ private final AllFlowsInTableService allFlowsInTable;
+ private final FlowsInTableService flowsInTable;
+ private final NotificationPublishService notificationService;
+
+ public OpendaylightFlowStatisticsServiceDelegateImpl(final RequestContextStack requestContextStack,
+ final DeviceContext deviceContext,
+ final NotificationPublishService notificationService,
+ final AtomicLong compatibilityXidSeed) {
+ this.notificationService = notificationService;
+ aggregateFlowsInTable = new AggregateFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+ allFlowsInAllTables = new AllFlowsInAllTablesService(requestContextStack, deviceContext, compatibilityXidSeed);
+ allFlowsInTable = new AllFlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+ flowsInTable = new FlowsInTableService(requestContextStack, deviceContext, compatibilityXidSeed);
+ }
+
+ /**
+ * @deprecated this is the only method with real implementation provided, in delegate it makes no sense
+ */
+ @Override
+ @Deprecated
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> getAggregateFlowStatisticsFromFlowTableForGivenMatch(
+ final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input) {
+ throw new IllegalAccessError("unsupported by backward compatibility delegate service " +
+ "- this rpc is always provided by default service implementation");
+ }
+
+ @Override
+ public Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> getAggregateFlowStatisticsFromFlowTableForAllFlows(
+ final GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input) {
+ return aggregateFlowsInTable.handleAndNotify(input, notificationService);
+ }
+
+ @Override
+ public Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> getAllFlowStatisticsFromFlowTable(
+ final GetAllFlowStatisticsFromFlowTableInput input) {
+ return allFlowsInTable.handleAndNotify(input, notificationService);
+ }
+
+ @Override
+ public Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> getAllFlowsStatisticsFromAllFlowTables(
+ final GetAllFlowsStatisticsFromAllFlowTablesInput input) {
+ return allFlowsInAllTables.handleAndNotify(input, notificationService);
+ }
+
+ @Override
+ public Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> getFlowStatisticsFromFlowTable(
+ final GetFlowStatisticsFromFlowTableInput input) {
+ return flowsInTable.handleAndNotify(input, notificationService);
+ }
+}
--- /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.impl.statistics.services;
+
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * Created by mirehak on 9/9/15.
+ */
+public abstract class AbstractSingleStatsServiceTest extends AbstractStatsServiceTest {
+
+ @Mock
+ protected NotificationPublishService notificationPublishService;
+
+ protected RequestContext<Object> rqContext;
+
+ protected RpcResult<Object> rpcResult;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+ rqContext = new AbstractRequestContext<Object>(42L) {
+ @Override
+ public void close() {
+ //NOOP
+ }
+ };
+ final Answer closeRequestFutureAnswer = new Answer() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ rqContext.setResult(rpcResult);
+ rqContext.close();
+ return null;
+ }
+ };
+
+ Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+ Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
+ Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
+ }
+}
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
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.RequestContextStack;
import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@RunWith(MockitoJUnitRunner.class)
public abstract class AbstractStatsServiceTest {
@Mock
- RequestContextStack rqContextStack;
+ protected RequestContextStack rqContextStack;
@Mock
- DeviceContext deviceContext;
+ protected DeviceContext deviceContext;
@Mock
- ConnectionContext connectionContext;
+ protected ConnectionContext connectionContext;
@Mock
- FeaturesReply features;
+ protected FeaturesReply features;
@Mock
- MessageSpy messageSpy;
+ private GetFeaturesOutput getFeaturesOutput;
@Mock
- OutboundQueue outboundQueueProvider;
+ protected MessageSpy messageSpy;
@Mock
- MultiMsgCollector multiMsgCollector;
+ protected OutboundQueue outboundQueueProvider;
@Mock
- TranslatorLibrary translatorLibrary;
+ protected MultiMsgCollector multiMsgCollector;
+ @Mock
+ protected TranslatorLibrary translatorLibrary;
+ @Mock
+ protected DeviceState deviceState;
+
- final Answer<Void> answerVoidToCallback = new Answer<Void>() {
+ public static final NodeId NODE_ID = new NodeId("unit-test-node:123");
+
+ protected final Answer<Void> answerVoidToCallback = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
final FutureCallback<OfHeader> callback = (FutureCallback<OfHeader>) (invocation.getArguments()[2]);
Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
Mockito.when(deviceContext.getMultiMsgCollector(Matchers.any(RequestContext.class))).thenReturn(multiMsgCollector);
Mockito.when(deviceContext.oook()).thenReturn(translatorLibrary);
+ Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+ Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
+ Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+ Mockito.when(deviceState.getFeatures()).thenReturn(getFeaturesOutput);
+ Mockito.when(getFeaturesOutput.getDatapathId()).thenReturn(BigInteger.valueOf(123L));
Mockito.when(connectionContext.getFeatures()).thenReturn(features);
Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
Mockito.when(features.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+
setUp();
}
//NOOP
}
- static NodeRef createNodeRef(String nodeIdValue) {
+ protected static NodeRef createNodeRef(String nodeIdValue) {
InstanceIdentifier<Node> nodePath = InstanceIdentifier.create(Nodes.class)
.child(Node.class, new NodeKey(new NodeId(nodeIdValue)));
return new NodeRef(nodePath);
package org.opendaylight.openflowplugin.impl.statistics.services;
-import com.google.common.util.concurrent.FutureCallback;
import java.util.concurrent.Future;
-import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
-import org.mockito.Matchers;
import org.mockito.Mockito;
import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
- * Test for {@link OpendaylightFlowStatisticsServiceImpl}
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods (failing)
*/
public class OpendaylightFlowStatisticsServiceImpl1Test extends AbstractStatsServiceTest {
private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
-
public void setUp() {
flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(rqContextStack, deviceContext);
Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
}
- @Test
+ @Test(expected = IllegalAccessError.class)
public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setTableId(new TableId((short) 1));
- final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture
- = flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
-
- Assert.assertTrue(resultFuture.isDone());
- final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = resultFuture.get();
- Assert.assertTrue(rpcResult.isSuccessful());
- Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+ flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
}
- @Test
+ @Test(expected = IllegalAccessError.class)
public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setTableId(new TableId((short) 1));
- final Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> resultFuture
- = flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
-
- Assert.assertTrue(resultFuture.isDone());
- final RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResult = resultFuture.get();
- Assert.assertTrue(rpcResult.isSuccessful());
- Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+ flowStatisticsService.getAllFlowStatisticsFromFlowTable(input.build());
}
- @Test
+ @Test(expected = IllegalAccessError.class)
public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
.setNode(createNodeRef("unitProt:123"));
- final Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> resultFuture
- = flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
-
- Assert.assertTrue(resultFuture.isDone());
- final RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResult = resultFuture.get();
- Assert.assertTrue(rpcResult.isSuccessful());
- Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+ flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input.build());
}
- @Test
+ @Test(expected = IllegalAccessError.class)
public void testGetFlowStatisticsFromFlowTable() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setPriority(5);
final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
= flowStatisticsService.getFlowStatisticsFromFlowTable(input.build());
-
- Assert.assertTrue(resultFuture.isDone());
- final RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResult = resultFuture.get();
- Assert.assertTrue(rpcResult.isSuccessful());
- Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
- * Test for {@link OpendaylightFlowStatisticsServiceImpl}
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only not delegated method
*/
public class OpendaylightFlowStatisticsServiceImpl2Test extends AbstractStatsServiceTest {
--- /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.impl.statistics.services;
+
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+
+/**
+ * Test for {@link OpendaylightFlowStatisticsServiceImpl} - only delegated methods
+ */
+public class OpendaylightFlowStatisticsServiceImpl3Test extends AbstractStatsServiceTest {
+
+ @Mock
+ private OpendaylightFlowStatisticsService flowStatisticsDelegate;
+
+ private OpendaylightFlowStatisticsServiceImpl flowStatisticsService;
+
+ public void setUp() {
+ flowStatisticsService = new OpendaylightFlowStatisticsServiceImpl(rqContextStack, deviceContext);
+ flowStatisticsService.setDelegate(flowStatisticsDelegate);
+ }
+
+ @Test
+ public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId(new TableId((short) 1))
+ .build();
+
+ flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+ Mockito.verify(flowStatisticsDelegate).getAggregateFlowStatisticsFromFlowTableForAllFlows(input);
+ }
+
+ @Test
+ public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
+ GetAllFlowStatisticsFromFlowTableInput input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId(new TableId((short) 1))
+ .build();
+
+ flowStatisticsService.getAllFlowStatisticsFromFlowTable(input);
+ Mockito.verify(flowStatisticsDelegate).getAllFlowStatisticsFromFlowTable(input);
+ }
+
+ @Test
+ public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
+ GetAllFlowsStatisticsFromAllFlowTablesInput input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .build();
+
+ flowStatisticsService.getAllFlowsStatisticsFromAllFlowTables(input);
+ Mockito.verify(flowStatisticsDelegate).getAllFlowsStatisticsFromAllFlowTables(input);
+ }
+
+ @Test
+ public void testGetFlowStatisticsFromFlowTable() throws Exception {
+ GetFlowStatisticsFromFlowTableInput input = new GetFlowStatisticsFromFlowTableInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setPriority(5)
+ .build();
+
+ flowStatisticsService.getFlowStatisticsFromFlowTable(input);
+ Mockito.verify(flowStatisticsDelegate).getFlowStatisticsFromFlowTable(input);
+ }
+}
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCase;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
* Test for {@link OpendaylightFlowTableStatisticsServiceImpl}
*/
-public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightFlowTableStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
+ private static final Short TABLE_ID = (short) 123;
@Captor
private ArgumentCaptor<MultipartRequestInput> requestInput;
- private RequestContext<Object> rqContext;
-
private OpendaylightFlowTableStatisticsServiceImpl flowTableStatisticsService;
public void setUp() {
- flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext);
-
- rqContext = new AbstractRequestContext<Object>(42L) {
- @Override
- public void close() {
- //NOOP
- }
- };
- Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+ flowTableStatisticsService = new OpendaylightFlowTableStatisticsServiceImpl(rqContextStack, deviceContext,
+ new AtomicLong(), notificationPublishService);
}
@Test
GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyTableCaseBuilder()
+ .setMultipartReplyTable(new MultipartReplyTableBuilder()
+ .setTableStats(Collections.singletonList(new TableStatsBuilder()
+ .setActiveCount(31L)
+ .setLookupCount(BigInteger.valueOf(32L))
+ .setMatchedCount(BigInteger.valueOf(33L))
+ .setMaxEntries(34L)
+ .setName("test-table")
+ .setNwDstMask((short) 35)
+ .setNwSrcMask((short) 36)
+ .setTableId(TABLE_ID)
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+
final Future<RpcResult<GetFlowTablesStatisticsOutput>> resultFuture
= flowTableStatisticsService.getFlowTablesStatistics(input.build());
final RpcResult<GetFlowTablesStatisticsOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType());
+
+ Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
}
@Test
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
* Test for {@link OpendaylightGroupStatisticsServiceImpl}
*/
-public class OpendaylightGroupStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightGroupStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId GROUP_ID =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(123L);
@Captor
private ArgumentCaptor<MultipartRequestInput> requestInput;
- private RequestContext<Object> rqContext;
-
private OpendaylightGroupStatisticsServiceImpl groupStatisticsService;
public void setUp() {
- groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext);
-
- rqContext = new AbstractRequestContext<Object>(42L) {
- @Override
- public void close() {
- //NOOP
- }
- };
- Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
- }
+ groupStatisticsService = new OpendaylightGroupStatisticsServiceImpl(rqContextStack, deviceContext,
+ new AtomicLong(), notificationPublishService);
- @Test
- public void testGetAllGroupStatistics() throws Exception {
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
.commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+ }
+ @Test
+ public void testGetAllGroupStatistics() throws Exception {
GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = buildGroupStatsResponse();
+
final Future<RpcResult<GetAllGroupStatisticsOutput>> resultFuture
= groupStatisticsService.getAllGroupStatistics(input.build());
Assert.assertTrue(resultFuture.isDone());
- final RpcResult<GetAllGroupStatisticsOutput> rpcResult = resultFuture.get();
- Assert.assertTrue(rpcResult.isSuccessful());
+ final RpcResult<GetAllGroupStatisticsOutput> rpcResultCompatible = resultFuture.get();
+ Assert.assertTrue(rpcResultCompatible.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
}
@Test
public void testGetGroupDescription() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyGroupDescCaseBuilder()
+ .setMultipartReplyGroupDesc(new MultipartReplyGroupDescBuilder()
+ .setGroupDesc(Collections.singletonList(new GroupDescBuilder()
+ .setGroupId(GROUP_ID)
+ .setBucketsList(Collections.singletonList(new BucketsListBuilder()
+ .setWatchGroup(51L)
+ .setWatchPort(new PortNumber(52L))
+ .setWeight(53)
+ .build()))
+ .setType(GroupType.OFPGTALL)
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+
final Future<RpcResult<GetGroupDescriptionOutput>> resultFuture
= groupStatisticsService.getGroupDescription(input.build());
@Test
public void testGetGroupFeatures() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyGroupFeaturesCaseBuilder()
+ .setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder()
+ .setActionsBitmap(Collections.singletonList(new ActionType(true,
+ false, false, false, false, false, false, false, false, false, false,
+ false, false, false, false, false, false)))
+ .setCapabilities(new GroupCapabilities(true, false, false, false))
+ .setTypes(new GroupTypes(true, false, false, false))
+ .setMaxGroups(Collections.singletonList(5L))
+ .build())
+ .build())
+ .build()
+ )).build();
+
final Future<RpcResult<GetGroupFeaturesOutput>> resultFuture
= groupStatisticsService.getGroupFeatures(input.build());
@Test
public void testGetGroupStatistics() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setGroupId(new GroupId(21L));
+ rpcResult = buildGroupStatsResponse();
+
final Future<RpcResult<GetGroupStatisticsOutput>> resultFuture
= groupStatisticsService.getGroupStatistics(input.build());
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
}
+
+ private static RpcResult<Object> buildGroupStatsResponse() {
+ return RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyGroupCaseBuilder()
+ .setMultipartReplyGroup(new MultipartReplyGroupBuilder()
+ .setGroupStats(Collections.singletonList(new GroupStatsBuilder()
+ .setByteCount(BigInteger.valueOf(21L))
+ .setPacketCount(BigInteger.valueOf(22L))
+ .setRefCount(23L)
+ .setDurationSec(24L)
+ .setDurationNsec(25L)
+ .setGroupId(GROUP_ID)
+ .setBucketStats(Collections.singletonList(new BucketStatsBuilder()
+ .setByteCount(BigInteger.valueOf(26L))
+ .setPacketCount(BigInteger.valueOf(27L))
+ .build()))
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+ }
}
\ No newline at end of file
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.meter.stats.MeterBandStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
* Test for {@link OpendaylightMeterStatisticsServiceImpl}
*/
-public class OpendaylightMeterStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightMeterStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId METER_ID = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(123L);
@Captor
private ArgumentCaptor<MultipartRequestInput> requestInput;
- private RequestContext<Object> rqContext;
-
private OpendaylightMeterStatisticsServiceImpl meterStatisticsService;
public void setUp() {
- meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext);
-
- rqContext = new AbstractRequestContext<Object>(42L) {
- @Override
- public void close() {
- //NOOP
- }
- };
- Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
- }
+ meterStatisticsService = new OpendaylightMeterStatisticsServiceImpl(rqContextStack, deviceContext,
+ new AtomicLong(), notificationPublishService);
- @Test
- public void testGetAllMeterConfigStatistics() throws Exception {
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
.commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+ }
+ @Test
+ public void testGetAllMeterConfigStatistics() throws Exception {
GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder()
+ .setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder()
+ .setMeterConfig(Collections.singletonList(new MeterConfigBuilder()
+ .setFlags(new MeterFlags(true, false, false, false))
+ .setMeterId(METER_ID)
+ .setBands(Collections.singletonList(new BandsBuilder()
+ .setMeterBand(new MeterBandDropCaseBuilder()
+ .setMeterBandDrop(new MeterBandDropBuilder()
+ .setBurstSize(61L)
+ .setRate(62L)
+ .setType(MeterBandType.OFPMBTDROP)
+ .build())
+ .build())
+ .build()))
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+
final Future<RpcResult<GetAllMeterConfigStatisticsOutput>> resultFuture
= meterStatisticsService.getAllMeterConfigStatistics(input.build());
@Test
public void testGetAllMeterStatistics() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = buildMeterStatisticsReply();
+
final Future<RpcResult<GetAllMeterStatisticsOutput>> resultFuture
= meterStatisticsService.getAllMeterStatistics(input.build());
@Test
public void testGetMeterFeatures() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyMeterFeaturesCaseBuilder()
+ .setMultipartReplyMeterFeatures(new MultipartReplyMeterFeaturesBuilder()
+ .setBandTypes(new MeterBandTypeBitmap(true, false))
+ .setCapabilities(new MeterFlags(true, false, false, false))
+ .setMaxBands((short) 71)
+ .setMaxColor((short) 72)
+ .setMaxMeter(73L)
+ .build())
+ .build())
+ .build()
+ )).build();
+
final Future<RpcResult<GetMeterFeaturesOutput>> resultFuture
= meterStatisticsService.getMeterFeatures(input.build());
@Test
public void testGetMeterStatistics() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setMeterId(new MeterId(21L));
+ rpcResult = buildMeterStatisticsReply();
+
final Future<RpcResult<GetMeterStatisticsOutput>> resultFuture
= meterStatisticsService.getMeterStatistics(input.build());
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPMETER, requestInput.getValue().getType());
}
+
+ protected RpcResult<Object> buildMeterStatisticsReply() {
+ return RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyMeterCaseBuilder()
+ .setMultipartReplyMeter(new MultipartReplyMeterBuilder()
+ .setMeterStats(Collections.singletonList(new MeterStatsBuilder()
+ .setMeterId(METER_ID)
+ .setByteInCount(BigInteger.valueOf(81L))
+ .setDurationSec(82L)
+ .setDurationNsec(83L)
+ .setFlowCount(84L)
+ .setPacketInCount(BigInteger.valueOf(85L))
+ .setMeterBandStats(Collections.singletonList(new MeterBandStatsBuilder()
+ .setByteBandCount(BigInteger.valueOf(86L))
+ .setPacketBandCount(BigInteger.valueOf(87L))
+ .build()))
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+ }
}
\ No newline at end of file
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutput;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
* Test for {@link OpendaylightPortStatisticsServiceImpl}
*/
-public class OpendaylightPortStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightPortStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
@Captor
private ArgumentCaptor<MultipartRequestInput> requestInput;
- private RequestContext<Object> rqContext;
-
private OpendaylightPortStatisticsServiceImpl portStatisticsService;
public void setUp() {
- portStatisticsService = new OpendaylightPortStatisticsServiceImpl(rqContextStack, deviceContext);
-
- rqContext = new AbstractRequestContext<Object>(42L) {
- @Override
- public void close() {
- //NOOP
- }
- };
- Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
- }
+ portStatisticsService = new OpendaylightPortStatisticsServiceImpl(rqContextStack, deviceContext,
+ new AtomicLong(), notificationPublishService);
- @Test
- public void testGetAllNodeConnectorsStatistics() throws Exception {
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
.commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
+ }
+ @Test
+ public void testGetAllNodeConnectorsStatistics() throws Exception {
GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = buildPortStatisticsReply();
+
final Future<RpcResult<GetAllNodeConnectorsStatisticsOutput>> resultFuture
= portStatisticsService.getAllNodeConnectorsStatistics(input.build());
Assert.assertEquals(MultipartType.OFPMPPORTSTATS, requestInput.getValue().getType());
}
+ private static RpcResult<Object> buildPortStatisticsReply() {
+ return RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyPortStatsCaseBuilder()
+ .setMultipartReplyPortStats(new MultipartReplyPortStatsBuilder()
+ .setPortStats(Collections.singletonList(new PortStatsBuilder()
+ .setDurationSec(90L)
+ .setDurationNsec(91L)
+ .setCollisions(BigInteger.valueOf(92L))
+ .setPortNo(93L)
+ .setRxBytes(BigInteger.valueOf(94L))
+ .setRxCrcErr(BigInteger.valueOf(95L))
+ .setRxDropped(BigInteger.valueOf(96L))
+ .setRxFrameErr(BigInteger.valueOf(97L))
+ .setRxErrors(BigInteger.valueOf(98L))
+ .setRxOverErr(BigInteger.valueOf(99L))
+ .setRxPackets(BigInteger.valueOf(100L))
+ .setTxBytes(BigInteger.valueOf(94L))
+ .setTxDropped(BigInteger.valueOf(96L))
+ .setTxErrors(BigInteger.valueOf(98L))
+ .setTxPackets(BigInteger.valueOf(98L))
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+ }
+
@Test
public void testGetNodeConnectorStatistics() throws Exception {
- Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
- .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
-
GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder()
.setNode(createNodeRef("unitProt:123"))
.setNodeConnectorId(new NodeConnectorId("unitProt:123:321"));
+ rpcResult = buildPortStatisticsReply();
+
final Future<RpcResult<GetNodeConnectorStatisticsOutput>> resultFuture
= portStatisticsService.getNodeConnectorStatistics(input.build());
package org.opendaylight.openflowplugin.impl.statistics.services;
import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
-import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput;
+import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
/**
* Test for {@link OpendaylightQueueStatisticsServiceImpl}
*/
-public class OpendaylightQueueStatisticsServiceImplTest extends AbstractStatsServiceTest {
+public class OpendaylightQueueStatisticsServiceImplTest extends AbstractSingleStatsServiceTest {
@Captor
private ArgumentCaptor<MultipartRequestInput> requestInput;
- private RequestContext<Object> rqContext;
-
private OpendaylightQueueStatisticsServiceImpl queueStatisticsService;
public void setUp() {
- queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(rqContextStack, deviceContext);
-
- rqContext = new AbstractRequestContext<Object>(42L) {
- @Override
- public void close() {
- //NOOP
- }
- };
- Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+ queueStatisticsService = new OpendaylightQueueStatisticsServiceImpl(rqContextStack, deviceContext,
+ new AtomicLong(), notificationPublishService);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
}
@Test
GetAllQueuesStatisticsFromAllPortsInputBuilder input = new GetAllQueuesStatisticsFromAllPortsInputBuilder()
.setNode(createNodeRef("unitProt:123"));
+ rpcResult = buildQueueStatsReply();
+
final Future<RpcResult<GetAllQueuesStatisticsFromAllPortsOutput>> resultFuture
= queueStatisticsService.getAllQueuesStatisticsFromAllPorts(input.build());
Assert.assertEquals(MultipartType.OFPMPQUEUE, requestInput.getValue().getType());
}
+ protected RpcResult<Object> buildQueueStatsReply() {
+ return RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyQueueCaseBuilder()
+ .setMultipartReplyQueue(new MultipartReplyQueueBuilder()
+ .setQueueStats(Collections.singletonList(new QueueStatsBuilder()
+ .setDurationSec(41L)
+ .setDurationNsec(42L)
+ .setTxBytes(BigInteger.valueOf(43L))
+ .setTxErrors(BigInteger.valueOf(44L))
+ .setTxPackets(BigInteger.valueOf(45L))
+ .setPortNo(46L)
+ .setQueueId(47L)
+ .build()))
+ .build())
+ .build())
+ .build()
+ )).build();
+ }
+
@Test
public void testGetAllQueuesStatisticsFromGivenPort() throws Exception {
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
.setNode(createNodeRef("unitProt:123"))
.setNodeConnectorId(new NodeConnectorId("unitProt:123:321"));
+ rpcResult = buildQueueStatsReply();
+
final Future<RpcResult<GetAllQueuesStatisticsFromGivenPortOutput>> resultFuture
= queueStatisticsService.getAllQueuesStatisticsFromGivenPort(input.build());
.setNodeConnectorId(new NodeConnectorId("unitProt:123:321"))
.setQueueId(new QueueId(21L));
+ rpcResult = buildQueueStatsReply();
+
final Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> resultFuture
= queueStatisticsService.getQueueStatisticsFromGivenPort(input.build());
package org.opendaylight.openflowplugin.impl.statistics.services;
+import java.util.concurrent.atomic.AtomicLong;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
private PortStatsService portStatsService;
public void setUp() {
- portStatsService = new PortStatsService(rqContextStack, deviceContext);
+ portStatsService = new PortStatsService(rqContextStack, deviceContext,
+ new AtomicLong());
}
@Test
--- /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.impl.statistics.services.compatibility;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest;
+import org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+/**
+ * Test for {@link AbstractCompatibleStatService}.
+ */
+public class AbstractCompatibleStatServiceTest extends AbstractStatsServiceTest {
+
+ private static final NodeId NODE_ID = new NodeId("unit-test-node:123");
+ @Captor
+ private ArgumentCaptor<MultipartRequestInput> requestInput;
+ @Mock
+ private NotificationPublishService notificationPublishService;
+ @Mock
+ private DeviceState deviceState;
+ @Mock
+ private MessageTranslator<Object, Object> translator;
+
+ private AbstractRequestContext<Object> rqContext;
+
+ private RpcResult<Object> rpcResult;
+
+ private AbstractCompatibleStatService<GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput,
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput, AggregateFlowStatisticsUpdate> service;
+
+ @Override
+ public void setUp() {
+ rqContext = new AbstractRequestContext<Object>(42L) {
+ @Override
+ public void close() {
+ //NOOP
+ }
+ };
+ final Answer closeRequestFutureAnswer = new Answer() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ rqContext.setResult(rpcResult);
+ rqContext.close();
+ return null;
+ }
+ };
+
+ Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
+ Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
+ Mockito.when(deviceState.getNodeId()).thenReturn(NODE_ID);
+ Mockito.when(deviceState.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
+ Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting();
+ Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
+
+ Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
+ .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+
+ Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
+
+ service = new AggregateFlowsInTableService(rqContextStack, deviceContext, new AtomicLong(20L));
+ }
+
+ @Test
+ public void testGetOfVersion() throws Exception {
+ Assert.assertEquals(OFConstants.OFP_VERSION_1_3, service.getOfVersion().getVersion());
+ }
+
+ @Test
+ public void testHandleAndNotify() throws Exception {
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input =
+ new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId(new TableId((short) 1))
+ .build();
+
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(
+ new MultipartReplyMessageBuilder()
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder()
+ .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder()
+ .setByteCount(BigInteger.valueOf(11L))
+ .setFlowCount(12L)
+ .setPacketCount(BigInteger.valueOf(13L))
+ .build())
+ .build())
+ .build()
+ )).build();
+
+ AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder()
+ .setByteCount(new Counter64(BigInteger.valueOf(11L)))
+ .setFlowCount(new Counter32(12L))
+ .setPacketCount(new Counter64(BigInteger.valueOf(13L)))
+ .build();
+ Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceContext), Matchers.any()))
+ .thenReturn(aggregatedStats);
+
+
+ ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture =
+ service.handleAndNotify(input, notificationPublishService);
+
+ Assert.assertTrue(resultFuture.isDone());
+ final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResult = resultFuture.get();
+ Assert.assertTrue(rpcResult.isSuccessful());
+ Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+ Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class));
+ }
+
+}
\ No newline at end of file
--- /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.impl.statistics.services.compatibility;
+
+import com.google.common.util.concurrent.FutureCallback;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator;
+import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
+import org.opendaylight.openflowplugin.impl.statistics.services.AbstractSingleStatsServiceTest;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter32;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.Counter64;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
+import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+
+/**
+ * Test for {@link OpendaylightFlowStatisticsServiceDelegateImpl}.
+ * Skipping notification verification. This will be tested in tests of underlying single task oriented services.
+ */
+public class OpendaylightFlowStatisticsServiceDelegateImplTest extends AbstractSingleStatsServiceTest {
+
+ public static final int NOTIFICATION_WAIT_TIMEOUT_MS = 500;
+ @Captor
+ private ArgumentCaptor<MultipartRequestInput> requestInput;
+
+ private OpendaylightFlowStatisticsServiceDelegateImpl flowStatisticsServiceDelegate;
+ @Mock
+ private MessageTranslator<Object, Object> translator;
+
+ @Override
+ public void setUp() {
+ flowStatisticsServiceDelegate = new OpendaylightFlowStatisticsServiceDelegateImpl(
+ rqContextStack, deviceContext, notificationPublishService, new AtomicLong(21));
+
+ Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider)
+ .commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
+ Mockito.when(translatorLibrary.lookupTranslator(Matchers.<TranslatorKey>any())).thenReturn(translator);
+ }
+
+ @Test(expected = IllegalAccessError.class)
+ public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws Exception {
+ flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForGivenMatch(null);
+ }
+
+ @Test
+ public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws Exception {
+ GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId(new TableId((short) 1));
+
+ Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceContext), Matchers.any()))
+ .thenReturn(new AggregatedFlowStatisticsBuilder()
+ .setByteCount(new Counter64(BigInteger.valueOf(50L)))
+ .setPacketCount(new Counter64(BigInteger.valueOf(51L)))
+ .setFlowCount(new Counter32(52L))
+ .build());
+
+ rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder()
+ .setType(MultipartType.OFPMPAGGREGATE)
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setFlags(new MultipartRequestFlags(false))
+ .setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder()
+ .setMultipartReplyAggregate(new MultipartReplyAggregateBuilder()
+ .setByteCount(BigInteger.valueOf(50L))
+ .setPacketCount(BigInteger.valueOf(51L))
+ .setFlowCount(52L)
+ .build())
+ .build())
+ .build()))
+ .build();
+
+ final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture
+ = flowStatisticsServiceDelegate.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build());
+
+ Assert.assertTrue(resultFuture.isDone());
+ final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> rpcResultCompatible = resultFuture.get();
+ Assert.assertTrue(rpcResultCompatible.isSuccessful());
+ Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
+
+ Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+ }
+
+ @Test
+ public void testGetAllFlowStatisticsFromFlowTable() throws Exception {
+ GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId(new TableId((short) 1));
+
+ rpcResult = buildFlowStatsReply();
+
+ final Future<RpcResult<GetAllFlowStatisticsFromFlowTableOutput>> resultFuture
+ = flowStatisticsServiceDelegate.getAllFlowStatisticsFromFlowTable(input.build());
+
+ Assert.assertTrue(resultFuture.isDone());
+ final RpcResult<GetAllFlowStatisticsFromFlowTableOutput> rpcResultCompatible = resultFuture.get();
+ Assert.assertTrue(rpcResultCompatible.isSuccessful());
+ Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+ Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+ }
+
+ private static RpcResult<Object> buildFlowStatsReply() {
+ return RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder()
+ .setType(MultipartType.OFPMPFLOW)
+ .setVersion(OFConstants.OFP_VERSION_1_3)
+ .setFlags(new MultipartRequestFlags(false))
+ .setMultipartReplyBody(new MultipartReplyFlowCaseBuilder()
+ .setMultipartReplyFlow(new MultipartReplyFlowBuilder()
+ .setFlowStats(Collections.singletonList(new FlowStatsBuilder()
+ .setTableId((short) 123)
+ .setDurationSec(10L)
+ .setDurationNsec(11L)
+ .setByteCount(BigInteger.valueOf(12L))
+ .setPacketCount(BigInteger.valueOf(13L))
+ .setCookie(BigInteger.ZERO)
+ .setPriority(14)
+ .setMatch(new MatchBuilder()
+ .setMatchEntry(Collections.<MatchEntry>emptyList())
+ .build())
+ .setHardTimeout(15)
+ .setIdleTimeout(16)
+ .setFlags(new FlowModFlags(true, false, false, false, false))
+ .setInstruction(Collections.singletonList(new InstructionBuilder()
+ .setInstructionChoice(new ApplyActionsCaseBuilder()
+ .setApplyActions(new ApplyActionsBuilder()
+ .setAction(Collections.singletonList(new ActionBuilder()
+ .setActionChoice(new OutputActionCaseBuilder()
+ .setOutputAction(new OutputActionBuilder()
+ .setMaxLength(17)
+ .setPort(new PortNumber(18L))
+ .build())
+ .build())
+ .build()))
+ .build())
+ .build())
+ .build()))
+ .build()))
+ .build())
+ .build())
+ .build()))
+ .build();
+ }
+
+ @Test
+ public void testGetAllFlowsStatisticsFromAllFlowTables() throws Exception {
+ GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input = new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder()
+ .setNode(createNodeRef("unitProt:123"));
+
+ rpcResult = buildFlowStatsReply();
+
+ final Future<RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput>> resultFuture
+ = flowStatisticsServiceDelegate.getAllFlowsStatisticsFromAllFlowTables(input.build());
+
+ Assert.assertTrue(resultFuture.isDone());
+ final RpcResult<GetAllFlowsStatisticsFromAllFlowTablesOutput> rpcResultCompatible = resultFuture.get();
+ Assert.assertTrue(rpcResultCompatible.isSuccessful());
+ Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+ Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+ }
+
+ @Test
+ public void testGetFlowStatisticsFromFlowTable() throws Exception {
+ GetFlowStatisticsFromFlowTableInputBuilder input = new GetFlowStatisticsFromFlowTableInputBuilder()
+ .setNode(createNodeRef("unitProt:123"))
+ .setTableId((short) 1)
+ .setPriority(123)
+ .setOutPort(BigInteger.ONE);
+
+ rpcResult = buildFlowStatsReply();
+
+ final Future<RpcResult<GetFlowStatisticsFromFlowTableOutput>> resultFuture
+ = flowStatisticsServiceDelegate.getFlowStatisticsFromFlowTable(input.build());
+
+ Assert.assertTrue(resultFuture.isDone());
+ final RpcResult<GetFlowStatisticsFromFlowTableOutput> rpcResultCompatible = resultFuture.get();
+ Assert.assertTrue(rpcResultCompatible.isSuccessful());
+ Assert.assertEquals(MultipartType.OFPMPFLOW, requestInput.getValue().getType());
+
+ Mockito.verify(notificationPublishService, Mockito.timeout(NOTIFICATION_WAIT_TIMEOUT_MS)).offerNotification(Matchers.any(Notification.class));
+ }
+}
\ No newline at end of file