本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFGroupAdd类的典型用法代码示例。如果您正苦于以下问题:Java OFGroupAdd类的具体用法?Java OFGroupAdd怎么用?Java OFGroupAdd使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OFGroupAdd类属于org.projectfloodlight.openflow.protocol包,在下文中一共展示了OFGroupAdd类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGroupAdd
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
/**
* Builds the GroupAdd OF message.
*
* @return GroupAdd OF message
*/
public OFGroupAdd buildGroupAdd() {
List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
for (GroupBucket bucket: buckets.buckets()) {
List<OFAction> actions = buildActions(bucket.treatment());
OFBucket.Builder bucketBuilder = factory.buildBucket();
bucketBuilder.setActions(actions);
if (type == GroupDescription.Type.SELECT) {
bucketBuilder.setWeight(1);
}
if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) {
bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong()));
} else {
bucketBuilder.setWatchPort(OFPort.ANY);
}
if (type == GroupDescription.Type.FAILOVER && bucket.watchGroup() != null) {
bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id()));
} else {
bucketBuilder.setWatchGroup(OFGroup.ANY);
}
OFBucket ofBucket = bucketBuilder.build();
ofBuckets.add(ofBucket);
}
OFGroupAdd groupMsg = factory.buildGroupAdd()
.setGroup(OFGroup.of(groupId.id()))
.setBuckets(ofBuckets)
.setGroupType(getOFGroupType(type))
.setXid(xid)
.build();
return groupMsg;
}
示例2: pushOFCreateGroup
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
private void pushOFCreateGroup(IOFSwitch sw) {
/* Creates group flow with set queue option */
OFFactory of13Factory = sw.getOFFactory();
OFGroupAdd addGroup = of13Factory.buildGroupAdd()
.setGroup(OFGroup.of(multicastGroup.ofGroupId))
.setGroupType(OFGroupType.ALL)
.setBuckets(multicastGroup.getMemberOFBucketList(sw.getId()))
.build();
sw.write(addGroup);
}
示例3: buildGroupAdd
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
/**
* Builds the GroupAdd OF message.
*
* @return GroupAdd OF message
*/
public OFGroupAdd buildGroupAdd() {
List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
for (GroupBucket bucket: buckets.buckets()) {
List<OFAction> actions = buildActions(bucket.treatment());
OFBucket.Builder bucketBuilder = factory.buildBucket();
bucketBuilder.setActions(actions);
if (type == GroupDescription.Type.SELECT) {
bucketBuilder.setWeight(1);
}
bucketBuilder.setWatchGroup(OFGroup.ANY);
bucketBuilder.setWatchPort(OFPort.ANY);
OFBucket ofBucket = bucketBuilder.build();
ofBuckets.add(ofBucket);
}
OFGroupAdd groupMsg = factory.buildGroupAdd()
.setGroup(OFGroup.of(groupId.id()))
.setBuckets(ofBuckets)
.setGroupType(getOFGroupType(type))
.setXid(xid)
.build();
return groupMsg;
}
示例4: buildGroupAdd
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
/**
* Builds the GroupAdd OF message.
*
* @return GroupAdd OF message
*/
public OFGroupAdd buildGroupAdd() {
List<OFBucket> ofBuckets = new ArrayList<OFBucket>();
for (GroupBucket bucket: buckets.buckets()) {
List<OFAction> actions = buildActions(bucket.treatment());
OFBucket.Builder bucketBuilder = factory.buildBucket();
bucketBuilder.setActions(actions);
if (type == GroupDescription.Type.SELECT) {
bucketBuilder.setWeight(bucket.weight());
}
if (type == GroupDescription.Type.FAILOVER && bucket.watchPort() != null) {
bucketBuilder.setWatchPort(OFPort.of((int) bucket.watchPort().toLong()));
} else {
bucketBuilder.setWatchPort(OFPort.ANY);
}
if (type == GroupDescription.Type.FAILOVER && bucket.watchGroup() != null) {
bucketBuilder.setWatchGroup(OFGroup.of(bucket.watchGroup().id()));
} else {
bucketBuilder.setWatchGroup(OFGroup.ANY);
}
OFBucket ofBucket = bucketBuilder.build();
ofBuckets.add(ofBucket);
}
OFGroupAdd groupMsg = factory.buildGroupAdd()
.setGroup(OFGroup.of(groupId.id()))
.setBuckets(ofBuckets)
.setGroupType(getOFGroupType(type))
.setXid(xid)
.build();
return groupMsg;
}
示例5: processGroupMod
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
private void processGroupMod(OFGroupMod groupMod) {
log.debug("processing GROUP_MOD {} message", groupMod.getCommand());
ApplicationId appId = ofSwitchService.appId();
GroupKey appCookie = new DefaultGroupKey(networkId.toString().getBytes());
switch (groupMod.getCommand()) {
case ADD:
// TODO return OFGroupModFailedCode.GROUP_EXISTS if group already exists
int groupId = groupMod.getGroup().getGroupNumber();
OFGroupAdd groupAdd = (OFGroupAdd) groupMod;
GroupBuckets groupAddBuckets = new OFAgentVirtualGroupBucketEntryBuilder(
Dpid.dpid(Dpid.uri(dpid().getLong())),
groupAdd.getBuckets(), groupAdd.getGroupType(), driverService)
.build();
GroupDescription groupDescription = new DefaultGroupDescription(
deviceId, getGroupType(groupAdd.getGroupType()), groupAddBuckets,
appCookie, groupId, appId);
groupService.addGroup(groupDescription);
break;
case MODIFY:
// TODO return OFGroupModFailedCode.INVALID_GROUP if group does not exist
OFGroupModify groupModify = (OFGroupModify) groupMod;
GroupBuckets groupModifyBuckets = new OFAgentVirtualGroupBucketEntryBuilder(
Dpid.dpid(Dpid.uri(dpid().getLong())),
groupModify.getBuckets(), groupModify.getGroupType(), driverService)
.build();
groupService.setBucketsForGroup(deviceId, appCookie, groupModifyBuckets,
appCookie, appId);
break;
case DELETE:
groupService.removeGroup(deviceId, appCookie, appId);
break;
default:
// INSERT_BUCKET, REMOVE_BUCKET are effective OF 1.5. OFAgent supports 1.3.
log.warn("Unsupported GROUP_MOD {} message received for switch {}",
groupMod.getCommand(), this);
}
}
示例6: createGroupByRoute
import org.projectfloodlight.openflow.protocol.OFGroupAdd; //导入依赖的package包/类
/**
* ��������·��·����ȡԴĿ��������grouptable���bucket��Ȼ���·�OFGroupAdd��Ϣ����Ӧ������
* @param firstRoute ����··��
* @param secondRoute ����··��
* @param isSrcSide Ϊtrueʱ��Ӧ·��·��Դ��Ͱ����Ϣ�·���������elseΪĿ�Ķ�
* @author ZX Peng
*/
private void createGroupByRoute(Route firstRoute, Route secondRoute, boolean isSrcSide) {
ArrayList<OFBucket> buckets = new ArrayList<OFBucket>(2);
IOFSwitch sw;
List<NodePortTuple> firstNptList = firstRoute.getPath();
List<NodePortTuple> secondNptList = secondRoute.getPath();
int firstIndex = 0, secondIndex = 0;
if(isSrcSide == true) {
firstIndex = 1;
secondIndex = 1;
sw = switchService.getSwitch(firstRoute.getId().getSrc());
} else {
firstIndex = firstNptList.size() - 2;
secondIndex = secondNptList.size() - 2;
sw = switchService.getSwitch(firstRoute.getId().getDst());
}
NodePortTuple firstWatchNpt = firstNptList.get(firstIndex);
NodePortTuple secondWatchNpt = secondNptList.get(secondIndex);
buckets.add(sw.getOFFactory().buildBucket()
.setWatchPort(firstWatchNpt.getPortId())
.setWatchGroup(OFGroup.ZERO)
.setActions(Collections.singletonList((OFAction) sw.getOFFactory().actions().buildOutput()
.setMaxLen(0x0fFFffFF)
.setPort(firstWatchNpt.getPortId())
.build()))
.build());
buckets.add(sw.getOFFactory().buildBucket()
.setWatchPort(secondWatchNpt.getPortId())
.setWatchGroup(OFGroup.ZERO)
.setActions(Collections.singletonList((OFAction) sw.getOFFactory().actions().buildOutput()
.setMaxLen(0x0fFFffFF)
.setPort(secondWatchNpt.getPortId())
.build()))
.build());
//push OFGroupAdd message to the switch
//TODO: group number has to be distinct from each other
OFGroupAdd groupAdd = sw.getOFFactory().buildGroupAdd()
.setGroup(OFGroup.of(GROUP_NUM))
.setGroupType(OFGroupType.FF)
.setBuckets(buckets)
.build();
sw.write(groupAdd);
}