public long addAndGet(long delta) { if (this.clustered) { return this.hzAtomicLong.addAndGet(delta); } else { return this.atomicLong.addAndGet(delta); } }
@AfterRun public void afterRun(ThreadState state) { totalCounter.addAndGet(state.increments); }
@AfterRun public void afterRun(ThreadState state) { expectedExecutedCounter.addAndGet(state.iteration); }
@AfterRun public void afterRun(ThreadState state) { totalExpectedCounter.addAndGet(state.count); }
@Override public void increment(String key, double by) { IAtomicLong long2 = h.getAtomicLong(key); long2.addAndGet((long) by); }
@AfterRun public void afterRun(ThreadState state) { totalCounter.addAndGet(state.increments); }
@AfterRun public void afterRun(ThreadState state) { totalMessagesSend.addAndGet(state.messagesSend); }
@AfterRun(executionGroup = "consumer") public void afterRun(ConsumerState state) { logger.severe("AfterRun(ConsumerState) caller with state: " + state.consumed); consumed.addAndGet(state.consumed); }
@ManagedAnnotation(value = "addAndGet", operation = true) @ManagedDescription("add value and get") public long addAndGet(long delta) { return managedObject.addAndGet(delta); }
@ManagedAnnotation(value = "addAndGet", operation = true) @ManagedDescription("add value and get") public long addAndGet(long delta) { return managedObject.addAndGet(delta); }
@Override public void run() { long iteration = 0; while (!testContext.isStopped()) { counter.incrementAndGet(); if (iteration % logFrequency == 0) { log.info(Thread.currentThread().getName() + " At iteration: " + iteration); } if (iteration % performanceUpdateFrequency == 0) { operations.addAndGet(performanceUpdateFrequency); } iteration++; } totalCounter.addAndGet(iteration); }
/** * Add given value to the distribute counter of caller context of given id. If it's not * distributed return local counter * * @param id of the caller context * @param value to set to the global counter */ public static long addAndGetDistributedCounter(String id, long value) { HazelcastInstance hazelcastInstance = getHazelcastInstance(); id = ThrottleConstants.THROTTLE_SHARED_COUNTER_KEY + id; if(hazelcastInstance != null) { return hazelcastInstance.getAtomicLong(id).addAndGet(value); } else { long currentCount = counters.get(id); long updatedCount = currentCount + value; counters.put(id, updatedCount); return updatedCount; } }
@Override public void run() { long iteration = 0; while (!context.isStopped()) { IAtomicLong counter = getRandomCounter(); counter.incrementAndGet(); if (iteration % logFrequency == 0) { log.info(Thread.currentThread().getName() + " At iteration: " + iteration); } if (iteration % performanceUpdateFrequency == 0) { operations.addAndGet(performanceUpdateFrequency); } iteration++; } totalCounter.addAndGet(iteration); }
@AfterRun(executionGroup = "producer") public void afterRun(ProducerState state) { logger.severe("AfterRun(ProducerState) caller with state: " + state.produced); produced.addAndGet(state.produced); workQueue.add(-1L); }
public static void main(String[] args) { // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1 HazelcastInstance hz = HazelcastClient.newHazelcastClient(); // Get an Atomic Counter, we'll call it "counter" IAtomicLong counter = hz.getAtomicLong("counter"); // Add and Get the "counter" counter.addAndGet(3); // value is now 3 // Display the "counter" value System.out.println("counter: " + counter.get()); // Shutdown this Hazelcast Client hz.shutdown(); } }
public static void main(String[] args) { // Start the Embedded Hazelcast Cluster Member. HazelcastInstance hz = Hazelcast.newHazelcastInstance(); // Get an Atomic Counter, we'll call it "counter" IAtomicLong counter = hz.getAtomicLong("counter"); // Add and Get the "counter" counter.addAndGet(3); // value is now 3 // Multiply the "counter" by passing it an IFunction counter.alter(new MultiplyByTwo()); //value is now 6 // Display the "counter" value System.out.println("counter: " + counter.get()); // Shutdown this Hazelcast Cluster Member hz.shutdown(); } }
@Override public void run() { try { long iteration = 0; while (!testContext.isStopped()) { long item = fromQueue.take(); toQueue.put(item + 1); if (iteration % 200 == 0) { log.info(Thread.currentThread().getName() + " At iteration: " + iteration+" fromQueue size="+fromQueue.size()+", toQueue size="+toQueue.size()); } iteration++; } toQueue.put(0L); totalCounter.addAndGet(iteration); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
@Setup public void setup() { this.estimators = new CardinalityEstimator[estimatorCount]; this.expectedCountMap = targetInstance.getMap(testContext.getTestId() + "-expectedCountMap"); String[] names = generateStringKeys(name, estimatorCount, keyLocality, targetInstance); for (int i = 0; i < estimatorCount; i++) { String estimatorName = names[i]; estimators[i] = targetInstance.getCardinalityEstimator(estimatorName); expectedCountMap.set(estimatorName, 0L); } this.totalThreadCount = targetInstance.getAtomicLong(testContext.getTestId() + "-totalThreadCount"); this.totalThreadCount.addAndGet(threadCount); this.threadIdGenerator = targetInstance.getAtomicLong(testContext.getTestId() + "-threadIdGenerator"); }
@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); } }