io.hekate.cluster.split.SplitBrainDetector Maven / Gradle / Ivy
Show all versions of hekate-core Show documentation
/*
* Copyright 2020 The Hekate Project
*
* The Hekate Project licenses this file to you 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 io.hekate.cluster.split;
import io.hekate.cluster.ClusterNode;
import io.hekate.cluster.ClusterServiceFactory;
/**
* Cluster split-brain detector.
*
*
* This interface represents a component which is responsible for cluster split-brain detection.
*
*
*
* Implementations of this component should perform a quick check (possibly by consulting with some shared resource) and verify that local
* node can reach other nodes.
*
*
*
* Cluster service calls this component when any of the following events happens:
*
*
* - Right before the local node joins to the cluster
* - When some other node leaves the cluster
* - Periodically, if {@link ClusterServiceFactory#setSplitBrainCheckInterval(long)} is set to a positive value
*
*
*
* If this component detects that local node can't reach other nodes then the cluster service will take actions according to the {@link
* SplitBrainAction} defined in its {@link ClusterServiceFactory#setSplitBrainDetector(SplitBrainDetector) configuration}.
*
*
*
* Note that it is possible combine multiple detectors with the help of {@link SplitBrainDetectorGroup}.
*
*
* @see ClusterServiceFactory#setSplitBrainDetector(SplitBrainDetector)
*/
public interface SplitBrainDetector {
/**
* Performs a split-brain check and returns {@code true} if local node can reach other members of the cluster.
*
*
* If this method returns {@code false} then the cluster service will take actions according to the {@link
* SplitBrainAction} defined in its {@link ClusterServiceFactory#setSplitBrainDetector(SplitBrainDetector) configuration}.
*
*
* @param localNode Local node (where the check is performed).
*
* @return {@code true} if local node can reach other members of the cluster.
*/
boolean isValid(ClusterNode localNode);
}