Example #1
0
  public void run() {
    try {
      this.session.init(contact);
      System.out.println("Session Init success");

      this.session.init(contact);
      System.out.println("Session Init success");

      System.out.println("drmaa_init() failed: Test " + this.type + " failed");
      this.session.exit();

    } catch (AlreadyActiveSessionException e) {
      System.out.println("Succesfully finished test " + this.type);

    } catch (DrmaaException e) {
      System.err.println("drmaa_init() failed: Test " + this.type + " failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }

    try {
      this.session.exit();
    } catch (DrmaaException e) {
      System.err.println("drmaa_exit() failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }
  }
 /**
  * Tear down of test.
  *
  * @throws DrmaaException
  */
 public void tearDown() throws DrmaaException {
   /* the system should be stable enough to call exit() twice */
   try {
     session.exit();
   } catch (NoActiveSessionException ex) {
     // this exception is expected
   } catch (DrmaaException ex) {
     ex.printStackTrace();
   }
 }
 public void test2882Test() throws DrmaaException {
   System.out.println("testIssue2882");
   /* call the underlaying japi_exit() before japi_init() */
   try {
     session.exit();
   } catch (NoActiveSessionException ex) {
     // this exception is expected
   } catch (DrmaaException ex) {
     ex.printStackTrace();
   }
 }
  public static void main(String[] args) {
    SessionFactory factory = SessionFactory.getFactory();
    Session session = factory.getSession();

    try {
      session.init("");
      JobTemplate jt = session.createJobTemplate();
      jt.setRemoteCommand("sleeper.sh");
      jt.setArgs(Collections.singletonList("5"));

      java.util.List ids = session.runBulkJobs(jt, 1, 30, 2);
      java.util.Iterator i = ids.iterator();

      while (i.hasNext()) {
        System.out.println("Your job has been submitted with id " + i.next());
      }

      session.deleteJobTemplate(jt);
      session.exit();
    } catch (DrmaaException e) {
      System.out.println("Error: " + e.getMessage());
    }
  }
Example #5
0
  public void run() {
    Set attributes;
    Iterator attrIterator;

    this.createJob = new CreateSleeperJobTemplate(this.session, this.executable, "5", false);

    try {
      this.session.init(null);
      System.out.println("Session Init success");

      this.jt = this.createJob.getJobTemplate();

      attributes = this.jt.getAttributeNames();

      attrIterator = attributes.iterator();

      while (attrIterator.hasNext()) {
        String attr = (String) attrIterator.next();
        System.out.println(attr);
      }

      System.out.println("Succesfully finished test " + this.type);

    } catch (Exception e) {
      System.err.println("Test " + this.type + " failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }

    try {
      this.session.exit();
    } catch (DrmaaException e) {
      System.err.println("drmaa_exit() failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }
  }
Example #6
0
  public void run() {
    int n = 20;

    this.createJob = new CreateSleeperJobTemplate(this.session, this.executable, "5", false);

    try {
      this.session.init(contact);
      System.out.println("Session Init success");

      this.jt = this.createJob.getJobTemplate();

      for (int i = 0; i < n; i++) {
        this.id = this.session.runJob(this.jt);
        System.out.println("Job successfully submitted ID: " + this.id);
      }

      for (int i = 0; i < n; i++) {
        JobInfo info = this.session.wait(Session.JOB_IDS_SESSION_ANY, Session.TIMEOUT_WAIT_FOREVER);
      }

      System.out.println("Succesfully finished test " + this.type);

    } catch (Exception e) {
      System.err.println("Test " + this.type + " failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }

    try {
      this.session.exit();
    } catch (DrmaaException e) {
      System.err.println("drmaa_exit() failed");
      e.printStackTrace();
      this.stateAllTest = false;
    }
  }
Example #7
0
  public static void master(int numJobs) {
    SessionFactory factory = SessionFactory.getFactory();
    Session session = factory.getSession();
    try {
      session.init("");
      JobTemplate jt = session.createJobTemplate();

      jt.setRemoteCommand("java");
      String home = java.lang.System.getProperty("user.dir");
      jt.setWorkingDirectory(home);
      List<String> jobIds = Lists.newArrayList();
      for (int i = 0; i < numJobs; i++) {
        jt.setErrorPath(":" + home + "/error" + i + ".txt");
        jt.setOutputPath(":" + home + "/out" + i + ".txt");
        jt.setArgs(
            Lists.newArrayList(
                "-Djava.library.path=/opt/uge816/lib/lx-amd64/:/opt/ibm/ILOG/CPLEX_Studio125/cplex/bin/x86-64_sles10_4.1/",
                "-jar",
                home + "/drmaaTest.jar",
                "worker",
                Integer.toString(i)));
        String id = session.runJob(jt);
        System.out.println("Your job has been submitted with id " + id);
      }

      session.deleteJobTemplate(jt);
      session.synchronize(jobIds, Session.TIMEOUT_WAIT_FOREVER, true);
      System.out.println("All jobs finished!");
      session.exit();
      List<String> answers = Lists.newArrayList();
      for (int i = 0; i < numJobs; i++) {
        String ans = "error";
        String jobName = "job" + i + ".txt";
        File file = new File(jobName);
        long msToWait = 2000;
        while (!file.exists()) {
          System.out.println(
              "waiting for file system to show " + jobName + ".  Sleeping " + msToWait + "ms");
          try {
            Thread.sleep(msToWait);
          } catch (InterruptedException e) {
          }
          msToWait = 2 * msToWait;
        }
        if (file.exists()) {
          try {
            BufferedReader reader = new BufferedReader(new FileReader(jobName));
            String firstLine = reader.readLine();
            if (firstLine != null) {
              ans = firstLine;
            }
            reader.close();
          } catch (IOException e) {
            ans = "I/O error";
          }
        }
        answers.add(ans);
      }
      System.out.println("Answers: " + answers);
    } catch (DrmaaException e) {
      System.out.println("Error: " + e.getMessage());
      throw new RuntimeException(e);
    }
  }