summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorValerij Fredriksen <valerij92@gmail.com>2020-04-21 11:08:56 +0200
committerValerij Fredriksen <valerij92@gmail.com>2020-04-22 14:02:40 +0200
commitc8dde657c38721f3f55182143a892e40bdb14db3 (patch)
tree03df32660088dea40c006f0ebc63364b56033565 /node-admin
parent61df1c38e0ca751fd0b015fdf5070af7bcaf2d7e (diff)
Use ClusterType in NodeMembership
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeMembership.java48
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java2
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandler.java6
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/FileFinder.java2
4 files changed, 49 insertions, 9 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeMembership.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeMembership.java
index 22633f67463..3d89b3a991a 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeMembership.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/configserver/noderepository/NodeMembership.java
@@ -1,28 +1,35 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.node.admin.configserver.noderepository;
+import java.util.Objects;
+
/**
* @author freva
*/
public class NodeMembership {
- private final String clusterType;
+ private final ClusterType clusterType;
private final String clusterId;
private final String group;
private final int index;
private final boolean retired;
public NodeMembership(String clusterType, String clusterId, String group, int index, boolean retired) {
- this.clusterType = clusterType;
+ this.clusterType = new ClusterType(clusterType);
this.clusterId = clusterId;
this.group = group;
this.index = index;
this.retired = retired;
}
- public String clusterType() {
+ public ClusterType type() {
return clusterType;
}
+ /** DEPRECATED: Use {@link #type()} instead */
+ public String clusterType() {
+ return clusterType.value();
+ }
+
public String clusterId() {
return clusterId;
}
@@ -74,4 +81,39 @@ public class NodeMembership {
" retired = " + retired +
" }";
}
+
+ public static class ClusterType {
+ private final String type;
+
+ private ClusterType(String type) {
+ this.type = Objects.requireNonNull(type);
+ }
+
+ public boolean isAdmin() { return "admin".equals(type); }
+ public boolean isContent() { return "content".equals(type) || "combined".equals(type); }
+ public boolean isContainer() { return "container".equals(type) || "combined".equals(type); }
+
+ public String value() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ return type;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ClusterType that = (ClusterType) o;
+ return type.equals(that.type);
+ }
+
+ @Override
+ public int hashCode() {
+ return type.hashCode();
+ }
+ }
}
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
index f5bb46ef62a..d7f248250a8 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/docker/DockerOperationsImpl.java
@@ -88,7 +88,7 @@ public class DockerOperationsImpl implements DockerOperations {
if (context.nodeType() != NodeType.proxy && context.nodeType() != NodeType.controller)
command.withSecurityOpt("no-new-privileges");
- if (context.node().membership().map(NodeMembership::clusterType).map("content"::equalsIgnoreCase).orElse(false))
+ if (context.node().membership().map(m -> m.type().isContent()).orElse(false))
command.withSecurityOpt("seccomp=unconfined");
DockerNetworking networking = context.dockerNetworking();
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandler.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandler.java
index 6aa5a8d9fc1..9d20d973676 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandler.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/maintenance/coredump/CoredumpHandler.java
@@ -2,10 +2,8 @@
package com.yahoo.vespa.hosted.node.admin.maintenance.coredump;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions;
import com.yahoo.vespa.hosted.dockerapi.metrics.Metrics;
-import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeMembership;
import com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeSpec;
import com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentContext;
import com.yahoo.vespa.hosted.node.admin.task.util.file.FileFinder;
@@ -44,7 +42,7 @@ public class CoredumpHandler {
private static final String LZ4_PATH = "/usr/bin/lz4";
private static final String PROCESSING_DIRECTORY_NAME = "processing";
private static final String METADATA_FILE_NAME = "metadata.json";
- private static final String COREDUMP_FILENAME_PREFIX = "dump_";
+ public static final String COREDUMP_FILENAME_PREFIX = "dump_";
private final Logger logger = Logger.getLogger(CoredumpHandler.class.getName());
private final ObjectMapper objectMapper = new ObjectMapper();
@@ -245,7 +243,7 @@ public class CoredumpHandler {
node.membership().ifPresent(membership ->
dimensionsBuilder
- .add("clustertype", membership.clusterType())
+ .add("clustertype", membership.type().value())
.add("clusterid", membership.clusterId())
);
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/FileFinder.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/FileFinder.java
index f10ebd5e315..f0b064373d2 100644
--- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/FileFinder.java
+++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/task/util/file/FileFinder.java
@@ -63,7 +63,7 @@ public class FileFinder {
/**
* Predicate that will be used to match files and directories under the base path.
*
- * NOTE: Consequtive calls to this method are ANDed (this include the initial filter from
+ * NOTE: Consecutive calls to this method are ANDed (this include the initial filter from
* {@link #files(Path)} or {@link #directories(Path)}.
*/
public FileFinder match(Predicate<FileAttributes> matcher) {