use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertor method convert.
@Override
public List<FlowAndStatisticsMapList> convert(List<FlowStats> source, FlowStatsResponseConvertorData data) {
final List<FlowAndStatisticsMapList> result = new ArrayList<>();
for (FlowStats flowStats : source) {
// Convert Openflow switch specific flow statistics to the MD-SAL format flow statistics
FlowAndStatisticsMapListBuilder salFlowStatsBuilder = new FlowAndStatisticsMapListBuilder();
salFlowStatsBuilder.setByteCount(new Counter64(flowStats.getByteCount()));
if (flowStats.getCookie() != null) {
salFlowStatsBuilder.setCookie(new FlowCookie(flowStats.getCookie()));
}
DurationBuilder time = new DurationBuilder();
time.setSecond(new Counter32(flowStats.getDurationSec()));
time.setNanosecond(new Counter32(flowStats.getDurationNsec()));
salFlowStatsBuilder.setDuration(time.build());
salFlowStatsBuilder.setHardTimeout(flowStats.getHardTimeout());
salFlowStatsBuilder.setIdleTimeout(flowStats.getIdleTimeout());
salFlowStatsBuilder.setPacketCount(new Counter64(flowStats.getPacketCount()));
salFlowStatsBuilder.setPriority(flowStats.getPriority());
salFlowStatsBuilder.setTableId(flowStats.getTableId());
Short ipProtocol = null;
if (flowStats.getMatchV10() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatchV10(), data);
if (matchBuilderOptional.isPresent()) {
if (Objects.nonNull(matchBuilderOptional.get().getIpMatch())) {
ipProtocol = matchBuilderOptional.get().getIpMatch().getIpProtocol();
}
salFlowStatsBuilder.setMatch(matchBuilderOptional.get().build());
}
if (flowStats.getAction() != null && flowStats.getAction().size() != 0) {
salFlowStatsBuilder.setInstructions(wrapOF10ActionsToInstruction(flowStats.getAction(), data.getVersion(), ipProtocol));
}
}
if (flowStats.getMatch() != null) {
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowStats.getMatch(), data);
if (matchBuilderOptional.isPresent()) {
final MatchBuilder matchBuilder = matchBuilderOptional.get();
final AugmentTuple<Match> matchExtensionWrap = MatchExtensionHelper.processAllExtensions(flowStats.getMatch().getMatchEntry(), OpenflowVersion.get(data.getVersion()), data.getMatchPath());
if (matchExtensionWrap != null) {
matchBuilder.addAugmentation(matchExtensionWrap.getAugmentationClass(), matchExtensionWrap.getAugmentationObject());
}
salFlowStatsBuilder.setMatch(matchBuilder.build());
}
salFlowStatsBuilder.setFlags(new FlowModFlags(flowStats.getFlags().isOFPFFCHECKOVERLAP(), flowStats.getFlags().isOFPFFRESETCOUNTS(), flowStats.getFlags().isOFPFFNOPKTCOUNTS(), flowStats.getFlags().isOFPFFNOBYTCOUNTS(), flowStats.getFlags().isOFPFFSENDFLOWREM()));
}
if (flowStats.getInstruction() != null) {
final VersionConvertorData simpleConvertorData = new VersionConvertorData(data.getVersion());
final Optional<Instructions> instructions = getConvertorExecutor().convert(flowStats.getInstruction(), simpleConvertorData);
salFlowStatsBuilder.setInstructions(instructions.orElse(new InstructionsBuilder().setInstruction(Collections.emptyList()).build()));
}
result.add(salFlowStatsBuilder.build());
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SalToOfSetNwDstActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwDstActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final ActionBuilder builder = new ActionBuilder();
final Address address = source.getSetNwDstAction().getAddress();
if (address instanceof Ipv4) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv4DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else if (address instanceof Ipv6) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
ipv6DstBuilder.setIpv6Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else {
throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
}
return Optional.of(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class FlowConvertor method toInstructions.
private List<Instruction> toInstructions(Flow flow, short version, BigInteger datapathid) {
final List<Instruction> instructionsList = new ArrayList<>();
final ActionConvertorData data = new ActionConvertorData(version);
data.setDatapathId(datapathid);
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
Instructions instructions = flow.getInstructions();
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions.getInstruction()) {
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
Optional<Instruction> result = PROCESSOR.process(curInstruction, data, getConvertorExecutor());
if (result.isPresent()) {
instructionsList.add(result.get());
}
}
return instructionsList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.
the class TxchainBaWrite method executeList.
@Override
public void executeList() {
final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
final LogicalDatastoreType dsType = getDataStoreType();
WriteTransaction tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
int writeCnt = 0;
for (OuterList element : this.list) {
InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class).child(OuterList.class, element.getKey());
if (oper == StartTestInput.Operation.PUT) {
tx.put(dsType, iid, element);
} else {
tx.merge(dsType, iid, element);
}
writeCnt++;
if (writeCnt == writesPerTx) {
txSubmitted++;
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
txOk++;
}
@Override
public void onFailure(final Throwable t) {
LOG.error("Transaction failed, {}", t);
txError++;
}
});
tx = chain.newWriteOnlyTransaction();
writeCnt = 0;
}
}
// We need to empty the transaction chain before closing it
try {
txSubmitted++;
tx.submit().checkedGet();
txOk++;
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed", e);
txError++;
}
try {
chain.close();
} catch (final IllegalStateException e) {
LOG.error("Transaction close failed,", e);
}
LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project controller by opendaylight.
the class GlobalBindingRTCServer method globalRpcBench.
@Override
public Future<RpcResult<GlobalRpcBenchOutput>> globalRpcBench(final GlobalRpcBenchInput input) {
GlobalRpcBenchOutput output = new GlobalRpcBenchOutputBuilder(input).build();
RpcResult<GlobalRpcBenchOutput> result = RpcResultBuilder.success(output).build();
numRpcs++;
return Futures.immediateFuture(result);
}
Aggregations