From 767412c8d62f4a2a8506b018da76b57a1f340a27 Mon Sep 17 00:00:00 2001 From: HÃ¥kon Hallingstad Date: Tue, 24 Oct 2017 14:03:07 +0200 Subject: Update wanted state on description changes, and fix method names --- .../restapiv2/requests/SetNodeStateRequest.java | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'clustercontroller-core') diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java index 79441bc4bb4..5b140ee2d87 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java @@ -22,6 +22,7 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState; import java.util.Map; +import java.util.Objects; import java.util.logging.Logger; public class SetNodeStateRequest extends Request { @@ -98,7 +99,7 @@ public class SetNodeStateRequest extends Request { " new-wanted-state=" + newWantedState + " change-check=" + result); - boolean success = ensureWantedState( + boolean success = setWantedStateAccordingToResult( result, newWantedState, condition, @@ -115,12 +116,13 @@ public class SetNodeStateRequest extends Request { * Returns true if the current/old wanted state already matches the requested * wanted state, or the requested state has been accepted as the new wanted state. */ - private static boolean ensureWantedState(NodeStateChangeChecker.Result result, - NodeState newWantedState, - SetUnitStateRequest.Condition condition, - NodeInfo nodeInfo, - ContentCluster cluster, - NodeStateOrHostInfoChangeHandler stateListener) { + private static boolean setWantedStateAccordingToResult( + NodeStateChangeChecker.Result result, + NodeState newWantedState, + SetUnitStateRequest.Condition condition, + NodeInfo nodeInfo, + ContentCluster cluster, + NodeStateOrHostInfoChangeHandler stateListener) { if (result.settingWantedStateIsAllowed()) { setNewWantedState(nodeInfo, newWantedState, stateListener); } @@ -133,7 +135,7 @@ public class SetNodeStateRequest extends Request { // of the distributor. E.g. setting the storage node to maintenance may cause // feeding issues unless distributor is also set down. - ensureDistributorWantedState(cluster, nodeInfo.getNodeIndex(), newWantedState, stateListener); + setDistributorWantedState(cluster, nodeInfo.getNodeIndex(), newWantedState, stateListener); } return success; @@ -143,10 +145,10 @@ public class SetNodeStateRequest extends Request { * Set the wanted state on the distributor to something appropriate given the storage is being * set to (or is equal to) newStorageWantedState. */ - private static void ensureDistributorWantedState(ContentCluster cluster, - int index, - NodeState newStorageWantedState, - NodeStateOrHostInfoChangeHandler stateListener) { + private static void setDistributorWantedState(ContentCluster cluster, + int index, + NodeState newStorageWantedState, + NodeStateOrHostInfoChangeHandler stateListener) { Node distributorNode = new Node(NodeType.DISTRIBUTOR, index); NodeInfo nodeInfo = cluster.getNodeInfo(distributorNode); if (nodeInfo == null) { @@ -174,7 +176,9 @@ public class SetNodeStateRequest extends Request { newWantedState.setDescription(newStorageWantedState.getDescription()); NodeState currentWantedState = nodeInfo.getUserWantedState(); - if (newWantedState.getState() != currentWantedState.getState()) { + if (newWantedState.getState() != currentWantedState.getState() || + !Objects.equals(newWantedState.getDescription(), + currentWantedState.getDescription())) { setNewWantedState(nodeInfo, newWantedState, stateListener); } } -- cgit v1.2.3