コード例 #1
0
  @Test
  @ClientCompatibleTest
  public void clear() {
    HazelcastInstance hazelcastInstance = createHazelcastInstance();
    IAtomicReference<String> ref = hazelcastInstance.getAtomicReference("clear");

    ref.clear();
    assertNull(ref.get());

    ref.set("foo");
    ref.clear();
    assertNull(ref.get());

    ref.set(null);
    assertNull(ref.get());
  }
コード例 #2
0
  @Override
  public void clearJob(String id) throws Exception {
    if (id == null) {
      log.warn("No job to clear; was null, returning");
      return;
    }

    IAtomicReference<Job> jRef = h.getAtomicReference("job-" + id);
    if (jRef.isNull()) return;
    jRef.clear();
    log.info("Destroyed job ref " + id);
    Job remove = null;
    for (Job j : jobs) {
      if (j.getWorkerId().equals(id)) {
        remove = j;
        break;
      }
    }

    jobs.remove(remove);
  }