当前位置: 首页>>代码示例>>Java>>正文


Java ICompletableFuture.andThen方法代码示例

本文整理汇总了Java中com.hazelcast.core.ICompletableFuture.andThen方法的典型用法代码示例。如果您正苦于以下问题:Java ICompletableFuture.andThen方法的具体用法?Java ICompletableFuture.andThen怎么用?Java ICompletableFuture.andThen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hazelcast.core.ICompletableFuture的用法示例。


在下文中一共展示了ICompletableFuture.andThen方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mapReduce

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
private static Map<String, Long> mapReduce(HazelcastInstance hazelcastInstance)
        throws Exception {

    // Retrieving the JobTracker by name
    JobTracker jobTracker = hazelcastInstance.getJobTracker("default");

    // Creating the KeyValueSource for a Hazelcast IMap
    IMap<String, String> map = hazelcastInstance.getMap("articles");
    KeyValueSource<String, String> source = KeyValueSource.fromMap(map);

    Job<String, String> job = jobTracker.newJob(source);

    // Creating a new Job
    ICompletableFuture<Map<String, Long>> future = job // returned future
            .mapper(new TokenizerMapper())             // adding a mapper
            .combiner(new WordCountCombinerFactory())  // adding a combiner through the factory
            .reducer(new WordCountReducerFactory())    // adding a reducer through the factory
            .submit();                                 // submit the task

    // Attach a callback listener
    future.andThen(buildCallback());

    // Wait and retrieve the result
    return future.get();
}
 
开发者ID:noctarius,项目名称:hz-map-reduce,代码行数:26,代码来源:MapReduceDemo.java

示例2: pushEntry

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void pushEntry(K key, V value) {
    if (storedException.get() != null) {
        throw new RuntimeException("Aborting pushEntry; problems are detected. Please check the cause",
                storedException.get());
    }

    acquirePermit(1);
    try {
        ICompletableFuture<V> future = storeAsync(key, value);
        future.andThen(callback);
    } catch (Exception e) {
        releasePermit(1);

        throw rethrow(e);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:19,代码来源:AbstractAsyncStreamer.java

示例3: executeAsync

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
private <T> void executeAsync(ICompletableFuture<T> future,
                              Handler<AsyncResult<T>> resultHandler) {
    future.andThen(
            new HandlerCallBackAdapter(resultHandler),
            VertxExecutorAdapter.getOrCreate(vertx.getOrCreateContext())
    );
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:8,代码来源:HazelcastInternalAsyncCounter.java

示例4: executeAsync

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
private <T> void executeAsync(ICompletableFuture<T> future,
                            Handler<AsyncResult<T>> resultHandler) {
  future.andThen(
          new HandlerCallBackAdapter(resultHandler),
          VertxExecutorAdapter.getOrCreate(vertx.getOrCreateContext())
  );
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:8,代码来源:HazelcastInternalAsyncMap.java

示例5: executeAsyncVoid

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
private void executeAsyncVoid(ICompletableFuture<Void> future,
                            Handler<AsyncResult<Void>> resultHandler) {
  future.andThen(
          new VoidHandlerCallBackAdapter(resultHandler),
          VertxExecutorAdapter.getOrCreate(vertx.getOrCreateContext())
  );
}
 
开发者ID:vert-x3,项目名称:vertx-hazelcast,代码行数:8,代码来源:HazelcastInternalAsyncMap.java

示例6: timeStep

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
@TimeStep
public void timeStep(ThreadState state) throws Exception {
    if (!state.semaphore.tryAcquire(1, acquireTimeoutMs, TimeUnit.MILLISECONDS)) {
        throw new TestException("Failed to acquire a license from the semaphore within the given timeout");
    }

    String key = keys[state.randomInt(keyCount)];
    ICompletableFuture<String> f = (ICompletableFuture<String>) map.putAsync(key, "");
    f.andThen(state);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:11,代码来源:PutAsyncAndThenTest.java

示例7: write

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
@TimeStep
public void write(ThreadState state, Probe probe, @StartNanos long startNanos) {
    AsyncAtomicLong counter = state.getRandomCounter();
    state.increments++;
    ICompletableFuture<Long> future = counter.asyncIncrementAndGet();
    state.add(future);
    future.andThen(new LongExecutionCallback(probe, startNanos));
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:9,代码来源:AsyncAtomicLongTest.java

示例8: get

import com.hazelcast.core.ICompletableFuture; //导入方法依赖的package包/类
@TimeStep(prob = -1)
public void get(ThreadState state, Probe probe, @StartNanos long startNanos) {
    AsyncAtomicLong counter = state.getRandomCounter();
    ICompletableFuture<Long> future = counter.asyncGet();
    state.add(future);
    future.andThen(new LongExecutionCallback(probe, startNanos));
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:8,代码来源:AsyncAtomicLongTest.java


注:本文中的com.hazelcast.core.ICompletableFuture.andThen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。