Trovare un Lattoniere: Come Utilizzare un Canale di Gronda.
Come Trovare un Lattoniere e Utilizzare un Canale di Gronda.
Scopri come scegliere un lattoniere esperto per installare e mantenere il tuo canale di gronda. Questo articolo offre consigli utili per garantire un lavoro di qualità, analizzando i materiali, le tecniche e l'importanza di un'installazione professionale. Non lasciare nulla al caso, leggi di più!
Trova professionisti vicino a te
Trova professionisti
package com.hazelcast.stabilizer.tests.map;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.logging.ILogger;
import com.hazelcast.logging.Logger;
import com.hazelcast.stabilizer.tests.TestContext;
import com.hazelcast.stabilizer.tests.TestRunner;
import com.hazelcast.stabilizer.tests.annotations.Performance;
import com.hazelcast.stabilizer.tests.annotations.Run;
import com.hazelcast.stabilizer.tests.annotations.Setup;
import com.hazelcast.stabilizer.tests.annotations.Verify;
import com.hazelcast.stabilizer.tests.utils.ThreadSpawner;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
public class MapPutTest {
private static final ILogger log = Logger.getLogger(MapPutTest.class);
public String basename = MapPutTest.class.getSimpleName();
public int threadCount = 3;
public int keyCount = 1000;
public int valueCount = 1000;
public double putProb = 0.1;
private TestContext testContext;
private IMap map;
private AtomicLong operations = new AtomicLong();
private Random random = new Random();
private HazelcastInstance targetInstance;
@Setup
public void setup(TestContext testContext) throws Exception {
this.testContext = testContext;
targetInstance = testContext.getTargetInstance();
map = targetInstance.getMap(basename);
}
@Run
public void run() {
ThreadSpawner spawner = new ThreadSpawner(testContext.getTestId());
for (int k = 0; k < threadCount; k++) {
spawner.spawn(new Worker());
}
spawner.awaitCompletion();
}
@Verify
public void verify() {
long expected = keyCount * valueCount * putProb;
long found = operations.get();
log.info(basename + ": " + expected + " entries, " + found + " found");
if (expected != found) {
throw new RuntimeException(basename + ": Expected " + expected + " entries, but found " + found);
}
}
@Performance
public long getOperationCount() {
return operations.get();
}
private class Worker implements Runnable {
@Override
public void run() {
for (int k = 0; k < keyCount; k++) {
int key = random.nextInt(valueCount);
if (random.nextDouble() < putProb) {
int value = random.nextInt();
map.put(key, value);
operations.incrementAndGet();
}
}
}
}
public static void main(String[] args) throws Throwable {
MapPutTest test = new MapPutTest();
new TestRunner(test).withDuration(10).run();
}
}