Example #1
0
 public void ping() {
   final List<DaemonConnection> copy;
   synchronized (connectionsLock) {
     copy = Lists.newArrayList(monitoredConnections.keySet());
   }
   for (final DaemonConnection connection : copy) {
     connection.sendWork(new PingWorkPacket(), pingListeners.get(connection));
   }
 }
Example #2
0
 /** Stop monitoring Swift. */
 @Override
 public void stop() {
   synchronized (connectionsLock) {
     if (scheduler != null) {
       clear();
       scheduler.shutdown();
       scheduler = null;
       for (final DaemonConnection connection : monitoredConnections.keySet()) {
         connection.stop();
       }
     }
   }
 }
Example #3
0
 @Override
 public void start() {
   super.start();
   manager.start();
   serviceFactory.start();
   daemonConnection.start();
 }
Example #4
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;
    }
  }
Example #5
0
 @Override
 public void stop() {
   // Disables message processing
   enabled = false;
   serviceFactory.stop();
   manager.stop();
   super.stop();
   daemonConnection.stop();
 }
Example #6
0
 /** Start monitoring Swift. */
 @Override
 public void start() {
   synchronized (connectionsLock) {
     if (!isRunning()) {
       initialize(context.getApplicationConfig());
       for (final DaemonConnection connection : monitoredConnections.keySet()) {
         connection.start();
       }
       if (scheduler == null) {
         scheduler = Executors.newScheduledThreadPool(1);
         scheduler.scheduleAtFixedRate(
             this,
             DaemonStatus.MONITOR_PERIOD_SECONDS,
             DaemonStatus.MONITOR_PERIOD_SECONDS,
             TimeUnit.SECONDS);
       }
     }
   }
 }
Example #7
0
 @Override
 public String toString() {
   return "Grid Daemon Runner for "
       + (daemonConnection == null ? "(null)" : daemonConnection.getConnectionName());
 }