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

项目:athena    文件:OfOpticalSwitchImplLinc13.java   
@Override
public void sendMsg(OFMessage msg) {
    // Ignore everything but flow mods and stat requests
    if (!(msg instanceof OFFlowMod || msg instanceof OFFlowStatsRequest)) {
        super.sendMsg(msg);
        return;
    }

    Match newMatch;
    OFMessage newMsg = null;

    if (msg instanceof OFFlowStatsRequest) {
        // Rewrite match only
        OFFlowStatsRequest fsr = (OFFlowStatsRequest) msg;
        newMatch = rewriteMatch(fsr.getMatch());
        newMsg = fsr.createBuilder().setMatch(newMatch).build();
    } else if (msg instanceof OFFlowMod) {
        // Rewrite match and actions
        OFFlowMod fm = (OFFlowMod) msg;
        newMatch = rewriteMatch(fm.getMatch());
        List<OFAction> actions = rewriteActions(fm.getActions());
        newMsg = fm.createBuilder().setMatch(newMatch).setActions(actions).build();
    }

    super.sendMsg(newMsg);
}
项目:athena    文件:FlowStatsCollector.java   
private void sendFlowStatistic() {
    if (sw.getRole() != RoleState.MASTER) {
        return;
    }
    Match match = sw.factory().buildMatch().build();

    //Long statsXid = xidAtomic.getAndIncrement();
    OFFlowStatsRequest statsRequest = sw.factory()
            .buildFlowStatsRequest()
            .setXid(1127)
            .setMatch(match)
            .setOutPort(OFPort.ANY)
            .setTableId(TableId.ALL)
            .build();

    sw.sendMsg(statsRequest);
}
项目:athena    文件:NewAdaptiveFlowStatsCollector.java   
private void ofFlowStatsRequestAllSend() {
    OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
            .setMatch(sw.factory().matchWildcardAll())
            .setTableId(TableId.ALL)
            .setOutPort(OFPort.NO_MASK)
            .build();

    synchronized (this) {
        // set the request xid to check the reply in OpenFlowRuleProvider
        // After processing the reply of this request message,
        // this must be set to NO_FLOW_MISSING_XID(-1) by provider
        setFlowMissingXid(request.getXid());
        log.debug("ofFlowStatsRequestAllSend: request={}, dpid={}",
                request.toString(), sw.getStringId());

        sw.sendMsg(request);
    }
}
项目:ravikumaran201504    文件:FlowStatsCollector.java   
private void sendFlowStatistics() {
    if (log.isTraceEnabled()) {
        log.trace("sendFlowStatistics {}:{}", sw.getStringId(), sw.getRole());
    }
    if (sw.getRole() != RoleState.MASTER) {
        // Switch not master.
        return;
    }
    OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
            .setMatch(sw.factory().matchWildcardAll())
            .setTableId(TableId.ALL)
            .setOutPort(OFPort.NO_MASK)
            .build();

    this.sw.sendMsg(request);

}
项目:onos    文件:OfOpticalSwitchImplLinc13.java   
@Override
public void sendMsg(OFMessage msg) {
    // Ignore everything but flow mods and stat requests
    if (!(msg instanceof OFFlowMod || msg instanceof OFFlowStatsRequest)) {
        super.sendMsg(msg);
        return;
    }

    Match newMatch;
    OFMessage newMsg = null;

    if (msg instanceof OFFlowStatsRequest) {
        // Rewrite match only
        OFFlowStatsRequest fsr = (OFFlowStatsRequest) msg;
        newMatch = rewriteMatch(fsr.getMatch());
        newMsg = fsr.createBuilder().setMatch(newMatch).build();
    } else if (msg instanceof OFFlowMod) {
        // Rewrite match and actions
        OFFlowMod fm = (OFFlowMod) msg;
        newMatch = rewriteMatch(fm.getMatch());
        List<OFAction> actions = rewriteActions(fm.getActions());
        newMsg = fm.createBuilder().setMatch(newMatch).setActions(actions).build();
    }

    super.sendMsg(newMsg);
}
项目:onos    文件:NewAdaptiveFlowStatsCollector.java   
private synchronized void ofFlowStatsRequestAllSend() {
    OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
            .setMatch(sw.factory().matchWildcardAll())
            .setTableId(TableId.ALL)
            .setOutPort(OFPort.NO_MASK)
            .build();

    // set the request xid to check the reply in OpenFlowRuleProvider
    // After processing the reply of this request message,
    // this must be set to NO_FLOW_MISSING_XID(-1) by provider
    setFlowMissingXid(request.getXid());
    log.debug("ofFlowStatsRequestAllSend: request={}, dpid={}",
                request.toString(), sw.getStringId());

    sw.sendMsg(request);
}
项目:open-kilda    文件:SwitchManager.java   
/**
 * {@inheritDoc}
 */
@Override
public OFFlowStatsReply dumpFlowTable(final DatapathId dpid) {
    OFFlowStatsReply values = null;
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);
    if (sw == null) {
        throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
    }

    OFFactory ofFactory = sw.getOFFactory();
    OFFlowStatsRequest flowRequest = ofFactory.buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().matchWildcardAll())
            .setTableId(TableId.ALL)
            .setOutPort(OFPort.ANY)
            .setOutGroup(OFGroup.ANY)
            .setCookieMask(U64.ZERO)
            .build();

    try {
        ListenableFuture<OFFlowStatsReply> future = sw.writeRequest(flowRequest);
        values = future.get(10, TimeUnit.SECONDS);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        logger.error("Could not get flow stats: {}", e.getMessage());
    }

    return values;
}
项目:athena    文件:CalientFiberSwitchHandshaker.java   
@Override
public final void sendMsg(OFMessage m) {
    OFMessage newMsg = m;

    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("Rebuilding stats request type {}", sr.getStatsType());
        switch (sr.getStatsType()) {
            case FLOW:
                OFCalientFlowStatsRequest request = this.factory().buildCalientFlowStatsRequest()
                        .setCookie(((OFFlowStatsRequest) sr).getCookie())
                        .setCookieMask(((OFFlowStatsRequest) sr).getCookieMask())
                        .setMatch(this.factory().matchWildcardAll())
                        .setOutGroup(((OFFlowStatsRequest) sr).getOutGroup().getGroupNumber())
                        .setOutPort(OFPort.ANY)
                        .setTableId(TableId.ALL)
                        .setXid(sr.getXid())
                        .setFlags(sr.getFlags())
                        .build();
                newMsg = request;
                break;
            case PORT:
                // TODO
                break;
            default:
                break;
        }
    }

    super.sendMsg(newMsg);
}
项目:athena    文件:FlowStatsCollector.java   
@Override
public void run() {
    if (sw.getRole() == RoleState.MASTER) {
        log.trace("Collecting stats for {}", sw.getStringId());
        OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
                .setMatch(sw.factory().matchWildcardAll())
                .setTableId(TableId.ALL)
                .setOutPort(OFPort.NO_MASK)
                .build();
        sw.sendMsg(request);
    }
}
项目:athena    文件:NewAdaptiveFlowStatsCollector.java   
private void ofFlowStatsRequestFlowSend(FlowEntry fe) {
    // set find match
    Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(),
            Optional.of(driverService)).buildMatch();
    // set find tableId
    TableId tableId = TableId.of(fe.tableId());
    // set output port
    Instruction ins = fe.treatment().allInstructions().stream()
            .filter(i -> (i.type() == Instruction.Type.OUTPUT))
            .findFirst()
            .orElse(null);
    OFPort ofPort = OFPort.NO_MASK;
    if (ins != null) {
        Instructions.OutputInstruction out = (Instructions.OutputInstruction) ins;
        ofPort = OFPort.of((int) ((out.port().toLong())));
    }

    OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
            .setMatch(match)
            .setTableId(tableId)
            .setOutPort(ofPort)
            .build();

    synchronized (this) {
        if (getFlowMissingXid() != NO_FLOW_MISSING_XID) {
            log.debug("ofFlowStatsRequestFlowSend: previous FlowStatsRequestAll does not be processed yet,"
                            + " set no flow missing xid anyway, for {}",
                    sw.getStringId());
            setFlowMissingXid(NO_FLOW_MISSING_XID);
        }

        sw.sendMsg(request);
    }
}
项目:fresco_floodlight    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:fresco_floodlight    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:fresco_floodlight    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:iTAP-controller    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:iTAP-controller    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:SDN-Multicast    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:SDN-Multicast    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:SDN-Multicast    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:arscheduler    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:arscheduler    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:arscheduler    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:floodlight1.2-delay    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:floodlight1.2-delay    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:floodlight1.2-delay    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:floodlight-hardware    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:floodlight-hardware    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:floodlight-hardware    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:ACAMPController    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:ACAMPController    文件:OFSwitchBaseTest.java   
@Test
public void testMasterSlaveWrites() {
    OFFactory factory = OFFactories.getFactory(OFVersion.OF_13);
    OFFlowAdd fa = factory.buildFlowAdd().build();
    OFFlowStatsRequest fsr = factory.buildFlowStatsRequest().build();
    List<OFMessage> msgList = new ArrayList<OFMessage>();
    msgList.add(fa);
    msgList.add(fsr);

    reset(switchManager);
       expect(switchManager.isCategoryRegistered(LogicalOFMessageCategory.MAIN)).andReturn(true).times(6);
       switchManager.handleOutgoingMessage(sw, fa);
       expectLastCall().times(2);
       switchManager.handleOutgoingMessage(sw, fsr);
       expectLastCall().times(4);
       replay(switchManager);

    /* test master -- both messages should be written */
    sw.setControllerRole(OFControllerRole.ROLE_MASTER);
    assertTrue(sw.write(fa));
    assertTrue(sw.write(fsr));
    assertEquals(Collections.<OFMessage>emptyList(), sw.write(msgList));

    /* test slave -- flow-add (mod op) should fail each time; flow stats (read op) should pass */
    sw.setControllerRole(OFControllerRole.ROLE_SLAVE);
    assertFalse(sw.write(fa)); /* flow-add should be stopped (mod op) */
    assertTrue(sw.write(fsr)); /* stats request makes it (read op) */
    assertEquals(Collections.<OFMessage>singletonList(fa), sw.write(msgList)); /* return bad flow-add */
}
项目:ACAMPController    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    eventLoop.runTasks();
    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:fast-failover-demo    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:fast-failover-demo    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:floodlightLB    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:floodlightLB    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:DSC    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:DSC    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:floodlight    文件:PortDownReconciliation.java   
/**
 * @param sw
 *            the switch object that we wish to get flows from
 * @param outPort
 *            the output action port we wish to find flows with
 * @return a list of OFFlowStatisticsReply objects or essentially flows
 */
public List<OFFlowStatsReply> getFlows(IOFSwitch sw, OFPort outPort) {

    statsReply = new ArrayList<OFFlowStatsReply>();
    List<OFFlowStatsReply> values = null;
    Future<List<OFFlowStatsReply>> future;

    // Statistics request object for getting flows
    OFFlowStatsRequest req = sw.getOFFactory().buildFlowStatsRequest()
            .setMatch(sw.getOFFactory().buildMatch().build())
            .setOutPort(outPort)
            .setTableId(TableId.ALL)
            .build();

    try {
        // System.out.println(sw.getStatistics(req));
        future = sw.writeStatsRequest(req);
        values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            for (OFFlowStatsReply stat : values) {
                statsReply.add(stat);
            }
        }
    } catch (Exception e) {
        log.error("Failure retrieving statistics from switch " + sw, e);
    }

    return statsReply;
}
项目:floodlight    文件:OFConnectionTest.java   
/** write a stats request message that triggers two responses */
@Test(timeout = 5000)
public void testWriteStatsRequestSuccess() throws InterruptedException, ExecutionException {
    Capture<List<OFMessage>> cMsgList = prepareChannelForWriteList();

    OFFlowStatsRequest flowStatsRequest = factory.buildFlowStatsRequest().build();
    ListenableFuture<List<OFFlowStatsReply>> future = conn.writeStatsRequest(flowStatsRequest);
    assertThat("Connection should have 1 pending request",
            conn.getPendingRequestIds().size(), equalTo(1));

    assertThat("Should have captured MsgList", cMsgList.getValue(),
            Matchers.<OFMessage> contains(flowStatsRequest));

    assertThat("Future should not be complete yet", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply1 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .setFlags(Sets.immutableEnumSet(OFStatsReplyFlags.REPLY_MORE))
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply1),
            equalTo(true));
    assertThat("Future should not be complete ", future.isDone(), equalTo(false));

    OFFlowStatsReply statsReply2 = factory.buildFlowStatsReply()
            .setXid(flowStatsRequest.getXid())
            .build();

    assertThat("Connection should have accepted the response",
            conn.deliverResponse(statsReply2),
            equalTo(true));
    assertThat("Future should be complete ", future.isDone(), equalTo(true));

    assertThat(future.get(), Matchers.contains(statsReply1, statsReply2));
    assertThat("Connection should have no pending requests",
            conn.getPendingRequestIds().isEmpty(), equalTo(true));
}
项目:onos    文件:CalientFiberSwitchHandshaker.java   
@Override
public final void sendMsg(OFMessage m) {
    OFMessage newMsg = m;

    if (m.getType() == OFType.STATS_REQUEST) {
        OFStatsRequest sr = (OFStatsRequest) m;
        log.debug("Rebuilding stats request type {}", sr.getStatsType());
        switch (sr.getStatsType()) {
            case FLOW:
                OFCalientFlowStatsRequest request = this.factory().buildCalientFlowStatsRequest()
                        .setCookie(((OFFlowStatsRequest) sr).getCookie())
                        .setCookieMask(((OFFlowStatsRequest) sr).getCookieMask())
                        .setMatch(this.factory().matchWildcardAll())
                        .setOutGroup(((OFFlowStatsRequest) sr).getOutGroup().getGroupNumber())
                        .setOutPort(OFPort.ANY)
                        .setTableId(TableId.ALL)
                        .setXid(sr.getXid())
                        .setFlags(sr.getFlags())
                        .build();
                newMsg = request;
                break;
            case PORT:
                // TODO
                break;
            default:
                break;
        }
    }

    super.sendMsg(newMsg);
}
项目:onos    文件:FlowStatsCollector.java   
@Override
public void run() {
    if (sw.getRole() == RoleState.MASTER) {
        log.trace("Collecting stats for {}", sw.getStringId());
        OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest()
                .setMatch(sw.factory().matchWildcardAll())
                .setTableId(TableId.ALL)
                .setOutPort(OFPort.NO_MASK)
                .build();
        sw.sendMsg(request);
    }
}