summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2017-10-24 14:03:07 +0200
committerHåkon Hallingstad <hakon@oath.com>2017-10-24 14:03:07 +0200
commit767412c8d62f4a2a8506b018da76b57a1f340a27 (patch)
tree8adb2c9cf8f227aa4dcdca1f1340cbc908e3c67b /clustercontroller-core
parent133616e0bdbc44d8094d4365b5ba2c96560ded33 (diff)
Update wanted state on description changes, and fix method names
Diffstat (limited to 'clustercontroller-core')
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java30
1 files changed, 17 insertions, 13 deletions
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<SetResponse> {
@@ -98,7 +99,7 @@ public class SetNodeStateRequest extends Request<SetResponse> {
" 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<SetResponse> {
* 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<SetResponse> {
// 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<SetResponse> {
* 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<SetResponse> {
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);
}
}