Search in sources :

Example 11 with NestedTransaction

use of com.yahoo.transaction.NestedTransaction in project vespa by vespa-engine.

the class DynamicDockerProvisioningTest method addAndAssignNode.

private Node addAndAssignNode(ApplicationId id, String hostname, String parentHostname, Flavor flavor, int index, ProvisioningTester tester) {
    Node node1a = Node.create("open1", Collections.singleton("127.0.0.100"), new HashSet<>(), hostname, Optional.of(parentHostname), flavor, NodeType.tenant);
    ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false).with(Optional.of(ClusterSpec.Group.from(0)));
    ClusterMembership clusterMembership1 = ClusterMembership.from(clusterSpec, index);
    Node node1aAllocation = node1a.allocate(id, clusterMembership1, Instant.now());
    tester.nodeRepository().addNodes(Collections.singletonList(node1aAllocation));
    NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(tester.getCurator()));
    tester.nodeRepository().activate(Collections.singletonList(node1aAllocation), transaction);
    transaction.commit();
    return node1aAllocation;
}
Also used : ClusterMembership(com.yahoo.config.provision.ClusterMembership) CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) Node(com.yahoo.vespa.hosted.provision.Node) NestedTransaction(com.yahoo.transaction.NestedTransaction) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Example 12 with NestedTransaction

use of com.yahoo.transaction.NestedTransaction in project vespa by vespa-engine.

the class ProvisioningTest method activate_after_reservation_timeout.

@Test
public void activate_after_reservation_timeout() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    tester.makeReadyNodes(10, "default");
    ApplicationId application = tester.makeApplicationId();
    SystemState state = prepare(application, 2, 2, 3, 3, "default", tester);
    // Simulate expiry
    NestedTransaction deactivateTransaction = new NestedTransaction();
    tester.nodeRepository().deactivate(application, deactivateTransaction);
    deactivateTransaction.commit();
    try {
        tester.activate(application, state.allHosts);
        fail("Expected exception");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().startsWith("Activation of " + application + " failed"));
    }
}
Also used : Zone(com.yahoo.config.provision.Zone) NestedTransaction(com.yahoo.transaction.NestedTransaction) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 13 with NestedTransaction

use of com.yahoo.transaction.NestedTransaction in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_variable_application_size.

@Test
public void application_deployment_variable_application_size() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(24, "default");
    // deploy
    SystemState state1 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy with increased sizes
    SystemState state2 = prepare(application1, 3, 4, 4, 5, "default", tester);
    state2.assertExtends(state1);
    assertEquals("New nodes are reserved", 6, tester.getNodes(application1, Node.State.reserved).size());
    tester.activate(application1, state2.allHosts);
    // decrease again
    SystemState state3 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state3.allHosts);
    assertEquals("Superfluous container nodes are deactivated", 3 - 2 + 4 - 2, tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Superfluous content nodes are retired", 4 - 3 + 5 - 3, tester.getNodes(application1, Node.State.active).retired().size());
    // increase even more, and remove one node before deploying
    SystemState state4 = prepare(application1, 4, 5, 5, 6, "default", tester);
    assertEquals("Inactive nodes are reused", 0, tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Earlier retired nodes are not unretired before activate", 4 - 3 + 5 - 3, tester.getNodes(application1, Node.State.active).retired().size());
    state4.assertExtends(state2);
    assertEquals("New and inactive nodes are reserved", 4 + 3, tester.getNodes(application1, Node.State.reserved).size());
    // Remove a retired host from one of the content clusters (which one is random depending on host names)
    HostSpec removed = state4.removeHost(tester.getNodes(application1, Node.State.active).retired().asList().get(0).hostname());
    tester.activate(application1, state4.allHosts);
    assertEquals("Retired active removed when activating became inactive", 1, tester.getNodes(application1, Node.State.inactive).asList().size());
    assertEquals(removed.hostname(), tester.getNodes(application1, Node.State.inactive).asList().get(0).hostname());
    assertEquals("Earlier retired nodes are unretired on activate", 0, tester.getNodes(application1, Node.State.active).retired().size());
    // decrease again
    SystemState state5 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state5.allHosts);
    assertEquals("Superfluous container nodes are also deactivated", 4 - 2 + 5 - 2 + 1, // 
    tester.getNodes(application1, Node.State.inactive).size());
    assertEquals("Superfluous content nodes are retired", 5 - 3 + 6 - 3 - 1, tester.getNodes(application1, Node.State.active).retired().size());
    // increase content slightly
    SystemState state6 = prepare(application1, 2, 2, 4, 3, "default", tester);
    tester.activate(application1, state6.allHosts);
    assertEquals("One content node is unretired", 5 - 4 + 6 - 3 - 1, tester.getNodes(application1, Node.State.active).retired().size());
    // Then reserve more
    SystemState state7 = prepare(application1, 8, 2, 2, 2, "default", tester);
    // delete app
    NestedTransaction removeTransaction = new NestedTransaction();
    tester.provisioner().remove(removeTransaction, application1);
    removeTransaction.commit();
    assertEquals(0, tester.getNodes(application1, Node.State.active).size());
    assertEquals(0, tester.getNodes(application1, Node.State.reserved).size());
}
Also used : Zone(com.yahoo.config.provision.Zone) NestedTransaction(com.yahoo.transaction.NestedTransaction) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Example 14 with NestedTransaction

use of com.yahoo.transaction.NestedTransaction in project vespa by vespa-engine.

the class ProvisioningTester method activate.

public void activate(ApplicationId application, Set<HostSpec> hosts) {
    NestedTransaction transaction = new NestedTransaction();
    transaction.add(new CuratorTransaction(curator));
    provisioner.activate(transaction, application, hosts);
    transaction.commit();
    assertEquals(toHostNames(hosts), toHostNames(nodeRepository.getNodes(application, Node.State.active)));
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) NestedTransaction(com.yahoo.transaction.NestedTransaction)

Example 15 with NestedTransaction

use of com.yahoo.transaction.NestedTransaction in project vespa by vespa-engine.

the class CuratorDatabaseClient method writeInactiveJobs.

public void writeInactiveJobs(Set<String> inactiveJobs) {
    NestedTransaction transaction = new NestedTransaction();
    CuratorTransaction curatorTransaction = curatorDatabase.newCuratorTransactionIn(transaction);
    curatorTransaction.add(CuratorOperations.setData(inactiveJobsPath().getAbsolute(), stringSetSerializer.toJson(inactiveJobs)));
    transaction.commit();
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) NestedTransaction(com.yahoo.transaction.NestedTransaction)

Aggregations

NestedTransaction (com.yahoo.transaction.NestedTransaction)18 CuratorTransaction (com.yahoo.vespa.curator.transaction.CuratorTransaction)9 Node (com.yahoo.vespa.hosted.provision.Node)5 HostSpec (com.yahoo.config.provision.HostSpec)4 Test (org.junit.Test)4 ApplicationId (com.yahoo.config.provision.ApplicationId)3 Zone (com.yahoo.config.provision.Zone)3 ClusterMembership (com.yahoo.config.provision.ClusterMembership)1 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 HostFilter (com.yahoo.config.provision.HostFilter)1 Path (com.yahoo.path.Path)1 ActivationConflictException (com.yahoo.vespa.config.server.ActivationConflictException)1 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)1 TenantApplications (com.yahoo.vespa.config.server.application.TenantApplications)1 InternalServerException (com.yahoo.vespa.config.server.http.InternalServerException)1 LocalSession (com.yahoo.vespa.config.server.session.LocalSession)1 LocalSessionRepo (com.yahoo.vespa.config.server.session.LocalSessionRepo)1 ActivateLock (com.yahoo.vespa.config.server.tenant.ActivateLock)1 Rotations (com.yahoo.vespa.config.server.tenant.Rotations)1 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)1