diff options
author | Haakon Dybdahl <dybis@users.noreply.github.com> | 2016-07-06 11:28:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 11:28:32 +0200 |
commit | 41f5c7c56addac17d724c5cc16cc7b02069b7240 (patch) | |
tree | 53aa6af1449abf642a09e779192ec062036fa27f | |
parent | e759337b58f8afc2cb89faba70700785c47142a5 (diff) | |
parent | 6bb9a2c49ddbe7e7aecd4adc30d01b4234f5e34d (diff) |
Merge pull request #314 from yahoo/hmusum/add-method-for-getting-node-state-from-node-agent
Add method for getting node repo node state
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java | 7 | ||||
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java | 19 |
2 files changed, 21 insertions, 5 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java index e16322af25c..fe6af0fdeec 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgent.java @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.nodeagent; +import com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec; + import java.util.Map; /** @@ -49,4 +51,9 @@ public interface NodeAgent { * method returns, no more actions will be taken by the agent. */ void stop(); + + /** + * Returns the {@link ContainerNodeSpec} for this node agent. + */ + ContainerNodeSpec getContainerNodeSpec(); } diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java index 249563146d3..eb343dc5820 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java @@ -63,7 +63,7 @@ public class NodeAgentImpl implements NodeAgent { } ContainerState containerState = ABSENT; - // The attributes of the last successful noderepo attribute update for this node. Used to avoid redundant calls. + // The attributes of the last successful node repo attribute update for this node. Used to avoid redundant calls. private NodeAttributes lastAttributesSet = null; private ContainerNodeSpec lastNodeSpec = null; @@ -122,6 +122,7 @@ public class NodeAgentImpl implements NodeAgent { debug.put("workToDoNow", workToDoNow); synchronized (monitor) { debug.put("History", new LinkedList<>(debugMessages)); + debug.put("Node repo state", lastNodeSpec.nodeState.name()); } return debug; } @@ -269,15 +270,17 @@ public class NodeAgentImpl implements NodeAgent { } } - // For testing + // Public for testing public void tick() throws Exception { final ContainerNodeSpec nodeSpec = nodeRepository.getContainerNodeSpec(hostname) .orElseThrow(() -> new IllegalStateException(String.format("Node '%s' missing from node repository.", hostname))); - if (!nodeSpec.equals(lastNodeSpec)) { - addDebugMessage("Loading new node spec: " + nodeSpec.toString()); - lastNodeSpec = nodeSpec; + synchronized (monitor) { + if (!nodeSpec.equals(lastNodeSpec)) { + addDebugMessage("Loading new node spec: " + nodeSpec.toString()); + lastNodeSpec = nodeSpec; + } } switch (nodeSpec.nodeState) { @@ -332,4 +335,10 @@ public class NodeAgentImpl implements NodeAgent { throw new RuntimeException("UNKNOWN STATE " + nodeSpec.nodeState.name()); } } + + public ContainerNodeSpec getContainerNodeSpec() { + synchronized (monitor) { + return lastNodeSpec; + } + } } |