コード例 #1
0
    /** {@inheritDoc} */
    @Override
    public Serializable execute() {
      synchronized (mux) {
        execCnt++;
      }

      if (log.isInfoEnabled()) log.info("Executing job: " + jobCtx.getJobId());

      long now = System.currentTimeMillis();

      while (!isCancelled && now < thresholdTime) {
        synchronized (mux) {
          try {
            mux.wait(thresholdTime - now);
          } catch (InterruptedException ignored) {
            // No-op.
          }
        }

        now = System.currentTimeMillis();
      }

      synchronized (mux) {
        return isCancelled ? 1 : 0;
      }
    }
コード例 #2
0
    /** {@inheritDoc} */
    @Override
    public void spiStart(String gridName) throws IgniteSpiException {
      // Start SPI start stopwatch.
      startStopwatch();

      // Ack start.
      if (log.isInfoEnabled()) log.info(startInfo());
    }
コード例 #3
0
    /** {@inheritDoc} */
    @Override
    public Collection<? extends ComputeJob> split(int gridSize, Serializable arg) {
      if (log.isInfoEnabled())
        log.info("Splitting task [task=" + this + ", gridSize=" + gridSize + ", arg=" + arg + ']');

      Collection<GridCancelTestJob> jobs = new ArrayList<>(SPLIT_COUNT);

      for (int i = 0; i < SPLIT_COUNT; i++) jobs.add(new GridCancelTestJob());

      return jobs;
    }
コード例 #4
0
    /** {@inheritDoc} */
    @Override
    public Object reduce(List<ComputeJobResult> results) {
      if (log.isInfoEnabled())
        log.info("Aggregating job [job=" + this + ", results=" + results + ']');

      int res = 0;

      for (ComputeJobResult result : results) {
        assert result != null;

        if (result.getData() != null) res += (Integer) result.getData();
      }

      return res;
    }
コード例 #5
0
    /** {@inheritDoc} */
    @Override
    public void cancel() {
      synchronized (mux) {
        isCancelled = true;

        cancelCnt++;

        mux.notifyAll();
      }

      log.warning("Job cancelled: " + jobCtx.getJobId());
    }
コード例 #6
0
 /** {@inheritDoc} */
 @Override
 public void spiStop() throws IgniteSpiException {
   // Ack stop.
   if (log.isInfoEnabled()) log.info(stopInfo());
 }