Search in sources :

Example 1 with TimeStep

use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.

the class TimeStepModel method loadTimeStepMethods.

private void loadTimeStepMethods() {
    List<Method> methods = new AnnotatedMethodRetriever(testClass, TimeStep.class).findAll();
    // we can easily increase the number to 256 in the future
    if (methods.size() > Byte.MAX_VALUE) {
        throw new IllegalTestException(testClass.getName() + " has more than 127 TimeStep methods, found: " + methods.size());
    }
    validateUniqueMethodNames(methods);
    validateModifiers(methods);
    validateTimeStepParameters(methods);
    for (Method method : methods) {
        TimeStep timeStep = method.getAnnotation(TimeStep.class);
        String group = timeStep.executionGroup();
        ensureExecutionGroupIsIdentifier(method, group);
        ExecutionGroup executionGroup = executionGroups.get(group);
        if (executionGroup == null) {
            executionGroup = new ExecutionGroup(group);
            executionGroups.put(group, executionGroup);
        }
        executionGroup.timeStepMethods.add(method);
    }
}
Also used : TimeStep(com.hazelcast.simulator.test.annotations.TimeStep) Method(java.lang.reflect.Method) AnnotatedMethodRetriever(com.hazelcast.simulator.utils.AnnotatedMethodRetriever)

Example 2 with TimeStep

use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.

the class ExtractorMapTest method query.

@TimeStep(prob = -1)
public void query(ThreadState state, Probe probe, @StartNanos long startedNanos) {
    int key = state.getRandomKey();
    int index = key % nestedValuesCount;
    String query = format("payloadFromExtractor[%d]", index);
    Predicate predicate = Predicates.equal(query, key);
    Collection<Object> result = null;
    try {
        result = map.values(predicate);
    } finally {
        probe.done(startedNanos);
    }
    if (throttlingLogger.requestLogSlot()) {
        throttlingLogger.logInSlot(Level.INFO, format("Query 'payloadFromExtractor[%d]= %d' returned %d results.", index, key, result.size()));
    }
    for (Object resultSillySequence : result) {
        state.assertValidSequence(key, resultSillySequence);
    }
}
Also used : Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 3 with TimeStep

use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.

the class MapGetVsQueryTest method sqlString.

@TimeStep(prob = 0)
public void sqlString(ThreadState state) {
    int id = state.randomInt(itemCount);
    SqlPredicate predicate = new SqlPredicate("id=" + id);
    map.values(predicate);
}
Also used : SqlPredicate(com.hazelcast.query.SqlPredicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 4 with TimeStep

use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.

the class MapGetVsQueryTest method predicateBuilder.

@TimeStep(prob = 0)
public void predicateBuilder(ThreadState state) {
    int id = state.randomInt(itemCount);
    EntryObject entryObject = new PredicateBuilder().getEntryObject();
    Predicate predicate = entryObject.get("id").equal(id);
    map.values(predicate);
}
Also used : EntryObject(com.hazelcast.query.EntryObject) PredicateBuilder(com.hazelcast.query.PredicateBuilder) SqlPredicate(com.hazelcast.query.SqlPredicate) Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 5 with TimeStep

use of com.hazelcast.simulator.test.annotations.TimeStep in project hazelcast-simulator by hazelcast.

the class MapPredicateTest method pagePredicate.

@TimeStep(prob = 0.2)
public void pagePredicate(ThreadState state) {
    double maxSalary = state.randomDouble() * Employee.MAX_SALARY;
    Predicate predicate = Predicates.lessThan("salary", maxSalary);
    SalaryComparator salaryComparator = new SalaryComparator();
    PagingPredicate pagingPredicate = new PagingPredicate(predicate, salaryComparator, pageSize);
    Collection<Employee> employees;
    List<Employee> employeeList;
    do {
        employees = map.values(pagingPredicate);
        employeeList = fillListWithQueryResultSet(employees);
        Employee nextEmployee;
        Employee currentEmployee;
        for (int i = 0; i < employeeList.size() - 1; i++) {
            currentEmployee = employeeList.get(i);
            nextEmployee = employeeList.get(i + 1);
            // check the order & max salary
            assertTrue(format(baseAssertMessage, currentEmployee.getSalary(), predicate), currentEmployee.getSalary() <= nextEmployee.getSalary() && nextEmployee.getSalary() < maxSalary);
        }
        pagingPredicate.nextPage();
    } while (!employees.isEmpty());
    state.operationCounter.pagePredicateCount++;
}
Also used : PagingPredicate(com.hazelcast.query.PagingPredicate) Employee(com.hazelcast.simulator.tests.map.helpers.Employee) SqlPredicate(com.hazelcast.query.SqlPredicate) PagingPredicate(com.hazelcast.query.PagingPredicate) Predicate(com.hazelcast.query.Predicate) 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