Search in sources :

Example 1 with Curator

use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.

the class ClusterController method setOptions.

public void setOptions(String clusterName, FleetControllerOptions options, Metric metricImpl) throws Exception {
    metricWrapper.updateMetricImplementation(metricImpl);
    if (options.zooKeeperServerAddress != null && !"".equals(options.zooKeeperServerAddress)) {
        // Wipe this path ... it's unclear why
        String path = "/" + options.clusterName + options.fleetControllerIndex;
        Curator curator = Curator.create(options.zooKeeperServerAddress);
        if (curator.framework().checkExists().forPath(path) != null)
            curator.framework().delete().deletingChildrenIfNeeded().forPath(path);
        curator.framework().create().creatingParentsIfNeeded().forPath(path);
    }
    synchronized (controllers) {
        FleetController controller = controllers.get(clusterName);
        if (controller == null) {
            StatusHandler.ContainerStatusPageServer statusPageServer = new StatusHandler.ContainerStatusPageServer();
            controller = FleetController.createForContainer(options, statusPageServer, metricWrapper);
            controllers.put(clusterName, controller);
            status.put(clusterName, statusPageServer);
        } else {
            controller.updateOptions(options, 0);
        }
    }
}
Also used : StatusHandler(com.yahoo.vespa.clustercontroller.core.status.StatusHandler) FleetController(com.yahoo.vespa.clustercontroller.core.FleetController) Curator(com.yahoo.vespa.curator.Curator)

Example 2 with Curator

use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.

the class ApplicationRepositoryTest method setup.

@Before
public void setup() {
    Curator curator = new MockCurator();
    Tenants tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).build());
    tenants.addTenant(tenantName);
    tenant = tenants.getTenant(tenantName);
    Provisioner provisioner = new SessionHandlerTest.MockProvisioner();
    applicationRepository = new ApplicationRepository(tenants, provisioner, clock);
    timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(60));
}
Also used : Provisioner(com.yahoo.config.provision.Provisioner) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 3 with Curator

use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.

the class RemoteSessionRepoTest method createSession.

private void createSession(long sessionId, boolean wait, TenantName tenantName) {
    Path sessionsPath = Tenants.getSessionsPath(tenantName);
    SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionsPath.append(String.valueOf(sessionId)));
    zkc.createNewSession(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    if (wait) {
        Curator.CompletionWaiter waiter = zkc.getUploadWaiter();
        waiter.awaitCompletion(Duration.ofSeconds(120));
    }
}
Also used : Path(com.yahoo.path.Path) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) Curator(com.yahoo.vespa.curator.Curator) TestWithCurator(com.yahoo.vespa.config.server.TestWithCurator)

Example 4 with Curator

use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.

the class ZookeeperStatusServiceTest method failing_to_get_lock_closes_SessionFailRetryLoop.

@Test
public void failing_to_get_lock_closes_SessionFailRetryLoop() throws Exception {
    try (Curator curator = createConnectedCuratorFramework(testingServer)) {
        ZookeeperStatusService zookeeperStatusService2 = new ZookeeperStatusService(curator);
        try (MutableStatusRegistry statusRegistry = zookeeperStatusService.lockApplicationInstance_forCurrentThreadOnly(TestIds.APPLICATION_INSTANCE_REFERENCE)) {
            // must run in separate thread, since having 2 locks in the same thread fails
            CompletableFuture<Void> resultOfZkOperationAfterLockFailure = CompletableFuture.runAsync(() -> {
                try {
                    zookeeperStatusService2.lockApplicationInstance_forCurrentThreadOnly(TestIds.APPLICATION_INSTANCE_REFERENCE, 1);
                    fail("Both zookeeper host status services locked simultaneously for the same application instance");
                } catch (RuntimeException e) {
                }
                killSession(curator.framework(), testingServer);
                // Throws SessionFailedException if the SessionFailRetryLoop has not been closed.
                zookeeperStatusService2.forApplicationInstance(TestIds.APPLICATION_INSTANCE_REFERENCE).getHostStatus(TestIds.HOST_NAME1);
            });
            assertThat(resultOfZkOperationAfterLockFailure, notHoldsException());
        }
    }
}
Also used : Curator(com.yahoo.vespa.curator.Curator) Test(org.junit.Test)

Example 5 with Curator

use of com.yahoo.vespa.curator.Curator in project vespa by vespa-engine.

the class MetricsReporterTest method test_registered_metric.

@Test
public void test_registered_metric() throws Exception {
    NodeFlavors nodeFlavors = FlavorConfigBuilder.createDummies("default");
    Curator curator = new MockCurator();
    NodeRepository nodeRepository = new NodeRepository(nodeFlavors, curator, Clock.systemUTC(), Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
    Node node = nodeRepository.createNode("openStackId", "hostname", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.tenant);
    nodeRepository.addNodes(Collections.singletonList(node));
    Node hostNode = nodeRepository.createNode("openStackId2", "parent", Optional.empty(), nodeFlavors.getFlavorOrThrow("default"), NodeType.proxy);
    nodeRepository.addNodes(Collections.singletonList(hostNode));
    Map<String, Number> expectedMetrics = new HashMap<>();
    expectedMetrics.put("hostedVespa.provisionedHosts", 1L);
    expectedMetrics.put("hostedVespa.parkedHosts", 0L);
    expectedMetrics.put("hostedVespa.readyHosts", 0L);
    expectedMetrics.put("hostedVespa.reservedHosts", 0L);
    expectedMetrics.put("hostedVespa.activeHosts", 0L);
    expectedMetrics.put("hostedVespa.inactiveHosts", 0L);
    expectedMetrics.put("hostedVespa.dirtyHosts", 0L);
    expectedMetrics.put("hostedVespa.failedHosts", 0L);
    expectedMetrics.put("hostedVespa.docker.totalCapacityDisk", 0.0);
    expectedMetrics.put("hostedVespa.docker.totalCapacityMem", 0.0);
    expectedMetrics.put("hostedVespa.docker.totalCapacityCpu", 0.0);
    expectedMetrics.put("hostedVespa.docker.freeCapacityDisk", 0.0);
    expectedMetrics.put("hostedVespa.docker.freeCapacityMem", 0.0);
    expectedMetrics.put("hostedVespa.docker.freeCapacityCpu", 0.0);
    expectedMetrics.put("wantedRebootGeneration", 0L);
    expectedMetrics.put("currentRebootGeneration", 0L);
    expectedMetrics.put("wantToReboot", 0);
    expectedMetrics.put("wantToRetire", 0);
    expectedMetrics.put("wantToDeprovision", 0);
    expectedMetrics.put("hardwareFailure", 0);
    expectedMetrics.put("hardwareDivergence", 0);
    expectedMetrics.put("allowedToBeDown", 0);
    expectedMetrics.put("numberOfServices", 0L);
    Orchestrator orchestrator = mock(Orchestrator.class);
    ServiceMonitor serviceMonitor = mock(ServiceMonitor.class);
    when(orchestrator.getNodeStatus(any())).thenReturn(HostStatus.NO_REMARKS);
    ServiceModel serviceModel = mock(ServiceModel.class);
    when(serviceMonitor.getServiceModelSnapshot()).thenReturn(serviceModel);
    when(serviceModel.getServiceInstancesByHostName()).thenReturn(Collections.emptyMap());
    TestMetric metric = new TestMetric();
    MetricsReporter metricsReporter = new MetricsReporter(nodeRepository, metric, orchestrator, serviceMonitor, Duration.ofMinutes(1), new JobControl(nodeRepository.database()));
    metricsReporter.maintain();
    assertEquals(expectedMetrics, metric.values);
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) HashMap(java.util.HashMap) Node(com.yahoo.vespa.hosted.provision.Node) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) ServiceMonitor(com.yahoo.vespa.service.monitor.ServiceMonitor) NodeFlavors(com.yahoo.config.provision.NodeFlavors) ServiceModel(com.yahoo.vespa.service.monitor.ServiceModel) MetricsReporter(com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) DockerImage(com.yahoo.config.provision.DockerImage) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Aggregations

Curator (com.yahoo.vespa.curator.Curator)11 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)6 Test (org.junit.Test)6 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)5 DockerImage (com.yahoo.config.provision.DockerImage)4 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)4 Zone (com.yahoo.config.provision.Zone)3 NodeFlavors (com.yahoo.config.provision.NodeFlavors)2 ManualClock (com.yahoo.test.ManualClock)2 Node (com.yahoo.vespa.hosted.provision.Node)2 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)2 MetricsReporter (com.yahoo.vespa.hosted.provision.maintenance.MetricsReporter)2 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)2 ServiceModel (com.yahoo.vespa.service.monitor.ServiceModel)2 ServiceMonitor (com.yahoo.vespa.service.monitor.ServiceMonitor)2 Before (org.junit.Before)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Provisioner (com.yahoo.config.provision.Provisioner)1 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)1 Path (com.yahoo.path.Path)1