コード例 #1
0
  /** Get config information about all the entities which an agent is servicing. */
  private MeasurementGetConfigs_result cmdMeasurementGetConfigs(MeasurementGetConfigs_args args)
      throws LatherRemoteException {
    ResourceTree tree;
    AuthzSubject overlord = authzSubjectManager.getOverlordPojo();
    try {
      tree = agentManager.getEntitiesForAgent(overlord, args.getAgentToken());
    } catch (PermissionException exc) {
      throw new SystemException("Overlord unable to get resource " + "tree list");
    } catch (AgentNotFoundException exc) {
      throw new SystemException("Validated an agent which could " + "not be found");
    }
    ArrayList<MeasurementConfigEntity> ents = new ArrayList<MeasurementConfigEntity>();
    for (Iterator<PlatformNode> p = tree.getPlatformIterator(); p.hasNext(); ) {
      PlatformNode pNode = p.next();
      addMeasurementConfig(ents, pNode.getPlatform());
      try {
        AppdefEntityValue aeval =
            new AppdefEntityValue(pNode.getPlatform().getEntityId(), overlord);
        List<AppdefResourceValue> services = aeval.getAssociatedServices(PageControl.PAGE_ALL);
        for (int i = 0; i < services.size(); i++) {
          ServiceValue val = (ServiceValue) services.get(i);

          AppdefEntityID id = val.getEntityId();

          addMeasurementConfig(ents, id, val.getServiceType().getName());
        }
      } catch (Exception e) {
        // Shouldn't happen
        log.error("Encountered exception looking up platform " + "services: " + e.getMessage(), e);
      }

      for (Iterator<ServerNode> s = pNode.getServerIterator(); s.hasNext(); ) {
        ServerNode sNode = s.next();

        addMeasurementConfig(ents, sNode.getServer());

        for (Iterator<ServiceNode> v = sNode.getServiceIterator(); v.hasNext(); ) {
          ServiceNode vNode = v.next();

          addMeasurementConfig(ents, vNode.getService());
        }
      }
    }

    MeasurementConfigList cList = new MeasurementConfigList();
    cList.setEntities(ents.toArray(new MeasurementConfigEntity[ents.size()]));
    MeasurementGetConfigs_result res = new MeasurementGetConfigs_result();
    res.setConfigs(cList);
    return res;
  }