本文整理汇总了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();
}
示例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);
}
}
示例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())
);
}
示例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())
);
}
示例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())
);
}
示例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);
}
示例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));
}
示例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));
}