Package net.jini.core.transaction

Examples of net.jini.core.transaction.Transaction


  }

  private void submit()
  {
    try {
      Transaction txn = createTransaction(10 * 1000);
      try {
        JobControlEntry jce = (JobControlEntry)
          space.takeIfExists(controlEntry, txn, JavaSpace.NO_WAIT);
        submit(jce, txn);
      } catch(Exception ex) {
View Full Code Here


  }

  private void destroyJobService()
  {
    try {
      Transaction txn = createTransaction(5 * 1000);
      try {
        JobControlEntry jce = (JobControlEntry)
          space.takeIfExists(killAction,
                             txn, JavaSpace.NO_WAIT);
        jce.jobStatus = JobStatus.KILLED;
        jce.jobAction = JobAction.NONE;
        space.write(jce, txn, Lease.FOREVER);
        //destroyJobService(jce);
      } catch(Exception ex) {
        System.out.println("--RMServer- Deleting job service aborted "
                           + ex);
        txn.abort();
      }
      txn.commit();
    } catch(Exception e) {
      System.out.println("--RMServer- Deleting job service aborted "
                         + e);
    }
  }
View Full Code Here

    throws ApplicationSubmissionException
  {
    if(appParams == null) {
      throw new ApplicationSubmissionException("AppParams is null");
    } else {
      Transaction txn = null;
      try {
        txn = createTransaction(10 * 1000);
        try {
          JobInfo info = new JobInfo(appParams.getName(),
                                     JobType.BATCH,
                                     name, userProperties.getLogin(),
                                     userProperties.getLogin(),
                                     new Random().nextInt());
          JobParams jp = new JobParams(info, -1,
                                       appParams.getScript(),
                                       appParams.getArgs());
          JobControlEntry jce = new JobControlEntry(info,
                                                    JobStatus.UNKNOWN,
                                                    JobAction.QUEUE,
                                                    jobAttr);
          space.write(info, txn, Lease.FOREVER);
          space.write(jp, txn, Lease.FOREVER);
          space.write(jce, txn, Lease.FOREVER);
          //System.out.println("--QueueProxy--: submitting:\n" + info
          //                   +"\n" + jp + "\n"+ jce);
        } catch(Exception ex) {
          txn.abort();
          throw new ApplicationSubmissionException(ex.getMessage());
        }
        txn.commit();
      } catch(Exception e) {
        //e.printStackTrace();
        throw new ApplicationSubmissionException(e.getMessage());
      }
    }
View Full Code Here

  }

  public void restart(JobParams jp)
    throws RemoteException
  {
    Transaction txn = null;
    try {
      txn = createTransaction(10 * 1000);
      JobParams old = (JobParams)
        space.takeIfExists(jpSnapshot, txn, JavaSpace.NO_WAIT);
      if(old == null) {
        txn.abort();
        throw new RemoteException("No JobParams in JavaSpace");
      }
      space.write(jp, txn, Lease.FOREVER);
    } catch(Exception ex) {
      throw new RemoteException(ex.toString());
View Full Code Here

        } catch(NativeSGECommException ncce){
        } catch(NativeSGEException ncrmae) {
          st = JobStatus.COMPLETED;
          terminate();
        }
        Transaction txn = null;
        try {
          txn = createTransaction(5 * 1000);
          JobControlEntry jce =
            (JobControlEntry)space.readIfExists(jControl, null,
                                                JavaSpace.NO_WAIT);
          if((st == null) || (jce == null)) {
            continue;
          }
          if(!st.equals(jce.jobStatus)) {
            jce = (JobControlEntry)
              space.takeIfExists(jControl, txn, JavaSpace.NO_WAIT);
            if(jce == null) {
              if(txn != null)
                txn.abort();
              continue;
            } else {
              jce.jobStatus = st;
              if(jce.jobAction.equals(JobAction.BLOCK)) {
                //To be deleted
                jce.jobAction = JobAction.NONE;
              }
              if(jce.jobStatus.equals(JobStatus.STOPPED)) {
                terminate();
              }
            }
            space.write(jce, txn, Lease.FOREVER);
          }
          if(txn != null)
            txn.commit();
        } catch(Exception e) {
//            if(txn != null)
//              txn.abort();
          e.printStackTrace();
        }
View Full Code Here

  }

  private void changeJobState(Entry entry)
  {
    JobControlEntry jce;
    Transaction txn;
    try {
      txn = createTransaction(5 * 1000);
      jce = (JobControlEntry)
        space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
      JobStat stat = null;
      try {
        switch(jce.jobAction.intValue()) {
         
        case JobAction._SUSPEND:
          stat = new JobStat(JobStat.JSUSPENDED,
                             JobStat.JRUNNING);
          break;
         
        case JobAction._RESUME:
          stat = new JobStat(JobStat.JRUNNING,
                             JobStat.JRUNNING);
          break;
         
        default:
          txn.abort();
          return;
        }
      } catch(JobStatException jse) {
        txn.abort();
        return;
      }
      try {
        JobParams jp = (JobParams)
          space.readIfExists(new JobParams(jce.jobInfo),
                             txn, JavaSpace.NO_WAIT);
        if(jp != null) {
          SGEJob jcod = new
            SGEJob(jp.submissionName, jp.submissionID.intValue());
          jce.jobAction = JobAction.BLOCK;
          space.write(jce, txn, Lease.FOREVER);
          nativeSGERMAdapter.changeJobState(jcod, stat);
        }
      } catch(Exception ex) {
        ex.printStackTrace();
        txn.abort();
      }
      txn.commit();
    } catch(Exception e) {
      System.out.println("--RMAdapter--: ChangeJobState failed" + e);
    }
  }
View Full Code Here

  }
 
  private void submit(Entry entry)
  {
    JobControlEntry jce;
    Transaction txn;
    try {
      txn = createTransaction(5 * 1000);
      try {
        jce = (JobControlEntry)
          space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
        JobInfo ji = jce.jobInfo;
        JobParams jp = (JobParams)
          space.takeIfExists(new JobParams(ji),
                     txn, JavaSpace.NO_WAIT);
        if(jp != null) {
          if(jp.submissionID != null) {
            deleteFiles(jp);
          }
          String subName = ji.name.substring(ji.name.lastIndexOf('/') + 1);
          subName = "jam_" + jobCount + "_" + ji.userID + "_" + subName;
          String script = cwd + "/" + subName;
          BufferedWriter writer = new BufferedWriter(new
            FileWriter(script));
          writer.write(jp.script, 0, jp.script.length());
          writer.flush();
          writer.close();
          jp.jobID = new Integer(jobCount);
          jp.input = new URL("file:" + script + ".in");
          jp.output =  new URL("file:" + script + ".out");
          jp.error = new URL("file:" + script + ".err");
          jp.submissionName = subName;
          jp.submissionID = new Integer(nativeSubmission(jp));
          jce.jobAction = JobAction.NONE;
          SingleJobStatusTracer tracer = new
            SingleJobStatusTracer(nativeSGERMAdapter, space,
                                  ji, jp.submissionID.intValue(),
                                  jp.submissionName);
//            SingleJobStatusTracer tracer = new
//              SingleJobStatusTracer(nativeSGERMAdapter, space,
//                                    ji, jp.submissionID.intValue(),
//                                    jp.submissionName, txnMgr);
          tracer.start();
          tracerTable.put(jp.jobID, tracer);
          jobCount++;
          space.write(jp, txn, Lease.FOREVER);
          space.write(jce, txn, Lease.FOREVER);
        }
      } catch(Exception ex) {
        ex.printStackTrace();
        txn.abort();
        return;
      }
      txn.commit();
    } catch(Exception e) {
      System.out.println("-- RMAdapter --:Exception in submitting job: "
                           + jobCount);
      e.printStackTrace();
    }
View Full Code Here

  }

  private void start(Entry entry)
  {
    JobControlEntry jce;
    Transaction txn;
    try {
      txn = createTransaction(5 * 1000);
      try {
        jce = (JobControlEntry)
          space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
        JobParams jp = (JobParams)
          space.readIfExists(new JobParams(jce.jobInfo),
                             txn, JavaSpace.NO_WAIT);
        if(jp != null) {
          SGEJob jcod = new SGEJob(jp.submissionName,
                                         jp.submissionID.intValue());
          nativeSGERMAdapter.unHold(jcod);
          jce.jobAction = JobAction.BLOCK;
          space.write(jce, txn, Lease.FOREVER);
        }
      } catch(Exception ex) {
        ex.printStackTrace();
        txn.abort();
        return;
      }
      txn.commit();
    } catch(Exception e) {
      System.out.println("--RMAdapter: ChangeJobState failed" + e);
      e.printStackTrace();
    }
  }
View Full Code Here

  }

  private void delete(Entry entry)
  {
    JobControlEntry jce;
    Transaction txn;
    try {
      txn = createTransaction(5 * 1000);
      try {
        jce = (JobControlEntry)
          space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
        JobParams jp = (JobParams)
          space.readIfExists(new JobParams(jce.jobInfo),
                             txn, JavaSpace.NO_WAIT);
        if(jp != null) {
          SGEJob jcod = new SGEJob(jp.submissionName,
                                         jp.submissionID.intValue());
          nativeSGERMAdapter.deleteJob(jcod);
          jce.jobAction = JobAction.BLOCK;
          space.write(jce, txn, Lease.FOREVER);
        }
      } catch(Exception ex) {
        ex.printStackTrace();
        txn.abort();
        return;
      }
      txn.commit();
    } catch(Exception e) {
      System.out.println("--RMAdapter: ChangeJobState failed" + e);
      e.printStackTrace();
    }
  }
View Full Code Here

  }

  private void cleanJobResource(Entry entry)
  {
    JobControlEntry jce;
    Transaction txn;
    try {
      txn = createTransaction(5 * 1000);
      try {
        jce = (JobControlEntry)
          space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
        if(jce != null && jce.jobInfo != null) {
          JobParams jp = (JobParams)
            space.takeIfExists(new JobParams(jce.jobInfo),
                               txn, JavaSpace.NO_WAIT);
          if(jp != null) {
            new File(jp.output.getFile()).delete();
            new File(jp.error.getFile()).delete();
            new File(cwd + "//" + jp.submissionName).delete();
            SingleJobStatusTracer tr = (SingleJobStatusTracer)
              tracerTable.remove(jp.jobID);
            if(tr != null) {
              tr.terminate();
            }
            SGEJob codJob = new SGEJob(jp.submissionName,
                                             jp.submissionID.intValue());
            try {
              nativeSGERMAdapter.deleteJob(codJob);
            } catch(NativeSGECommException ncce) {
            } catch(NativeSGEException ncrmae) {
            }
            space.takeIfExists(jce.jobInfo,
                               txn, JavaSpace.NO_WAIT);
          } else{
            System.out.println("--RMAdapter: Killing aborted JP is null");
            space.write(jce, txn, Lease.FOREVER);
            txn.commit();
            return;
          }
        } else {
          System.out.println("--RMAdapter--: Killing aborted JCE is null");
          txn.abort();
          return;
        }
      } catch(Exception ex) {
        ex.printStackTrace();
        txn.abort();
        return;
      }
      txn.commit();
    } catch(Exception ex) {
      ex.printStackTrace();
    }
  }
View Full Code Here

TOP

Related Classes of net.jini.core.transaction.Transaction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.