예제 #1
0
 protected <K> Iterable<Data> convertToData(Iterable<K> keys) {
   return IterableUtil.map(
       nullToEmpty(keys),
       new IFunction<K, Data>() {
         public Data apply(K key) {
           return toData(key);
         }
       });
 }
  private void updateMapAndRunQuery(final IMap<Object, Value> map, final int runCount) {
    final String name = randomString();
    Predicate<?, ?> predicate = equal("name", name);
    map.put(name, new Value(name, 0));
    map
        .size(); // helper call on nodes to sync partitions.. see issue
                 // github.com/hazelcast/hazelcast/issues/1282

    for (int j = 1; j <= runCount && !interrupted(); j++) {
      Value v = map.get(name);
      v.setIndex(j);
      map.put(name, v);

      sleepMillis(rand.nextInt(100) + 1);

      Collection<Value> values = map.values(predicate);
      assertEquals(1, values.size());
      Value v2 = IterableUtil.getFirst(values, null);
      assertEquals(v, v2);
    }
  }