blob: fbc6c95f1c5cb2a29ea28d3e59041f7f9a67137f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.curator.transaction;
import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.curator.Curator;
import org.apache.curator.framework.api.transaction.CuratorTransaction;
/**
* The ZooKeeper operations that we support doing transactional.
*
* @author Ulf Lilleengen
* @author bratseth
*/
public interface CuratorOperation extends Transaction.Operation {
/**
* Returns the transaction resulting from combining this operation with the input transaction
*
* @param transaction {@link CuratorTransaction} to append this operation to.
* @return the transaction, for chaining.
* @throws Exception if unable to create transaction for this operation.
*/
CuratorTransaction and(CuratorTransaction transaction) throws Exception;
/**
* Check if this operation can be performed by calling check(curator, new TransactionChanges()).
*
* @throws IllegalStateException if it cannot
*/
default void check(Curator curator) {
check(curator, new TransactionChanges());
}
/**
* Check if this operation can be performed.
*
* @param curator the curator instance to check against
* @param changes changes which will be done prior to this operation as part of the same transaction.
* Operations should use both this and the curator instance to check if they can be performed.
* In addition, they are required to add the change(s) they will perform to the set of changes.
* @throws IllegalStateException if it cannot be performed
*/
void check(Curator curator, TransactionChanges changes);
}
|