コード例 #1
0
  /** @throws Exception If failed. */
  public void testSyncCommitRollbackFlags() throws Exception {
    commSpiEnabled = true;

    try {
      GridClientData data = client.data(REPLICATED_ASYNC_CACHE_NAME);

      info("Before put x1");

      data.put("x1", "y1");

      info("Before put x2");

      data.flagsOn(GridClientCacheFlag.SYNC_COMMIT).put("x2", "y2");

      info("Before put x3");

      data.put("x3", "y3");

      info("Before put x4");

      data.flagsOn(GridClientCacheFlag.SYNC_COMMIT).put("x4", "y4");
    } finally {
      commSpiEnabled = false;
    }
  }
コード例 #2
0
  /** @throws Exception If failed. */
  public void testInvalidateFlag() throws Exception {
    GridEx g0 = grid(0);

    GridCache<String, String> cache = g0.cache(PARTITIONED_CACHE_NAME);

    String key = null;

    for (int i = 0; i < 10_000; i++) {
      if (!cache.affinity().isPrimaryOrBackup(g0.localNode(), String.valueOf(i))) {
        key = String.valueOf(i);

        break;
      }
    }

    assertNotNull(key);

    cache.put(key, key); // Create entry in near cache, it is invalidated if INVALIDATE flag is set.

    assertNotNull(cache.peek(key));

    GridClientData d = client.data(PARTITIONED_CACHE_NAME);

    d.flagsOn(GridClientCacheFlag.INVALIDATE).put(key, "zzz");

    for (Grid g : G.allGrids()) {
      cache = g.cache(PARTITIONED_CACHE_NAME);

      if (cache.affinity().isPrimaryOrBackup(g.localNode(), key))
        assertEquals("zzz", cache.peek(key));
      else assertNull(cache.peek(key));
    }
  }