• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExecutionCallback类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ExecutionCallback类属于com.hazelcast.core包,在下文中一共展示了ExecutionCallback类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendMessage

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
/**
 * Send internal message to hazelcast ring
 *
 * @param ring    Hazelcast RingBuffer
 * @param message Internal Message
 */
protected void sendMessage(Ringbuffer<InternalMessage> ring, InternalMessage message) {
    ring.addAsync(message, OverflowPolicy.OVERWRITE).andThen(new ExecutionCallback<Long>() {
        @Override
        public void onResponse(Long response) {
            if (response > 0) {
                logger.debug("Communicator succeed: Successful add message {} to ring buffer {}", message.getMessageType(), ring.getName());
            } else {
                logger.debug("Communicator failed: Failed to add message {} to ring buffer {}: no space", message.getMessageType(), ring.getName());
            }
        }

        @Override
        public void onFailure(Throwable t) {
            logger.warn("Communicator failed: Failed to add message {} to ring buffer {}: ", message.getMessageType(), ring.getName(), t);
        }
    });
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:24,代码来源:HazelcastApplicationCommunicator.java


示例2: main

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    IExecutorService executor = hz.getExecutorService("executor");
    ExecutionCallback<Long> executionCallback = new ExecutionCallback<Long>() {
        public void onFailure(Throwable t) {
            t.printStackTrace();
        }

        public void onResponse(Long response) {
            System.out.println("Result: " + response);
        }
    };
    executor.submit(new FibonacciCallable(10), executionCallback);
    System.out.println("Fibonacci task submitted");
}
 
开发者ID:gAmUssA,项目名称:jpoint-2016-computing-talk,代码行数:16,代码来源:MasterMember.java


示例3: accept

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Override
public void accept(Command command, CompletableFuture<CommandResult> commandResultCompletableFuture) {
    executorService.submitToKeyOwner(
            RemoteCommand.processing(command),
            command.getAggregateId().getId(),
            new ExecutionCallback<CommandResult>() {
        @Override
        public void onResponse(CommandResult commandResult) {
            commandResultCompletableFuture.complete(commandResult);
        }

        @Override
        public void onFailure(Throwable throwable) {
            commandResultCompletableFuture.completeExceptionally(throwable);
        }
    });
}
 
开发者ID:opencredo,项目名称:concursus,代码行数:18,代码来源:HazelcastCommandExecutor.java


示例4: testAwait_withExceptionInFuture

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Test(timeout = DEFAULT_TIMEOUT, expected = IllegalArgumentException.class)
@SuppressWarnings("unchecked")
public void testAwait_withExceptionInFuture() {
    when(map.putAsync(anyInt(), anyString())).thenReturn(future);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            ExecutionCallback<String> callback = (ExecutionCallback<String>) arguments[0];

            Exception exception = new IllegalArgumentException("expected exception");
            callback.onFailure(exception);
            return null;
        }
    }).when(future).andThen(any(ExecutionCallback.class));

    streamer.pushEntry(1, "value");
    streamer.await();
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:20,代码来源:AsyncMapStreamerTest.java


示例5: testAwait_withExceptionInFuture

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Test(timeout = DEFAULT_TIMEOUT, expected = IllegalArgumentException.class)
@SuppressWarnings("unchecked")
public void testAwait_withExceptionInFuture() {
    when(cache.putAsync(anyInt(), anyString())).thenReturn(future);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            ExecutionCallback<String> callback = (ExecutionCallback<String>) arguments[0];

            Exception exception = new IllegalArgumentException("expected exception");
            callback.onFailure(exception);
            return null;
        }
    }).when(future).andThen(any(ExecutionCallback.class));

    streamer.pushEntry(1, "value");
    streamer.await();
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:20,代码来源:AsyncCacheStreamerTest.java


示例6: submitToKey

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @deprecated not implemented yet
 * @throws UnsupportedOperationException not implemented yet
 */
@Deprecated
@SuppressWarnings("rawtypes")
@Override
public void submitToKey(K key, EntryProcessor entryProcessor,
        ExecutionCallback callback) {
    throw new UnsupportedOperationException();
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:14,代码来源:SMap.java


示例7: andThen

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Override
public void andThen(ExecutionCallback<Void> callback) {
    future.andThen(new ExecutionCallback<T>() {
        @Override
        public void onResponse(T response) {
            callback.onResponse(null);
        }

        @Override
        public void onFailure(Throwable t) {
            callback.onFailure(t);
        }
    });
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:15,代码来源:ClientJobProxy.java


示例8: invokeStartExecution

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
private void invokeStartExecution() {
    jobStatus.set(RUNNING);
    logger.fine("Executing " + jobIdString());

    long executionId = this.executionId;

    AtomicBoolean cancellation = new AtomicBoolean();
    ExecutionCallback<Object> callback = new ExecutionCallback<Object>() {
        @Override
        public void onResponse(Object response) {
        }

        @Override
        public void onFailure(Throwable t) {
            if (cancellation.compareAndSet(false, true)) {
                cancelExecute(jobId, executionId);
            }
        }
    };

    cancellationFuture.whenComplete(withTryCatch(logger, (r, e) -> {
        if (e instanceof CancellationException) {
            callback.onFailure(e);
        }
    }));

    Function<ExecutionPlan, Operation> operationCtor = plan -> new StartExecutionOperation(jobId, executionId);
    invoke(operationCtor, this::onExecuteStepCompleted, callback);

    if (isSnapshottingEnabled()) {
        coordinationService.scheduleSnapshot(jobId, executionId);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:34,代码来源:MasterContext.java


示例9: callbackOf

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
/**
 * This method will generate an {@link ExecutionCallback} which
 * allows to asynchronously get notified when the execution is completed,
 * either successfully or with error by calling {@code onResponse} on success
 * and {@code onError} on error respectively.
 *
 * @param onResponse function to call when execution is completed successfully
 * @param onError function to call when execution is completed with error
 * @param <T> type of the response
 * @return {@link ExecutionCallback}
 */
public static <T> ExecutionCallback<T> callbackOf(Consumer<T> onResponse, Consumer<Throwable> onError) {
    return new ExecutionCallback<T>() {
        @Override
        public void onResponse(T o) {
            onResponse.accept(o);
        }

        @Override
        public void onFailure(Throwable throwable) {
            onError.accept(throwable);
        }
    };
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:25,代码来源:Util.java


示例10: invokeAsync

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
private <T extends Serializable> CompletableFuture<CommandResult<T>> invokeAsync(K key, JCacheEntryProcessor<K, T> entryProcessor) {
    CompletableFuture<CommandResult<T>> future = new CompletableFuture<>();
    cache.submitToKey(key, adoptEntryProcessor(entryProcessor), new ExecutionCallback() {
        @Override
        public void onResponse(Object response) {
            future.complete((CommandResult<T>) response);
        }

        @Override
        public void onFailure(Throwable t) {
            future.completeExceptionally(t);
        }
    });
    return future;
}
 
开发者ID:vladimir-bukhtoyarov,项目名称:bucket4j,代码行数:16,代码来源:HazelcastProxy.java


示例11: buildCallback

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
private static ExecutionCallback<Map<String, Long>> buildCallback() {
    return new ExecutionCallback<Map<String, Long>>() {
        @Override
        public void onResponse(Map<String, Long> stringLongMap) {
            System.out.println("Calculation finished! :)");
        }

        @Override
        public void onFailure(Throwable throwable) {
            throwable.printStackTrace();
        }
    };
}
 
开发者ID:noctarius,项目名称:hz-map-reduce,代码行数:14,代码来源:MapReduceDemo.java


示例12: testAwait

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Test(timeout = DEFAULT_TIMEOUT)
@SuppressWarnings("unchecked")
public void testAwait() {
    when(map.putAsync(anyInt(), anyString())).thenReturn(future);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            ExecutionCallback<String> callback = (ExecutionCallback<String>) arguments[0];

            callback.onResponse("value");
            return null;
        }
    }).when(future).andThen(any(ExecutionCallback.class));

    Thread thread = new Thread() {
        @Override
        public void run() {
            for (int i = 0; i < 5000; i++) {
                streamer.pushEntry(i, "value");
            }
        }
    };
    thread.start();

    streamer.await();
    joinThread(thread);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:29,代码来源:AsyncMapStreamerTest.java


示例13: testAwait

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Test(timeout = DEFAULT_TIMEOUT)
@SuppressWarnings("unchecked")
public void testAwait() {
    when(cache.putAsync(anyInt(), anyString())).thenReturn(future);
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Object[] arguments = invocation.getArguments();
            ExecutionCallback<String> callback = (ExecutionCallback<String>) arguments[0];

            callback.onResponse("value");
            return null;
        }
    }).when(future).andThen(any(ExecutionCallback.class));

    Thread thread = new Thread() {
        @Override
        public void run() {
            for (int i = 0; i < 5000; i++) {
                streamer.pushEntry(i, "value");
            }
        }
    };
    thread.start();

    streamer.await();
    joinThread(thread);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:29,代码来源:AsyncCacheStreamerTest.java


示例14: main

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
public static void main(String[] args)
    throws Exception {

    // Prepare Hazelcast cluster
    HazelcastInstance hazelcastInstance = buildCluster(3);

    try {

        // Read data
        fillMapWithData(hazelcastInstance);

        JobTracker tracker = hazelcastInstance.getJobTracker(TRACKER_NAME);

        IMap<String, String> map = hazelcastInstance.getMap(MAP_NAME);
        KeyValueSource<String, String> source = KeyValueSource.fromMap(map);

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

        final JobCompletableFuture<List<Map.Entry<String, Integer>>> future = job
            .mapper(new TokenizerMapper())
            // Activate Combiner to add combining phase!
            // .combiner(new WordcountCombinerFactory())
            .reducer(new WordcountReducerFactory())
            //                .submit();
            // add collator for sorting and top10
            .submit(new WordcountCollator());

        future.andThen(new ExecutionCallback<List<Map.Entry<String, Integer>>>() {
            @Override public void onResponse(List<Map.Entry<String, Integer>> response) {
                System.out.println(ToStringPrettyfier.toString(response));
            }

            @Override public void onFailure(Throwable t) {

            }
        });

        //System.out.println(ToStringPrettyfier.toString(future.get()));

    } finally {
        // Shutdown cluster
        //Hazelcast.shutdownAll();
    }
}
 
开发者ID:gAmUssA,项目名称:jpoint-2016-computing-talk,代码行数:45,代码来源:WordCountExample.java


示例15: submitToKey

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Override
public void submitToKey(K key, EntryProcessor entryProcessor, ExecutionCallback callback) {
    map.submitToKey(key, entryProcessor, callback);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:5,代码来源:MapDecorator.java


示例16: andThen

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Override
public void andThen(ExecutionCallback<Object> executionCallback) {
    executionCallback.onResponse(null);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:5,代码来源:TestContainer_TimeStep_AsyncSupportTest.java


示例17: submitToKey

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
@Override
public void submitToKey(Object key, EntryProcessor entryProcessor, ExecutionCallback callback) {

}
 
开发者ID:gurbuzali,项目名称:hazel-local-cache,代码行数:5,代码来源:LocalCacheProxy.java


示例18: getExecutionCallback

import com.hazelcast.core.ExecutionCallback; //导入依赖的package包/类
ExecutionCallback<V> getExecutionCallback(); 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:2,代码来源:InnerFutureTask.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EmailValidator类代码示例发布时间:2022-05-21
下一篇:
Java NativePreviewHandler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap