Package com.dianping.cat.home.nettopo.entity

Examples of com.dianping.cat.home.nettopo.entity.NetGraph


    throw new UnsupportedOperationException("no daily report builder for net topology!");
  }

  @Override
  public boolean buildHourlyTask(String name, String domain, Date period) {
    NetGraph netGraphTemplate = m_netGraphConfigManager.getConfig().getNetGraphs().get(0);
    Set<String> groups = new HashSet<String>();

    for (NetTopology netTopology : netGraphTemplate.getNetTopologies()) {
      for (Connection connection : netTopology.getConnections()) {
        for (Interface inter : connection.getInterfaces()) {
          groups.add(inter.getGroup());
        }
      }
View Full Code Here


public class NetTopoModelTest {

  @Test
  public void test() throws Exception {
    NetGraphSet netGraphSet = new NetGraphSet();
    NetGraph netGraph = new NetGraph();
    netGraphSet.getNetGraphs().put(0, netGraph);
    netGraph = new NetGraph();
    netGraph.setMinute(1);
    netGraphSet.getNetGraphs().put(1, netGraph);
    System.out.println("0:"+netGraphSet.getNetGraphs().get(0));
    System.out.println("1:"+netGraphSet.getNetGraphs().get(1));
    DefaultXmlBuilder defaultXmlBuilder = new DefaultXmlBuilder();
    System.out.println(netGraphSet);
View Full Code Here

      netGraphSet = m_reportService.queryNetTopologyReport(Constants.CAT, start, new Date(start.getTime()
            + TimeHelper.ONE_HOUR));
    }

    if (netGraphSet != null) {
      NetGraph netGraph = netGraphSet.findNetGraph(minute);

      if (netGraph != null) {
        for (NetTopology netTopology : netGraph.getNetTopologies()) {
          String topoName = netTopology.getName();
          String data = jb.toJson(netTopology);

          netGraphData.add(new Pair<String, String>(topoName, data));
        }
View Full Code Here

      while (active) {
        Transaction t = Cat.newTransaction("NetGraph", TimeHelper.getMinuteStr());
        long current = System.currentTimeMillis();
       
        try {
          NetGraph netGraphTemplate = m_netGraphConfigManager.getConfig().getNetGraphs().get(0);
          Set<String> groups = queryAllGroups(netGraphTemplate);
          Map<String, MetricReport> currentMetricReports = queryMetricReports(groups, ModelPeriod.CURRENT);
          List<AlertMetric> alertKeys = m_alertInfo.queryLastestAlarmKey(5);

          m_currentNetGraphSet = m_netGraphBuilder
View Full Code Here

  public NetGraphSet buildGraphSet(NetGraph netGraphTemplate, Map<String, MetricReport> reports,
        List<AlertMetric> alertKeys) {
    NetGraphSet netGraphSet = new NetGraphSet();

    for (int minute = 0; minute <= 59; minute++) {
      NetGraph netGraph = copyBaseInfoFromTemplate(netGraphTemplate);

      for (NetTopology netTopology : netGraph.getNetTopologies()) {
        List<String> alertSwitchs = new ArrayList<String>();

        for (Connection connection : netTopology.getConnections()) {
          try {
            buildConnectionInfo(reports, alertKeys, minute, alertSwitchs, connection);
          } catch (Exception e) {
            Cat.logError(e);
          }
        }

        for (Switch sw : netTopology.getSwitchs()) {
          if (alertSwitchs.contains(sw.getName())) {
            sw.setState(ERROR);
          }
        }
      }
      netGraph.setMinute(minute);
      netGraphSet.addNetGraph(netGraph);
    }

    return netGraphSet;
  }
View Full Code Here

    }
    return false;
  }

  private NetGraph copyBaseInfoFromTemplate(NetGraph netGraph) {
    NetGraph to = new NetGraph();
    for (NetTopology netTopologyA : netGraph.getNetTopologies()) {
      NetTopology netTopologyB = new NetTopology();

      for (Anchor anchorA : netTopologyA.getAnchors()) {
        Anchor anchorB = new Anchor();
        anchorB.setName(anchorA.getName());
        anchorB.setX(anchorA.getX());
        anchorB.setY(anchorA.getY());
        netTopologyB.addAnchor(anchorB);
      }

      for (Switch switchA : netTopologyA.getSwitchs()) {
        Switch switchB = new Switch();
        switchB.setName(switchA.getName());
        switchB.setX(switchA.getX());
        switchB.setY(switchA.getY());
        switchB.setState(switchA.getState());
        netTopologyB.addSwitch(switchB);
      }

      for (Connection connectionA : netTopologyA.getConnections()) {
        Connection connectionB = new Connection();
        for (Interface interA : connectionA.getInterfaces()) {
          Interface interB = new Interface();
          interB.setDomain(interA.getDomain());
          interB.setGroup(interA.getGroup());
          interB.setKey(interA.getKey());
          interB.setIn(interA.getIn());
          interB.setOut(interA.getOut());
          interB.setInstate(interA.getInstate());
          interB.setOutstate(interA.getOutstate());
          interB.setInstate(interA.getInstate());
          interB.setOutstate(interA.getOutstate());
          interB.setInDiscardsState(interA.getInDiscardsState());
          interB.setOutDiscardsState(interA.getOutDiscardsState());
          interB.setInErrorsState(interA.getInErrorsState());
          interB.setOutErrorsState(interA.getOutErrorsState());
          connectionB.addInterface(interB);
        }
        connectionB.setInsum(connectionA.getInsum());
        connectionB.setOutsum(connectionA.getOutsum());
        connectionB.setFrom(connectionA.getFrom());
        connectionB.setTo(connectionA.getTo());
        connectionB.setInstate(connectionA.getInstate());
        connectionB.setOutstate(connectionA.getOutstate());
        connectionB.setInDiscardsState(connectionA.getInDiscardsState());
        connectionB.setOutDiscardsState(connectionA.getOutDiscardsState());
        connectionB.setInErrorsState(connectionA.getInErrorsState());
        connectionB.setOutErrorsState(connectionA.getOutErrorsState());
        netTopologyB.addConnection(connectionB);
      }

      to.addNetTopology(netTopologyB);
    }

    return to;
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.home.nettopo.entity.NetGraph

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.