@Override public IAtomicLong getAtomicLong(String name) { return delegatedInstance.getAtomicLong(name); }
public HazelcastAtomicnumberProducer(HazelcastInstance hazelcastInstance, HazelcastDefaultEndpoint endpoint, String cacheName) { super(endpoint); this.atomicnumber = hazelcastInstance.getAtomicLong(cacheName); }
@Setup public void setup() { totalCounter = targetInstance.getAtomicLong(name + ":TotalCounter"); counters = new IAtomicLong[countersLength]; String[] names = generateStringKeys(name, countersLength, keyLocality, targetInstance); for (int i = 0; i < countersLength; i++) { counters[i] = targetInstance.getAtomicLong(names[i]); } }
@Override public double count(String key) { IAtomicLong long2 = h.getAtomicLong(key); return long2.get(); }
@Setup public void setup() { executors = new IExecutorService[executorCount]; for (int i = 0; i < executors.length; i++) { executors[i] = targetInstance.getExecutorService(name + '-' + i); } executedCounter = targetInstance.getAtomicLong(name + ":ExecutedCounter"); expectedExecutedCounter = targetInstance.getAtomicLong(name + ":ExpectedExecutedCounter"); }
@Setup public void setup() { produced = targetInstance.getAtomicLong(name + ":Produced"); consumed = targetInstance.getAtomicLong(name + ":Consumed"); workQueue = targetInstance.getQueue(name + ":WorkQueue"); }
@Setup public void setup() { totalCounter = targetInstance.getAtomicLong(name + ":TotalCounter"); if (isMemberNode(targetInstance)) { counters = new AsyncAtomicLong[countersLength]; String[] names = generateStringKeys(name, countersLength, keyLocality, targetInstance); for (int i = 0; i < countersLength; i++) { counters[i] = (AsyncAtomicLong) targetInstance.getAtomicLong(names[i]); } } }
@Produces public IAtomicLong produceIAtomicLongs( final ProviderContext context ) { final String name = retrieveSourceNameFrom( context ); final IAtomicLong data = hazelcast.getAtomicLong( name ); notifyDataWasProduced( data, IAtomicLong.class ); return data; }
public HazelcastJobQueue(String name, HazelcastInstance hazelcast) { this.hazelcast = hazelcast; this.queueName = name; this.highQueue = hazelcast.getQueue(format("jobs-%s-high", name)); this.midQueue = hazelcast.getQueue(format("jobs-%s-mid", name)); this.lowQueue = hazelcast.getQueue(format("jobs-%s-low", name)); this.uniqueIds = hazelcast.getSet(format("uniqueids-%s", name)); this.maxQueueSize = hazelcast.getAtomicLong(format("maxsize-%s", name)); this.localJobs = new ConcurrentHashMap<>(); }
@Setup public void setup() { map = targetInstance.getMap(name); keyCounter = targetInstance.getAtomicLong(name); assertMapStoreConfiguration(logger, targetInstance, name, MapStoreWithCounterPerKey.class); }
@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; }
@Warmup(global = true) public void warmup() throws Exception { for (int k = 0; k < maxAccounts; k++) { IAtomicLong account = targetInstance.getAtomicLong(basename+k); account.set(initialValue); } totalValue = initialValue * maxAccounts; }
@Setup public void setup(TestContext context) throws Exception { this.context = context; log.info("countersLength:" + countersLength + " threadCount:" + threadCount); HazelcastInstance targetInstance = context.getTargetInstance(); totalCounter = targetInstance.getAtomicLong(context.getTestId() + ":TotalCounter"); counters = new IAtomicLong[countersLength]; for (int k = 0; k < counters.length; k++) { counters[k] = targetInstance.getAtomicLong(basename + "-" + context.getTestId() + "r-" + k); } }
@Setup public void setup(TestContext testContext) throws Exception { this.testContext = testContext; targetInstance = testContext.getTargetInstance(); executors = new IExecutorService[executorCount]; for (int k = 0; k < executors.length; k++) { executors[k] = targetInstance.getExecutorService(basename + "-" + testContext.getTestId() + "-" + k); } executedCounter = targetInstance.getAtomicLong(testContext.getTestId() + ":ExecutedCounter"); expectedExecutedCounter = targetInstance.getAtomicLong(testContext.getTestId() + ":ExpectedExecutedCounter"); }
@Setup public void setup(TestContext testContext) throws Exception { this.testContext = testContext; HazelcastInstance targetInstance = testContext.getTargetInstance(); produced = targetInstance.getAtomicLong(basename + "-" + testContext.getTestId() + ":Produced"); consumed = targetInstance.getAtomicLong(basename + "-" + testContext.getTestId() + ":Consumed"); workQueue = targetInstance.getQueue(basename + "-" + testContext.getTestId() + ":WorkQueue"); }
@Prepare(global = true) public void prepare() { for (int i = 0; i < lockCount; i++) { long key = lockCounter.getAndIncrement(); targetInstance.getLock(getLockId(key)); IAtomicLong account = targetInstance.getAtomicLong(getAccountId(key)); account.set(initialAmount); } }
@Verify public void verify() { int value = 0; for (int k = 0; k < maxAccounts; k++) { ILock lock = targetInstance.getLock(basename+k); IAtomicLong account = targetInstance.getAtomicLong(basename+k); System.out.println(account+" "+account.get()); assertFalse("Lock should be unlocked", lock.isLocked()); assertTrue("Amount is < 0 ", account.get() >= 0); value += account.get(); } assertEquals(totalValue, value); }
@Warmup(global = true) public void warmup() throws Exception { for (int k = 0; k < lockCount; k++) { long key = lockCounter.getAndIncrement(); targetInstance.getLock(getLockId(key)); IAtomicLong account = targetInstance.getAtomicLong(getAccountId(key)); account.set(initialAmount); totalMoney.addAndGet(initialAmount); } }
@Teardown public void teardown() { lockCounter.destroy(); for (long i = 0; i < lockCounter.get(); i++) { targetInstance.getLock(getLockId(i)).destroy(); targetInstance.getAtomicLong(getAccountId(i)).destroy(); } } }
@Teardown public void teardown() throws Exception { lockCounter.destroy(); totalMoney.destroy(); for (long k = 0; k < lockCounter.get(); k++) { targetInstance.getLock(getLockId(k)).destroy(); targetInstance.getAtomicLong(getAccountId(k)).destroy(); } }