本文整理汇总了Java中org.onosproject.net.flow.instructions.Instruction类的典型用法代码示例。如果您正苦于以下问题:Java Instruction类的具体用法?Java Instruction怎么用?Java Instruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instruction类属于org.onosproject.net.flow.instructions包,在下文中一共展示了Instruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public String format(Object value) {
FlowEntry flow = (FlowEntry) value;
List<Instruction> instructions = flow.treatment().allInstructions();
if (instructions.isEmpty()
&& flow.treatment().metered() == null
&& flow.treatment().tableTransition() == null) {
return "(No traffic treatment instructions for this flow)";
}
StringBuilder sb = new StringBuilder("Treatment Instructions: ");
for (Instruction i : instructions) {
sb.append(i).append(COMMA);
}
if (flow.treatment().metered() != null) {
sb.append(flow.treatment().metered().toString()).append(COMMA);
}
if (flow.treatment().tableTransition() != null) {
sb.append(flow.treatment().tableTransition().toString()).append(COMMA);
}
removeTrailingComma(sb);
return sb.toString();
}
示例2: buildConnectivityDetails
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void buildConnectivityDetails(ConnectivityIntent intent,
StringBuilder sb) {
Set<Criterion> criteria = intent.selector().criteria();
List<Instruction> instructions = intent.treatment().allInstructions();
List<Constraint> constraints = intent.constraints();
if (!criteria.isEmpty()) {
sb.append("Selector: ").append(criteria);
}
if (!instructions.isEmpty()) {
sb.append("Treatment: ").append(instructions);
}
if (constraints != null && !constraints.isEmpty()) {
sb.append("Constraints: ").append(constraints);
}
}
示例3: findVlanOps
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private List<Pair<Instruction, Instruction>> findVlanOps(List<Instruction> instructions,
L2ModificationInstruction.L2SubType type) {
List<Instruction> vlanPushs = findL2Instructions(
type,
instructions);
List<Instruction> vlanSets = findL2Instructions(
L2ModificationInstruction.L2SubType.VLAN_ID,
instructions);
if (vlanPushs.size() != vlanSets.size()) {
return null;
}
List<Pair<Instruction, Instruction>> pairs = Lists.newArrayList();
for (int i = 0; i < vlanPushs.size(); i++) {
pairs.add(new ImmutablePair<>(vlanPushs.get(i), vlanSets.get(i)));
}
return pairs;
}
示例4: sendPacket
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void sendPacket(Ethernet eth) {
List<Instruction> ins = treatmentBuilder().build().allInstructions();
OFPort p = null;
//TODO: support arbitrary list of treatments must be supported in ofPacketContext
for (Instruction i : ins) {
if (i.type() == Type.OUTPUT) {
p = buildPort(((OutputInstruction) i).port());
break; //for now...
}
}
if (eth == null) {
ofPktCtx.build(p);
} else {
ofPktCtx.build(eth, p);
}
ofPktCtx.send();
}
示例5: getInstructionType
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
* converts string of instruction type to Instruction type enum.
*
* @param instType string representing the instruction type
* @return Instruction.Type
*/
private Instruction.Type getInstructionType(String instType) {
String instTypeUC = instType.toUpperCase();
if (instTypeUC.equals("OUTPUT")) {
return Instruction.Type.OUTPUT;
} else if (instTypeUC.equals("GROUP")) {
return Instruction.Type.GROUP;
} else if (instTypeUC.equals("L0MODIFICATION")) {
return Instruction.Type.L0MODIFICATION;
} else if (instTypeUC.equals("L2MODIFICATION")) {
return Instruction.Type.L2MODIFICATION;
} else if (instTypeUC.equals("TABLE")) {
return Instruction.Type.TABLE;
} else if (instTypeUC.equals("L3MODIFICATION")) {
return Instruction.Type.L3MODIFICATION;
} else if (instTypeUC.equals("METADATA")) {
return Instruction.Type.METADATA;
} else {
return null; // instruction type error
}
}
示例6: getFlowRulesFrom
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private Set<FlowEntry> getFlowRulesFrom(ConnectPoint egress) {
ImmutableSet.Builder<FlowEntry> builder = ImmutableSet.builder();
flowRuleService.getFlowEntries(egress.deviceId()).forEach(r -> {
if (r.appId() == appId.id()) {
r.treatment().allInstructions().forEach(i -> {
if (i.type() == Instruction.Type.OUTPUT) {
if (((Instructions.OutputInstruction) i).port().equals(egress.port())) {
builder.add(r);
}
}
});
}
});
return builder.build();
}
示例7: cleanAllFlowRules
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private void cleanAllFlowRules() {
Iterable<Device> deviceList = deviceService.getAvailableDevices();
for (Device d : deviceList) {
DeviceId id = d.id();
log.trace("Searching for flow rules to remove from: " + id);
for (FlowEntry r : flowRuleService.getFlowEntries(id)) {
boolean match = false;
for (Instruction i : r.treatment().allInstructions()) {
if (i.type() == Instruction.Type.OUTPUT) {
OutputInstruction oi = (OutputInstruction) i;
// if the flow has matching src and dst
for (Criterion cr : r.selector().criteria()) {
if (cr.type() == Criterion.Type.ETH_DST || cr.type() == Criterion.Type.ETH_SRC) {
match = true;
}
}
}
}
if (match) {
log.trace("Removed flow rule from device: " + id);
flowRuleService.removeFlowRules((FlowRule) r);
}
}
}
}
示例8: DefaultTrafficTreatment
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
* Creates a new traffic treatment from the specified list of instructions.
*
* @param deferred deferred instructions
* @param immediate immediate instructions
* @param table table transition instruction
* @param clear instruction to clear the deferred actions list
*/
private DefaultTrafficTreatment(List<Instruction> deferred,
List<Instruction> immediate,
Instructions.TableTypeTransition table,
boolean clear,
Instructions.MetadataInstruction meta,
Instructions.MeterInstruction meter) {
this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
this.all = new ImmutableList.Builder<Instruction>()
.addAll(immediate)
.addAll(deferred)
.build();
this.table = table;
this.meta = meta;
this.hasClear = clear;
this.meter = meter;
}
示例9: equals
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof DefaultGroupBucket) {
DefaultGroupBucket that = (DefaultGroupBucket) obj;
List<Instruction> myInstructions = this.treatment.allInstructions();
List<Instruction> theirInstructions = that.treatment.allInstructions();
return Objects.equals(type, that.type) &&
myInstructions.containsAll(theirInstructions) &&
theirInstructions.containsAll(myInstructions);
}
return false;
}
示例10: loadAllByType
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadAllByType(Device device,
TypedStoredFlowEntry.FlowLiveType liveType,
Instruction.Type instType) {
checkPermission(STATISTIC_READ);
Map<ConnectPoint, List<TypedFlowEntryWithLoad>> allLoad = new TreeMap<>(CONNECT_POINT_COMPARATOR);
if (device == null) {
return allLoad;
}
List<Port> ports = new ArrayList<>(deviceService.getPorts(device.id()));
for (Port port : ports) {
ConnectPoint cp = new ConnectPoint(device.id(), port.number());
List<TypedFlowEntryWithLoad> tfel = loadAllPortInternal(cp, liveType, instType);
allLoad.put(cp, tfel);
}
return allLoad;
}
示例11: loadTopnByType
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
@Override
public Map<ConnectPoint, List<TypedFlowEntryWithLoad>> loadTopnByType(Device device,
TypedStoredFlowEntry.FlowLiveType liveType,
Instruction.Type instType,
int topn) {
checkPermission(STATISTIC_READ);
Map<ConnectPoint, List<TypedFlowEntryWithLoad>> allLoad = new TreeMap<>(CONNECT_POINT_COMPARATOR);
if (device == null) {
return allLoad;
}
List<Port> ports = new ArrayList<>(deviceService.getPorts(device.id()));
for (Port port : ports) {
ConnectPoint cp = new ConnectPoint(device.id(), port.number());
List<TypedFlowEntryWithLoad> tfel = loadTopnPortInternal(cp, liveType, instType, topn);
allLoad.put(cp, tfel);
}
return allLoad;
}
示例12: typedFlowEntryLoadByInstInternal
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
private List<TypedFlowEntryWithLoad> typedFlowEntryLoadByInstInternal(ConnectPoint cp,
Map<FlowRule, TypedStoredFlowEntry> currentMap,
Map<FlowRule, TypedStoredFlowEntry> previousMap,
boolean isAllInstType,
Instruction.Type instType,
int liveTypePollInterval) {
List<TypedFlowEntryWithLoad> fel = new ArrayList<>();
for (TypedStoredFlowEntry tfe : currentMap.values()) {
if (isAllInstType ||
tfe.treatment().allInstructions().stream().
filter(i -> i.type() == instType).
findAny().isPresent()) {
long currentBytes = tfe.bytes();
long previousBytes = previousMap.getOrDefault(tfe, new DefaultTypedFlowEntry((FlowRule) tfe)).bytes();
Load fLoad = new DefaultLoad(currentBytes, previousBytes, liveTypePollInterval);
fel.add(new TypedFlowEntryWithLoad(cp, tfe, fLoad));
}
}
return fel;
}
示例13: decodeL1
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
* Decodes a Layer 1 instruction.
*
* @return instruction object decoded from the JSON
* @throws IllegalArgumentException if the JSON is invalid
*/
private Instruction decodeL1() {
String subType = json.get(InstructionCodec.SUBTYPE).asText();
if (subType.equals(L1ModificationInstruction.L1SubType.ODU_SIGID.name())) {
int tributaryPortNumber = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_PORT_NUMBER),
InstructionCodec.TRIBUTARY_PORT_NUMBER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
int tributarySlotLen = nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_LEN),
InstructionCodec.TRIBUTARY_SLOT_LEN + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
byte[] tributarySlotBitmap = null;
tributarySlotBitmap = HexString.fromHexString(
nullIsIllegal(json.get(InstructionCodec.TRIBUTARY_SLOT_BITMAP),
InstructionCodec.TRIBUTARY_SLOT_BITMAP + InstructionCodec.MISSING_MEMBER_MESSAGE).asText());
return Instructions.modL1OduSignalId(OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen,
tributarySlotBitmap));
}
throw new IllegalArgumentException("L1 Instruction subtype "
+ subType + " is not supported");
}
示例14: decodeExtension
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
* Decodes a extension instruction.
*
* @return extension treatment
*/
private Instruction decodeExtension() {
ObjectNode node = (ObjectNode) json.get(InstructionCodec.EXTENSION);
if (node != null) {
DeviceId deviceId = getDeviceId();
ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
DeviceService deviceService = serviceDirectory.get(DeviceService.class);
Device device = deviceService.getDevice(deviceId);
if (device.is(ExtensionTreatmentCodec.class)) {
ExtensionTreatmentCodec treatmentCodec = device.as(ExtensionTreatmentCodec.class);
ExtensionTreatment treatment = treatmentCodec.decode(node, null);
return Instructions.extension(treatment, deviceId);
} else {
log.warn("There is no codec to decode extension for device {}", deviceId.toString());
}
}
return null;
}
示例15: codecSimpleFlowTest
import org.onosproject.net.flow.instructions.Instruction; //导入依赖的package包/类
/**
* Checks that a simple rule decodes properly.
*
* @throws IOException if the resource cannot be processed
*/
@Test
public void codecSimpleFlowTest() throws IOException {
FlowRule rule = getRule("simple-flow.json");
checkCommonData(rule);
assertThat(rule.selector().criteria().size(), is(1));
Criterion criterion1 = rule.selector().criteria().iterator().next();
assertThat(criterion1.type(), is(Criterion.Type.ETH_TYPE));
assertThat(((EthTypeCriterion) criterion1).ethType(), is(new EthType(2054)));
assertThat(rule.treatment().allInstructions().size(), is(1));
Instruction instruction1 = rule.treatment().allInstructions().get(0);
assertThat(instruction1.type(), is(Instruction.Type.OUTPUT));
assertThat(((Instructions.OutputInstruction) instruction1).port(), is(PortNumber.CONTROLLER));
}