Op (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper

## Class Op

- java.lang.Object
- - org.apache.zookeeper.Op

- Direct Known Subclasses:
    Op.Check, Op.Create, Op.Delete, Op.GetChildren, Op.GetData, Op.SetData

      public abstract class Op
      extends Object

  Represents a single operation in a multi-operation transaction. Each operation can be a create, update, delete, a version check or just read operations like getChildren or getData. Sub-classes of Op each represent each detailed type but should not normally be referenced except via the provided factory methods.
  See Also:
    `ZooKeeper.create(String, byte[], java.util.List, CreateMode)`, `ZooKeeper.create(String, byte[], java.util.List, CreateMode, org.apache.zookeeper.AsyncCallback.StringCallback, Object)`, `ZooKeeper.delete(String, int)`, `ZooKeeper.setData(String, byte[], int)`, `ZooKeeper.getData(String, boolean, Stat)`, `ZooKeeper.getChildren(String, boolean)`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Op.Check`
    `static class` | `Op.Create`
    `static class` | `Op.CreateTTL`
    `static class` | `Op.Delete`
    `static class` | `Op.GetChildren`
    `static class` | `Op.GetData`
    `static class` | `Op.OpKind`
    `static class` | `Op.SetData`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Op` | `check(String path, int version)` Constructs an version check operation.
    `static Op` | `create(String path, byte[] data, List<ACL> acl, CreateMode createMode)` Constructs a create operation.
    `static Op` | `create(String path, byte[] data, List<ACL> acl, CreateMode createMode, long ttl)` Constructs a create operation.
    `static Op` | `create(String path, byte[] data, List<ACL> acl, int flags)` Constructs a create operation.
    `static Op` | `create(String path, byte[] data, List<ACL> acl, int flags, long ttl)` Constructs a create operation.
    `static Op` | `delete(String path, int version)` Constructs a delete operation.
    `static Op` | `getChildren(String path)`
    `static Op` | `getData(String path)`
    `Op.OpKind` | `getKind()` Gets the kind of an Op.
    `String` | `getPath()` Gets the path for an Op.
    `int` | `getType()` Gets the integer type code for an Op.
    `static Op` | `setData(String path, byte[] data, int version)` Constructs an update operation.
    `abstract Record` | `toRequestRecord()` Encodes an op for wire transmission.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### create

          public static Op create(String path,
                                  byte[] data,
                                  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 node
        `data` - the initial data for the node
        `acl` - the acl for the node
        `flags` - 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(String path,
                                  byte[] data,
                                  List<ACL> acl,
                                  int flags,
                                  long ttl)

      Constructs a create operation. Arguments are as for the ZooKeeper method of the same name but adding an optional ttl
      Parameters:
        `path` - the path for the node
        `data` - the initial data for the node
        `acl` - the acl for the node
        `flags` - specifying whether the node to be created is ephemeral and/or sequential but using the integer encoding.
        `ttl` - optional ttl or 0 (flags must imply a TTL creation mode)
      See Also:
        `ZooKeeper.create(String, byte[], java.util.List, CreateMode)`, `CreateMode.fromFlag(int)`

    - #### create

          public static Op create(String path,
                                  byte[] data,
                                  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 node
        `data` - the initial data for the node
        `acl` - the acl for the node
        `createMode` - specifying whether the node to be created is ephemeral and/or sequential
      See Also:
        `ZooKeeper.create(String, byte[], java.util.List, CreateMode)`

    - #### create

          public static Op create(String path,
                                  byte[] data,
                                  List<ACL> acl,
                                  CreateMode createMode,
                                  long ttl)

      Constructs a create operation. Arguments are as for the ZooKeeper method of the same name but adding an optional ttl
      Parameters:
        `path` - the path for the node
        `data` - the initial data for the node
        `acl` - the acl for the node
        `createMode` - specifying whether the node to be created is ephemeral and/or sequential
        `ttl` - optional ttl or 0 (createMode must imply a TTL)
      See Also:
        `ZooKeeper.create(String, byte[], java.util.List, CreateMode)`

    - #### delete

          public static Op delete(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(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 node
        `data` - the data to set
        `version` - the expected matching version
      See Also:
        `ZooKeeper.setData(String, byte[], int)`

    - #### check

          public static Op check(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 node
        `version` - the expected matching version

    - #### getChildren

          public static Op getChildren(String path)

    - #### getData

          public static Op getData(String path)

    - #### 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 String getPath()

      Gets the path for an Op.
      Returns:
        The path.

    - #### getKind

          public Op.OpKind getKind()

      Gets the kind of an Op.
      Returns:
        The OpKind value.

    - #### toRequestRecord

          public abstract Record toRequestRecord()

      Encodes an op for wire transmission.
      Returns:
        An appropriate Record structure.

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.