Пример #1
0
 @Override
 public void add(final K k, final V v, final Handler<AsyncResult<Void>> completionHandler) {
   vertx.executeBlocking(
       () -> {
         map.put(k, HazelcastServerID.convertServerID(v));
         return null;
       },
       completionHandler);
 }
Пример #2
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);
 }
Пример #3
0
 @Override
 public void get(final K k, final Handler<AsyncResult<ChoosableIterable<V>>> resultHandler) {
   ChoosableSet<V> entries = cache.get(k);
   Future<ChoosableIterable<V>> result = Future.future();
   if (entries != null && entries.isInitialised()) {
     result.setResult(entries).setHandler(resultHandler);
   } else {
     vertx.executeBlocking(
         () -> map.get(k),
         (AsyncResult<Collection<V>> res2) -> {
           Future<ChoosableIterable<V>> sresult = Future.future();
           if (res2.succeeded()) {
             Collection<V> entries2 = res2.result();
             ChoosableSet<V> sids;
             if (entries2 != null) {
               sids = new ChoosableSet<>(entries2.size());
               for (V hid : entries2) {
                 sids.add(hid);
               }
             } else {
               sids = new ChoosableSet<>(0);
             }
             ChoosableSet<V> prev = cache.putIfAbsent(k, sids);
             if (prev != null) {
               // Merge them
               prev.merge(sids);
               sids = prev;
             }
             sids.setInitialised();
             sresult.setResult(sids);
           } else {
             sresult.setFailure(result.cause());
           }
           sresult.setHandler(resultHandler);
         });
   }
 }
Пример #4
0
 @Override
 public void remove(final K k, final V v, final Handler<AsyncResult<Boolean>> completionHandler) {
   vertx.executeBlocking(() -> map.remove(k, v), completionHandler);
 }