org.apache.ignite.internal.util.typedef.F.asSet()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中org.apache.ignite.internal.util.typedef.F.asSet()方法的一些代码示例,展示了F.asSet()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。F.asSet()方法的具体详情如下:
包路径:org.apache.ignite.internal.util.typedef.F
类名称:F
方法名:asSet

F.asSet介绍

暂无

代码示例

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    final Map<Object, Object> res1 = checkAndGetAll(false, cache, F.asSet(key1, key2), SCAN);
    final Map<Object, Object> res2 = checkAndGetAll(false, cache, F.asSet(key1, key2), GET);
    assertEquals(2, res1.size());
    assertEquals(2, res2.size());
    return null;
  }
}, "get");

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
  @Override public Integer call() throws Exception {
    info("Start operation.");
    Set<Integer> keys = F.asSet(1, 2, 3);
    clientCache().getAll(keys);
    info("Stop operation.");
    return null;
  }
});

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    cache.invokeAll(F.asSet("key1"), null);
    return null;
  }
}, NullPointerException.class, null);

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    cache.invokeAll(F.asSet("key1"), null);
    return null;
  }
}, NullPointerException.class, null);

代码示例来源:origin: apache/ignite

@Override public void apply(IgniteCache<Object, Object> cache) {
    cache.getAll(F.asSet(1, 2));
  }
};

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override protected Collection<? extends ComputeJob> split(int gridSize, Void arg) {
  return F.asSet(new ComputeJobAdapter() {
    @TaskSessionResource
    private ComputeTaskSession ses;
    @Override public Object execute() {
      CNT.incrementAndGet();
      if (fail)
        throw new ComputeExecutionRejectedException("Expected error.");
      return ses.getTaskName();
    }
  });
}

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    U.await(getLatch);
    while (!putFut1.isDone() || !putFut2.isDone()) {
      Map<Object, Object> vals1 = checkAndGetAll(false, cache, F.asSet(key1, key2), SCAN);
      Map<Object, Object> vals2 = checkAndGetAll(false, cache, F.asSet(key1, key2), GET);
      assertEquals(2, vals1.size());
      assertEquals(2, vals2.size());
    }
    return null;
  }
}, 4, "get-thread");

代码示例来源:origin: apache/ignite

/**
 * @param wfg Wait-for-graph.
 */
private static void assertAllNull(Map<GridCacheVersion, Set<GridCacheVersion>> wfg, GridCacheVersion... ignore) {
  Set<GridCacheVersion> excl = F.asSet(ignore);
  for (GridCacheVersion tx : ALL) {
    if (!excl.contains(tx))
      assertNull(tx + " could not be part of cycle", findCycle(wfg, tx));
  }
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testClearKeysPartitionedNear() throws Exception {
  testClear(CacheMode.PARTITIONED, true, F.asSet(2, 6, 9));
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testClearKeysReplicated() throws Exception {
  testClear(CacheMode.REPLICATED, false, F.asSet(2, 6, 9));
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testClearKeysPartitioned() throws Exception {
  testClear(CacheMode.PARTITIONED, false, F.asSet(2, 6, 9));
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testClearKeysReplicatedNear() throws Exception {
  testClear(CacheMode.REPLICATED, true, F.asSet(2, 6, 9));
}

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    IgniteCache cache = client.cache(DEFAULT_CACHE_NAME);
    cache.getAll(F.asSet(1, 2, 3));
    return null;
  }
});

代码示例来源:origin: apache/ignite

@Override public Void call() throws Exception {
    try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
      cache.put(1, 3);
      cache.put(2, 3);
      tx.commit();
    }
    // Should see changes mady by both tx1 and tx2.
    Map<Object, Object> res = checkAndGetAll(false, cache, F.asSet(1, 2, 3), SCAN, GET);
    assertEquals(3, res.get(1));
    assertEquals(3, res.get(2));
    assertEquals(2, res.get(3));
    return null;
  }
});

代码示例来源:origin: apache/ignite

/**
 * Sends get atomically and handles fail.
 *
 * @param k Key.
 */
protected void failGetAll(int k) {
  try {
    Set<Object> keys = F.<Object>asSet(new TestKey(String.valueOf(k)));
    jcache(0).getAll(keys);
    assert false : "p2p marshalling failed, but error response was not sent";
  }
  catch (CacheException e) {
    assert X.hasCause(e, IOException.class);
  }
}

代码示例来源:origin: apache/ignite

/**
 * @param cache Cache.
 */
private void checkStoreMap(IgniteCache<Object, Object> cache) {
  cache.put(1, new MyMap());
  cache.put(2, new MyMap());
  MyMap map = (MyMap)cache.get(1);
  assertNotNull(map);
  Map<Integer, MyMap> vals = (Map)cache.getAll(F.asSet(1, 2));
  assertEquals(2, vals.size());
  assertTrue("Unexpected value: " + vals.get(1), vals.get(1) instanceof MyMap);
  assertTrue("Unexpected value: " + vals.get(2), vals.get(2) instanceof MyMap);
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testPutAll() throws Exception {
  client.cachePutAll(DEFAULT_CACHE_NAME, F.asMap("key1", "val1", "key2", "val2"));
  Map<String, String> map = grid().<String, String>cache(DEFAULT_CACHE_NAME).getAll(F.asSet("key1", "key2"));
  assertEquals(2, map.size());
  assertEquals("val1", map.get("key1"));
  assertEquals("val2", map.get("key2"));
  client.cachePutAll(CACHE_NAME, F.asMap("key1", "val1", "key2", "val2"));
  map = grid().<String, String>cache(CACHE_NAME).getAll(F.asSet("key1", "key2"));
  assertEquals(2, map.size());
  assertEquals("val1", map.get("key1"));
  assertEquals("val2", map.get("key2"));
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception In case of error.
 */
@Test
public void testRemoveAllAsync() throws Exception {
  IgniteCache<String, Integer> cache = jcache();
  cache.put("key1", 1);
  cache.put("key2", 2);
  cache.put("key3", 3);
  checkSize(F.asSet("key1", "key2", "key3"));
  assertNull(cache.removeAllAsync(F.asSet("key1", "key2")).get());
  checkSize(F.asSet("key3"));
  checkContainsKey(false, "key1");
  checkContainsKey(false, "key2");
  checkContainsKey(true, "key3");
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception In case of error.
 */
@Test
public void testRemoveAllAsync() throws Exception {
  IgniteCache<String, Integer> cache = jcache();
  cache.put("key1", 1);
  cache.put("key2", 2);
  cache.put("key3", 3);
  checkSize(F.asSet("key1", "key2", "key3"));
  assertNull(cache.removeAllAsync(F.asSet("key1", "key2")).get());
  checkSize(F.asSet("key3"));
  checkContainsKey(false, "key1");
  checkContainsKey(false, "key2");
  checkContainsKey(true, "key3");
}

代码示例来源:origin: apache/ignite

/**
 * @throws Exception In case of error.
 */
@Test
public void testPutAllAsync() throws Exception {
  Map<String, Integer> map = F.asMap("key1", 1, "key2", 2);
  IgniteCache<String, Integer> cache = jcache();
  IgniteFuture<?> f1 = cache.putAllAsync(map);
  map.put("key1", 10);
  map.put("key2", 20);
  IgniteFuture<?> f2 = cache.putAllAsync(map);
  assertNull(f2.get());
  assertNull(f1.get());
  checkSize(F.asSet("key1", "key2"));
  assert cache.get("key1") == 10;
  assert cache.get("key2") == 20;
}

相关文章