Ejemplo n.º 1
0
 private ResourceNode nodeFromMap(Map<String, String> map) throws MalformedURLException {
   if (map == null) {
     return null;
   }
   ResourceNode node = new ResourceNode();
   System.out.println("MAP IS " + map);
   System.out.println("Setting hostname to " + map.get(NAME));
   node.setId(map.get(NAME));
   node.setIpAddr(new URL("http://" + map.get(NAME) + ":" + DEFAULT_PORT));
   return node;
 }
Ejemplo n.º 2
0
  @Override
  public boolean reduceLoad(ResourceNode node, int loadValue) throws MonitorException {
    String nodeId = node.getNodeId();
    if (this.loadMap.containsKey(nodeId)) {
      int currLoad = loadMap.get(nodeId);
      currLoad = Math.min(0, currLoad - loadValue);
      this.loadMap.put(nodeId, currLoad);
    } else {
      this.loadMap.put(nodeId, 0);
    }

    return true;
  }
Ejemplo n.º 3
0
  @Override
  public int getLoad(ResourceNode node) throws MonitorException {
    Map<String, String> nodeProperties;
    String nodeId = node.getNodeId();
    nodeProperties = this.locateNode(nodeId);
    if (nodeProperties == null) {
      throw new MonitorException("GangliaMonitor: not tracking requested node: [" + nodeId + "]");
    }

    // calculate load
    double calcLoad = this.loadCalculator.calculateLoad(nodeProperties);
    System.out.println(calcLoad);
    int load = Long.valueOf(Math.round(calcLoad)).intValue();
    System.out.println("LOAD is: " + load);
    return load;
  }
Ejemplo n.º 4
0
 @Override
 public boolean assignLoad(ResourceNode node, int loadValue) throws MonitorException {
   // technically this method should simply do nothing, since
   // putting a job onto a node should cause Ganglia to detect
   // for now we'll simply track what the current perceived load
   // on a node is - we may want to factor this into the weighting
   // in load calculator later
   String nodeId = node.getNodeId();
   if (loadMap.containsKey(nodeId)) {
     int currLoad = loadMap.get(nodeId);
     currLoad += loadValue;
     loadMap.put(nodeId, currLoad);
   } else {
     loadMap.put(nodeId, loadValue);
   }
   return true;
 }
Ejemplo n.º 5
0
 @Override
 public void addNode(ResourceNode node) {
   this.addGmetadNode(node.getIpAddr().getHost(), node.getIpAddr().getPort());
 }