コード例 #1
0
ファイル: GLite.java プロジェクト: Elbehery/pegasus
  /**
   * Constructs an error message in case of style mismatch.
   *
   * @param job the job object.
   * @param key the missing key
   */
  protected String missingKeyError(Job job, String key) {
    StringBuffer sb = new StringBuffer();
    sb.append("( ")
        .append("Missing key ")
        .append(key)
        .append(" for job ")
        .append(job.getName())
        .append("with style ")
        .append(STYLE_NAME);

    return sb.toString();
  }
コード例 #2
0
ファイル: GLite.java プロジェクト: Elbehery/pegasus
  /**
   * Constructs the value for remote CE requirements expression for the job .
   *
   * <p>For e.g. the expression in the submit file may look as
   *
   * <pre>
   * +remote_cerequirements = "PROCS==18 && NODES==1 && PRIORITY==10 && WALLTIME==3600
   *   && PASSENV==1 && JOBNAME==\"TEST JOB\" && MYENV ==\"GAURANG=MEHTA,KARAN=VAHI\""
   *
   * </pre>
   *
   * The requirements are generated on the basis of certain profiles associated with the jobs. The
   * following globus profiles if associated with the job are picked up
   *
   * <pre>
   * hostcount    -> NODES
   * xcount       -> PROCS
   * maxwalltime  -> WALLTIME
   * totalmemory  -> TOTAL_MEMORY
   * maxmemory    -> PER_PROCESS_MEMORY
   * </pre>
   *
   * The following condor profiles if associated with the job are picked up
   *
   * <pre>
   * priority  -> PRIORITY
   * </pre>
   *
   * All the env profiles are translated to MYENV
   *
   * @param job
   * @return the value to the expression and it is condor quoted
   * @throws CondorStyleException in case of condor quoting error
   */
  protected String getCERequirementsForJob(Job job) throws CondorStyleException {
    StringBuffer value = new StringBuffer();

    /* append the job name */
    /* job name cannot have - or _ */
    String id = job.getID().replace("-", "");
    id = id.replace("_", "");
    // the jobname in case of pbs can only be 15 characters long
    id = (id.length() > 15) ? id.substring(0, 15) : id;

    // add the jobname so that it appears when we do qstat
    addSubExpression(value, "JOBNAME", id);
    value.append(" && ");

    /* always have PASSENV to true */
    // value.append( " && ");
    addSubExpression(value, "PASSENV", 1);

    /* specifically pass the queue in the requirement since
    some versions dont handle +remote_queue correctly */
    if (job.globusRSL.containsKey("queue")) {
      value.append(" && ");
      addSubExpression(value, "QUEUE", (String) job.globusRSL.get("queue"));
    }

    /* the globus key hostCount is NODES */
    if (job.globusRSL.containsKey("hostcount")) {
      value.append(" && ");
      addSubExpression(value, "NODES", (String) job.globusRSL.get("hostcount"));
    }

    /* the globus key xcount is PROCS */
    if (job.globusRSL.containsKey("xcount")) {
      value.append(" && ");
      addSubExpression(value, "PROCS", (String) job.globusRSL.get("xcount"));
    }

    /* the globus key maxwalltime is WALLTIME */
    if (job.globusRSL.containsKey("maxwalltime")) {
      value.append(" && ");
      addSubExpression(
          value, "WALLTIME", pbsFormattedTimestamp((String) job.globusRSL.get("maxwalltime")));
    }

    /* the globus key maxmemory is PER_PROCESS_MEMORY */
    if (job.globusRSL.containsKey("maxmemory")) {
      value.append(" && ");
      addSubExpression(value, "PER_PROCESS_MEMORY", (String) job.globusRSL.get("maxmemory"));
    }

    /* the globus key totalmemory is TOTAL_MEMORY */
    if (job.globusRSL.containsKey("totalmemory")) {
      value.append(" && ");
      addSubExpression(value, "TOTAL_MEMORY", (String) job.globusRSL.get("totalmemory"));
    }

    /* the condor key priority is PRIORITY */
    if (job.condorVariables.containsKey("priority")) {
      value.append(" && ");
      addSubExpression(
          value, "PRIORITY", Integer.parseInt((String) job.condorVariables.get("priority")));
    }

    /* the pegasus key glite.arguments is EXTRA_ARGUMENTS */
    if (job.vdsNS.containsKey(Pegasus.GLITE_ARGUMENTS_KEY)) {
      value.append(" && ");
      addSubExpression(
          value, "EXTRA_ARGUMENTS", (String) job.vdsNS.get(Pegasus.GLITE_ARGUMENTS_KEY));
    }

    return value.toString();
  }
コード例 #3
0
ファイル: GLite.java プロジェクト: Elbehery/pegasus
  /**
   * Applies the gLite style to the job.
   *
   * @param job the job on which the style needs to be applied.
   * @throws CondorStyleException in case of any error occuring code generation.
   */
  public void apply(Job job) throws CondorStyleException {

    String workdir = job.getDirectory();

    /* universe is always set to grid*/
    job.condorVariables.construct(Condor.UNIVERSE_KEY, Condor.GRID_UNIVERSE);

    /* figure out the remote scheduler. should be specified with the job*/
    if (!job.condorVariables.containsKey(Condor.GRID_RESOURCE_KEY)) {
      throw new CondorStyleException(missingKeyError(job, Condor.GRID_RESOURCE_KEY));
    }

    job.condorVariables.construct(
        GLite.CONDOR_REMOTE_DIRECTORY_KEY, workdir == null ? null : quote(workdir));

    // also set it as an environment variable, since for MPI jobs
    // glite and BLAHP dont honor +remote_iwd and we cannot use kickstart
    // the only way to get it to work is for the wrapper around the mpi
    // executable to a cd to the directory pointed to by this variable.
    if (workdir != null) {
      job.envVariables.construct("_PEGASUS_SCRATCH_DIR", workdir);
    }

    /* transfer_executable does not work with gLite
     * Explicitly set to false */
    // PM-950 looks like it works now. for pegasus lite modes we need
    // the planner to be able to set it to true
    // job.condorVariables.construct( Condor.TRANSFER_EXECUTABLE_KEY, "false" );

    /* retrieve some keys from globus rsl and convert to gLite format */
    if (job.globusRSL.containsKey("queue")) {
      job.condorVariables.construct("batch_queue", (String) job.globusRSL.get("queue"));
    }

    /* convert some condor keys and globus keys to remote ce requirements
    +remote_cerequirements = blah */
    job.condorVariables.construct("+remote_cerequirements", getCERequirementsForJob(job));

    /*
     PM-934 construct environment accordingly
    */
    job.condorVariables.construct(
        GLite.CONDOR_REMOTE_ENVIRONMENT_KEY, mEnvEscape.escape(job.envVariables));
    job.envVariables.reset();

    /* do special handling for jobs scheduled to local site
     * as condor file transfer mechanism does not work
     * Special handling for the JPL cluster */
    if (job.getSiteHandle().equals("local") && job instanceof TransferJob) {
      /* remove the change dir requirments for the
       * third party transfer on local host */
      job.condorVariables.removeKey(GLite.CONDOR_REMOTE_DIRECTORY_KEY);
    }

    /* similar handling for registration jobs */
    if (job.getSiteHandle().equals("local") && job.getJobType() == Job.REPLICA_REG_JOB) {
      /* remove the change dir requirments for the
       * third party transfer on local host */
      job.condorVariables.removeKey(GLite.CONDOR_REMOTE_DIRECTORY_KEY);
    }

    if (job.getSiteHandle().equals("local")) {
      applyCredentialsForLocalExec(job);
    } else {
      applyCredentialsForRemoteExec(job);
    }
  }