use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class TxnQueueWithLockTest method timeStep.
@TimeStep
public void timeStep(ThreadState state) {
firstLock.lock();
try {
TransactionContext ctx = targetInstance.newTransactionContext();
try {
ctx.beginTransaction();
TransactionalQueue<Integer> queue = ctx.getQueue(name + 'q');
queue.offer(1);
secondLock.lock();
secondLock.unlock();
queue.take();
ctx.commitTransaction();
state.counter.committed++;
} catch (Exception txnException) {
try {
ctx.rollbackTransaction();
state.counter.rolled++;
logger.fatal(name + ": Exception in txn " + state.counter, txnException);
} catch (Exception rollException) {
state.counter.failedRollbacks++;
logger.fatal(name + ": Exception in roll " + state.counter, rollException);
}
}
} catch (Exception e) {
logger.fatal(name + ": outer Exception" + state.counter, e);
} finally {
firstLock.unlock();
}
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class ReliableTopicTest method timeStep.
@TimeStep
public void timeStep(ThreadState state) throws Exception {
ITopic<MessageEntity> topic = state.getRandomTopic();
AtomicLong counter = state.counterMap.get(topic);
MessageEntity msg = new MessageEntity(state.id, counter.incrementAndGet());
state.messagesSend++;
topic.publish(msg);
}
Aggregations