コード例 #1
0
  public void updateForPage(String aName) {
    // KH - we should probably set the instance information as we get the
    // responses, to avoid waiting, then doing it in serial! (not that it's
    // _that_ slow)
    MSiteConfig siteConfig = WOTaskdHandler.siteConfig();
    startReading();
    try {
      aName = ERXStringUtilities.lastPropertyKeyInKeyPath(aName);
      if (siteConfig.hostArray().count() != 0) {
        if (ApplicationsPage.class.getName().endsWith(aName)
            && (siteConfig.applicationArray().count() != 0)) {

          for (Enumeration e = siteConfig.applicationArray().objectEnumerator();
              e.hasMoreElements(); ) {
            MApplication anApp = (MApplication) e.nextElement();
            anApp.setRunningInstancesCount(0);
          }
          NSArray<MHost> hostArray = siteConfig.hostArray();
          getApplicationStatusForHosts(hostArray);
        } else if (AppDetailPage.class.getName().endsWith(aName)) {
          NSArray<MHost> hostArray = siteConfig.hostArray();

          getInstanceStatusForHosts(hostArray);
        } else if (HostsPage.class.getName().endsWith(aName)) {
          NSArray<MHost> hostArray = siteConfig.hostArray();

          getHostStatusForHosts(hostArray);
        }
      }
    } finally {
      endReading();
    }
  }
コード例 #2
0
  public void getApplicationStatusForHosts(NSArray<MHost> hostArray) {

    WOResponse[] responses = sendQueryToWotaskds("APPLICATION", hostArray);

    NSMutableArray errorArray = new NSMutableArray();
    NSDictionary applicationResponseDictionary;
    NSDictionary queryResponseDictionary;
    NSArray responseArray = null;
    NSDictionary responseDictionary = null;
    for (int i = 0; i < responses.length; i++) {
      if ((responses[i] == null) || (responses[i].content() == null)) {
        queryResponseDictionary = emptyResponse;
      } else {
        try {
          queryResponseDictionary =
              (NSDictionary) new _JavaMonitorDecoder().decodeRootObject(responses[i].content());
        } catch (WOXMLException wxe) {
          NSLog.err.appendln(
              "MonitorComponent pageWithName(ApplicationsPage) Error decoding response: "
                  + responses[i].contentString());
          queryResponseDictionary = responseParsingFailed;
        }
      }
      getGlobalErrorFromResponse(queryResponseDictionary, errorArray);

      applicationResponseDictionary =
          (NSDictionary) queryResponseDictionary.valueForKey("queryWotaskdResponse");
      if (applicationResponseDictionary != null) {
        responseArray = (NSArray) applicationResponseDictionary.valueForKey("applicationResponse");
        if (responseArray != null) {
          for (int j = 0; j < responseArray.count(); j++) {
            responseDictionary = (NSDictionary) responseArray.objectAtIndex(j);
            String appName = (String) responseDictionary.valueForKey("name");
            Integer runningInstances = (Integer) responseDictionary.valueForKey("runningInstances");
            MApplication anApplication = siteConfig().applicationWithName(appName);
            if (anApplication != null) {
              anApplication.setRunningInstancesCount(
                  anApplication.runningInstancesCount() + runningInstances.intValue());
            }
          }
        }
      }
    } // for
    if (NSLog.debugLoggingAllowedForLevelAndGroups(
        NSLog.DebugLevelDetailed, NSLog.DebugGroupDeployment))
      NSLog.debug.appendln("##### pageWithName(ApplicationsPage) errors: " + errorArray);
    mySession().addObjectsFromArrayIfAbsentToErrorMessageArray(errorArray);
  }