use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class ListenerICacheTest method getExpiryAsync.
@TimeStep(prob = 0)
public void getExpiryAsync(ThreadState state) throws ExecutionException, InterruptedException {
int expiryDuration = state.randomInt(maxExpiryDurationMs);
ExpiryPolicy expiryPolicy = new CreatedExpiryPolicy(new Duration(MILLISECONDS, expiryDuration));
int key = state.randomInt(keyCount);
Future<Long> future = cache.getAsync(key, expiryPolicy);
future.get();
state.getAsyncExpiry++;
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class ListenerICacheTest method getExpiry.
@TimeStep(prob = 0)
public void getExpiry(ThreadState state) {
int expiryDuration = state.randomInt(maxExpiryDurationMs);
ExpiryPolicy expiryPolicy = new CreatedExpiryPolicy(new Duration(MILLISECONDS, expiryDuration));
int key = state.randomInt(keyCount);
cache.get(key, expiryPolicy);
state.getExpiry++;
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class LeaseLockTest method timeStep.
@TimeStep
public void timeStep(BaseThreadState state) {
int lockIndex = state.randomInt(lockCount);
ILock lock = targetInstance.getLock(name + lockIndex);
int leaseTime = 1 + state.randomInt(maxLeaseTimeMillis);
int tryTime = 1 + state.randomInt(maxTryTimeMillis);
if (state.randomBoolean()) {
lock.lock(leaseTime, MILLISECONDS);
} else {
try {
lock.tryLock(tryTime, MILLISECONDS, leaseTime, MILLISECONDS);
} catch (InterruptedException e) {
logger.info("tryLock() got exception: " + e.getMessage());
}
}
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class SimpleLockTest method timeStep.
@TimeStep
public void timeStep(BaseThreadState state) {
int key1 = state.randomInt(maxAccounts);
int key2;
do {
key2 = state.randomInt(maxAccounts);
} while (key1 == key2);
ILock lock1 = targetInstance.getLock(name + key1);
if (lock1.tryLock()) {
try {
ILock lock2 = targetInstance.getLock(name + key2);
if (lock2.tryLock()) {
try {
IAtomicLong account1 = targetInstance.getAtomicLong(name + key1);
IAtomicLong account2 = targetInstance.getAtomicLong(name + key2);
int delta = state.randomInt(100);
if (account1.get() >= delta) {
account1.set(account1.get() - delta);
account2.set(account2.get() + delta);
}
} finally {
lock2.unlock();
}
}
} finally {
lock1.unlock();
}
}
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class ExecutorTest method timeStep.
@TimeStep
public void timeStep(ThreadState state) throws Exception {
int index = state.randomInt(executors.length);
IExecutorService executorService = executors[index];
state.futureList.clear();
for (int i = 0; i < submitCount; i++) {
Future future = executorService.submit(new Task(testContext.getTestId()));
state.futureList.add(future);
state.iteration++;
}
for (Future future : state.futureList) {
future.get();
}
}
Aggregations