Search in sources :

Example 1 with AtomicReferenceContainer

use of com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer in project hazelcast by hazelcast.

the class AlterOperation method run.

@Override
public void run() throws Exception {
    NodeEngine nodeEngine = getNodeEngine();
    IFunction f = nodeEngine.toObject(function);
    AtomicReferenceContainer reference = getReferenceContainer();
    Data originalData = reference.get();
    Object input = nodeEngine.toObject(originalData);
    //noinspection unchecked
    Object output = f.apply(input);
    Data serializedOutput = nodeEngine.toData(output);
    shouldBackup = !isEquals(originalData, serializedOutput);
    if (shouldBackup) {
        backup = serializedOutput;
        reference.set(backup);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer) Data(com.hazelcast.nio.serialization.Data) IFunction(com.hazelcast.core.IFunction)

Example 2 with AtomicReferenceContainer

use of com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer in project hazelcast by hazelcast.

the class ApplyOperation method run.

@Override
public void run() throws Exception {
    NodeEngine nodeEngine = getNodeEngine();
    IFunction f = nodeEngine.toObject(function);
    AtomicReferenceContainer atomicReferenceContainer = getReferenceContainer();
    Object input = nodeEngine.toObject(atomicReferenceContainer.get());
    //noinspection unchecked
    Object output = f.apply(input);
    returnValue = nodeEngine.toData(output);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer) IFunction(com.hazelcast.core.IFunction)

Example 3 with AtomicReferenceContainer

use of com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer in project hazelcast by hazelcast.

the class AtomicReferenceReplicationOperation method run.

@Override
public void run() throws Exception {
    AtomicReferenceService atomicReferenceService = getService();
    for (Map.Entry<String, Data> entry : migrationData.entrySet()) {
        String name = entry.getKey();
        AtomicReferenceContainer atomicReferenceContainer = atomicReferenceService.getReferenceContainer(name);
        Data value = entry.getValue();
        atomicReferenceContainer.set(value);
    }
}
Also used : AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer) Data(com.hazelcast.nio.serialization.Data) Map(java.util.Map) HashMap(java.util.HashMap) AtomicReferenceService(com.hazelcast.concurrent.atomicreference.AtomicReferenceService)

Example 4 with AtomicReferenceContainer

use of com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer in project hazelcast by hazelcast.

the class ContainsOperation method run.

@Override
public void run() throws Exception {
    AtomicReferenceContainer atomicReferenceContainer = getReferenceContainer();
    returnValue = atomicReferenceContainer.contains(contains);
}
Also used : AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer)

Example 5 with AtomicReferenceContainer

use of com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer in project hazelcast by hazelcast.

the class GetAndAlterOperation method run.

@Override
public void run() throws Exception {
    NodeEngine nodeEngine = getNodeEngine();
    IFunction f = nodeEngine.toObject(function);
    AtomicReferenceContainer atomicReferenceContainer = getReferenceContainer();
    response = atomicReferenceContainer.get();
    Object input = nodeEngine.toObject(atomicReferenceContainer.get());
    //noinspection unchecked
    Object output = f.apply(input);
    Data serializedOutput = nodeEngine.toData(output);
    shouldBackup = !isEquals(response, serializedOutput);
    if (shouldBackup) {
        atomicReferenceContainer.set(serializedOutput);
        backup = serializedOutput;
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer) Data(com.hazelcast.nio.serialization.Data) IFunction(com.hazelcast.core.IFunction)

Aggregations

AtomicReferenceContainer (com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer)12 IFunction (com.hazelcast.core.IFunction)4 Data (com.hazelcast.nio.serialization.Data)4 NodeEngine (com.hazelcast.spi.NodeEngine)4 AtomicReferenceService (com.hazelcast.concurrent.atomicreference.AtomicReferenceService)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1