예제 #1
0
  public void execute() {
    // Publish queued LB requests
    pubishLoadBalancerRequests();

    for (Iterator it = healthMonitorRequests.getAddedCollection().iterator(); it.hasNext(); ) {
      HealthMonitorRequest hsm = (HealthMonitorRequest) it.next();
      if (hsm.getRequestType() == HealthMonitorRequest.LOAD_BALANCE) {
        doLoadBalance();
      }
    }

    for (Iterator it = loadBalanceRequests.getChangedCollection().iterator(); it.hasNext(); ) {
      LoadBalanceRequest lbr = (LoadBalanceRequest) it.next();
      if (lbr.isResult()) {
        CougaarSociety society = lbr.getCougaarSociety();
        if (society != null) {
          if (logger.isDebugEnabled()) {
            logger.debug("LoadBalancer result: \n" + society.toXML());
          }
          Map layout = layoutFromSociety(society);
          if (lbr instanceof UniqueLoadBalanceRequest) {
            UniqueLoadBalanceRequest ulbr = (UniqueLoadBalanceRequest) lbr;
            LoadBalancerListener listener = (LoadBalancerListener) myRequests.remove(ulbr.getUID());
            if (listener != null) {
              listener.layoutReady(layout);
            }
          }
        }
      }
    }
  }
예제 #2
0
 private Map layoutFromSociety(CougaarSociety newSociety) {
   Map layout = new HashMap();
   String society = controller.getCompleteStatus();
   int index = society.indexOf("<community name=");
   index = society.indexOf("\"", index);
   String comm = society.substring(index + 1, society.indexOf("\"", index + 1));
   for (Iterator it = newSociety.getNodes(); it.hasNext(); ) {
     CougaarNode node = (CougaarNode) it.next();
     for (Iterator ait = node.getAgents(); ait.hasNext(); ) {
       CougaarAgent agent = (CougaarAgent) ait.next();
       layout.put(agent.getName(), node.getName());
     }
   }
   return layout;
 }