Package org.apache.zookeeper
Class Op
- java.lang.Object
-
- org.apache.zookeeper.Op
-
- Direct Known Subclasses:
Op.Check
,Op.Create
,Op.Delete
,Op.SetData
public abstract class Op extends java.lang.Object
Represents a single operation in a multi-operation transaction. Each operation can be a create, update or delete or can just be a version check. Sub-classes of Op each represent each detailed type but should not normally be referenced except via the provided factory methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Op.Check
static class
Op.Create
static class
Op.Delete
static class
Op.SetData
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Op
check(java.lang.String path, int version)
Constructs an version check operation.static Op
create(java.lang.String path, byte[] data, java.util.List<ACL> acl, int flags)
Constructs a create operation.static Op
create(java.lang.String path, byte[] data, java.util.List<ACL> acl, CreateMode createMode)
Constructs a create operation.static Op
delete(java.lang.String path, int version)
Constructs a delete operation.java.lang.String
getPath()
Gets the path for an Op.int
getType()
Gets the integer type code for an Op.static Op
setData(java.lang.String path, byte[] data, int version)
Constructs an update operation.abstract org.apache.jute.Record
toRequestRecord()
Encodes an op for wire transmission.
-
-
-
Method Detail
-
create
public static Op create(java.lang.String path, byte[] data, java.util.List<ACL> acl, int flags)
Constructs a create operation. Arguments are as for the ZooKeeper method of the same name.- Parameters:
path
- the path for the nodedata
- the initial data for the nodeacl
- the acl for the nodeflags
- specifying whether the node to be created is ephemeral and/or sequential but using the integer encoding.- See Also:
ZooKeeper.create(String, byte[], java.util.List, CreateMode)
,CreateMode.fromFlag(int)
-
create
public static Op create(java.lang.String path, byte[] data, java.util.List<ACL> acl, CreateMode createMode)
Constructs a create operation. Arguments are as for the ZooKeeper method of the same name.- Parameters:
path
- the path for the nodedata
- the initial data for the nodeacl
- the acl for the nodecreateMode
- specifying whether the node to be created is ephemeral and/or sequential- See Also:
ZooKeeper.create(String, byte[], java.util.List, CreateMode)
-
delete
public static Op delete(java.lang.String path, int version)
Constructs a delete operation. Arguments are as for the ZooKeeper method of the same name.- Parameters:
path
- the path of the node to be deleted.version
- the expected node version.- See Also:
ZooKeeper.delete(String, int)
-
setData
public static Op setData(java.lang.String path, byte[] data, int version)
Constructs an update operation. Arguments are as for the ZooKeeper method of the same name.- Parameters:
path
- the path of the nodedata
- the data to setversion
- the expected matching version- See Also:
ZooKeeper.setData(String, byte[], int)
-
check
public static Op check(java.lang.String path, int version)
Constructs an version check operation. Arguments are as for the ZooKeeper.setData method except that no data is provided since no update is intended. The purpose for this is to allow read-modify-write operations that apply to multiple znodes, but where some of the znodes are involved only in the read, not the write. A similar effect could be achieved by writing the same data back, but that leads to way more version updates than are necessary and more writing in general.- Parameters:
path
- the path of the nodeversion
- the expected matching version
-
getType
public int getType()
Gets the integer type code for an Op. This code should be as from ZooDefs.OpCode- Returns:
- The type code.
- See Also:
ZooDefs.OpCode
-
getPath
public java.lang.String getPath()
Gets the path for an Op.- Returns:
- The path.
-
toRequestRecord
public abstract org.apache.jute.Record toRequestRecord()
Encodes an op for wire transmission.- Returns:
- An appropriate Record structure.
-
-