我正在尝试评估性能b / w IExecutorService& DurableExecutorService。
我发现对于同一条代码,IExecutorService提供25K TPS,而DurableExecutorService提供300 TPS。
他们的表现有什么不同,或者我错过了一些东西。
执行在DurableExecutorService中回调也没有任何改进。
有没有其他方法可以确保Hazelcast的耐用性。
添加一些代码:
public class TransactionValidationTask implements Callable<Result>, DataSerializable, HazelcastInstanceAware {
public Result call() throws Exception {
IMap<String, List<Events>> mapTranx = hz.getMap("transactionData");
//Process data
//Remove old events less than 15 mins
//Store current event if its timestamp is greater that old events
//generate alerts is any
return result;
}//Other methods omitted
}
在IExecutor / DurableExecutorService中调用Callable
final HazelcastInstance hazelcastInstance = HazelcastClient.newHazelcastClient();
final IExecutorService executorService = hazelcastInstance.getExecutorService("MyExecutorService");
//final DurableExecutorService durableexecutorService = hazelcastInstance.getDurableExecutorService("default");
Thread processThread = new Thread() {
@Override
public void run() {
try {
while (!Thread.interrupted()) {
if (!eventQueue.isEmpty()) {
Event currentEvent = getEvent();
ExecutionCallback<Result> executionCallback = new ExecutionCallback<Result>() {
@Override
public void onFailure(Throwable t) {
// Log for time being
log.log(Level.WARNING, "Error in executor service:" + t.getLocalizedMessage() + ", " + t.getMessage());
}
@Override
public void onResponse(Result result) {
//Process result
}
};
executorService.submitToKeyOwner(new TransactionValidationTask(currentEvent), currentTxn.getDeviceId(), executionCallback);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
executorService.shutdown();
while(!executorService.isTerminated()) {}
}
}
};
processThread.setDaemon(true);
processThread.start();
}