Search in sources :

Example 16 with Prepare

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

the class ReadWriteTest method prepare.

@Prepare
public void prepare() {
    Random random = new Random();
    values = new byte[valueCount][];
    for (int i = 0; i < values.length; i++) {
        int delta = maxSize - minSize;
        int length = delta == 0 ? minSize : minSize + random.nextInt(delta);
        values[i] = generateByteArray(random, length);
    }
    for (String key : keys) {
        client.add(key, ttl, values[random.nextInt(values.length)]);
    }
}
Also used : Random(java.util.Random) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 17 with Prepare

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

the class NetworkTest method prepare.

@Prepare
public void prepare() throws Exception {
    networkCreateLock.lock();
    try {
        logger.info("Starting connections: " + (targetInstance.getCluster().getMembers().size() - 1));
        for (Member member : targetInstance.getCluster().getMembers()) {
            if (member.localMember()) {
                continue;
            }
            Address memberAddress = member.getAddress();
            Address targetAddress = new Address(memberAddress.getHost(), memberAddress.getPort() + PORT_OFFSET);
            logger.info("Connecting to: " + targetAddress);
            connectionManager.getOrConnect(targetAddress);
            Connection connection;
            for (; ; ) {
                connection = connectionManager.getConnection(targetAddress);
                if (connection != null) {
                    break;
                }
                logger.info("Waiting for connection to: " + targetAddress);
                sleepMillis(100);
            }
            connections.add(connection);
            logger.info("Successfully created connection to: " + targetAddress);
        }
        logger.info("Successfully started all connections");
    } finally {
        networkCreateLock.unlock();
    }
    // temporary delay
    Thread.sleep(30);
}
Also used : Address(com.hazelcast.nio.Address) Connection(com.hazelcast.nio.Connection) Member(com.hazelcast.core.Member) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 18 with Prepare

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

the class SimpleLockTest method prepare.

@Prepare(global = true)
public void prepare() {
    for (int i = 0; i < maxAccounts; i++) {
        IAtomicLong account = targetInstance.getAtomicLong(name + i);
        account.set(INITIAL_VALUE);
    }
    totalValue = INITIAL_VALUE * maxAccounts;
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 19 with Prepare

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

the class LongStringMapTest method prepare.

@Prepare(global = true)
public void prepare() {
    Random random = new Random();
    for (long key = 0; key < keyDomain; key++) {
        String value = values[random.nextInt(valueCount)];
        map.put(key, value);
    }
}
Also used : Random(java.util.Random) Prepare(com.hazelcast.simulator.test.annotations.Prepare)

Example 20 with Prepare

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

the class LongSerializableCacheTest method prepare.

@Prepare(global = true)
public void prepare() {
    Streamer<Long, SerializablePojo> streamer = StreamerFactory.getInstance(cache);
    for (long key = 0; key < keyDomain; key++) {
        streamer.pushEntry(key, new SerializablePojo());
    }
    streamer.await();
}
Also used : SerializablePojo(com.hazelcast.simulator.hz.SerializablePojo) 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