Package ca.eandb.jdcp.job

Examples of ca.eandb.jdcp.job.TaskDescription


  /* (non-Javadoc)
   * @see ca.eandb.jdcp.remote.JobService#setIdleTime(int)
   */
  public void setIdleTime(int idleSeconds) throws IllegalArgumentException,
      SecurityException {
    idleTask = new TaskDescription(null, 0, idleSeconds);
    if (logger.isInfoEnabled()) {
      logger.info("Idle time set to " + Integer.toString(idleSeconds));
    }
  }
View Full Code Here


          // Wait for idling to complete.
          if (!idleWait()) {
            return; // Monitor signaled worker should cancel.
          }

          TaskDescription taskDesc = service.requestTask();
          UUID jobId = taskDesc.getJobId();
          int taskId = taskDesc.getTaskId();

          if (jobId != null) { // server has a task to perform.

            idleEnd(); // Signal that idling is complete.
            currentJobId = jobId;
            currentTaskId = taskId;
            activeWorkers.add(this);

            this.monitor.notifyStatusChanged("Obtaining task worker...");
            TaskWorker worker;
            try {
              worker = getTaskWorker(jobId);
            } catch (DelegationException e) {
              worker = null;
            } catch (ClassNotFoundException e) {
              service.reportException(jobId, 0, e);
              idle(EXCEPTION_IDLE_SECONDS, EXCEPTION_IDLE_MESSAGE);
              worker = null;
            }

            if (worker == null) {
              this.monitor.notifyStatusChanged("Could not obtain worker...");
              this.monitor.notifyCancelled();
              return;
            }

            this.monitor.notifyStatusChanged("Performing task...");
            ClassLoader loader = worker.getClass().getClassLoader();
            Object results;

            try {
              Object task = taskDesc.getTask().deserialize(loader);
              results = worker.performTask(task, monitor);
            } catch (DelegationException e) {
              results = null;
            } catch (Exception e) {
              service.reportException(jobId, taskId, e);
              idle(EXCEPTION_IDLE_SECONDS, EXCEPTION_IDLE_MESSAGE);
              results = null;
            }

            if (results != null && !monitor.isCancelPending()) {
              this.monitor.notifyStatusChanged("Submitting task results...");
              service.submitTaskResults(jobId, taskId, new Serialized<Object>(results));
            }

          } else { // server has no tasks to perform.

            if (idleBegin()) {
              try {
                int seconds = (Integer) taskDesc.getTask().deserialize();
                this.idle(seconds);
              } catch (ClassNotFoundException e) {
                throw new UnexpectedException(e);
              }
            }
View Full Code Here

TOP

Related Classes of ca.eandb.jdcp.job.TaskDescription

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.