コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public <T> T affinityKey() {
   try {
     return (T) job.getDeployment().annotatedValue(job.getJob(), GridCacheAffinityMapped.class);
   } catch (GridException e) {
     throw F.wrap(e);
   }
 }
コード例 #2
0
 /** {@inheritDoc} */
 @Override
 public String cacheName() {
   try {
     return (String) job.getDeployment().annotatedValue(job.getJob(), GridCacheName.class);
   } catch (GridException e) {
     throw F.wrap(e);
   }
 }
コード例 #3
0
  /** {@inheritDoc} */
  @Override
  public boolean heldcc() {
    if (ctx == null) return false;

    if (job == null) job = ctx.job().activeJob(jobId);

    return job != null && job.held();
  }
コード例 #4
0
  /** {@inheritDoc} */
  @Override
  public void callcc() {
    if (ctx != null) {
      if (job == null) job = ctx.job().activeJob(jobId);

      if (job != null)
        // Execute in the same thread.
        job.execute();
    }
  }
コード例 #5
0
  /** {@inheritDoc} */
  @Override
  public <T> T holdcc(long timeout) {
    if (ctx != null) {
      if (job == null) job = ctx.job().activeJob(jobId);

      // Completed?
      if (job != null) {
        if (timeout > 0 && !job.isDone()) {
          final long endTime = System.currentTimeMillis() + timeout;

          // Overflow.
          if (endTime > 0) {
            ctx.timeout()
                .addTimeoutObject(
                    new GridTimeoutObject() {
                      private final GridUuid id = GridUuid.randomUuid();

                      @Override
                      public GridUuid timeoutId() {
                        return id;
                      }

                      @Override
                      public long endTime() {
                        return endTime;
                      }

                      @Override
                      public void onTimeout() {
                        callcc();
                      }
                    });
          }
        }

        job.hold();
      }
    }

    return null;
  }