use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class SessionZooKeeperClient method createWriteStatusTransaction.
public Transaction createWriteStatusTransaction(Session.Status status) {
String path = sessionStatusPath.getAbsolute();
CuratorTransaction transaction = new CuratorTransaction(curator);
if (configCurator.exists(path)) {
transaction.add(CuratorOperations.setData(sessionStatusPath.getAbsolute(), Utf8.toBytes(status.name())));
} else {
transaction.add(CuratorOperations.create(sessionStatusPath.getAbsolute(), Utf8.toBytes(status.name())));
}
return transaction;
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction in project vespa by vespa-engine.
the class SessionZooKeeperClient method createNewSession.
/**
* Create necessary paths atomically for a new session.
* @param createTime Time of session creation.
* @param timeUnit Time unit of createTime.
*/
public void createNewSession(long createTime, TimeUnit timeUnit) {
CuratorTransaction transaction = new CuratorTransaction(curator);
transaction.add(CuratorOperations.create(sessionPath.getAbsolute()));
transaction.add(CuratorOperations.create(sessionPath.append(UPLOAD_BARRIER).getAbsolute()));
transaction.add(createWriteStatusTransaction(Session.Status.NEW).operations());
transaction.add(CuratorOperations.create(getCreateTimePath(), Utf8.toBytes(String.valueOf(timeUnit.toSeconds(createTime)))));
transaction.commit();
}
use of com.yahoo.vespa.curator.transaction.CuratorTransaction 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.vespa.curator.transaction.CuratorTransaction 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.vespa.curator.transaction.CuratorTransaction 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