use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class MultiValueMapTest method query.
@TimeStep(prob = -1)
public void query(ThreadState state, Probe probe, @StartNanos long startNanos) {
int key = state.getRandomKey();
Predicate predicate = Predicates.equal("payloadField[any]", key);
Collection<Object> result = null;
try {
result = map.values(predicate);
} finally {
probe.done(startNanos);
}
if (throttlingLogger.requestLogSlot()) {
throttlingLogger.logInSlot(Level.INFO, format("Query 'payloadField[any]= %d' returned %d results.", key, result.size()));
}
for (Object resultSillySequence : result) {
state.assertValidSequence(resultSillySequence);
}
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class MapPredicateTest method sqlString.
@TimeStep(prob = 0.2)
public void sqlString(ThreadState state) {
long startMs = System.currentTimeMillis();
boolean active = state.randomBoolean();
int age = state.randomInt(Employee.MAX_AGE);
SqlPredicate predicate = new SqlPredicate("active=" + active + " AND age >" + age);
Collection<Employee> employees = map.values(predicate);
for (Employee emp : employees) {
String assertMessage = format(baseAssertMessage, emp, predicate);
assertTrue(assertMessage, emp.isActive() == active);
assertTrue(assertMessage, emp.getAge() > age);
}
state.operationCounter.sqlStringCount++;
updateStats(state, startMs);
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class MapPredicateTest method updateEmployee.
@TimeStep(prob = 0.3)
public void updateEmployee(ThreadState state) {
Integer key = state.randomInt(keyCount);
Employee employee = map.get(key);
if (employee != null) {
employee.randomizeProperties();
map.put(key, employee);
state.operationCounter.updateEmployeeCount++;
}
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class MapReduceTest method mapReduce.
@TimeStep(prob = 0.5)
public void mapReduce(ThreadState state) throws Exception {
JobTracker tracker = targetInstance.getJobTracker(Thread.currentThread().getName() + name);
KeyValueSource<Integer, Employee> source = KeyValueSource.fromMap(map);
Job<Integer, Employee> job = tracker.newJob(source);
ICompletableFuture<Map<Integer, Set<Employee>>> future = job.mapper(new ModIdMapper(2)).combiner(new RangeIdCombinerFactory(10, 30)).reducer(new IdReducerFactory(10, 20, 30)).submit();
Map<Integer, Set<Employee>> result = future.get();
for (Set<Employee> set : result.values()) {
for (Employee employee : set) {
assertTrue(employee.getId() % 2 == 0);
assertTrue(employee.getId() >= 10 && employee.getId() <= 30);
assertTrue(employee.getId() != 10);
assertTrue(employee.getId() != 20);
assertTrue(employee.getId() != 30);
}
}
state.operationCounter.mapReduce++;
}
use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.
the class ProducerConsumerTest method consume.
@TimeStep(executionGroup = "consumer")
public void consume(ConsumerState state) throws Exception {
Long item = workQueue.take();
if (item.equals(-1L)) {
workQueue.add(item);
throw new StopException();
}
state.consumed++;
Thread.sleep(state.randomInt(maxIntervalMillis));
}
Aggregations