Exemplo n.º 1
0
 @Override
 public void start() {
   super.start();
   manager.start();
   serviceFactory.start();
   daemonConnection.start();
 }
Exemplo n.º 2
0
  @Override
  protected void processRequest(final DaemonRequest request) {
    final GridWorkPacket gridWorkPacket =
        getBaseGridWorkPacket(gridScriptFactory.getApplicationName(wrapperScript));
    final File sgePacketFile =
        new File(getSharedTempDirectory(), queueName + "_" + uniqueId.incrementAndGet());

    try {
      final SgeMessageListener allocatorListener = new SgeMessageListener(request);
      final SgePacket sgePacket =
          new SgePacket(
              serviceFactory.serializeRequest(
                  request.getWorkPacket(), getDaemon().getResponseDispatcher(), allocatorListener),
              daemonConnection.getConnectionName(),
              fileTokenFactory.getDaemonConfigInfo(),
              getDaemonLoggerFactory().getLogFolder());

      writeWorkerAllocatorInputObject(sgePacketFile, sgePacket);

      final List<String> parameters = gridScriptFactory.getParameters(wrapperScript, sgePacketFile);
      gridWorkPacket.setParameters(parameters);

      // Set our own listener to the work packet progress. When the packet returns, the execution
      // will be resumed
      final MyWorkPacketStateListener listener =
          new MyWorkPacketStateListener(request, sgePacketFile, allocatorListener);
      gridWorkPacket.setListener(listener);
      gridWorkPacket.setPriority(request.getWorkPacket().getPriority());
      // Run the job
      final String requestId = manager.passToGridEngine(gridWorkPacket);

      // Report the information about the running task to the caller, making sure they get the task
      // id and the logs
      final AssignedTaskData data = new AssignedTaskData(requestId);

      final RunnerProgressReporter reporter = new RunnerProgressReporter(this, request);

      // Report the assigned ID
      reporter.reportProgress(data);

      final ParentLog log =
          getDaemonLoggerFactory().createLog(request.getWorkPacket().getTaskId(), reporter);

      // Report that we spawned a child with its own SGE log, we use the SGE-based log paths for
      // this
      log.createChildLog(
          gridWorkPacket.getOutputLogFilePath(), gridWorkPacket.getErrorLogFilePath());

      // We are not done yet! The grid work packet's progress listener will get called when the
      // state of the task changes,
      // and either mark the task failed or successful.
    } catch (Exception t) {
      final DaemonException daemonException = processFailedJob(gridWorkPacket, sgePacketFile, t);
      sendResponse(request, daemonException, true);
      throw daemonException;
    }
  }
Exemplo n.º 3
0
 @Override
 public void stop() {
   // Disables message processing
   enabled = false;
   serviceFactory.stop();
   manager.stop();
   super.stop();
   daemonConnection.stop();
 }