Java 类org.projectfloodlight.openflow.protocol.OFBucket 实例源码

项目:fresco_floodlight    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:iTAP-controller    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:SDN-Multicast    文件:MulticastTree.java   
protected void sendOFGroupModDelMemberMsg(IOFSwitch sw, OFPort destPort) {
    /* removes member port form the group*/
    OFBucket ofb = multicastGroup.removeMemberOFBucket(sw.getId(), destPort);
    /* prepares a modify object sends it to the switch */
    pushOFModifyGroup(sw);

    long queueId = -1;
    for (OFAction ofa:  ofb.getActions()){
        if (ofa.getType() == OFActionType.SET_QUEUE){
            OFActionSetQueue ofas = (OFActionSetQueue) ofa;
            queueId = ofas.getQueueId();
        }
    }
    /* removes queue using OVSDBContext on the switch */
    OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId());
    ovsdbContext.deleteQueueOnPort(destPort, (int)queueId);
}
项目:SDN-Multicast    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:arscheduler    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:floodlight1.2-delay    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:floodlight-hardware    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());
        jGen.writeFieldName("buckets");
        jGen.writeStartArray();
        for(OFBucket buckets : entry.getBuckets()) {
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:ACAMPController    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:fast-failover-demo    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:ravikumaran201504    文件:GroupModBuilder.java   
/**
 * Builds the GroupMod OF message.
 *
 * @return GroupMod OF message
 */
public OFGroupMod buildGroupMod() {
    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);
    }

    OFGroupMod groupMsg = factory.buildGroupModify()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
项目:floodlightLB    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:DSC    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:floodlight    文件:StatsReplySerializer.java   
/***
 * Serializes Group Desc Reply
 * @author Naveen
 * @param groupDescReplies
 * @param jGen
 * @throws IOException
 * @throws JsonProcessingException
 */
public static void serializeGroupDescReply(List<OFGroupDescStatsReply> groupDescReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
    OFGroupDescStatsReply groupDescReply = groupDescReplies.get(0);
    jGen.writeStringField("version", groupDescReply.getVersion().toString()); //return the enum name
    jGen.writeFieldName("groupDesc");
    jGen.writeStartArray();
    for(OFGroupDescStatsEntry entry : groupDescReply.getEntries()) {
        jGen.writeStartObject();                        
        jGen.writeStringField("groupType",entry.getGroupType().toString());
        jGen.writeStringField("groupNumber",entry.getGroup().toString());                                               
        jGen.writeFieldName("buckets");            
        jGen.writeStartArray();            
        for(OFBucket buckets : entry.getBuckets()) {                
            jGen.writeStartObject();
            jGen.writeNumberField("weight", buckets.getWeight());
            jGen.writeNumberField("watchPortNumber", buckets.getWatchPort().getPortNumber());
            jGen.writeStringField("watchGroup", buckets.getWatchGroup().toString());                
            OFActionListSerializer.serializeActions(jGen, buckets.getActions());                
            jGen.writeEndObject();
        }//End of for loop - buckets
        jGen.writeEndArray();//end of buckets            
        jGen.writeEndObject();//end of group Desc iteration
    }//End of for loop - GroupDescStats
    jGen.writeEndArray();//end of group Desc
}
项目:onos    文件:DefaultOFSwitch.java   
private OFGroupDescStatsEntry ofGroupDescStatsEntry(Group group) {
    List<OFBucket> ofBuckets = Lists.newArrayList();
    group.buckets().buckets().forEach(groupBucket -> {
        ofBuckets.add(FACTORY.buildBucket()
                .setWeight(groupBucket.weight())
                .setWatchGroup(OFGroup.of(groupBucket.watchGroup().id()))
                .setWatchPort(OFPort.of((int) groupBucket.watchPort().toLong()))
                .build()
        );
    });
    OFGroup ofGroup = OFGroup.of(group.givenGroupId());
    OFGroupType ofGroupType = OFGroupType.valueOf(group.type().name());
    OFGroupDescStatsEntry entry = FACTORY.buildGroupDescStatsEntry()
            .setGroup(ofGroup)
            .setGroupType(ofGroupType)
            .setBuckets(ofBuckets)
            .build();
    return entry;
}
项目:athena    文件:GroupBucketEntryBuilder.java   
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment);
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new DefaultGroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            case ALL:
                groupBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
项目:athena    文件:GroupModBuilder.java   
/**
 * 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;
}
项目:athena    文件:GroupModBuilder.java   
/**
 * Builds the GroupMod OF message.
 *
 * @return GroupMod OF message
 */
public OFGroupMod buildGroupMod() {
    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);
    }

    OFGroupMod groupMsg = factory.buildGroupModify()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
项目:SDN-Multicast    文件:MulticastTree.java   
protected void pushOFDeleteGroup(IOFSwitch sw) {

    /* Delete the queues attached to all the member ports*/
    long queueId = -1;
    OFPort ofp = null;
    ArrayList<OFBucket> ofBuckets = multicastGroup.getMemberOFBucketList(sw.getId());
    OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId());
    for (OFBucket ofb : ofBuckets) {
        queueId = -1;
        ofp = null;
        for (OFAction ofa:  ofb.getActions()){
            if (ofa.getType() == OFActionType.SET_QUEUE){
                OFActionSetQueue ofas = (OFActionSetQueue) ofa;
                queueId = ofas.getQueueId();
                /* removes queue using OVSDBContext on the switch */

            }
            if (ofa.getType() == OFActionType.OUTPUT){
                OFActionOutput ofo = (OFActionOutput) ofa;
                ofp = ofo.getPort();
                /* removes queue using OVSDBContext on the switch */

            }
        }
        if (ofp != null && queueId != -1)
            ovsdbContext.deleteQueueOnPort(ofp, (int)queueId);
        else
            logger.error("pushOFDeleteGroup: unexpected actionset in group bucket");
    }

    /* Creates group flow with set queue option */
    OFFactory of13Factory = sw.getOFFactory();

    OFGroupDelete delGroup = of13Factory.buildGroupDelete()
            .setGroup(OFGroup.of(multicastGroup.ofGroupId))
            .setGroupType(OFGroupType.ALL)
            .build();
    sw.write(delGroup);
}
项目:SDN-Multicast    文件:MulticastTree.java   
private void addQoSOFBucketToGroup(IOFSwitch sw, OFPort destPort, long bandwidth) {

        /* creates queue using OVSDBContext on the switch */
        OVSDBContext ovsdbContext = mcObject.ovsdbChannelMap.get(sw.getId());

        /* FIXME: hardcoded priority '1' for all flows */
        int queueId = ovsdbContext.createQueueOnPort(destPort, Long.toString(bandwidth), "1");

        OFFactory of13Factory = sw.getOFFactory();

        /* creates actions for the bucket */
        ArrayList<OFAction> actionList = new ArrayList<OFAction>();
        OFActions actions = of13Factory.actions();
        OFActionSetQueue setQueue = actions.buildSetQueue().setQueueId(queueId).build();
        actionList.add(setQueue);
        OFActionOutput output = actions.buildOutput()
                .setMaxLen(0xFFffFFff)
                .setPort(destPort).build();
        actionList.add(output);

        /* creates a bucket */
        OFBucket bucket = of13Factory.buildBucket()
                .setActions(actionList)
                .setWatchGroup(OFGroup.ANY)
                .setWatchPort(OFPort.ANY)
                .build();
        /* store the bucket in multicastGroup object */
        multicastGroup.addMemberOFBucket(sw.getId(), 
                destPort.getShortPortNumber(), bucket);
    }
项目:ravikumaran201504    文件:GroupBucketEntryBuilder.java   
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment);
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new DefaultGroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
项目:ravikumaran201504    文件:GroupModBuilder.java   
/**
 * 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;
}
项目:spring-open    文件:OFSwitchImplSpringOpenTTP.java   
private void processGroupDesc(OFGroupDescStatsReply gdsr) {
    log.info("Sw: {} Group Desc {} in driverState {} ", getStringId(), gdsr,
            driverState);

    if (driverState == DriverState.AUDIT_GROUPS)
    {
        auditBucketToGroupIds = new ConcurrentHashMap<List<BucketInfo>, List<Integer>>();
        for (OFGroupDescStatsEntry entry : gdsr.getEntries()) {
            int groupId = entry.getGroup().getGroupNumber();
            OFGroupType groupType = entry.getGroupType();
            List<OFBucket> buckets = entry.getBuckets();
            List<BucketInfo> driverBuckets = new ArrayList<BucketInfo>();
            for (OFBucket bucket : buckets) {
                driverBuckets.add(getDriverBucketFromOFBucket(bucket));
            }
            Collections.sort(driverBuckets);
            List<Integer> groupIds = auditBucketToGroupIds.get(driverBuckets);
            if (groupIds == null)
                groupIds = new ArrayList<Integer>();
            groupIds.add(groupId);
            auditBucketToGroupIds.put(driverBuckets, groupIds);
            ecmpGroups.put(groupId, new EcmpInfo(groupId, groupType, driverBuckets));
        }
        log.debug("processGroupDesc: Groups that are present in "
                + "switch {} are {} ", getStringId(), ecmpGroups);
    }
    else {
        // TODO -- actually do verification
    }
    try {
        nextDriverState();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:onos    文件:GroupBucketEntryBuilder.java   
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            case ALL:
                groupBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
项目:onos    文件:GroupModBuilder.java   
/**
 * 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;
}
项目:onos    文件:GroupModBuilder.java   
/**
 * Builds the GroupMod OF message.
 *
 * @return GroupMod OF message
 */
public OFGroupMod buildGroupMod() {
    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);
    }

    OFGroupMod groupMsg = factory.buildGroupModify()
            .setGroup(OFGroup.of(groupId.id()))
            .setBuckets(ofBuckets)
            .setGroupType(getOFGroupType(type))
            .setXid(xid)
            .build();

    return groupMsg;
}
项目:onos    文件:OFAgentVirtualGroupBucketEntryBuilder.java   
/**
 * Builds a GroupBuckets.
 *
 * @return GroupBuckets object, a list of GroupBuckets
 */
public GroupBuckets build() {
    List<GroupBucket> bucketList = Lists.newArrayList();

    for (OFBucket bucket: ofBuckets) {
        TrafficTreatment treatment = buildTreatment(bucket.getActions());
        // TODO: Use GroupBucketEntry
        GroupBucket groupBucket = null;
        switch (type) {
            case INDIRECT:
                groupBucket =
                        DefaultGroupBucket.createIndirectGroupBucket(treatment);
                break;
            case SELECT:
                groupBucket =
                        DefaultGroupBucket.createSelectGroupBucket(treatment, (short) bucket.getWeight());
                break;
            case FF:
                PortNumber port =
                        PortNumber.portNumber(bucket.getWatchPort().getPortNumber());
                GroupId groupId =
                        new GroupId(bucket.getWatchGroup().getGroupNumber());
                groupBucket =
                        DefaultGroupBucket.createFailoverGroupBucket(treatment,
                                port, groupId);
                break;
            case ALL:
                groupBucket =
                        DefaultGroupBucket.createAllGroupBucket(treatment);
                break;
            default:
                log.error("Unsupported Group type : {}", type);
        }
        if (groupBucket != null) {
            bucketList.add(groupBucket);
        }
    }
    return new GroupBuckets(bucketList);
}
项目:SDN-Multicast    文件:MulticastGroup.java   
public void addMemberOFBucket(DatapathId did, Short portNum, OFBucket ofBucket) {
    ArrayList<OFBucket> ofBucketList = ofBucketListMap.get(did);
    HashMap<Short, OFBucket> ofBucketMap = ofBucketMapMap.get(did);
    ofBucketList.add(ofBucket);
    ofBucketMap.put(portNum, ofBucket);
}
项目:SDN-Multicast    文件:MulticastGroup.java   
public OFBucket removeMemberOFBucket(DatapathId did, OFPort ofPort) {
    HashMap<Short, OFBucket> ofBucketMap = ofBucketMapMap.get(did);
    OFBucket ofb = ofBucketMap.get(ofPort.getShortPortNumber());
    ofBucketListMap.get(did).remove(ofb);
    return ofb;
}
项目:SDN-Multicast    文件:MulticastGroup.java   
public ArrayList<OFBucket> getMemberOFBucketList(DatapathId did) {
    return ofBucketListMap.get(did);
}
项目:SDN-Multicast    文件:MulticastGroup.java   
public void createMemberOFBucketList(DatapathId did) {
    ofBucketListMap.put(did, new ArrayList<OFBucket>());
    ofBucketMapMap.put(did, new HashMap<Short, OFBucket>());
}
项目:floodlight    文件:ProtectionForwarding.java   
/**
 * ��������·��·����ȡԴĿ��������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);
}
项目:spring-open    文件:OFSwitchImplSpringOpenTTP.java   
private BucketInfo getDriverBucketFromOFBucket(OFBucket bucket) {
    List<OFAction> actions = bucket.getActions();
    int bucketPort = -1;
    int bucketLabel = -1;
    int bucketToGroup = -1;
    MacAddress dlSrc = null;
    MacAddress dlDst = null;
    for (OFAction action : actions) {
        if (action.getType().compareTo(OFActionType.OUTPUT) == 0) {
            bucketPort = ((OFActionOutput) action).getPort()
                    .getPortNumber();
        }
        else if (action.getType().compareTo(OFActionType.GROUP) == 0) {
            bucketToGroup = ((OFActionGroup) action).getGroup()
                    .getGroupNumber();
        }
        else if (action.getType().compareTo(OFActionType.SET_FIELD) == 0) {
            if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmMplsLabelVer13")) {
                bucketLabel = Integer.decode(
                        ((OFActionSetField) action).
                                getField().getValue().toString());
            }
            else if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmEthSrcVer13")) {
                dlSrc = MacAddress.of(((OFActionSetField) action)
                        .getField().getValue().toString());
            }
            else if (((OFActionSetField) action).getField().toString()
                    .contains("OFOxmEthDstVer13")) {
                dlDst = MacAddress.of(((OFActionSetField) action)
                        .getField().getValue().toString());
            }
        }
    }

    if ((bucketPort == -1) && (bucketLabel == -1)
            && (bucketToGroup == -1)) {
        log.warn("processGroupDesc: A group with no port, no label, no to group");
    }
    BucketInfo driverBucket = new BucketInfo(null, dlSrc, dlDst,
            PortNumber.uint32(bucketPort), bucketLabel, true,
            bucketToGroup);

    return driverBucket;
}
项目:spring-open    文件:OFGroupDescStatsEntryModSerializer.java   
@Override
public void serialize(OFGroupDescStatsEntryMod groupDescStatsModEntry, JsonGenerator jGen,
        SerializerProvider sp) throws IOException,
        JsonGenerationException {
    OFGroupDescStatsEntry groupDescStatsEntryMod = groupDescStatsModEntry.getGroupDescStatsEntry();
    List<OFBucket> Buckets = groupDescStatsEntryMod.getBuckets();
    jGen.writeStartObject();
    jGen.writeNumberField("groupId", groupDescStatsEntryMod.getGroup().getGroupNumber());
    jGen.writeStringField("groupType", groupDescStatsEntryMod.getGroupType().name());
    jGen.writeArrayFieldStart("bucketsActions");
    for (OFBucket bucket : Buckets){
        jGen.writeStartObject();
        List<OFAction> actions = bucket.getActions();
        for (OFAction action : actions ){
            if(action.getType().compareTo(OFActionType.SET_FIELD) == 0){
                /*
                 * TODO: 1-Need better if condition.
                 * TODO: 2-Complete REST response. (Right now we are only sending what 
                 * SegmentRouter CLI needs).
                 */
                if (((OFActionSetField)action).getField().toString().contains("OFOxmEthSrcVer13")){
                    jGen.writeStringField("SET_DL_SRC", ((OFActionSetField)action).getField().getValue().toString());
                }
                else if (((OFActionSetField)action).getField().toString().contains("OFOxmEthDstVer13")){
                    jGen.writeStringField("SET_DL_DST", ((OFActionSetField)action).getField().getValue().toString());
                }
                else if (((OFActionSetField)action).getField().toString().contains("OFOxmMplsLabelVer13")){
                    jGen.writeNumberField("PUSH_MPLS_LABEL", 
                            Integer.decode(((OFActionSetField)action).getField().getValue().toString()));
                }
                else if (((OFActionSetField)action).getField().toString().contains("OFOxmMplsBosVer13")){
                    jGen.writeStringField("PUSH_MPLS_BOS", 
                            ((OFActionSetField)action).getField().getValue().toString());
                }
            }
            else if(action.getType().compareTo(OFActionType.OUTPUT) == 0){
                jGen.writeNumberField("OUTPUT", ((OFActionOutput)action).getPort().getPortNumber());
            }
            else if(action.getType().compareTo(OFActionType.POP_MPLS) == 0){
                jGen.writeStringField("POP_MPLS",  "0x"+((OFActionPopMpls)action).getEthertype().toString());
            }
            else if(action.getType().compareTo(OFActionType.GROUP) == 0){
                ((OFActionGroup)action).getGroup().getGroupNumber();
                jGen.writeNumberField("goToGroup", ((OFActionGroup)action).getGroup().getGroupNumber());
            }
            else if(action.getType().compareTo(OFActionType.COPY_TTL_IN) == 0
                    || action.getType().compareTo(OFActionType.COPY_TTL_OUT) == 0
                    || action.getType().compareTo(OFActionType.DEC_MPLS_TTL) == 0
                    || action.getType().compareTo(OFActionType.DEC_NW_TTL) == 0
                    || action.getType().compareTo(OFActionType.POP_PBB) == 0
                    || action.getType().compareTo(OFActionType.POP_VLAN) == 0){
                jGen.writeStringField(action.getType().name(), "True");
            }
        }
        jGen.writeEndObject();
    }
    jGen.writeEndArray();
    jGen.writeEndObject();

}
项目:athena    文件:GroupBucketEntryBuilder.java   
/**
 * Creates a builder.
 *
 * @param dpid dpid
 * @param ofBuckets list of OFBucket
 * @param type Group type
 * @param driverService driver service
 */
public GroupBucketEntryBuilder(Dpid dpid, List<OFBucket> ofBuckets, OFGroupType type,
                               DriverService driverService) {
    this.dpid = dpid;
    this.ofBuckets = ofBuckets;
    this.type = type;
    this.driverService = driverService;
}
项目:onos    文件:GroupBucketEntryBuilder.java   
/**
 * Creates a builder.
 *
 * @param dpid dpid
 * @param ofBuckets list of OFBucket
 * @param type Group type
 * @param driverService driver service
 */
public GroupBucketEntryBuilder(Dpid dpid, List<OFBucket> ofBuckets, OFGroupType type,
                               DriverService driverService) {
    this.dpid = dpid;
    this.ofBuckets = ofBuckets;
    this.type = type;
    this.driverService = driverService;
}
项目:onos    文件:OFAgentVirtualGroupBucketEntryBuilder.java   
/**
 * Creates a builder.
 *
 * @param dpid dpid
 * @param ofBuckets list of OFBucket
 * @param type Group type
 * @param driverService driver service
 */
public OFAgentVirtualGroupBucketEntryBuilder(Dpid dpid, List<OFBucket> ofBuckets, OFGroupType type,
                               DriverService driverService) {
    this.dpid = dpid;
    this.ofBuckets = ofBuckets;
    this.type = type;
    this.driverService = driverService;
}
项目:ravikumaran201504    文件:GroupBucketEntryBuilder.java   
/**
 * Creates a builder.
 *
 * @param ofBuckets list of OFBucket
 * @param type Group type
 */
public GroupBucketEntryBuilder(List<OFBucket> ofBuckets, OFGroupType type) {
    this.ofBuckets = ofBuckets;
    this.type = type;
}