@Override public long getNext() { return id.getAndIncrement(); }
@Override public long getAsLong() { return getDistributedObject().getAndIncrement(); } }
@Override public long newMessageID() { return hazelcast.getAtomicLong("MSGID-".concat(getName())).getAndIncrement(); }
@ManagedAnnotation(value = "getAndIncrement", operation = true) @ManagedDescription("get the current value then increment") public long getAndIncrement() { return managedObject.getAndIncrement(); }
@ManagedAnnotation(value = "getAndIncrement", operation = true) @ManagedDescription("get the current value then increment") public long getAndIncrement() { return managedObject.getAndIncrement(); }
@Override public synchronized Horse getByName(final String name) { final Collection<Horse> stud = cache.values(); final Optional<Horse> horse = stud.stream() .filter(h -> h.getName().equals(name)) .findFirst(); if (horse.isPresent()) return horse.get(); final Horse newHorse = new Horse(name, id.getAndIncrement()); cache.put(newHorse.getID(), newHorse); return newHorse; } }
@BeforeRun public void beforeRun(ThreadState state) { state.threadId = (int) threadIdGenerator.getAndIncrement(); state.totalThreadCount = (int) totalThreadCount.get(); logger.info("totalThreadCount: " + state.totalThreadCount); logger.info("threadId: " + state.threadId); }
@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); } }
@Override public long newId() { long block = local; int value = RESIDUE.getAndIncrement(this); if (local != block) { return newId(); } if (value < BLOCK_SIZE) { return block * BLOCK_SIZE + value; } synchronized (this) { value = residue; if (value >= BLOCK_SIZE) { LOCAL.set(this, blockGenerator.getAndIncrement()); RESIDUE.set(this, 0); } } return newId(); }
@Override public long newId() { long block = local; int value = RESIDUE.getAndIncrement(this); if (local != block) { return newId(); } if (value < BLOCK_SIZE) { return block * BLOCK_SIZE + value; } synchronized (this) { value = residue; if (value >= BLOCK_SIZE) { LOCAL.set(this, blockGenerator.getAndIncrement()); RESIDUE.set(this, 0); } } return newId(); }
@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); } }