Package edu.iu.incntre.flowscale

Examples of edu.iu.incntre.flowscale.SwitchDevice


                intervalTime);

            List<OFStatistics> portStats;
            List<OFStatistics> flowStats;
            List<OFPhysicalPort> portStatus;
            SwitchDevice swd = null;
            String[] datapathIdStringElements = datapathIdStrings.split(",");
            try {

              while (statThread != null) {
                calendar = Calendar.getInstance();
                logger.trace("getting flows from switches");
               
                //check if conn is null if it is, reset connection
                if(conn == null){
                conn = DriverManager.getConnection(databaseDriver, dbUsername,
                    dbPassword);
                }
               
               
                for (String datapathIdString : datapathIdStringElements) {

                  try {

                 
                    swd = flowscaleController
                        .getSwitchDevices()
                        .get(HexString
                            .toLong(datapathIdString));
                   
                   
                   
                    if (swd == null) {
                      logger.info("switch {} does not exist, is it connected?",
                          datapathIdString);
                      continue;
                    }
                   
                   
                    logger.info(
                        "Getting flows from switch {} with ID {}",
                        swd.getSwitchName(), datapathIdString);

                   

                    try {
                      portStats = flowscaleController
                          .getSwitchStatisticsFromInterface(
                              datapathIdString,
                              "port");

                      flowStats = flowscaleController
                          .getSwitchStatisticsFromInterface(
                              datapathIdString,
                              "flow");

                      portStatus = swd.getPortStates();

                      if (flowStats != null
                          && portStats != null) {

                        String flowStatsJSON = JSONConverter
                            .toStat(flowStats,
                                "flow")
                            .toJSONString();
                        String portStatsJSON = JSONConverter
                            .toStat(portStats,
                                "port")
                            .toJSONString();
                        String portStatusJSON = JSONConverter
                            .toPortStatus(
                                portStatus)
                            .toJSONString();

                        // initialize or set hashmaps

                        HashMap<Long, Long> tempPortStatTransmitted;
                        HashMap<Long, Long> tempPortStatReceived;
                        HashMap<String, Long> tempFlowStat;

                        long datapathId = HexString
                            .toLong(datapathIdString);
                        if (tempPortStatTransmittedHashMap
                            .get(datapathId) == null) {

                          tempPortStatTransmitted = new HashMap<Long, Long>();
                          tempPortStatTransmittedHashMap
                              .put(datapathId,
                                  tempPortStatTransmitted);
                        } else {
                          tempPortStatTransmitted = tempPortStatTransmittedHashMap
                              .get(datapathId);

                        }

                        if (tempPortStatReceivedHashMap
                            .get(datapathId) == null) {
                          tempPortStatReceived = new HashMap<Long, Long>();
                          tempPortStatReceivedHashMap
                              .put(datapathId,
                                  tempPortStatReceived);
                        } else {
                          tempPortStatReceived = tempPortStatReceivedHashMap
                              .get(datapathId);
                        }
                        if (tempFlowStatHashMap
                            .get(datapathId) == null) {
                          tempFlowStat = new HashMap<String, Long>();
                          tempFlowStatHashMap.put(
                              datapathId,
                              tempFlowStat);
                        } else {

                          tempFlowStat = tempFlowStatHashMap
                              .get(datapathId);
                        }

                        storeSwitchDetails(
                            HexString
                                .toLong(datapathIdString),
                            portStatsJSON,
                            flowStatsJSON,
                            portStatusJSON,
                            tempPortStatTransmitted,
                            tempPortStatReceived,
                            tempFlowStat);
                      } else {
                        logger.error(
                            "Switch {} returned a null result possibility because the switch is not connected to the controller",
                            datapathIdString);
                      }
                    } catch (NoSwitchException e1) {
                      // TODO Auto-generated catch block
                      logger.error(
                          "Switch {} with ID {} is not connected aborting",
                          swd.getSwitchName(),datapathIdString)
                    } catch (IOException e1) {
                      logger.error("IOException {}", e1);

                    } catch (InterruptedException e1) {
                      logger.error(
View Full Code Here


logger.info("datapathId {} sensorId {}", datapathIdString,sensorIdString);
logger.info("update status {}", updateStatus);

      try {

        SwitchDevice switchDevice = flowscaleController
            .getSwitchDevices().get(
                HexString.toLong(datapathIdString));

        IOFSwitch sw = switchDevice.getOpenFlowSwitch();
        List<OFPhysicalPort> switchPorts = switchDevice.getPortStates();
        OFPhysicalPort updatedPort = null;

        for (OFPhysicalPort ofPort : switchPorts) {

          if (ofPort.getPortNumber() == Short
View Full Code Here

    short port = Short.parseShort(portString);
   

    try {

      SwitchDevice switchDevice = flowscaleController
          .getSwitchDevices().get(
              HexString.toLong(datapathIdString));

      IOFSwitch sw = switchDevice.getOpenFlowSwitch();
      List<OFPhysicalPort> switchPorts = switchDevice.getPortStates();
      OFPhysicalPort updatedPort = null;

      for (OFPhysicalPort ofPort : switchPorts) {

        if (ofPort.getPortNumber() == port) {
View Full Code Here

TOP

Related Classes of edu.iu.incntre.flowscale.SwitchDevice

Copyright © 2018 www.massapicom. 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.