Пример #1
0
  /**
   * Sends the planner metrics to the metrics server
   *
   * @param metrics the metrics to log
   * @param url the url to send the metrics to
   */
  private void sendMetricsSynchronously(PlannerMetrics metrics, String url) throws IOException {

    SendMetrics sm = new SendMetrics(metrics, url);

    SendMetricsResult result = sm.call();

    if (result.getCode() == 202) {
      mLogger.log("Metrics succesfully sent to the server", LogManager.DEBUG_MESSAGE_LEVEL);
    } else {
      mLogger.log("Unable to send metrics to the server " + result, LogManager.DEBUG_MESSAGE_LEVEL);
    }
  }
Пример #2
0
  /**
   * Sends the planner metrics to the metrics server asynchrnously with a timeout of 5 seconds
   *
   * @param metrics the metrics to log
   * @param url the url to send the metrics to
   */
  private void sendMetricsAsynchronously(PlannerMetrics metrics, String url) {

    ExecutorService executor = Executors.newSingleThreadExecutor();
    //      Future<SendMetricsResult> future =   (Future<SendMetricsResult>) executor.submit(
    //                                                           new FutureTask<SendMetricsResult>(
    // new SendMetrics( metrics, url ) ));

    Future<SendMetricsResult> future =
        (Future<SendMetricsResult>) executor.submit(new SendMetrics(metrics, url));

    SendMetricsResult result = null;
    try {
      result = future.get(METRICS_SEND_TIMEOUT, TimeUnit.SECONDS);

    } catch (InterruptedException ex) {
      mLogger.log("Interrupted while sending metrics " + url, ex, LogManager.DEBUG_MESSAGE_LEVEL);
    } catch (ExecutionException ex) {
      mLogger.log(
          "Exception caught while sending metrics to server " + url,
          ex,
          LogManager.DEBUG_MESSAGE_LEVEL);
    } catch (TimeoutException e) {
      mLogger.log(
          "Sending of metrics to server timed out " + url, e, LogManager.DEBUG_MESSAGE_LEVEL);
    } finally {
      executor.shutdownNow();
    }

    if (result != null) {
      if (result.getCode() == 202) {
        mLogger.log("Metrics succesfully sent to the server", LogManager.DEBUG_MESSAGE_LEVEL);
      } else {
        mLogger.log(
            "Unable to send metrics to the server " + result, LogManager.DEBUG_MESSAGE_LEVEL);
      }
    }
  }
Пример #3
0
  /**
   * It returns profile information associated with a particular namespace and pool.
   *
   * @param siteID the name of the site, whose profile information you want.
   * @param namespace the namespace correspoinding to which the profile information of a particular
   *     site is desired.
   * @return List of <code>Profile</code> objects NULL when the information about the site is not
   *     there or no profile information associated with the site.
   * @see org.griphyn.cPlanner.classes.Profile
   */
  public List getPoolProfile(String siteID, String namespace) {
    logMessage("List getPoolProfile(String siteID, String namespace");
    logMessage("\tList getPoolProfile(" + siteID + "," + namespace + ")");
    List profileList = null;
    ArrayList namespList = null;
    // sanity checks
    if (siteID == null || namespace == null || namespace.length() < 2) {
      return null;
    }

    // check if the namespace asked for
    // is a valid namespace or not
    if (!Namespace.isNamespaceValid(namespace)) {
      mLogger.log(
          "Namespace " + namespace + " not suppored. Ignoring", LogManager.WARNING_MESSAGE_LEVEL);
      return null;
    }

    // get information about all the profiles
    profileList = this.getPoolProfile(siteID);

    if (profileList == null) {
      return profileList;
    }

    // iterate through the list and add to the namespace list
    Iterator it = profileList.iterator();
    namespList = new ArrayList(3);
    Profile poolPf = null;
    while (it.hasNext()) {
      poolPf = (Profile) it.next();
      if (poolPf.getProfileNamespace().equalsIgnoreCase(namespace)) {
        namespList.add(poolPf);
      }
    }

    if (namespList.isEmpty()) {
      namespList = null;
    }
    return namespList;
  }
Пример #4
0
  /**
   * Logs the metrics to the metrics server and to the submit directory
   *
   * @param metrics
   * @throws IOException
   */
  public void logMetrics(PlannerMetrics metrics) throws IOException {
    // lets write out to the local file
    this.writeOutMetricsFile(metrics);

    if (this.mSendMetricsToServer) {
      int count = mMetricsServers.size();
      int i = 1;
      for (String url : mMetricsServers) {
        StringBuffer message = new StringBuffer();
        message
            .append("Sending Planner Metrics to [")
            .append(i)
            .append(" of ")
            .append(count)
            .append("] ")
            .append(url);
        mLogger.log(message.toString(), LogManager.DEBUG_MESSAGE_LEVEL);
        sendMetricsAsynchronously(metrics, url);
        i++;
      }
    }
  }
Пример #5
0
  /**
   * An adapter method that converts the <code>SiteInfo</code> object to <code>SiteCatalogEntry
   * </code> object.
   *
   * @param s <code>SiteInfo</code> to be converted.
   * @param logger the hande to the LogManager
   * @return the converted <code>SiteCatalogEntry</code> object.
   */
  public static SiteCatalogEntry convert(SiteInfo s, LogManager logger) {
    SiteCatalogEntry3 site = new SiteCatalogEntry3();

    /* set the handle */
    site.setSiteHandle((String) s.getInfo(SiteInfo.HANDLE));

    VDSSysInfo sysinfo = (VDSSysInfo) s.getInfo(SiteInfo.SYSINFO);
    if (sysinfo != null) {
      site.setVDSSysInfo(sysinfo);
    }

    // describe the head node filesystem
    HeadNodeFS hfs = new HeadNodeFS();

    /* set the work directory as shared scratch */
    HeadNodeScratch hscratch = new HeadNodeScratch();
    SharedDirectory hscratchShared = new SharedDirectory();
    String workDir = s.getExecMountPoint();
    for (Iterator it = ((List) s.getInfo(SiteInfo.GRIDFTP)).iterator(); it.hasNext(); ) {
      GridFTPServer g = (GridFTPServer) it.next();
      hscratchShared.addFileServer(
          new FileServer("gsiftp", (String) g.getInfo(GridFTPServer.GRIDFTP_URL), workDir));
    }
    hscratchShared.setInternalMountPoint(new InternalMountPoint(workDir));
    hscratch.setSharedDirectory(hscratchShared);
    hfs.setScratch(hscratch);

    /* set the storage directory as shared storage */
    HeadNodeStorage hstorage = new HeadNodeStorage();
    SharedDirectory hstorageShared = new SharedDirectory();
    String storageDir = null;
    for (Iterator it = ((List) s.getInfo(SiteInfo.GRIDFTP)).iterator(); it.hasNext(); ) {
      GridFTPServer g = (GridFTPServer) it.next();
      storageDir = (String) g.getInfo(GridFTPServer.STORAGE_DIR);
      hstorageShared.addFileServer(
          new FileServer("gsiftp", (String) g.getInfo(GridFTPServer.GRIDFTP_URL), storageDir));
    }
    hstorageShared.setInternalMountPoint(new InternalMountPoint(storageDir));
    hstorage.setSharedDirectory(hstorageShared);
    hfs.setStorage(hstorage);

    site.setHeadNodeFS(hfs);

    /* set the storage directory as GridGateways */
    for (Iterator it = ((List) s.getInfo(SiteInfo.JOBMANAGER)).iterator(); it.hasNext(); ) {
      JobManager jm = (JobManager) it.next();
      GridGateway gw = new GridGateway();

      String universe = (String) jm.getInfo(JobManager.UNIVERSE);
      if (universe.equals("vanilla")) {
        gw.setJobType(GridGateway.JOB_TYPE.compute);
      } else if (universe.equals("transfer")) {
        gw.setJobType(GridGateway.JOB_TYPE.auxillary);
      } else {
        throw new RuntimeException(
            "Unknown universe type " + universe + " for site " + site.getSiteHandle());
      }

      String url = (String) jm.getInfo(JobManager.URL);
      gw.setContact(url);

      if (url.endsWith("condor")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.Condor);
      } else if (url.endsWith("fork")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.Fork);
      } else if (url.endsWith("pbs")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.PBS);
      } else if (url.endsWith("lsf")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.LSF);
      } else if (url.endsWith("sge")) {
        gw.setScheduler(GridGateway.SCHEDULER_TYPE.SGE);
      }

      gw.setIdleNodes((String) jm.getInfo(JobManager.IDLE_NODES));
      gw.setTotalNodes((String) jm.getInfo(JobManager.TOTAL_NODES));

      site.addGridGateway(gw);
    }

    /* set the LRC as Replica Catalog */
    for (Iterator it = ((List) s.getInfo(SiteInfo.LRC)).iterator(); it.hasNext(); ) {
      LRC lrc = (LRC) it.next();
      ReplicaCatalog rc = new ReplicaCatalog(lrc.getURL(), "LRC");
      site.addReplicaCatalog(rc);
    }

    /* add Profiles */
    for (Iterator it = ((List) s.getInfo(SiteInfo.PROFILE)).iterator(); it.hasNext(); ) {
      site.addProfile((Profile) it.next());
    }

    // do another conversion.
    SiteCatalogEntry result = Adapter.convert(site);

    logger.log("SiteCatalogEntry object created is " + result, LogManager.DEBUG_MESSAGE_LEVEL);
    return result;
  }