diff options
author | Harald Musum <musum@yahooinc.com> | 2022-09-07 19:54:43 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-09-07 19:54:43 +0200 |
commit | 3ccd10630d013821abfa70a3fd8c1067ddb4eb54 (patch) | |
tree | 30453c972c21bb523162050bc7170ed4094c288b /clustercontroller-core | |
parent | 9ebb7848b51f05209ab735e05d115c55d08ade1a (diff) |
Remove unused and undocumented partition state request support
Diffstat (limited to 'clustercontroller-core')
6 files changed, 17 insertions, 177 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerStateRestAPI.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerStateRestAPI.java index 60b60d5fc89..5ca76d40fe1 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerStateRestAPI.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterControllerStateRestAPI.java @@ -2,7 +2,12 @@ package com.yahoo.vespa.clustercontroller.core.restapiv2; import com.yahoo.vespa.clustercontroller.core.RemoteClusterControllerTaskScheduler; -import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.*; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.ClusterListRequest; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.ClusterStateRequest; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.NodeStateRequest; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.ServiceStateRequest; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStateRequest; +import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStatesForClusterRequest; import com.yahoo.vespa.clustercontroller.utils.staterestapi.StateRestAPI; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OtherMasterException; @@ -11,8 +16,6 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStat import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.UnitStateRequest; import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse; import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse; - -import java.util.EnumSet; import java.util.Map; import java.util.Objects; import java.util.logging.Logger; @@ -86,10 +89,6 @@ public class ClusterControllerStateRestAPI implements StateRestAPI { public Request<? extends UnitResponse> visitNode(Id.Node id) { return new NodeStateRequest(id); } - @Override - public Request<? extends UnitResponse> visitPartition(Id.Partition id) { - return new PartitionStateRequest(id, EnumSet.of(VerboseReport.STATISTICS)); - } }); if (req instanceof ClusterListRequest) { log.fine("Got cluster list request"); diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/UnitPathResolver.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/UnitPathResolver.java index 9c32d0511bb..11fd5f39fad 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/UnitPathResolver.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/UnitPathResolver.java @@ -6,8 +6,6 @@ import com.yahoo.vespa.clustercontroller.core.RemoteClusterControllerTaskSchedul import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingUnitException; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OperationNotSupportedForUnitException; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException; -import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse; - import java.util.HashMap; import java.util.Map; @@ -19,16 +17,15 @@ public class UnitPathResolver<T> { Request<? extends T> visitCluster(Id.Cluster id) throws StateRestApiException; Request<? extends T> visitService(Id.Service id) throws StateRestApiException; Request<? extends T> visitNode(Id.Node id) throws StateRestApiException; - Request<? extends T> visitPartition(Id.Partition id) throws StateRestApiException; } public static abstract class AbstractVisitor<T> implements Visitor<T> { - private final String path[]; + private final String[] path; private final String failureMessage; - public AbstractVisitor(String path[], String failureMessage) { + public AbstractVisitor(String[] path, String failureMessage) { this.path = path; this.failureMessage = failureMessage; } @@ -40,7 +37,6 @@ public class UnitPathResolver<T> { public Request<? extends T> visitCluster(Id.Cluster id) throws StateRestApiException { return fail(); } public Request<? extends T> visitService(Id.Service id) throws StateRestApiException { return fail(); } public Request<? extends T> visitNode(Id.Node id) throws StateRestApiException { return fail(); } - public Request<? extends T> visitPartition(Id.Partition id) throws StateRestApiException { return fail(); } } @@ -50,7 +46,7 @@ public class UnitPathResolver<T> { this.fleetControllers = new HashMap<>(fleetControllers); } - public RemoteClusterControllerTaskScheduler resolveFleetController(String path[]) throws StateRestApiException { + public RemoteClusterControllerTaskScheduler resolveFleetController(String[] path) throws StateRestApiException { if (path.length == 0) return null; RemoteClusterControllerTaskScheduler fc = fleetControllers.get(path[0]); if (fc == null) { @@ -59,7 +55,7 @@ public class UnitPathResolver<T> { return fc; } - public Request<? extends T> visit(String path[], Visitor<T> visitor) throws StateRestApiException { + public Request<? extends T> visit(String[] path, Visitor<T> visitor) throws StateRestApiException { if (path.length == 0) { return visitor.visitGlobal(); } @@ -87,15 +83,6 @@ public class UnitPathResolver<T> { if (path.length == 3) { return visitor.visitNode(node); } - Id.Partition partition; - try{ - partition = new Id.Partition(node, Integer.valueOf(path[3])); - } catch (NumberFormatException e) { - throw new MissingUnitException(path, 3); - } - if (path.length == 4) { - return visitor.visitPartition(partition); - } throw new MissingUnitException(path, 4); } diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/PartitionStateRequest.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/PartitionStateRequest.java deleted file mode 100644 index 345a998e873..00000000000 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/PartitionStateRequest.java +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.clustercontroller.core.restapiv2.requests; - -import com.yahoo.vdslib.state.NodeState; -import com.yahoo.vespa.clustercontroller.core.RemoteClusterControllerTask; -import com.yahoo.vespa.clustercontroller.core.hostinfo.Metrics; -import com.yahoo.vespa.clustercontroller.core.restapiv2.Id; -import com.yahoo.vespa.clustercontroller.core.restapiv2.Request; -import com.yahoo.vespa.clustercontroller.core.restapiv2.Response; -import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException; - -import java.util.Set; -import java.util.logging.Logger; - -//TODO Remove once we have ensured that partition level is no longer used (it has never been) -public class PartitionStateRequest extends Request<Response.PartitionResponse> { - private static final Logger log = Logger.getLogger(PartitionStateRequest.class.getName()); - private final Id.Partition id; - private final Set<VerboseReport> verboseReports; - - public PartitionStateRequest(Id.Partition id, Set<VerboseReport> verboseReports) { - super(MasterState.MUST_BE_MASTER); - this.id = id; - this.verboseReports = verboseReports; - } - - @Override - public Response.PartitionResponse calculateResult(RemoteClusterControllerTask.Context context) - throws StateRestApiException { - Response.PartitionResponse result = new Response.PartitionResponse(); - if (verboseReports.contains(VerboseReport.STATISTICS)) { - fillInMetrics(context.cluster.getNodeInfo(id.getNode()).getHostInfo().getMetrics(), result); - } - NodeState nodeState = context.currentConsolidatedState.getNodeState(id.getNode()); - result.addState("generated", new Response.UnitStateImpl(nodeState)); - - return result; - } - - private static void fillInMetrics(Metrics metrics, Response.PartitionResponse result) { - for (Metrics.Metric metric: metrics.getMetrics()) { - fillInMetricValue(metric.getName(), metric.getValue(), result); - } - } - - private static void fillInMetricValue( - String name, Metrics.Value value, Response.PartitionResponse result) { - if (name.equals("vds.datastored.alldisks.docs")) { - if (value.getLast() == null) { - log.warning("Proper doc count value did not exist in value set."); - return; - } - result.addMetric("unique-document-count", value.getLast()); - } else if (name.equals("vds.datastored.alldisks.bytes")) { - if (value.getLast() == null) { - log.warning("Proper doc size value did not exist in value set."); - return; - } - result.addMetric("unique-document-total-size", value.getLast()); - } else if (name.equals("vds.datastored.alldisks.buckets")) { - if (value.getLast() == null) { - log.warning("Proper bucket count value did not exist in value set."); - return; - } - result.addMetric("bucket-count", value.getLast()); - } - } -} diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java index 15aeded2d37..3beeecf8dc4 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java @@ -4,10 +4,12 @@ package com.yahoo.vespa.clustercontroller.core.restapiv2; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OtherMasterException; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException; import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse; -import static com.yahoo.vespa.defaults.Defaults.getDefaults; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static com.yahoo.vespa.defaults.Defaults.getDefaults; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class NotMasterTest extends StateRestApiTest { @@ -52,12 +54,6 @@ public class NotMasterTest extends StateRestApiTest { assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage()); } try { - restAPI.getState(new StateRequest("music/storage/1/0", 0)); - fail(); - } catch (UnknownMasterException e) { - assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage()); - } - try { restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1") .setNewState("user", "down", "test")); fail(); @@ -116,14 +112,6 @@ public class NotMasterTest extends StateRestApiTest { assertEquals(e.getPort(), getDefaults().vespaWebServicePort()); } try { - restAPI.getState(new StateRequest("music/storage/1/0", 0)); - fail(); - } catch (OtherMasterException e) { - assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage()); - assertEquals("otherhost", e.getHost()); - assertEquals(e.getPort(), getDefaults().vespaWebServicePort()); - } - try { restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1") .setNewState("user", "down", "test")); fail(); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java deleted file mode 100644 index 65acea02d34..00000000000 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.clustercontroller.core.restapiv2; - -import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse; -import org.codehaus.jettison.json.JSONObject; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class PartitionTest extends StateRestApiTest { - - @Test - void testPartition() throws Exception { - setUp(true); - UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 0)); - String expected = - "{\n" + - " \"state\": {\"generated\": {\n" + - " \"state\": \"up\",\n" + - " \"reason\": \"\"\n" + - " }},\n" + - " \"metrics\": {\n" + - " \"bucket-count\": 1,\n" + - " \"unique-document-count\": 2,\n" + - " \"unique-document-total-size\": 3\n" + - " }\n" + - "}"; - assertEquals(expected, jsonWriter.createJson(response).toString(2)); - } - - @Test - void testRecursiveCluster() throws Exception { - setUp(true); - UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 1)); - String expected = - "{\n" + - " \"state\": {\"generated\": {\n" + - " \"state\": \"up\",\n" + - " \"reason\": \"\"\n" + - " }},\n" + - " \"metrics\": {\n" + - " \"bucket-count\": 1,\n" + - " \"unique-document-count\": 2,\n" + - " \"unique-document-total-size\": 3\n" + - " }\n" + - "}"; - assertEquals(expected, jsonWriter.createJson(response).toString(2)); - } -} diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java index 1b52194b270..33a962a532d 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java @@ -341,6 +341,7 @@ public class SetNodeStateTest extends StateRestApiTest { setUp(true); String wrongUnitMessage = "State can only be set at cluster or node level"; + try { restAPI.setUnitState(new SetUnitStateRequestImpl( "").setNewState("user", "down", "testing")); @@ -349,8 +350,6 @@ public class SetNodeStateTest extends StateRestApiTest { assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage()); } - // ... setting at cluster-level is allowed - try { restAPI.setUnitState(new SetUnitStateRequestImpl( "music/distributor").setNewState("user", "down", "testing")); @@ -358,16 +357,6 @@ public class SetNodeStateTest extends StateRestApiTest { } catch (OperationNotSupportedForUnitException e) { assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage()); } - - // ... setting at node-level is allowed - - try { - restAPI.setUnitState(new SetUnitStateRequestImpl( - "music/storage/1/0").setNewState("user", "down", "testing")); - fail(); - } catch (OperationNotSupportedForUnitException e) { - assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage()); - } } @Test @@ -403,12 +392,6 @@ public class SetNodeStateTest extends StateRestApiTest { fail(); } catch (MissingUnitException e) { } - try { - restAPI.setUnitState(new SetUnitStateRequestImpl( - "music/storage/1/bar").setNewState("user", "down", "testing")); - fail(); - } catch (MissingUnitException e) { - } } @Test @@ -520,7 +503,7 @@ public class SetNodeStateTest extends StateRestApiTest { // important to test (and expected to happen) for requests that have dependencies on cluster // state version publishing. @Test - void leadership_loss_fails_set_node_state_request() throws Exception { + void leadership_loss_fails_set_node_state_request() { Throwable exception = assertThrows(UnknownMasterException.class, () -> { SetNodeStateRequest request = createDummySetNodeStateRequest(); @@ -538,7 +521,7 @@ public class SetNodeStateTest extends StateRestApiTest { } @Test - void deadline_exceeded_fails_set_node_state_request() throws Exception { + void deadline_exceeded_fails_set_node_state_request() { Throwable exception = assertThrows(DeadlineExceededException.class, () -> { SetNodeStateRequest request = createDummySetNodeStateRequest(); |