From 7c18bb73fb7081b3c8d7e5287c9faf5fc302b649 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 21 Aug 2024 15:44:32 +0200 Subject: [PATCH] Avoid this escape --- .../core/ContentCluster.java | 2 +- .../core/database/MasterDataGatherer.java | 13 +++++++++--- .../core/restapiv2/Response.java | 20 +++++++++---------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java index c0710a2898f7..7192bc681d35 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/ContentCluster.java @@ -19,7 +19,7 @@ import static com.yahoo.vdslib.state.NodeState.ORCHESTRATOR_RESERVED_DESCRIPTION; import static com.yahoo.vespa.clustercontroller.core.NodeStateChangeChecker.Result; -public class ContentCluster { +public final class ContentCluster { private static final int pollingFrequency = 5000; diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/database/MasterDataGatherer.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/database/MasterDataGatherer.java index 3f6c494a3623..91625e64472c 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/database/MasterDataGatherer.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/database/MasterDataGatherer.java @@ -1,16 +1,23 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.core.database; +import org.apache.zookeeper.AsyncCallback; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.WatchedEvent; +import org.apache.zookeeper.Watcher; +import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.Stat; -import org.apache.zookeeper.*; import java.nio.charset.StandardCharsets; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.logging.Logger; -import java.util.*; import java.util.logging.Level; -public class MasterDataGatherer { +public final class MasterDataGatherer { private static final Logger log = Logger.getLogger(MasterDataGatherer.class.getName()); diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/Response.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/Response.java index 7af5f93fa219..ec6bf5045ed6 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/Response.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/Response.java @@ -32,16 +32,16 @@ public UnitStateImpl(NodeState ns) throws StateRestApiException { this.reason = ns.getDescription(); } - public String parseId(State id) throws StateRestApiException { - switch (id) { - case UP: return "up"; - case DOWN: return "down"; - case INITIALIZING: return "initializing"; - case MAINTENANCE: return "maintenance"; - case RETIRED: return "retired"; - case STOPPING: return "stopping"; - } - throw new InternalFailure("Unknown state '" + id + "' found."); + public static String parseId(State id) throws StateRestApiException { + return switch (id) { + case UP -> "up"; + case DOWN -> "down"; + case INITIALIZING -> "initializing"; + case MAINTENANCE -> "maintenance"; + case RETIRED -> "retired"; + case STOPPING -> "stopping"; + default -> throw new InternalFailure("Unknown state '" + id + "' found."); + }; } @Override