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;
}
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"));
}
}
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());
}
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)));
}
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();
}
Aggregations