use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class CuratorDatabase method newCuratorTransactionIn.
// --------- Write operations ------------------------------------------------------------------------------
// These must either create a nested transaction ending in a counter increment or not depend on prior state
/**
* Creates a new curator transaction against this database and adds it to the given nested transaction.
* Important: It is the nested transaction which must be committed - never the curator transaction directly.
*/
public CuratorTransaction newCuratorTransactionIn(NestedTransaction transaction) {
// Add a counting transaction first, to make sure we always invalidate the current state on any transaction commit
transaction.add(new EagerCountingCuratorTransaction(changeGenerationCounter), CuratorTransaction.class);
CuratorTransaction curatorTransaction = new CuratorTransaction(curator);
transaction.add(curatorTransaction);
return curatorTransaction;
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class CuratorDatabaseTest method commitCreate.
private void commitCreate(String path, CuratorDatabase database) {
NestedTransaction t = new NestedTransaction();
CuratorTransaction c = database.newCuratorTransactionIn(t);
c.add(CuratorOperations.create(path));
t.commit();
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class CuratorDatabaseTest method testThatCounterIncreasesAlsoOnCommitFailureFromExistingTransaction.
@Test
public void testThatCounterIncreasesAlsoOnCommitFailureFromExistingTransaction() throws Exception {
MockCurator curator = new MockCurator();
CuratorDatabase database = new CuratorDatabase(curator, Path.fromString("/"), true);
assertEquals(0L, (long) curator.counter("/changeCounter").get().get().postValue());
try {
NestedTransaction t = new NestedTransaction();
CuratorTransaction separateC = new CuratorTransaction(curator);
// fail as parent does not exist
separateC.add(CuratorOperations.create("/1/2"));
t.add(separateC);
CuratorTransaction c = database.newCuratorTransactionIn(t);
// does not fail
c.add(CuratorOperations.create("/1"));
t.commit();
fail("Expected exception");
} catch (Exception expected) {
// expected because the parent does not exist
}
assertEquals(1L, (long) curator.counter("/changeCounter").get().get().postValue());
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class NodeFailTester method activate.
private void activate(ApplicationId applicationId, ClusterSpec cluster, Capacity capacity) {
List<HostSpec> hosts = provisioner.prepare(applicationId, cluster, capacity, 1, null);
NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(curator));
provisioner.activate(transaction, applicationId, hosts);
transaction.commit();
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class RetiredExpirerTest method activate.
private void activate(ApplicationId applicationId, ClusterSpec cluster, int nodes, int groups, NodeRepositoryProvisioner provisioner) {
List<HostSpec> hosts = provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(nodes), groups, null);
NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(curator));
provisioner.activate(transaction, applicationId, hosts);
transaction.commit();
}
Aggregations