Пример #1
0
  @Test
  public void testRemove_whenKeyNotExist() {
    final MultiMap mm = client.getMultiMap(randomString());
    Collection coll = mm.remove("NOT_THERE");

    assertEquals(Collections.EMPTY_SET, coll);
  }
 @Test
 public void removeFromMultiMap() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, Integer> multiMap = hClient.getMultiMap("removeFromMultiMap");
   assertTrue(multiMap.put("a", 1));
   assertTrue(multiMap.remove("a", 1));
 }
Пример #3
0
  @Test
  public void testRemoveValue_whenValueNotExists() {
    final Object key = "key";
    final int maxItemsPerKey = 4;
    final MultiMap mm = client.getMultiMap(randomString());

    for (int i = 0; i < maxItemsPerKey; i++) {
      mm.put(key, i);
    }
    boolean result = mm.remove(key, "NOT_THERE");

    assertFalse(result);
  }
Пример #4
0
 @Override
 public void removeAllForValue(final V val, final Handler<AsyncResult<Void>> completionHandler) {
   vertx.executeBlocking(
       () -> {
         for (Map.Entry<K, V> entry : map.entrySet()) {
           V v = entry.getValue();
           if (val.equals(v)) {
             map.remove(entry.getKey(), v);
           }
         }
         return null;
       },
       completionHandler);
 }
Пример #5
0
  @Test
  public void testRemoveKeyValue() {
    final Object key = "key";
    final int maxItemsPerKey = 4;
    final MultiMap mm = client.getMultiMap(randomString());

    for (int i = 0; i < maxItemsPerKey; i++) {
      mm.put(key, i);
    }

    for (int i = 0; i < maxItemsPerKey; i++) {
      boolean result = mm.remove(key, i);
      assertTrue(result);
    }
  }
 @Test
 public void testMultiMapRemoveEntries() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapRemoveEntries");
   map.put("Hello", "World");
   map.put("Hello", "Europe");
   map.put("Hello", "America");
   map.put("Hello", "Asia");
   map.put("Hello", "Africa");
   map.put("Hello", "Antartica");
   map.put("Hello", "Australia");
   boolean removed = map.remove("Hello", "World");
   assertTrue(removed);
   assertEquals(6, map.size());
 }
Пример #7
0
  @Test
  public void testRemoveKey() {
    final Object key = "key";
    final int maxItemsPerKey = 44;
    final MultiMap mm = client.getMultiMap(randomString());

    Set expeted = new TreeSet();
    for (int i = 0; i < maxItemsPerKey; i++) {
      mm.put(key, i);
      expeted.add(i);
    }
    Set resultSet = new TreeSet(mm.remove(key));

    assertEquals(expeted, resultSet);
    assertEquals(0, mm.size());
  }
 @Test
 public void removeKey() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, Integer> multiMap = hClient.getMultiMap("removeKey");
   assertTrue(multiMap.put("a", 1));
   assertTrue(multiMap.put("a", 2));
   Map<Integer, CountDownLatch> map = new HashMap<Integer, CountDownLatch>();
   map.put(1, new CountDownLatch(1));
   map.put(2, new CountDownLatch(1));
   Collection<Integer> collection = multiMap.remove("a");
   assertEquals(Values.class, collection.getClass());
   assertEquals(2, collection.size());
   for (Iterator<Integer> it = collection.iterator(); it.hasNext(); ) {
     Object o = it.next();
     map.get((Integer) o).countDown();
   }
   assertTrue(map.get(1).await(10, TimeUnit.SECONDS));
   assertTrue(map.get(2).await(10, TimeUnit.SECONDS));
 }
 @Test
 public void testMultiMapRemove() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapRemove");
   map.put("Hello", "World");
   map.put("Hello", "Europe");
   map.put("Hello", "America");
   map.put("Hello", "Asia");
   map.put("Hello", "Africa");
   map.put("Hello", "Antarctica");
   map.put("Hello", "Australia");
   assertEquals(7, map.size());
   assertEquals(1, map.keySet().size());
   Collection<String> values = map.remove("Hello");
   assertEquals(7, values.size());
   assertEquals(0, map.size());
   assertEquals(0, map.keySet().size());
   map.put("Hello", "World");
   assertEquals(1, map.size());
   assertEquals(1, map.keySet().size());
 }
 @Test
 public void testTransactionAtomicity_whenMultiMapValueCountIsUsed_withoutTransaction()
     throws InterruptedException {
   final HazelcastInstance hz = Hazelcast.newHazelcastInstance(createConfigWithDummyTxService());
   final String name = HazelcastTestSupport.generateRandomString(5);
   Thread producerThread = startProducerThread(hz, name);
   try {
     IQueue<String> q = hz.getQueue(name);
     for (int i = 0; i < 1000; i++) {
       String id = q.poll();
       if (id != null) {
         MultiMap<Object, Object> multiMap = hz.getMultiMap(name);
         assertEquals(1, multiMap.valueCount(id));
         multiMap.remove(id);
       } else {
         LockSupport.parkNanos(100);
       }
     }
   } finally {
     stopProducerThread(producerThread);
   }
 }
Пример #11
0
 @Override
 public void remove(final K k, final V v, final Handler<AsyncResult<Boolean>> completionHandler) {
   vertx.executeBlocking(() -> map.remove(k, v), completionHandler);
 }
 @Override
 public boolean remove(Object key, Object value) {
   return delegate.remove(key, value);
 }
 @Override
 public Collection<V> remove(Object key) {
   return delegate.remove(key);
 }