Search in sources :

Example 1 with UNHEALTHY

use of org.opensearch.monitor.StatusInfo.Status.UNHEALTHY in project OpenSearch by opensearch-project.

the class Coordinator method startElectionScheduler.

private void startElectionScheduler() {
    assert electionScheduler == null : electionScheduler;
    if (getLocalNode().isMasterNode() == false) {
        return;
    }
    final TimeValue gracePeriod = TimeValue.ZERO;
    electionScheduler = electionSchedulerFactory.startElectionScheduler(gracePeriod, new Runnable() {

        @Override
        public void run() {
            synchronized (mutex) {
                if (mode == Mode.CANDIDATE) {
                    final ClusterState lastAcceptedState = coordinationState.get().getLastAcceptedState();
                    if (localNodeMayWinElection(lastAcceptedState) == false) {
                        logger.trace("skip prevoting as local node may not win election: {}", lastAcceptedState.coordinationMetadata());
                        return;
                    }
                    final StatusInfo statusInfo = nodeHealthService.getHealth();
                    if (statusInfo.getStatus() == UNHEALTHY) {
                        logger.debug("skip prevoting as local node is unhealthy: [{}]", statusInfo.getInfo());
                        return;
                    }
                    if (prevotingRound != null) {
                        prevotingRound.close();
                    }
                    final List<DiscoveryNode> discoveredNodes = getDiscoveredNodes().stream().filter(n -> isZen1Node(n) == false).collect(Collectors.toList());
                    prevotingRound = preVoteCollector.start(lastAcceptedState, discoveredNodes);
                }
            }
        }

        @Override
        public String toString() {
            return "scheduling of new prevoting round";
        }
    });
}
Also used : VotingConfigExclusion(org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion) Metadata(org.opensearch.cluster.metadata.Metadata) STATE_NOT_RECOVERED_BLOCK(org.opensearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK) AllocationService(org.opensearch.cluster.routing.allocation.AllocationService) Level(org.apache.logging.log4j.Level) Random(java.util.Random) Strings(org.opensearch.common.Strings) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) ActionListener(org.opensearch.action.ActionListener) UNHEALTHY(org.opensearch.monitor.StatusInfo.Status.UNHEALTHY) TimeValue(org.opensearch.common.unit.TimeValue) ClusterApplier(org.opensearch.cluster.service.ClusterApplier) MasterService(org.opensearch.cluster.service.MasterService) Collection(java.util.Collection) NodeHealthService(org.opensearch.monitor.NodeHealthService) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) HandshakingTransportAddressConnector(org.opensearch.discovery.HandshakingTransportAddressConnector) TransportService(org.opensearch.transport.TransportService) Collectors(java.util.stream.Collectors) Nullable(org.opensearch.common.Nullable) TransportAddress(org.opensearch.common.transport.TransportAddress) AbstractLifecycleComponent(org.opensearch.common.component.AbstractLifecycleComponent) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Stream(java.util.stream.Stream) ClusterStateUpdateTask(org.opensearch.cluster.ClusterStateUpdateTask) StatusInfo(org.opensearch.monitor.StatusInfo) Optional(java.util.Optional) ListenableFuture(org.opensearch.common.util.concurrent.ListenableFuture) Scheduler(org.opensearch.threadpool.Scheduler) Names(org.opensearch.threadpool.ThreadPool.Names) DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Priority(org.opensearch.common.Priority) Releasable(org.opensearch.common.lease.Releasable) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) OpenSearchExecutors(org.opensearch.common.util.concurrent.OpenSearchExecutors) Supplier(java.util.function.Supplier) SeedHostsResolver(org.opensearch.discovery.SeedHostsResolver) NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) PeerFinder(org.opensearch.discovery.PeerFinder) LegacyESVersion(org.opensearch.LegacyESVersion) ClusterApplyListener(org.opensearch.cluster.service.ClusterApplier.ClusterApplyListener) DiscoveryStats(org.opensearch.discovery.DiscoveryStats) Booleans(org.opensearch.common.Booleans) RerouteService(org.opensearch.cluster.routing.RerouteService) BiConsumer(java.util.function.BiConsumer) ClusterStateTaskConfig(org.opensearch.cluster.ClusterStateTaskConfig) StreamSupport(java.util.stream.StreamSupport) VoteCollection(org.opensearch.cluster.coordination.CoordinationState.VoteCollection) ClusterSettings(org.opensearch.common.settings.ClusterSettings) ClusterBlocks(org.opensearch.cluster.block.ClusterBlocks) SeedHostsProvider(org.opensearch.discovery.SeedHostsProvider) Empty(org.opensearch.transport.TransportResponse.Empty) Setting(org.opensearch.common.settings.Setting) SetOnce(org.apache.lucene.util.SetOnce) ClusterFormationState(org.opensearch.cluster.coordination.ClusterFormationFailureHelper.ClusterFormationState) VotingConfiguration(org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfiguration) InitialJoinAccumulator(org.opensearch.cluster.coordination.JoinHelper.InitialJoinAccumulator) Discovery(org.opensearch.discovery.Discovery) IOException(java.io.IOException) NO_MASTER_BLOCK_ID(org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_ID) LocalClusterUpdateTask(org.opensearch.cluster.LocalClusterUpdateTask) XContentHelper(org.opensearch.common.xcontent.XContentHelper) FollowerCheckRequest(org.opensearch.cluster.coordination.FollowersChecker.FollowerCheckRequest) ClusterStateUpdaters.hideStateIfNotRecovered(org.opensearch.gateway.ClusterStateUpdaters.hideStateIfNotRecovered) JsonXContent(org.opensearch.common.xcontent.json.JsonXContent) ClusterName(org.opensearch.cluster.ClusterName) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) DiscoveryModule(org.opensearch.discovery.DiscoveryModule) ClusterChangedEvent(org.opensearch.cluster.ClusterChangedEvent) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) StatusInfo(org.opensearch.monitor.StatusInfo) TimeValue(org.opensearch.common.unit.TimeValue)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Random (java.util.Random)1 Set (java.util.Set)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 BiConsumer (java.util.function.BiConsumer)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StreamSupport (java.util.stream.StreamSupport)1 Level (org.apache.logging.log4j.Level)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)1 SetOnce (org.apache.lucene.util.SetOnce)1