本文整理汇总了Java中org.onosproject.net.flow.DefaultTrafficTreatment.emptyTreatment方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTrafficTreatment.emptyTreatment方法的具体用法?Java DefaultTrafficTreatment.emptyTreatment怎么用?Java DefaultTrafficTreatment.emptyTreatment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.net.flow.DefaultTrafficTreatment
的用法示例。
在下文中一共展示了DefaultTrafficTreatment.emptyTreatment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateIntents
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Intent> intents = Lists.newArrayList();
for (int i = 0; i < count; i++) {
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
intents.add(
PointToPointIntent.builder()
.appId(appId())
.key(Key.of(i + keyOffset, appId()))
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build());
}
return intents;
}
示例2: generateIntents
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4);
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Intent> intents = Lists.newArrayList();
for (int i = 0; i < count; i++) {
TrafficSelector selector = selectorBldr
.matchEthSrc(MacAddress.valueOf(i + keyOffset))
.build();
intents.add(PointToPointIntent.builder()
.appId(appId())
.key(Key.of(i + keyOffset, appId()))
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build());
keysForInstall.add(Key.of(i + keyOffset, appId()));
keysForWithdraw.add(Key.of(i + keyOffset, appId()));
}
return intents;
}
示例3: buildBrcIntent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Builds a Single Point to Multi Point intent.
*
* @param key The intent key
* @param src The source Connect Point
* @param dsts The destination Connect Points
* @return Single Point to Multi Point intent generated.
*/
private SinglePointToMultiPointIntent buildBrcIntent(Key key,
ConnectPoint src,
Set<ConnectPoint> dsts,
VlanId vlanId) {
SinglePointToMultiPointIntent intent;
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.BROADCAST)
.matchVlanId(vlanId)
.build();
intent = SinglePointToMultiPointIntent.builder()
.appId(APPID)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.egressPoints(dsts)
.priority(PRIORITY_OFFSET)
.build();
return intent;
}
示例4: run
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
public void run() {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Constraint> constraint = Lists.newArrayList();
List<Host> hosts = Lists.newArrayList(hostService.getHosts());
while (!hosts.isEmpty()) {
Host src = hosts.remove(0);
for (Host dst : hosts) {
HostToHostIntent intent = HostToHostIntent.builder()
.appId(appId)
.one(src.id())
.two(dst.id())
.selector(selector)
.treatment(treatment)
.constraints(constraint)
.build();
existingIntents.add(intent);
intentService.submit(intent);
}
}
}
示例5: createIntent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
private Intent createIntent(Key key, long mac, NodeId node, Multimap<NodeId, Device> devices) {
// choose a random device for which this node is master
List<Device> deviceList = devices.get(node).stream().collect(Collectors.toList());
Device device = deviceList.get(RandomUtils.nextInt(deviceList.size()));
//FIXME we currently ignore the path length and always use the same device
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.valueOf(mac)).build();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
ConnectPoint ingress = new ConnectPoint(device.id(), PortNumber.portNumber(1));
ConnectPoint egress = new ConnectPoint(device.id(), PortNumber.portNumber(2));
return PointToPointIntent.builder()
.appId(appId)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoint(ingress)
.egressPoint(egress)
.build();
}
示例6: forwardingObjective
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests adding a forwarding objective.
*/
@Test
public void forwardingObjective() {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
ForwardingObjective forward =
DefaultForwardingObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withSelector(selector)
.withTreatment(treatment)
.makePermanent()
.add();
manager.forward(id1, forward);
TestTools.assertAfter(RETRY_MS, () ->
assertThat(forwardingObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasItem("of:d1"));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasSize(0));
}
示例7: filteringObjective
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests adding a filtering objective.
*/
@Test
public void filteringObjective() {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
FilteringObjective filter =
DefaultFilteringObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withMeta(treatment)
.makePermanent()
.deny()
.addCondition(Criteria.matchEthType(12))
.add();
manager.activate();
manager.filter(id1, filter);
TestTools.assertAfter(RETRY_MS, () ->
assertThat(filteringObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasSize(0));
assertThat(filteringObjectives, hasItem("of:d1"));
assertThat(nextObjectives, hasSize(0));
}
示例8: nextObjective
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests adding a next objective.
*/
@Test
public void nextObjective() {
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
NextObjective next =
DefaultNextObjective.builder()
.withId(manager.allocateNextId())
.addTreatment(treatment)
.withType(NextObjective.Type.BROADCAST)
.fromApp(NetTestTools.APP_ID)
.makePermanent()
.add();
manager.next(id1, next);
TestTools.assertAfter(RETRY_MS, () ->
assertThat(nextObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasSize(0));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasItem("of:d1"));
}
示例9: process
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
// TODO: add protection against device ids and non-existent hosts.
Set<HostId> src = getHostIds((ArrayNode) payload.path(SRC));
HostId dst = hostId(string(payload, DST));
Host dstHost = hostService.getHost(dst);
Set<ConnectPoint> ingressPoints = getHostLocations(src);
// FIXME: clearly, this is not enough
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthDst(dstHost.mac()).build();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
MultiPointToSinglePointIntent intent =
MultiPointToSinglePointIntent.builder()
.appId(appId)
.selector(selector)
.treatment(treatment)
.ingressPoints(ingressPoints)
.egressPoint(dstHost.location())
.build();
intentService.submit(intent);
if (overlayCache.isActive(TrafficOverlay.TRAFFIC_ID)) {
traffic.monitor(intent);
}
}
示例10: execute
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
@Override
protected void execute() {
IntentService service = get(IntentService.class);
if (deviceStrings.length < 2) {
return;
}
String ingressDeviceString = deviceStrings[0];
ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Set<ConnectPoint> egressPoints = new HashSet<>();
for (int index = 1; index < deviceStrings.length; index++) {
String egressDeviceString = deviceStrings[index];
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
egressPoints.add(egress);
}
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
List<Constraint> constraints = buildConstraints();
SinglePointToMultiPointIntent intent =
SinglePointToMultiPointIntent.builder()
.appId(appId())
.key(key())
.selector(selector)
.treatment(treatment)
.ingressPoint(ingressPoint)
.egressPoints(egressPoints)
.constraints(constraints)
.priority(priority())
.build();
service.submit(intent);
print("Single point to multipoint intent submitted:\n%s", intent.toString());
}
示例11: buildBrcIntent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Builds a Single Point to Multi Point intent.
*
* @param src The source Connect Point
* @param dsts The destination Connect Points
* @return Single Point to Multi Point intent generated.
*/
private SinglePointToMultiPointIntent buildBrcIntent(Key key,
ConnectPoint src,
Set<ConnectPoint> dsts,
VlanId vlanId) {
log.debug("Building p2mp intent from {}", src);
SinglePointToMultiPointIntent intent;
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
.matchEthDst(MacAddress.BROADCAST)
.matchVlanId(vlanId);
TrafficSelector selector = builder.build();
intent = SinglePointToMultiPointIntent.builder()
.appId(appId)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoint(src)
.egressPoints(dsts)
.priority(PRIORITY_OFFSET)
.build();
return intent;
}
示例12: buildUniIntent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Builds a Multi Point to Single Point intent.
*
* @param srcs The source Connect Points
* @param dst The destination Connect Point
* @return Multi Point to Single Point intent generated.
*/
private MultiPointToSinglePointIntent buildUniIntent(Key key,
Set<ConnectPoint> srcs,
ConnectPoint dst,
VlanId vlanId,
MacAddress mac) {
log.debug("Building mp2p intent to {}", dst);
MultiPointToSinglePointIntent intent;
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
.matchEthDst(mac)
.matchVlanId(vlanId);
TrafficSelector selector = builder.build();
intent = MultiPointToSinglePointIntent.builder()
.appId(appId)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoints(srcs)
.egressPoint(dst)
.priority(PRIORITY_OFFSET)
.build();
return intent;
}
示例13: buildUniIntent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Builds a Multi Point to Single Point intent.
*
* @param key The intent key
* @param srcs The source Connect Points
* @param dst The destination Connect Point
* @return Multi Point to Single Point intent generated.
*/
private MultiPointToSinglePointIntent buildUniIntent(Key key,
Set<ConnectPoint> srcs,
ConnectPoint dst,
VlanId vlanId,
MacAddress mac) {
MultiPointToSinglePointIntent intent;
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
TrafficSelector.Builder builder = DefaultTrafficSelector.builder()
.matchEthDst(mac)
.matchVlanId(vlanId);
TrafficSelector selector = builder.build();
intent = MultiPointToSinglePointIntent.builder()
.appId(APPID)
.key(key)
.selector(selector)
.treatment(treatment)
.ingressPoints(srcs)
.egressPoint(dst)
.priority(PRIORITY_OFFSET)
.build();
return intent;
}
示例14: deviceUpEvent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests receipt of a device up event.
*
* @throws TestUtilsException if lookup of a field fails
*/
@Test
public void deviceUpEvent() throws TestUtilsException {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, d2);
DeviceListener listener = TestUtils.getField(manager, "deviceListener");
assertThat(listener, notNullValue());
listener.event(event);
ForwardingObjective forward =
DefaultForwardingObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withSelector(selector)
.withTreatment(treatment)
.makePermanent()
.add();
manager.forward(id2, forward);
// new device should have an objective now
TestTools.assertAfter(RETRY_MS, () ->
assertThat(forwardingObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasItem("of:d2"));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasSize(0));
}
示例15: deviceMastershipEvent
import org.onosproject.net.flow.DefaultTrafficTreatment; //导入方法依赖的package包/类
/**
* Tests recepit of a device mastership event.
*
* @throws TestUtilsException if lookup of a field fails
*/
@Test
public void deviceMastershipEvent() throws TestUtilsException {
TrafficSelector selector = DefaultTrafficSelector.emptySelector();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
MastershipEvent event =
new MastershipEvent(MastershipEvent.Type.MASTER_CHANGED, id2, null);
MastershipListener listener = TestUtils.getField(manager, "mastershipListener");
assertThat(listener, notNullValue());
listener.event(event);
ForwardingObjective forward =
DefaultForwardingObjective.builder()
.fromApp(NetTestTools.APP_ID)
.withFlag(ForwardingObjective.Flag.SPECIFIC)
.withSelector(selector)
.withTreatment(treatment)
.makePermanent()
.add();
manager.forward(id2, forward);
// new device should have an objective now
TestTools.assertAfter(RETRY_MS, () ->
assertThat(forwardingObjectives, hasSize(1)));
assertThat(forwardingObjectives, hasItem("of:d2"));
assertThat(filteringObjectives, hasSize(0));
assertThat(nextObjectives, hasSize(0));
}