Пример #1
0
  @Override
  public void pollSubNodes() {

    //		System.out.println("Before SubNodesPolled: Load=" + networkLoad + "hops, subNodeStatusMap: "
    // + subNodesStatusMap.entrySet().toString());

    Datacentre dc = World.getInstance().getDatacentre(location.dc());

    // poll each sub-node for latest status
    for (Map.Entry<Integer, Boolean> entry : subNodesStatusMap.entrySet()) {

      //			Server s = dc.getServer(entry.getKey());
      //			System.out.println(s.getStatus());
      entry.setValue(dc.getServer(entry.getKey()).isAlive()); // poll current server status

      PartialIP node_ip = new PartialIP(dc.getServer(entry.getKey()).getIP());
      int hops =
          2
              * PartialIP.navigatePointToPoint(
                  location, node_ip); // x2 for round trip (request/response)
      networkLoad += hops;
    }

    //		System.out.println("After SubNodesPolled: Load=" + networkLoad + "hops, subNodeStatusMap: "
    // + subNodesStatusMap.entrySet().toString());
  }
Пример #2
0
  /**
   * DatacentrePoller periodically polls and records the status of all nodes in the network, making
   * this status information available for other nodes on the network to enquire.
   *
   * @param location - the network location of the DatacentrePoller
   */
  public DatacentrePoller(PartialIP location) {
    super(location);

    logger.info("Constructing new DCPoller, IP(" + location + ")");

    Datacentre dc = World.getInstance().getDatacentre(location.dc());
    int[] serverIDs = dc.getServerIDs();

    subNodesStatusMap = new HashMap<Integer, Boolean>();

    logger.debug("ServerIDs: " + Arrays.toString(serverIDs));

    int firstNodeID = serverIDs[0];

    int nodeIndex;

    // initial set up of subNodesMap
    for (int i = 0; i < serverIDs.length; i++) {

      nodeIndex = serverIDs[i] - firstNodeID;

      subNodesStatusMap.put(nodeIndex, dc.getServer(nodeIndex).isAlive());

      PartialIP node_ip = new PartialIP(dc.getServer(nodeIndex).getIP());

      int hops =
          2
              * PartialIP.navigatePointToPoint(
                  location, node_ip); // x2 for round trip (request/response)

      networkLoad += hops;
    }

    logger.info(
        "Load="
            + networkLoad
            + "hops, Created new DCPoller with subNodeStatusMap: "
            + subNodesStatusMap.entrySet().toString());
  }