Search in sources :

Example 31 with TimeStep

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();
    }
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 32 with TimeStep

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);
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) AtomicLong(java.util.concurrent.atomic.AtomicLong) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Aggregations

TimeStep (com.hazelcast.simulator.test.annotations.TimeStep)32 IAtomicLong (com.hazelcast.core.IAtomicLong)6 Predicate (com.hazelcast.query.Predicate)6 Employee (com.hazelcast.simulator.tests.map.helpers.Employee)6 SqlPredicate (com.hazelcast.query.SqlPredicate)5 ILock (com.hazelcast.core.ILock)4 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)4 Duration (javax.cache.expiry.Duration)4 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)4 AsyncAtomicLong (com.hazelcast.core.AsyncAtomicLong)2 EntryObject (com.hazelcast.query.EntryObject)2 PagingPredicate (com.hazelcast.query.PagingPredicate)2 PredicateBuilder (com.hazelcast.query.PredicateBuilder)2 TestException (com.hazelcast.simulator.test.TestException)2 TransactionContext (com.hazelcast.transaction.TransactionContext)2 Cache (javax.cache.Cache)2 JsonObject (com.couchbase.client.java.document.json.JsonObject)1 IExecutorService (com.hazelcast.core.IExecutorService)1 IMap (com.hazelcast.core.IMap)1 JobTracker (com.hazelcast.mapreduce.JobTracker)1