@Override
  public final void andThen(ExecutionCallback<V> callback, Executor executor) {
    isNotNull(callback, "callback");
    isNotNull(executor, "executor");

    Object response = registerWaiter(callback, executor);
    if (response != VOID) {
      unblock(callback, executor);
    }
  }
  @Override
  public <SuppliedValue, Result> Result aggregate(
      Supplier<K, V, SuppliedValue> supplier,
      Aggregation<K, SuppliedValue, Result> aggregation,
      JobTracker jobTracker) {

    try {
      Preconditions.isNotNull(jobTracker, "jobTracker");
      KeyValueSource<K, V> keyValueSource = KeyValueSource.fromMultiMap(this);
      Job<K, V> job = jobTracker.newJob(keyValueSource);
      Mapper mapper = aggregation.getMapper(supplier);
      CombinerFactory combinerFactory = aggregation.getCombinerFactory();
      ReducerFactory reducerFactory = aggregation.getReducerFactory();
      Collator collator = aggregation.getCollator();

      MappingJob mappingJob = job.mapper(mapper);
      ReducingSubmittableJob reducingJob;
      if (combinerFactory != null) {
        reducingJob = mappingJob.combiner(combinerFactory).reducer(reducerFactory);
      } else {
        reducingJob = mappingJob.reducer(reducerFactory);
      }

      ICompletableFuture<Result> future = reducingJob.submit(collator);
      return future.get();
    } catch (Exception e) {
      throw new HazelcastException(e);
    }
  }
Exemplo n.º 3
0
 @Override
 public ListenerConfig setImplementation(EventListener implementation) {
   isNotNull(implementation, "implementation");
   this.implementation = toEntryListener(implementation);
   this.className = null;
   return this;
 }
  public String addEntryListener(EntryListener<K, V> listener, boolean includeValue) {
    isNotNull(listener, "listener");
    ClientMessage request = MultiMapAddEntryListenerCodec.encodeRequest(name, includeValue);

    EventHandler<ClientMessage> handler = createHandler(listener, includeValue);
    ClientMessageDecoder responseDecoder =
        new ClientMessageDecoder() {
          @Override
          public <T> T decodeClientMessage(ClientMessage clientMessage) {
            return (T) MultiMapAddEntryListenerCodec.decodeResponse(clientMessage).response;
          }
        };
    return listen(request, handler, responseDecoder);
  }