diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-06-11 17:26:23 +0200 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@oath.com> | 2018-06-11 17:26:23 +0200 |
commit | be579425c40efc330e9b78b27024c1ea79dec1a2 (patch) | |
tree | f27f9386886e6a2508b78ab8ab88a124eeb9b2b6 /clustercontroller-core | |
parent | 8ec25d827c1cefa65d23b34a00284e1558bb1164 (diff) |
Remove support for ancient legacy node state protocol versions
Protocol versions 0 and 1 haven't been in use for years. No point
in maintaining complexity to support automatic downgrades to these.
Diffstat (limited to 'clustercontroller-core')
3 files changed, 17 insertions, 83 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java index 55331e4bbed..54cf2dad00a 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeInfo.java @@ -70,8 +70,10 @@ abstract public class NodeInfo implements Comparable<NodeInfo> { private long timeOfFirstFailingConnectionAttempt; /** * Sets the version of the state transaction that this node accepts. - * Version 0 is the original one, with getnodestate command. - * Version 1 is the new one, with getnodestate2 command too. + * Version 0 is the original one, with getnodestate command (legacy, not supported). + * Version 1 is for the getnodestate2 command ((legacy, not supported). + * Version 2 is for the getnodestate3 command + * Version 3 adds support for setdistributionstates */ private int version; @@ -374,15 +376,7 @@ abstract public class NodeInfo implements Comparable<NodeInfo> { /** @return True if we demoted communication version so this can be valid error. */ public boolean notifyNoSuchMethodError(String methodName, Timer timer) { - if (methodName.equals("getnodestate3")) { - if (version > 1) { - downgradeToRpcVersion(1, methodName, timer); - return true; - } else if (timer.getCurrentTimeInMillis() - 2000 < adjustedVersionTime) { - log.log(LogLevel.DEBUG, "Node " + toString() + " does not support " + methodName + " call. Version already at 1 and was recently adjusted, so ignoring it."); - return true; - } - } else if (methodName.equals(RPCCommunicator.SET_DISTRIBUTION_STATES_RPC_METHOD_NAME)) { + if (methodName.equals(RPCCommunicator.SET_DISTRIBUTION_STATES_RPC_METHOD_NAME)) { if (version == RPCCommunicator.SET_DISTRIBUTION_STATES_RPC_VERSION) { downgradeToRpcVersion(RPCCommunicator.LEGACY_SET_SYSTEM_STATE2_RPC_VERSION, methodName, timer); return true; @@ -390,14 +384,6 @@ abstract public class NodeInfo implements Comparable<NodeInfo> { log.log(LogLevel.DEBUG, () -> "Node " + toString() + " does not support " + methodName + " call. Version already downgraded, so ignoring it."); return true; } - } else if (methodName.equals("getnodestate2") || methodName.equals(RPCCommunicator.LEGACY_SET_SYSTEM_STATE2_RPC_METHOD_NAME)) { - if (version > 0) { - downgradeToRpcVersion(0, methodName, timer); - return true; - } else if (timer.getCurrentTimeInMillis() - 2000 < adjustedVersionTime) { - log.log(LogLevel.DEBUG, "Node " + toString() + " does not support " + methodName + " call. Version already at 0 and was recently adjusted, so ignoring it."); - return true; - } } log.log(LogLevel.WARNING, "Node " + toString() + " does not support " + methodName + " which it should."); return false; diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java index 8941b2e32ec..bad32f87a8c 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicator.java @@ -79,43 +79,6 @@ public class RPCCommunicator implements Communicator { return t; } - public void doVersion0HandShake(Target connection, final NodeInfo node) { - log.log(LogLevel.DEBUG, "Sending version 0 handshake request as version has been set down to 0 for " + node); - Request req = new Request("vespa.storage.connect"); - req.parameters().add(new StringValue("storage/cluster." + node.getCluster().getName() + (node.isDistributor() ? "/distributor/" : "/storage/") + node.getNodeIndex())); - connection.invokeAsync(req, 10.0, new RequestWaiter(){ - public void handleRequestDone(Request req) { - if (req.isError()) { - log.log(LogLevel.WARNING, "Failed to do version 0 handshake towards " + node + ", " + req.errorCode() + ": " + req.errorMessage()); - } else if (!req.checkReturnTypes("i")) { - log.log(LogLevel.WARNING, "Wrong arguments returned from version 0 handshake attempt towards " + node); - } else if (req.returnValues().get(0).asInt32() == 1) { - log.log(LogLevel.DEBUG, "Session already opened when handshaking towards " + node + "."); - } else if (req.returnValues().get(0).asInt32() > 1) { - log.log(LogLevel.WARNING, "Handshaking attempt towards " + node + " failed with code " + req.returnValues().get(0).asInt32()); - } - } - }); - node.setConnectionVersion(0); - } - - public void clearOldStoredNodeState(Target connection, final NodeInfo node) { - log.log(LogLevel.DEBUG, "In case old node had stored a wanted state it is reporting, send a command to clear any unwanted stored state."); - Request req = new Request("setnodestate"); - req.parameters().add(new StringValue("")); - connection.invokeAsync(req, 10.0, new RequestWaiter() { - public void handleRequestDone(Request req) { - if (req.isError()) { - if (node.getReportedState().getState() != State.DOWN) { - log.log(LogLevel.WARNING, "Failed to clear nodestate on old node " + node + ", " + req.errorCode() + ": " + req.errorMessage()); - } - } else if (!req.checkReturnTypes("is")) { - log.log(LogLevel.WARNING, "Wrong arguments returned from version 0 setnodestate attempt to clear any unwanted state on " + node); - } - } - }); - } - @Override public void propagateOptions(final FleetControllerOptions options) { checkArgument(options.nodeStateRequestTimeoutMS > 0); @@ -137,25 +100,13 @@ public class RPCCommunicator implements Communicator { if ( ! connection.isValid()) { log.log(LogLevel.DEBUG, "Connection to " + node.getRpcAddress() + " could not be created."); } - // TODO remove this deprecated legacy stuff - if (node.getVersion() == 0 && node.getConnectionVersion() > 0) { - doVersion0HandShake(connection, node); - clearOldStoredNodeState(connection, node); - } NodeState currentState = node.getReportedState(); - Request req; - if (node.getVersion() == 0) { - req = new Request("getnodestate"); - } else { - req = new Request(node.getVersion() == 1 ? "getnodestate2" : "getnodestate3"); - req.parameters().add(new StringValue( - currentState.getState().equals(State.DOWN) || node.getConnectionAttemptCount() > 0 - ? "unknown" : currentState.serialize())); - req.parameters().add(new Int32Value(generateNodeStateRequestTimeoutMs())); - if (node.getVersion() > 1) { - req.parameters().add(new Int32Value(fleetControllerIndex)); - } - } + Request req = new Request("getnodestate3"); + req.parameters().add(new StringValue( + currentState.getState().equals(State.DOWN) || node.getConnectionAttemptCount() > 0 + ? "unknown" : currentState.serialize())); + req.parameters().add(new Int32Value(generateNodeStateRequestTimeoutMs())); + req.parameters().add(new Int32Value(fleetControllerIndex)); RPCGetNodeStateRequest stateRequest = new RPCGetNodeStateRequest(node, req); RPCGetNodeStateWaiter waiter = new RPCGetNodeStateWaiter(stateRequest, externalWaiter, timer); @@ -179,16 +130,8 @@ public class RPCCommunicator implements Communicator { return; } final int nodeVersion = node.getVersion(); - // TODO remove this deprecated legacy stuff - if (nodeVersion == 0 && node.getConnectionVersion() > 0) { - doVersion0HandShake(connection, node); - clearOldStoredNodeState(connection, node); - } Request req; - if (nodeVersion == 0) { - req = new Request("setsystemstate"); - req.parameters().add(new StringValue(baselineState.toString(true))); - } else if (nodeVersion <= 2) { + if (nodeVersion <= 2) { req = new Request(LEGACY_SET_SYSTEM_STATE2_RPC_METHOD_NAME); req.parameters().add(new StringValue(baselineState.toString(false))); } else { diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java index 2665175c637..7602f0c83a2 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/rpc/RPCCommunicatorTest.java @@ -3,6 +3,9 @@ package com.yahoo.vespa.clustercontroller.core.rpc; import com.yahoo.jrt.*; import com.yahoo.vdslib.state.Node; +import com.yahoo.vdslib.state.NodeState; +import com.yahoo.vdslib.state.NodeType; +import com.yahoo.vdslib.state.State; import com.yahoo.vespa.clustercontroller.core.*; import org.junit.Test; import org.mockito.Mockito; @@ -87,6 +90,8 @@ public class RPCCommunicatorTest { when(target.isValid()).thenReturn(true); when(nodeInfo.getConnection()).thenReturn(target); + when(nodeInfo.getVersion()).thenReturn(3); + when(nodeInfo.getReportedState()).thenReturn(new NodeState(NodeType.DISTRIBUTOR, State.UP)); communicator.getNodeState(nodeInfo, null); Mockito.verify(target).invokeAsync( (Request)any(), |