Examples of OFFlowStatisticsReply


Examples of org.openflow.protocol.statistics.OFFlowStatisticsReply

        OFMatch m = new OFMatch();
        // Set the incoming port to 1 so that it will find the connected
        m.setInputPort((short) 1);

        // STATS_REPLY object
        OFFlowStatisticsReply reply = new OFFlowStatisticsReply();
        reply.setActions(actions);
        reply.setMatch(m);
        // Add the reply to the list of OFStatistics
        statsReply.add(reply);

        // Create the STATS_REPLY asynchronous reply object
        Callable<List<OFStatistics>> replyFuture = new ReplyFuture();
        // Assign the callable object to a Futuretask so that it will produce
        // future results
        FutureTask<List<OFStatistics>> futureStats = new FutureTask<List<OFStatistics>>(
                                                                                        replyFuture);

        // Assign the results of calling the object (the asynchronous reply)
        Future<List<OFStatistics>> results = getResults(futureStats);

        // SW1 -- Mock switch for base and multiple switch test case
        sw1 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 1
        expect(sw1.getId()).andReturn(1L).anyTimes();
        expect(sw1.queryStatistics(req)).andReturn(results).once();
        // Captures to hold resulting flowmod delete messages
        wc1 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc1 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passed when sw1.write is invoked
        sw1.write(capture(wc1), capture(bc1));
        expectLastCall().once();
        replay(sw1);

        // SW2 -- Mock switch for extended test cases
        sw2 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 2
        expect(sw2.getId()).andReturn(2L).anyTimes();
        expect(sw2.queryStatistics(req)).andReturn(results).once();
        wc2 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc2 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passwed when sw1.write is invoked
        sw2.write(capture(wc2), capture(bc2));
        expectLastCall().anyTimes();
        replay(sw2);

        // SW3 -- Mock switch for extended test cases
        sw3 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 3
        expect(sw3.getId()).andReturn(3L).anyTimes();
        expect(sw3.queryStatistics(req)).andReturn(results).once();
        wc3 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc3 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passwed when sw1.write is invoked
        sw3.write(capture(wc3), capture(bc3));
        expectLastCall().anyTimes();
        replay(sw3);

        // SW4 -- Mock switch for extended test cases
        sw4 = EasyMock.createNiceMock(IOFSwitch.class);
        // Expect that the switch's ID is 4
        expect(sw4.getId()).andReturn(4L).anyTimes();
        expect(sw4.queryStatistics(req)).andReturn(results).once();
        wc4 = new Capture<List<OFMessage>>(CaptureType.ALL);
        bc4 = new Capture<FloodlightContext>(CaptureType.ALL);
        // Capture the parameters passed when sw1.write is invoked
        sw4.write(capture(wc4), capture(bc4));
        expectLastCall().anyTimes();
        replay(sw4);

        // Here we create the OFMatch Reconcile list we wish to pass
        lofmr = new ArrayList<OFMatchReconcile>();

        // Create the only OFMatch Reconcile object that will be in the list
        ofmr = new OFMatchReconcile();
        long affectedSwitch = sw1.getId();
        OFMatchWithSwDpid ofmatchsw = new OFMatchWithSwDpid(new OFMatch().setWildcards(OFMatch.OFPFW_ALL),
                                                            affectedSwitch);
        ofmr.rcAction = OFMatchReconcile.ReconcileAction.UPDATE_PATH;
        ofmr.ofmWithSwDpid = ofmatchsw;

        // We'll say port 3 went down
        ofmr.outPort = 3;

        // Add the OFMatch Reconcile object to the list
        lofmr.add(ofmr);

        // Expected Flow Mod Deletes Messages
        // Flow Mod Delete for base switch
        fm = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory()
                                                 .getMessage(OFType.FLOW_MOD)).setMatch(new OFMatch().setWildcards(OFMatch.OFPFW_ALL))
                                                                              .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                              // Notice
                                                                              // we
                                                                              // specify
                                                                              // an
                                                                              // outPort
                                                                              .setOutPort((short) 3)
                                                                              .setLength(U16.t(OFFlowMod.MINIMUM_LENGTH));

        // Flow Mod Delete for the neighborswitches
        fm2 = ((OFFlowMod) mockFloodlightProvider.getOFMessageFactory()
                                                  .getMessage(OFType.FLOW_MOD))
        // Notice that this Match object is more specific
        .setMatch(reply.getMatch())
                                                                               .setCommand(OFFlowMod.OFPFC_DELETE)
                                                                               // Notice
                                                                               // we
                                                                               // specific
                                                                               // an
View Full Code Here

Examples of org.openflow.protocol.statistics.OFFlowStatisticsReply

        OFStatisticsReply sr = new OFStatisticsReply();
        sr.setXid(transactionId);
        sr.setStatisticType(OFStatisticsType.FLOW);
        List<OFStatistics> statistics = new ArrayList<OFStatistics>();
        for (int i = 0; i < count; ++i) {
            statistics.add(new OFFlowStatisticsReply());
        }
        sr.setStatistics(statistics);
        if (moreReplies)
            sr.setFlags((short) 1);
        return sr;
View Full Code Here

Examples of org.openflow.protocol.statistics.OFFlowStatisticsReply

   
   
   
    for (OFStatistics ofst : ofs) {

      OFFlowStatisticsReply st = (OFFlowStatisticsReply) ofst;

      JSONObject jsonObject = new JSONObject();
      String[] a = st.getActions().toString().split("port=");
      String c;
      c = st.getActions().toString();
      if (a.length == 1) {
        c = st.getActions().toString();
      } else {

        String[] b = a[1].split(",");
        c = b[0];
      }

      // parse the output
      String outputString = "";
      try {
        Pattern pattern = Pattern.compile("port=\\w*");

        Matcher matcher = pattern.matcher(st.getActions()
            .toString());

        while (matcher.find()) {

          outputString += matcher.group().split("=")[1] + ",";
        }

      } catch (PatternSyntaxException pse) {
        outputString = "malformed";
      }

      if (outputString.length() == 0) {
        outputString = "DROP,";
      }
      jsonObject.put("actions",
          outputString.substring(0, outputString.length() - 1));
      jsonObject.put("hard_timeout", st.getHardTimeout());
      jsonObject.put("idle_timeout", st.getIdleTimeout());
      jsonObject.put("match", st.getMatch().toString());
      jsonObject.put("priority", st.getPriority());
      jsonObject.put("packet_count", st.getPacketCount());
      jsonObject.put("byte_count", st.getByteCount());
      jsonObject.put("table_id", st.getTableId());

      jsonArray.add(jsonObject);

    }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.