Search in sources :

Example 21 with Setup

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

the class PerformanceICacheTest method setup.

@Setup
public void setup() {
    CacheManager cacheManager = createCacheManager(targetInstance);
    cache = cacheManager.getCache(name);
}
Also used : CacheUtils.createCacheManager(com.hazelcast.simulator.tests.icache.helpers.CacheUtils.createCacheManager) CacheManager(javax.cache.CacheManager) Setup(com.hazelcast.simulator.test.annotations.Setup)

Example 22 with Setup

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

the class ReadWriteICacheTest method setup.

@Setup
public void setup() {
    counters = targetInstance.getList(name + "counters");
    RecordingCacheLoader<Integer> loader = new RecordingCacheLoader<Integer>();
    loader.loadDelayMs = getDelayMs;
    RecordingCacheWriter<Integer, Integer> writer = new RecordingCacheWriter<Integer, Integer>();
    writer.writeDelayMs = putDelayMs;
    writer.deleteDelayMs = removeDelayMs;
    config = new CacheConfig<Integer, Integer>();
    config.setReadThrough(true);
    config.setWriteThrough(true);
    config.setCacheLoaderFactory(FactoryBuilder.factoryOf(loader));
    config.setCacheWriterFactory(FactoryBuilder.factoryOf(writer));
    CacheManager cacheManager = createCacheManager(targetInstance);
    cacheManager.createCache(name, config);
    cache = cacheManager.getCache(name);
}
Also used : RecordingCacheWriter(com.hazelcast.simulator.tests.icache.helpers.RecordingCacheWriter) CacheUtils.createCacheManager(com.hazelcast.simulator.tests.icache.helpers.CacheUtils.createCacheManager) CacheManager(javax.cache.CacheManager) RecordingCacheLoader(com.hazelcast.simulator.tests.icache.helpers.RecordingCacheLoader) Setup(com.hazelcast.simulator.test.annotations.Setup)

Example 23 with Setup

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

the class StringICacheTest method setup.

@Setup
public void setup() {
    CacheManager cacheManager = createCacheManager(targetInstance);
    cache = cacheManager.getCache(name);
}
Also used : CacheUtils.createCacheManager(com.hazelcast.simulator.tests.icache.helpers.CacheUtils.createCacheManager) CacheManager(javax.cache.CacheManager) Setup(com.hazelcast.simulator.test.annotations.Setup)

Example 24 with Setup

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

the class TestContainer method registerSetupTask.

private void registerSetupTask() {
    List<Method> setupMethods = new AnnotatedMethodRetriever(testClass, Setup.class).withVoidReturnType().withPublicNonStaticModifier().findAll();
    List<Callable> callableList = new ArrayList<Callable>(setupMethods.size());
    for (Method setupMethod : setupMethods) {
        Class[] parameterTypes = setupMethod.getParameterTypes();
        Object[] args;
        switch(parameterTypes.length) {
            case 0:
                args = new Object[0];
                break;
            case 1:
                Class<?> parameterType = setupMethod.getParameterTypes()[0];
                if (!parameterType.isAssignableFrom(TestContext.class) || parameterType.isAssignableFrom(Object.class)) {
                    throw new IllegalTestException(format("Method %s.%s() supports arguments of type %s, but found %s", testClass.getSimpleName(), setupMethod, TestContext.class.getName(), parameterType.getName()));
                }
                args = new Object[] { testContext };
                break;
            default:
                throw new IllegalTestException(format("Setup method '%s' can have at most a single argument", setupMethod));
        }
        callableList.add(new MethodInvokingCallable(testInstance, setupMethod, args));
    }
    taskPerPhaseMap.put(SETUP, new CompositeCallable(callableList));
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) AnnotatedMethodRetriever(com.hazelcast.simulator.utils.AnnotatedMethodRetriever) Callable(java.util.concurrent.Callable) Setup(com.hazelcast.simulator.test.annotations.Setup)

Example 25 with Setup

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

the class MapDataIntegrityTest method setup.

@Setup
public void setup() {
    integrityMap = targetInstance.getMap(name + "Integrity");
    stressMap = targetInstance.getMap(name + "Stress");
    integrityThreads = new MapIntegrityThread[mapIntegrityThreadCount];
    value = new byte[valueSize];
    Random random = new Random();
    random.nextBytes(value);
    if (mapLoad && isMemberNode(targetInstance)) {
        PartitionService partitionService = targetInstance.getPartitionService();
        final Set<Partition> partitionSet = partitionService.getPartitions();
        for (Partition partition : partitionSet) {
            while (partition.getOwner() == null) {
                sleepSeconds(1);
            }
        }
        logger.info(format("%s: %d partitions", name, partitionSet.size()));
        Member localMember = targetInstance.getCluster().getLocalMember();
        for (int i = 0; i < totalIntegrityKeys; i++) {
            Partition partition = partitionService.getPartition(i);
            if (localMember.equals(partition.getOwner())) {
                integrityMap.put(i, value);
            }
        }
        logger.info(format("%s: integrityMap=%s size=%d", name, integrityMap.getName(), integrityMap.size()));
        Config config = targetInstance.getConfig();
        MapConfig mapConfig = config.getMapConfig(integrityMap.getName());
        logger.info(format("%s: %s", name, mapConfig));
    }
}
Also used : Partition(com.hazelcast.core.Partition) Random(java.util.Random) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) PartitionService(com.hazelcast.core.PartitionService) MapConfig(com.hazelcast.config.MapConfig) Member(com.hazelcast.core.Member) Setup(com.hazelcast.simulator.test.annotations.Setup)

Aggregations

Setup (com.hazelcast.simulator.test.annotations.Setup)25 CacheManager (javax.cache.CacheManager)16 CacheUtils.createCacheManager (com.hazelcast.simulator.tests.icache.helpers.CacheUtils.createCacheManager)14 Random (java.util.Random)3 RecordingCacheLoader (com.hazelcast.simulator.tests.icache.helpers.RecordingCacheLoader)2 BucketSettings (com.couchbase.client.java.cluster.BucketSettings)1 ClusterManager (com.couchbase.client.java.cluster.ClusterManager)1 CacheConfig (com.hazelcast.config.CacheConfig)1 Config (com.hazelcast.config.Config)1 MapConfig (com.hazelcast.config.MapConfig)1 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)1 Member (com.hazelcast.core.Member)1 Partition (com.hazelcast.core.Partition)1 PartitionService (com.hazelcast.core.PartitionService)1 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 Node (com.hazelcast.instance.Node)1 MetricsRegistry (com.hazelcast.internal.metrics.MetricsRegistry)1 IOThreadingModel (com.hazelcast.internal.networking.IOThreadingModel)1 LoggingService (com.hazelcast.logging.LoggingService)1 Address (com.hazelcast.nio.Address)1