Search in sources :

Example 6 with TimeStep

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

the class MapPredicateTest method predicateBuilder.

@TimeStep(prob = 0.2)
public void predicateBuilder(ThreadState state) {
    long startMs = System.currentTimeMillis();
    int age = state.randomInt(Employee.MAX_AGE);
    String name = Employee.getRandomName();
    // TODO: Still broken because it relies on reflection which is dog slow, so we need an explicit AgeNamePredicate
    EntryObject entryObject = new PredicateBuilder().getEntryObject();
    Predicate agePredicate = entryObject.get("age").lessThan(age);
    Predicate ageNamePredicate = entryObject.get("name").equal(name).and(agePredicate);
    Collection<Employee> employees = map.values(ageNamePredicate);
    for (Employee emp : employees) {
        String assertMessage = format(baseAssertMessage, emp, ageNamePredicate);
        assertTrue(assertMessage, emp.getAge() < age);
        assertTrue(assertMessage, emp.getName().equals(name));
    }
    state.operationCounter.predicateBuilderCount++;
    updateStats(state, startMs);
}
Also used : EntryObject(com.hazelcast.query.EntryObject) Employee(com.hazelcast.simulator.tests.map.helpers.Employee) PredicateBuilder(com.hazelcast.query.PredicateBuilder) SqlPredicate(com.hazelcast.query.SqlPredicate) PagingPredicate(com.hazelcast.query.PagingPredicate) Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 7 with TimeStep

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

the class MapReduceTest method modifyMapEntry.

@TimeStep(prob = 0.25)
public void modifyMapEntry(ThreadState state) {
    Employee employee = map.get(state.randomInt(keyCount));
    employee.randomizeProperties();
    map.put(employee.getId(), employee);
    state.operationCounter.modifyMapEntry++;
}
Also used : Employee(com.hazelcast.simulator.tests.map.helpers.Employee) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 8 with TimeStep

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

the class SerializationStrategyTest method getByStringIndex.

@TimeStep(prob = 1)
public void getByStringIndex(ThreadState state) {
    String string = state.getUniqueString();
    Predicate predicate = Predicates.equal("stringVal", string);
    Set<Map.Entry<String, DomainObject>> entries = map.entrySet(predicate);
    throttlingLogger.log(Level.INFO, "GetByStringIndex: " + entries.size() + " entries");
}
Also used : Predicate(com.hazelcast.query.Predicate) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 9 with TimeStep

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

the class MangleICacheTest method closeCache.

@TimeStep(prob = 0.1)
public void closeCache(ThreadState state) {
    int cacheNumber = state.randomInt(maxCaches);
    Cache cache = state.getCacheIfExists(cacheNumber);
    try {
        if (cache != null) {
            cache.close();
            state.counter.cacheClose++;
        }
    } catch (CacheException e) {
        state.counter.cacheCloseException++;
    } catch (IllegalStateException e) {
        state.counter.cacheCloseException++;
    }
}
Also used : CacheException(javax.cache.CacheException) Cache(javax.cache.Cache) TimeStep(com.hazelcast.simulator.test.annotations.TimeStep)

Example 10 with TimeStep

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

the class ListenerICacheTest method putExpiry.

@TimeStep(prob = 0)
public void putExpiry(ThreadState state) {
    int expiryDuration = state.randomInt(maxExpiryDurationMs);
    ExpiryPolicy expiryPolicy = new CreatedExpiryPolicy(new Duration(MILLISECONDS, expiryDuration));
    int key = state.randomInt(keyCount);
    cache.put(key, state.randomLong(), expiryPolicy);
    state.putExpiry++;
}
Also used : CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) Duration(javax.cache.expiry.Duration) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) 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