diff options
Diffstat (limited to 'clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraint.java')
-rw-r--r-- | clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraint.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraint.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraint.java new file mode 100644 index 00000000000..35cfb76f0ce --- /dev/null +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/UpEdgeMaintenanceTransitionConstraint.java @@ -0,0 +1,37 @@ +// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.vespa.clustercontroller.core; + +import com.yahoo.vdslib.state.ClusterState; +import com.yahoo.vdslib.state.Node; +import com.yahoo.vdslib.state.NodeState; + +/** + * Simple implementation which considers a node eligible for being set to maintenance iff + * it was down or in maintenance in the cluster state previously published. This avoids + * taking down nodes with pending global merges if these have already passed through an + * up-edge, but runs the risk of taking down a large set of nodes when the cluster + * controller is restarted (due to not knowing the previously published state). + * + * Output from this checker must always be combined with other constraints to decide whether + * a node should be in maintenance; used alone it would most certainly cause havoc. + * + * Considered sufficient for beta testing use cases. + */ +public class UpEdgeMaintenanceTransitionConstraint implements MaintenanceTransitionConstraint { + + private final ClusterState previouslyPublishedDerivedState; + + private UpEdgeMaintenanceTransitionConstraint(ClusterState previouslyPublishedDerivedState) { + this.previouslyPublishedDerivedState = previouslyPublishedDerivedState; + } + + public static UpEdgeMaintenanceTransitionConstraint forPreviouslyPublishedState(ClusterState state) { + return new UpEdgeMaintenanceTransitionConstraint(state); + } + + @Override + public boolean maintenanceTransitionAllowed(int contentNodeIndex) { + NodeState prevState = previouslyPublishedDerivedState.getNodeState(Node.ofStorage(contentNodeIndex)); + return prevState.getState().oneOf("dm"); + } +} |