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

项目:athena    文件:OFOpticalSwitch13.java   
private void processOFMultipartReply(OFStatsReply stats) {
    log.debug("Received message {} during switch-driver " +
               "subhandshake " + "from switch {} ... " +
               stats,
               getStringId());

     if (stats.getStatsType() == OFStatsType.EXPERIMENTER) {
         try {
           OFExpPortDescReply expPortDescReply =  (OFExpPortDescReply) stats;
           expPortDes.addAll(expPortDescReply.getEntries());
           if (!expPortDescReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
               driverHandshakeComplete.set(true);
               return;
           }
          } catch (ClassCastException e) {
              log.error("Unexspected Experimenter Multipart message type {} ",
                      stats.getClass().getName());
        }
    }
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:fresco_floodlight    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:iTAP-controller    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:iTAP-controller    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:SDN-Multicast    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:SDN-Multicast    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:arscheduler    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:arscheduler    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:arscheduler    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:floodlight1.2-delay    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:floodlight1.2-delay    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there
 * are no more remaining. Then, pass the list to the switch for
 * parsing and configuration.
 *
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 *
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        }
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:floodlight-hardware    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:floodlight-hardware    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:ACAMPController    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:ACAMPController    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:ACAMPController    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:fast-failover-demo    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:fast-failover-demo    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:ravikumaran201504    文件:OFChannelHandler.java   
@Override
void processOFStatisticsReply(OFChannelHandler h, OFStatsReply m)
        throws SwitchStateException {
    // Read port description
    if (m.getStatsType() != OFStatsType.PORT_DESC) {
        log.warn("Expecting port description stats but received stats "
                + "type {} from {}. Ignoring ...", m.getStatsType(),
                h.channel.getRemoteAddress());
        return;
    }
    if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
        log.warn("Stats reply indicates more stats from sw {} for "
                + "port description - not currently handled",
                h.getSwitchInfoString());
    }
    h.portDescReply = (OFPortDescStatsReply) m; // temp store
    log.info("Received port desc reply for switch at {}",
            h.getSwitchInfoString());
    try {
        h.sendHandshakeSetConfig();
    } catch (IOException e) {
        log.error("Unable to send setConfig after PortDescReply. "
                + "Error: {}", e.getMessage());
    }
    h.setState(WAIT_CONFIG_REPLY);
}
项目:floodlightLB    文件:OFSwitchHandshakeHandler.java   
@Override
/**
 * Accumulate a list of the OFTableFeaturesStatsReply's until there 
 * are no more remaining. Then, pass the list to the switch for 
 * parsing and configuration.
 * 
 * The assumption is that the OFMessage dispatcher will call this each
 * time, which it does. We don't loop and receive here.
 * 
 * @param m, The potential OFTableFeaturesStatsReply message we want to include
 */
void processOFStatsReply(OFStatsReply m) {
    if (m.getStatsType() == OFStatsType.TABLE_FEATURES) {
        replies.add((OFTableFeaturesStatsReply) m);
        if (!((OFTableFeaturesStatsReply)m).getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
            handleTableFeaturesMessage(replies, false);
            nextState();
        } 
    } else {
        /* should only receive TABLE_FEATURES here */
        log.error("Received {} message but expected TABLE_FEATURES.", m.getStatsType().toString());
    }

}
项目:floodlightLB    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:floodlightLB    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:DSC    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:DSC    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:floodlight    文件:MockOFSwitchImpl.java   
@SuppressWarnings("unchecked")
@Override
public <REPLY extends OFStatsReply> ListenableFuture<List<REPLY>> writeStatsRequest(OFStatsRequest<REPLY> request) {
    ListenableFuture<List<REPLY>> ofStatsFuture =
            EasyMock.createNiceMock(ListenableFuture.class);

    // We create a mock future and return info from the map
    try {
        OFStatsType statsType = request.getStatsType();
        List<REPLY> replies = (List<REPLY>) statsMap.get(statsType);
        EasyMock.expect(ofStatsFuture.get(EasyMock.anyLong(),
                EasyMock.anyObject(TimeUnit.class))).andReturn(replies).anyTimes();
        EasyMock.expect(ofStatsFuture.get()).andReturn(replies).anyTimes();
        EasyMock.replay(ofStatsFuture);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return ofStatsFuture;
}
项目:floodlight    文件:OFSwitchHandlerTestBase.java   
/** Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();

    connection.clearMessages();
    OFGetConfigReply cr = factory.buildGetConfigReply()
            .setMissSendLen(0xFFFF)
            .build();

    switchHandler.processOFMessage(cr);

    OFMessage msg = connection.retrieveMessage();
    assertEquals(OFType.STATS_REQUEST, msg.getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>)msg;
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msg);
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitDescriptionStatReplyState.class));
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer12.java   
public static OFStatsType ofWireValue(short val) {
    switch(val) {
        case DESC_VAL:
            return OFStatsType.DESC;
        case FLOW_VAL:
            return OFStatsType.FLOW;
        case AGGREGATE_VAL:
            return OFStatsType.AGGREGATE;
        case TABLE_VAL:
            return OFStatsType.TABLE;
        case PORT_VAL:
            return OFStatsType.PORT;
        case QUEUE_VAL:
            return OFStatsType.QUEUE;
        case GROUP_VAL:
            return OFStatsType.GROUP;
        case GROUP_DESC_VAL:
            return OFStatsType.GROUP_DESC;
        case GROUP_FEATURES_VAL:
            return OFStatsType.GROUP_FEATURES;
        case EXPERIMENTER_VAL:
            return OFStatsType.EXPERIMENTER;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.2: " + val);
    }
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer12.java   
public static short toWireValue(OFStatsType e) {
    switch(e) {
        case DESC:
            return DESC_VAL;
        case FLOW:
            return FLOW_VAL;
        case AGGREGATE:
            return AGGREGATE_VAL;
        case TABLE:
            return TABLE_VAL;
        case PORT:
            return PORT_VAL;
        case QUEUE:
            return QUEUE_VAL;
        case GROUP:
            return GROUP_VAL;
        case GROUP_DESC:
            return GROUP_DESC_VAL;
        case GROUP_FEATURES:
            return GROUP_FEATURES_VAL;
        case EXPERIMENTER:
            return EXPERIMENTER_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.2: " + e);
    }
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer10.java   
public static OFStatsType ofWireValue(short val) {
    switch(val) {
        case DESC_VAL:
            return OFStatsType.DESC;
        case FLOW_VAL:
            return OFStatsType.FLOW;
        case AGGREGATE_VAL:
            return OFStatsType.AGGREGATE;
        case TABLE_VAL:
            return OFStatsType.TABLE;
        case PORT_VAL:
            return OFStatsType.PORT;
        case QUEUE_VAL:
            return OFStatsType.QUEUE;
        case EXPERIMENTER_VAL:
            return OFStatsType.EXPERIMENTER;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.0: " + val);
    }
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer10.java   
public static short toWireValue(OFStatsType e) {
    switch(e) {
        case DESC:
            return DESC_VAL;
        case FLOW:
            return FLOW_VAL;
        case AGGREGATE:
            return AGGREGATE_VAL;
        case TABLE:
            return TABLE_VAL;
        case PORT:
            return PORT_VAL;
        case QUEUE:
            return QUEUE_VAL;
        case EXPERIMENTER:
            return EXPERIMENTER_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.0: " + e);
    }
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer11.java   
public static OFStatsType ofWireValue(short val) {
    switch(val) {
        case DESC_VAL:
            return OFStatsType.DESC;
        case FLOW_VAL:
            return OFStatsType.FLOW;
        case AGGREGATE_VAL:
            return OFStatsType.AGGREGATE;
        case TABLE_VAL:
            return OFStatsType.TABLE;
        case PORT_VAL:
            return OFStatsType.PORT;
        case QUEUE_VAL:
            return OFStatsType.QUEUE;
        case GROUP_VAL:
            return OFStatsType.GROUP;
        case GROUP_DESC_VAL:
            return OFStatsType.GROUP_DESC;
        case EXPERIMENTER_VAL:
            return OFStatsType.EXPERIMENTER;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.1: " + val);
    }
}
项目:openflowj-otn    文件:OFStatsTypeSerializerVer11.java   
public static short toWireValue(OFStatsType e) {
    switch(e) {
        case DESC:
            return DESC_VAL;
        case FLOW:
            return FLOW_VAL;
        case AGGREGATE:
            return AGGREGATE_VAL;
        case TABLE:
            return TABLE_VAL;
        case PORT:
            return PORT_VAL;
        case QUEUE:
            return QUEUE_VAL;
        case GROUP:
            return GROUP_VAL;
        case GROUP_DESC:
            return GROUP_DESC_VAL;
        case EXPERIMENTER:
            return EXPERIMENTER_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.1: " + e);
    }
}
项目:spring-open    文件:OFSwitchImplBase.java   
@SuppressWarnings("unused")
private void analyzeStatsReply(OFMessage reply) {
    log.info("recieved stats reply (xid = {} type: {}) from sw {} ",
            reply.getXid(), reply.getType(), getStringId());
    if (reply.getType() == OFType.STATS_REPLY) {
        OFStatsReply sr = (OFStatsReply) reply;
        if (sr.getStatsType() == OFStatsType.FLOW) {
            OFFlowStatsReply fsr = (OFFlowStatsReply) sr;
            log.info("received flow stats sw {} --> {}", getStringId(), fsr);
            // fsr.getEntries().get(0).getMatch().getMatchFields()
            for (OFFlowStatsEntry e : fsr.getEntries()) {
                for (MatchField<?> mf : e.getMatch().getMatchFields()) {
                    log.info("mf is exact: {} for {}: {}",
                            e.getMatch().isExact(mf),
                            mf.id,
                            e.getMatch().get(mf));
                }
            }

        }
    }
}
项目:spring-open    文件:OFChannelHandlerTest.java   
/**
 * Move the channel from scratch to WAIT_DESCRIPTION_STAT_REPLY state
 * Builds on moveToWaitConfigReply()
 * adds testing for WAIT_CONFIG_REPLY state
 */
@Test
public void moveToWaitDescriptionStatReply() throws Exception {
    moveToWaitConfigReply();
    resetChannel();
    channel.write(capture(writeCapture));
    expectLastCall().andReturn(null).atLeastOnce();
    replay(channel);

    OFGetConfigReply cr = (OFGetConfigReply)buildOFMessage(OFType.GET_CONFIG_REPLY);

    sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(cr));

    List<OFMessage> msgs = getMessagesFromCapture();
    assertEquals(1, msgs.size());
    assertEquals(OFType.STATS_REQUEST, msgs.get(0).getType());
    OFStatsRequest<?> sr = (OFStatsRequest<?>) msgs.get(0);
    assertEquals(OFStatsType.DESC, sr.getStatsType());
    verifyUniqueXids(msgs);
    assertEquals(OFChannelHandler.ChannelState.WAIT_DESCRIPTION_STAT_REPLY,
            handler.getStateForTesting());
}