Search in sources :

Example 6 with Prepare

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

the class MapPutAllOnTheFlyTest method prepare.

@Prepare
@SuppressWarnings("unchecked")
public void prepare() {
    if (mapCount > 0) {
        // prepare the input maps
        Integer[] keys = generateIntegerKeys(keyRange, SHARED, targetInstance);
        inputMaps = new Map[mapCount];
        Random random = new Random();
        for (int mapIndex = 0; mapIndex < mapCount; mapIndex++) {
            Map<Integer, Integer> inputMap = new HashMap<Integer, Integer>(batchSize);
            while (inputMap.size() < batchSize) {
                Integer key = keys[random.nextInt(keyRange)];
                inputMap.put(key, key);
            }
            inputMaps[mapIndex] = inputMap;
        }
    }
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 7 with Prepare

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

the class BackupExpirationMapTest method prepare.

@Prepare(global = false)
public void prepare() {
    waitClusterSize(logger, targetInstance, minNumberOfMembers);
    keys = generateIntKeys(keyCount, keyLocality, targetInstance);
    Streamer<Integer, Integer> streamer = StreamerFactory.getInstance(map);
    Random random = new Random();
    for (int key : keys) {
        int value = random.nextInt(Integer.MAX_VALUE);
        streamer.pushEntry(key, value);
    }
    streamer.await();
}
Also used : Random(java.util.Random) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 8 with Prepare

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

the class SqlPredicateTest method prepare.

@Prepare(global = true)
public void prepare() {
    Random random = new Random();
    Streamer<String, DataSerializableEmployee> streamer = StreamerFactory.getInstance(map);
    for (int i = 0; i < keyCount; i++) {
        String key = generateString(keyLength);
        DataSerializableEmployee value = generateRandomEmployee(random);
        streamer.pushEntry(key, value);
    }
    streamer.await();
    logger.info("Map size is: " + map.size());
    logger.info("Map localKeySet size is: " + map.localKeySet().size());
}
Also used : Random(java.util.Random) GeneratorUtils.generateString(com.hazelcast.simulator.utils.GeneratorUtils.generateString) DataSerializableEmployee(com.hazelcast.simulator.tests.map.helpers.DataSerializableEmployee) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 9 with Prepare

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

the class LongStringCacheTest method prepare.

@Prepare(global = true)
public void prepare() {
    Random random = new Random();
    Streamer<Long, String> streamer = StreamerFactory.getInstance(cache);
    for (long key = 0; key < keyDomain; key++) {
        String value = values[random.nextInt(valueCount)];
        streamer.pushEntry(key, value);
    }
    streamer.await();
}
Also used : Random(java.util.Random) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 10 with Prepare

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

the class BucketReadWriteTest method prepare.

@Prepare(global = true)
public void prepare() {
    Random random = new Random();
    for (int k = 0; k < keyDomain; k++) {
        JsonObject content = JsonObject.create().put("x", values[random.nextInt(valueCount)]);
        bucket.upsert(JsonDocument.create("" + k, content));
    }
}
Also used : Random(java.util.Random) JsonObject(com.couchbase.client.java.document.json.JsonObject) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Aggregations

Prepare (com.hazelcast.simulator.test.annotations.Prepare)29 Random (java.util.Random)17 GeneratorUtils.generateString (com.hazelcast.simulator.utils.GeneratorUtils.generateString)4 IAtomicLong (com.hazelcast.core.IAtomicLong)2 HashMap (java.util.HashMap)2 JsonObject (com.couchbase.client.java.document.json.JsonObject)1 Member (com.hazelcast.core.Member)1 Address (com.hazelcast.nio.Address)1 Connection (com.hazelcast.nio.Connection)1 ExternalizablePojo (com.hazelcast.simulator.hz.ExternalizablePojo)1 SerializablePojo (com.hazelcast.simulator.hz.SerializablePojo)1 DomainObject (com.hazelcast.simulator.tests.map.domain.DomainObject)1 DomainObjectFactory (com.hazelcast.simulator.tests.map.domain.DomainObjectFactory)1 ComplexDomainObject (com.hazelcast.simulator.tests.map.helpers.ComplexDomainObject)1 DataSerializableEmployee (com.hazelcast.simulator.tests.map.helpers.DataSerializableEmployee)1 Employee (com.hazelcast.simulator.tests.map.helpers.Employee)1 EventCount (com.hazelcast.simulator.tests.map.helpers.EventCount)1 TreeMap (java.util.TreeMap)1