@Test public void testFlowEntry() { OFFlowStatsEntry ofEntry = buildFlowStatsEntry(); FlowEntry entry = OfFlowStatsMapper.INSTANCE.toFlowEntry(ofEntry); assertEquals(tableId, entry.getTableId()); assertEquals(cookie, entry.getCookie()); assertEquals(packetCount, entry.getPacketCount()); assertEquals(byteCount, entry.getByteCount()); assertEquals(durationSec, entry.getDurationSeconds()); assertEquals(durationNsec, entry.getDurationNanoSeconds()); assertEquals(hardTimeout, entry.getHardTimeout()); assertEquals(idleTimeout, entry.getIdleTimeout()); assertEquals(priority, entry.getPriority()); assertEquals(String.valueOf(vlanVid.getVlan()), entry.getMatch().getVlanVid()); assertEquals(ethType.toString(), entry.getMatch().getEthType()); assertEquals(ethDst.toString(), entry.getMatch().getEthDst()); assertEquals(port.toString(), entry.getMatch().getInPort()); assertEquals(ipProto.toString(), entry.getMatch().getIpProto()); assertEquals(udpSrc.toString(), entry.getMatch().getUdpSrc()); assertEquals(udpDst.toString(), entry.getMatch().getUdpDst()); FlowSetFieldAction flowSetEthSrcAction = new FlowSetFieldAction("eth_src", MAC_ADDRESS_1); FlowSetFieldAction flowSetEthDstAction = new FlowSetFieldAction("eth_dst", MAC_ADDRESS_2); FlowCopyFieldAction flowCopyFieldAction = FlowCopyFieldAction.builder() .bits(String.valueOf(bits)) .srcOffset(String.valueOf(srcOffset)) .dstOffset(String.valueOf(dstOffset)) .srcOxm(String.valueOf(oxmSrcHeader)) .dstOxm(String.valueOf(oxmDstHeader)) .build(); FlowSwapFieldAction flowSwapFieldAction = FlowSwapFieldAction.builder() .bits(String.valueOf(bits)) .srcOffset(String.valueOf(srcOffset)) .dstOffset(String.valueOf(dstOffset)) .srcOxm(String.valueOf(oxmSrcHeader)) .dstOxm(String.valueOf(oxmDstHeader)) .build(); FlowApplyActions applyActions = new FlowApplyActions(port.toString(), Lists.newArrayList(flowSetEthSrcAction, flowSetEthDstAction), ethType.toString(), null, null, null, group.toString(), flowCopyFieldAction, flowSwapFieldAction); FlowInstructions instructions = new FlowInstructions(applyActions, null, meterId, goToTable.getValue()); assertEquals(instructions, entry.getInstructions()); }
public FlowEntry toFlowEntry(final OFFlowStatsEntry entry) { return FlowEntry.builder() .version(entry.getVersion().toString()) .durationSeconds(entry.getDurationSec()) .durationNanoSeconds(entry.getDurationNsec()) .hardTimeout(entry.getHardTimeout()) .idleTimeout(entry.getIdleTimeout()) .priority(entry.getPriority()) .byteCount(entry.getByteCount().getValue()) .packetCount(entry.getPacketCount().getValue()) .flags(entry.getFlags().stream() .map(OFFlowModFlags::name) .toArray(String[]::new)) .cookie(entry.getCookie().getValue()) .tableId(entry.getTableId().getValue()) .match(toFlowMatchField(entry.getMatch())) .instructions(toFlowInstructions(entry.getInstructions())) .build(); }
OfFlowStatsMapper { public FlowEntry toFlowEntry(final OFFlowStatsEntry entry) { return FlowEntry.builder() .version(entry.getVersion().toString()) .durationSeconds(entry.getDurationSec()) .durationNanoSeconds(entry.getDurationNsec()) .hardTimeout(entry.getHardTimeout()) .idleTimeout(entry.getIdleTimeout()) .priority(entry.getPriority()) .byteCount(entry.getByteCount().getValue()) .packetCount(entry.getPacketCount().getValue()) .flags(entry.getFlags().stream() .map(OFFlowModFlags::name) .toArray(String[]::new)) .cookie(entry.getCookie().getValue()) .tableId(entry.getTableId().getValue()) .match(toFlowMatchField(entry.getMatch())) .instructions(toFlowInstructions(entry.getInstructions())) .build(); } }
OfFlowStatsMapper { public FlowEntry toFlowEntry(final OFFlowStatsEntry entry) { return FlowEntry.builder() .version(entry.getVersion().toString()) .durationSeconds(entry.getDurationSec()) .durationNanoSeconds(entry.getDurationNsec()) .hardTimeout(entry.getHardTimeout()) .idleTimeout(entry.getIdleTimeout()) .priority(entry.getPriority()) .byteCount(entry.getByteCount().getValue()) .packetCount(entry.getPacketCount().getValue()) .flags(entry.getFlags().stream() .map(OFFlowModFlags::name) .toArray(String[]::new)) .cookie(entry.getCookie().getValue()) .tableId(entry.getTableId().getValue()) .match(toFlowMatchField(entry.getMatch())) .instructions(toFlowInstructions(entry.getInstructions())) .build(); }  }
OfFlowStatsMapper { public FlowEntry toFlowEntry(final OFFlowStatsEntry entry) { return FlowEntry.builder() .version(entry.getVersion().toString()) .durationSeconds(entry.getDurationSec()) .durationNanoSeconds(entry.getDurationNsec()) .hardTimeout(entry.getHardTimeout()) .idleTimeout(entry.getIdleTimeout()) .priority(entry.getPriority()) .byteCount(entry.getByteCount().getValue()) .packetCount(entry.getPacketCount().getValue()) .flags(entry.getFlags().stream() .map(OFFlowModFlags::name) .toArray(String[]::new)) .cookie(entry.getCookie().getValue()) .tableId(entry.getTableId().getValue()) .match(toFlowMatchField(entry.getMatch())) .instructions(toFlowInstructions(entry.getInstructions())) .build(); }  FlowEntry toFlowEntry(final OFFlowStatsEntry entry); FlowEntry toFlowEntry(final OFFlowMod entry); FlowMatchField toFlowMatchField(final Match match); FlowInstructions toFlowInstructions(final List<OFInstruction> instructions); GroupEntry toFlowGroupEntry(OFGroupDescStatsEntry ofGroupDescStatsEntry); GroupBucket toGroupBucket(OFBucket ofBucket); FlowApplyActions toFlowApplyActions(List<OFAction> ofApplyActions); FlowStatsData toFlowStatsData(List<OFFlowStatsReply> data, SwitchId switchId); FlowStatsEntry toFlowStatsEntry(OFFlowStatsEntry entry); }
OfFlowStatsMapper { public FlowEntry toFlowEntry(final OFFlowStatsEntry entry) { return FlowEntry.builder() .version(entry.getVersion().toString()) .durationSeconds(entry.getDurationSec()) .durationNanoSeconds(entry.getDurationNsec()) .hardTimeout(entry.getHardTimeout()) .idleTimeout(entry.getIdleTimeout()) .priority(entry.getPriority()) .byteCount(entry.getByteCount().getValue()) .packetCount(entry.getPacketCount().getValue()) .flags(entry.getFlags().stream() .map(OFFlowModFlags::name) .toArray(String[]::new)) .cookie(entry.getCookie().getValue()) .tableId(entry.getTableId().getValue()) .match(toFlowMatchField(entry.getMatch())) .instructions(toFlowInstructions(entry.getInstructions())) .build(); }  FlowEntry toFlowEntry(final OFFlowStatsEntry entry); FlowEntry toFlowEntry(final OFFlowMod entry); FlowMatchField toFlowMatchField(final Match match); FlowInstructions toFlowInstructions(final List<OFInstruction> instructions); GroupEntry toFlowGroupEntry(OFGroupDescStatsEntry ofGroupDescStatsEntry); GroupBucket toGroupBucket(OFBucket ofBucket); FlowApplyActions toFlowApplyActions(List<OFAction> ofApplyActions); FlowStatsData toFlowStatsData(List<OFFlowStatsReply> data, SwitchId switchId); FlowStatsEntry toFlowStatsEntry(OFFlowStatsEntry entry); static final OfFlowStatsMapper INSTANCE; }