Java 类com.hazelcast.core.IAtomicReference 实例源码

项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
@Setup
public void setup() {
    values = new Object[valueCount];
    Random random = new Random();
    for (int i = 0; i < valueCount; i++) {
        if (useStringValue) {
            values[i] = generateString(valueLength);
        } else {
            values[i] = generateByteArray(random, valueLength);
        }
    }

    counters = getCounters();
    String[] names = generateStringKeys(name, countersLength, keyLocality, targetInstance);
    for (int i = 0; i < counters.length; i++) {
        IAtomicReference<Object> atomicReference = targetInstance.getAtomicReference(names[i]);
        atomicReference.set(values[random.nextInt(values.length)]);
        counters[i] = atomicReference;
    }
}
项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
@Teardown
public void teardown() {
    for (IAtomicReference counter : counters) {
        counter.destroy();
    }
    logger.info(getOperationCountInformation(targetInstance));
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public <E> IAtomicReference<E> getAtomicReference(String s) {
    return null;
}
项目:Cherry    文件:HazelcastService.java   
@Override
public <E> IAtomicReference<E> getAtomicReference(final String name) {
  return getHazelcastInstance().getAtomicReference(name);
}
项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
@SuppressWarnings("unchecked")
private IAtomicReference<Object>[] getCounters() {
    return (IAtomicReference<Object>[]) new IAtomicReference[countersLength];
}
项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
@TimeStep(prob = 1)
public void put(ThreadState state) {
    IAtomicReference<Object> counter = state.getRandomCounter();
    Object value = values[state.randomInt(values.length)];
    counter.set(value);
}
项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
@TimeStep(prob = -1)
public void get(ThreadState state) {
    IAtomicReference<Object> counter = state.getRandomCounter();
    counter.get();
}
项目:hazelcast-simulator    文件:AtomicReferenceTest.java   
private IAtomicReference<Object> getRandomCounter() {
    return counters[randomInt(counters.length)];
}
项目:jcconf2014-hazelcast-sample    文件:HazelcastHelper.java   
/**
 * Returns the atomic reference related with the given name.
 *
 * @param referenceName the atomic reference
 * @return the name of atomic reference
 * @throws NullPointerException if the given name is {@code null}
 */
private static <T> IAtomicReference<T> getAtomicReference(final String referenceName) {
    Objects.requireNonNull(referenceName, "The given atomic reference name must not be null.");
    return Holder.INSTANCE.getInstance().getAtomicReference(referenceName);
}