Search in sources :

Example 1 with RingbufferMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes in project hazelcast by hazelcast.

the class MergeOperation method merge.

/**
 * Merges the provided {@code mergingValue} into the {@code existingContainer}
 * and returns the merged ringbuffer.
 *
 * @param existingContainer the container into which to merge the data
 * @param mergingValue      the data to merge
 * @return the merged ringbuffer
 */
private Ringbuffer<Object> merge(RingbufferContainer<Object, Object> existingContainer, RingbufferMergeTypes mergingValue) {
    RingbufferMergeTypes existingValue = createMergingValueOrNull(existingContainer);
    RingbufferMergeData resultData = mergePolicy.merge(mergingValue, existingValue);
    if (resultData == null) {
        ringbufferService.destroyDistributedObject(namespace.getObjectName());
        return null;
    } else {
        if (existingContainer == null) {
            RingbufferConfig config = getRingbufferConfig(ringbufferService, namespace);
            existingContainer = ringbufferService.getOrCreateContainer(getPartitionId(), namespace, config);
        }
        setRingbufferData(resultData, existingContainer);
        return existingContainer.getRingbuffer();
    }
}
Also used : RingbufferMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes) RingbufferMergeData(com.hazelcast.spi.merge.RingbufferMergeData) RingbufferConfig(com.hazelcast.config.RingbufferConfig)

Example 2 with RingbufferMergeTypes

use of com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes in project hazelcast by hazelcast.

the class MergeOperation method run.

@Override
public void run() throws Exception {
    RingbufferContainer<Object, Object> existingContainer = ringbufferService.getContainerOrNull(getPartitionId(), namespace);
    RingbufferMergeTypes mergingValue = createMergingValue(serializationService, mergingRingbuffer);
    mergePolicy = (SplitBrainMergePolicy<RingbufferMergeData, RingbufferMergeTypes, RingbufferMergeData>) serializationService.getManagedContext().initialize(mergePolicy);
    resultRingbuffer = merge(existingContainer, mergingValue);
}
Also used : RingbufferMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes) RingbufferMergeData(com.hazelcast.spi.merge.RingbufferMergeData) IOUtil.readObject(com.hazelcast.internal.nio.IOUtil.readObject) IOUtil.writeObject(com.hazelcast.internal.nio.IOUtil.writeObject)

Aggregations

RingbufferMergeData (com.hazelcast.spi.merge.RingbufferMergeData)2 RingbufferMergeTypes (com.hazelcast.spi.merge.SplitBrainMergeTypes.RingbufferMergeTypes)2 RingbufferConfig (com.hazelcast.config.RingbufferConfig)1 IOUtil.readObject (com.hazelcast.internal.nio.IOUtil.readObject)1 IOUtil.writeObject (com.hazelcast.internal.nio.IOUtil.writeObject)1