summaryrefslogtreecommitdiffstats
path: root/node-admin
diff options
context:
space:
mode:
authorvalerijf <valerijf@yahoo-inc.com>2017-06-19 14:45:07 +0200
committervalerijf <valerijf@yahoo-inc.com>2017-06-19 14:45:07 +0200
commit3045b803c2a85a0655a9116d50876b25d369d6a0 (patch)
tree8d43f802e493b4aa7e2abf696cb804fb51cb4c24 /node-admin
parentf88f6fe359cecc5f09fb809ad92b5954bd1bda72 (diff)
Remove unneeded created field in Container
Diffstat (limited to 'node-admin')
-rw-r--r--node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java17
-rw-r--r--node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java3
2 files changed, 3 insertions, 17 deletions
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 3c8327d1836..87d4509d7c9 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
@@ -96,7 +96,7 @@ public class NodeAgentImpl implements NodeAgent {
// 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;
- private CpuUsageReporter lastCpuMetric;
+ private CpuUsageReporter lastCpuMetric = new CpuUsageReporter();
public NodeAgentImpl(
final String hostName,
@@ -134,12 +134,8 @@ public class NodeAgentImpl implements NodeAgent {
};
// If the container is already running, initialize vespaVersion and lastCpuMetric
- lastCpuMetric = new CpuUsageReporter(clock.instant());
dockerOperations.getContainer(containerName)
.ifPresent(container -> {
- if (container.state.isRunning()) {
- lastCpuMetric = new CpuUsageReporter(container.created);
- }
containerState = RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN;
logger.info("Container is already running, setting containerState to " + containerState);
});
@@ -260,7 +256,7 @@ public class NodeAgentImpl implements NodeAgent {
private void startContainer(ContainerNodeSpec nodeSpec) {
aclMaintainer.ifPresent(AclMaintainer::run);
dockerOperations.startContainer(containerName, nodeSpec);
- lastCpuMetric = new CpuUsageReporter(clock.instant());
+ lastCpuMetric = new CpuUsageReporter();
currentFilebeatRestarter = filebeatRestarter.scheduleWithFixedDelay(() -> serviceRestarter.accept("filebeat"), 1, 1, TimeUnit.DAYS);
storageMaintainer.ifPresent(maintainer -> {
@@ -626,11 +622,6 @@ public class NodeAgentImpl implements NodeAgent {
class CpuUsageReporter {
private long totalContainerUsage = 0;
private long totalSystemUsage = 0;
- private final Instant created;
-
- CpuUsageReporter(Instant created) {
- this.created = created;
- }
double getCpuUsagePercentage(long currentContainerUsage, long currentSystemUsage) {
long deltaSystemUsage = currentSystemUsage - totalSystemUsage;
@@ -641,10 +632,6 @@ public class NodeAgentImpl implements NodeAgent {
totalSystemUsage = currentSystemUsage;
return cpuUsagePct;
}
-
- long getUptime() {
- return Duration.between(created, clock.instant()).getSeconds();
- }
}
// TODO: Also skip orchestration if we're downgrading in test/staging
diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
index d71d130f9b8..91d9b382b7c 100644
--- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
+++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java
@@ -573,8 +573,7 @@ public class NodeAgentImplTest {
dockerImage,
containerName,
isRunning ? Container.State.RUNNING : Container.State.EXITED,
- isRunning ? 1 : 0,
- clock.instant().toString())) :
+ isRunning ? 1 : 0)) :
Optional.empty();
when(dockerOperations.getContainerStats(any())).thenReturn(Optional.of(emptyContainerStats));