com.hazelcast.spi.impl.merge.AbstractContainerMerger Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.spi.impl.merge;
import com.hazelcast.config.MergePolicyConfig;
import com.hazelcast.logging.ILogger;
import com.hazelcast.spi.impl.NodeEngine;
import com.hazelcast.spi.impl.executionservice.ExecutionService;
import com.hazelcast.spi.impl.operationservice.Operation;
import com.hazelcast.spi.impl.operationservice.OperationService;
import com.hazelcast.spi.merge.MergingValue;
import com.hazelcast.spi.merge.SplitBrainMergePolicy;
import com.hazelcast.spi.merge.SplitBrainMergePolicyProvider;
import java.util.concurrent.Executor;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import static com.hazelcast.internal.util.ExceptionUtil.rethrow;
/**
* Merges data structures which have been collected via an {@link AbstractContainerCollector}.
*
* @param container of the data structure
* @param the type of the merged value
* @param the type of the merging value, e.g. {@code MergingValue} or {@code MergingEntry & MergingHits}
*/
public abstract class AbstractContainerMerger> implements Runnable {
private static final long TIMEOUT_FACTOR = 500;
private static final long MINIMAL_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
protected final AbstractContainerCollector collector;
private final Semaphore semaphore = new Semaphore(0);
private final BiConsumer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy