Search in sources :

Example 1 with NodeAgent

use of com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent in project vespa by vespa-engine.

the class NodeAdminImpl method updateNodeAgentMetrics.

private void updateNodeAgentMetrics() {
    int numberContainersWaitingImage = 0;
    int numberOfNewUnhandledExceptions = 0;
    for (NodeAgent nodeAgent : nodeAgents.values()) {
        if (nodeAgent.isDownloadingImage())
            numberContainersWaitingImage++;
        numberOfNewUnhandledExceptions += nodeAgent.getAndResetNumberOfUnhandledExceptions();
    }
    numberOfContainersInLoadImageState.sample(numberContainersWaitingImage);
    numberOfUnhandledExceptionsInNodeAgent.add(numberOfNewUnhandledExceptions);
}
Also used : NodeAgent(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent)

Example 2 with NodeAgent

use of com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent in project vespa by vespa-engine.

the class NodeAdminImpl method ensureNodeAgentForNodeIsStarted.

private void ensureNodeAgentForNodeIsStarted(ContainerName containerName, String hostname) {
    if (nodeAgents.containsKey(containerName)) {
        return;
    }
    final NodeAgent agent = nodeAgentFactory.apply(hostname);
    agent.start();
    nodeAgents.put(containerName, agent);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        logger.info("Interrupted while waiting between starting node-agents");
    }
}
Also used : NodeAgent(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent)

Example 3 with NodeAgent

use of com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent in project vespa by vespa-engine.

the class NodeAdminImplTest method mockNodeAgentSetFrozenResponse.

private void mockNodeAgentSetFrozenResponse(List<NodeAgent> nodeAgents, boolean... responses) {
    for (int i = 0; i < nodeAgents.size(); i++) {
        NodeAgent nodeAgent = nodeAgents.get(i);
        when(nodeAgent.setFrozen(anyBoolean())).thenReturn(responses[i]);
    }
}
Also used : NodeAgent(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent)

Example 4 with NodeAgent

use of com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent in project vespa by vespa-engine.

the class NodeAdminImplTest method testSetFrozen.

@Test
public void testSetFrozen() throws Exception {
    List<NodeAgent> nodeAgents = new ArrayList<>();
    List<String> existingContainerHostnames = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        final String hostName = "host" + i + ".test.yahoo.com";
        NodeAgent nodeAgent = mock(NodeAgent.class);
        nodeAgents.add(nodeAgent);
        when(nodeAgentFactory.apply(eq(hostName))).thenReturn(nodeAgent);
        existingContainerHostnames.add(hostName);
    }
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(existingContainerHostnames, existingContainerHostnames.stream().map(ContainerName::fromHostname).collect(Collectors.toList()));
    // Initially everything is frozen to force convergence
    assertTrue(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, true, true, true);
    // Unfreeze everything
    assertTrue(nodeAdmin.setFrozen(false));
    mockNodeAgentSetFrozenResponse(nodeAgents, false, false, false);
    // NodeAdmin freezes only when all the NodeAgents are frozen
    assertFalse(nodeAdmin.setFrozen(true));
    mockNodeAgentSetFrozenResponse(nodeAgents, false, true, true);
    assertFalse(nodeAdmin.setFrozen(true));
    assertFalse(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, true, true, true);
    assertTrue(nodeAdmin.setFrozen(true));
    assertTrue(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, true, true, true);
    assertTrue(nodeAdmin.setFrozen(true));
    assertTrue(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, false, false, false);
    assertFalse(nodeAdmin.setFrozen(false));
    // NodeAdmin unfreezes instantly
    assertFalse(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, false, false, true);
    assertFalse(nodeAdmin.setFrozen(false));
    assertFalse(nodeAdmin.isFrozen());
    mockNodeAgentSetFrozenResponse(nodeAgents, true, true, true);
    assertTrue(nodeAdmin.setFrozen(false));
    assertFalse(nodeAdmin.isFrozen());
}
Also used : ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) ArrayList(java.util.ArrayList) NodeAgent(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent) Test(org.junit.Test)

Example 5 with NodeAgent

use of com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent in project vespa by vespa-engine.

the class NodeAdminImplTest method nodeAgentsAreProperlyLifeCycleManaged.

@Test
public void nodeAgentsAreProperlyLifeCycleManaged() throws Exception {
    final String hostName1 = "host1.test.yahoo.com";
    final String hostName2 = "host2.test.yahoo.com";
    final ContainerName containerName1 = ContainerName.fromHostname(hostName1);
    final NodeAgent nodeAgent1 = mock(NodeAgentImpl.class);
    final NodeAgent nodeAgent2 = mock(NodeAgentImpl.class);
    when(nodeAgentFactory.apply(eq(hostName1))).thenReturn(nodeAgent1);
    when(nodeAgentFactory.apply(eq(hostName2))).thenReturn(nodeAgent2);
    final InOrder inOrder = inOrder(nodeAgentFactory, nodeAgent1, nodeAgent2);
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.emptyList(), Collections.singletonList(containerName1));
    verifyNoMoreInteractions(nodeAgentFactory);
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.singletonList(hostName1), Collections.singletonList(containerName1));
    inOrder.verify(nodeAgentFactory).apply(hostName1);
    inOrder.verify(nodeAgent1).start();
    inOrder.verify(nodeAgent1, never()).stop();
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.singletonList(hostName1), Collections.singletonList(containerName1));
    inOrder.verify(nodeAgentFactory, never()).apply(any(String.class));
    inOrder.verify(nodeAgent1, never()).start();
    inOrder.verify(nodeAgent1, never()).stop();
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.emptyList(), Collections.singletonList(containerName1));
    inOrder.verify(nodeAgentFactory, never()).apply(any(String.class));
    verify(nodeAgent1).stop();
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.singletonList(hostName2), Collections.singletonList(containerName1));
    inOrder.verify(nodeAgentFactory).apply(hostName2);
    inOrder.verify(nodeAgent2).start();
    inOrder.verify(nodeAgent2, never()).stop();
    verify(nodeAgent1).stop();
    nodeAdmin.synchronizeNodeSpecsToNodeAgents(Collections.emptyList(), Collections.emptyList());
    inOrder.verify(nodeAgentFactory, never()).apply(any(String.class));
    inOrder.verify(nodeAgent2, never()).start();
    inOrder.verify(nodeAgent2).stop();
    verifyNoMoreInteractions(nodeAgent1);
    verifyNoMoreInteractions(nodeAgent2);
}
Also used : InOrder(org.mockito.InOrder) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) NodeAgent(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent) Test(org.junit.Test)

Aggregations

NodeAgent (com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgent)6 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)2 Test (org.junit.Test)2 ClassLocking (com.yahoo.concurrent.classlock.ClassLocking)1 ProcessExecuter (com.yahoo.system.ProcessExecuter)1 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)1 MetricReceiverWrapper (com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper)1 ConfigServerConfig (com.yahoo.vespa.hosted.node.admin.config.ConfigServerConfig)1 ConfigServerClients (com.yahoo.vespa.hosted.node.admin.configserver.ConfigServerClients)1 DockerOperations (com.yahoo.vespa.hosted.node.admin.docker.DockerOperations)1 DockerOperationsImpl (com.yahoo.vespa.hosted.node.admin.docker.DockerOperationsImpl)1 StorageMaintainer (com.yahoo.vespa.hosted.node.admin.maintenance.StorageMaintainer)1 AclMaintainer (com.yahoo.vespa.hosted.node.admin.maintenance.acl.AclMaintainer)1 NodeAdmin (com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdmin)1 NodeAdminImpl (com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminImpl)1 NodeAdminStateUpdaterImpl (com.yahoo.vespa.hosted.node.admin.nodeadmin.NodeAdminStateUpdaterImpl)1 NodeAgentImpl (com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl)1 NodeAdminStateUpdater (com.yahoo.vespa.hosted.node.admin.provider.NodeAdminStateUpdater)1 IPAddressesImpl (com.yahoo.vespa.hosted.node.admin.task.util.network.IPAddressesImpl)1 Clock (java.time.Clock)1