コード例 #1
0
ファイル: NetGraphManager.java プロジェクト: jinbochen/cat
    @Override
    public void run() {
      boolean active = true;

      while (active) {
        long current = System.currentTimeMillis();
        int minute = (int) (current / 60000 % 60);
        NetGraph netGraph = new NetGraph("/config/nettopology-config.xml");
        double insum, outsum;

        for (NetTopology netTopology : netGraph.getNetTopologys()) {
          for (Connection connection : netTopology.getConnections()) {
            insum = 0;
            outsum = 0;
            for (Interface inter : connection.getFirstData()) {
              updateInterface(inter, minute);
              insum += inter.getIn();
              outsum += inter.getOut();
            }
            connection.setFirstInSum(insum);
            connection.setFirstOutSum(outsum);

            insum = 0;
            outsum = 0;
            for (Interface inter : connection.getSecondData()) {
              updateInterface(inter, minute);
              insum += inter.getIn();
              outsum += inter.getOut();
            }
            connection.setSecondInSum(insum);
            connection.setSecondOutSum(outsum);
          }
        }

        m_netGraph = netGraph;

        long duration = System.currentTimeMillis() - current;

        try {
          if (duration < DURATION) {
            Thread.sleep(DURATION - duration);
          }
        } catch (InterruptedException e) {
          active = false;
        }
      }
    }