Search in sources :

Example 6 with CuratorTransaction

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;
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction)

Example 7 with CuratorTransaction

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();
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction)

Example 8 with CuratorTransaction

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;
}
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 9 with CuratorTransaction

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)));
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) NestedTransaction(com.yahoo.transaction.NestedTransaction)

Example 10 with CuratorTransaction

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();
}
Also used : CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) NestedTransaction(com.yahoo.transaction.NestedTransaction)

Aggregations

CuratorTransaction (com.yahoo.vespa.curator.transaction.CuratorTransaction)13 NestedTransaction (com.yahoo.transaction.NestedTransaction)9 Node (com.yahoo.vespa.hosted.provision.Node)4 HostSpec (com.yahoo.config.provision.HostSpec)2 ClusterMembership (com.yahoo.config.provision.ClusterMembership)1 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 Path (com.yahoo.path.Path)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1