com.h3c.dist.sync

## Interface SyncServiceNode

-     public interface SyncServiceNode

  `SyncServiceNode` provides access nodes of `SyncService`. Users can perform read/write/delete operations on the node. Users can also get access to child nodes in the hierarchy.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `delete(boolean force)` Delete node from distributed database
    `int` | `getChildCount()` Get number of child nodes when the data was read by last invocation of `getData`
    `Collection<SyncServiceNode>` | `getChildren()` Get child nodes for node
    `Collection<SyncServiceNode>` | `getChildren(SyncServiceUser watcher)` Get child nodes for node & register watch for changes to child nodes
    `long` | `getCreateTime()` The time in milliseconds from epoch when this node was created.
    `byte[]` | `getData()` Get data stored in the distributed database for this node
    `byte[]` | `getData(SyncServiceUser watcher)` Get data stored in the distributed database for this node and set watch.
    `int` | `getDataVersion()` Get version number of data read by last invocation of `getData`
    `SyncServiceNodePath` | `getNodePath()` Get node's hierarchy in the distributed database from the root
    `void` | `setData(byte[] data, boolean force)` Write data to the node in the distributed database
    `boolean` | `syncPath()` Sync the current node with other cluster zk instances

- - ### Method Detail

    - #### getNodePath

          SyncServiceNodePath getNodePath()

      Get node's hierarchy in the distributed database from the root
      Returns:
        node's path from the root

    - #### getData

          byte[] getData()
                         throws ServiceNotAvailableException,
                                InterruptedException,
                                SyncServiceException.NodeNotFoundException

      Get data stored in the distributed database for this node
      Returns:
        data stored
      Throws:
        `InterruptedException` - Interrupted exception
        `ServiceNotAvailableException` - Sync service is not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception

    - #### getData

          byte[] getData(SyncServiceUser watcher)
                         throws ServiceNotAvailableException,
                                InterruptedException,
                                SyncServiceException.NodeNotFoundException

      Get data stored in the distributed database for this node and set watch.
      Parameters:
        `watcher` - Watch is notified when node's data is changed or node is deleted
      Returns:
        data stored
      Throws:
        `InterruptedException` - Interrupted exception
        `ServiceNotAvailableException` - Sync service is not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception

    - #### getDataVersion

          int getDataVersion()
                             throws SyncServiceException.NodeNeverReadException

      Get version number of data read by last invocation of `getData`
      Returns:
        version of data read
      Throws:
        `SyncServiceException.NodeNeverReadException` - Node never read exception

    - #### getCreateTime

          long getCreateTime()
                             throws ServiceNotAvailableException,
                                    SyncServiceException.NodeNotFoundException,
                                    InterruptedException

      The time in milliseconds from epoch when this node was created.
      Returns:
        create time of the node
      Throws:
        `ServiceNotAvailableException` - Sync service not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception
        `InterruptedException` - Operation interrupted exception

    - #### getChildCount

          int getChildCount()
                            throws ServiceNotAvailableException,
                                   SyncServiceException.NodeNotFoundException,
                                   InterruptedException

      Get number of child nodes when the data was read by last invocation of `getData`
      Returns:
        number of children
      Throws:
        `ServiceNotAvailableException` - Sync service not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception
        `InterruptedException` - Operation interrupted exception

    - #### setData

          void setData(byte[] data,
                     boolean force)
                       throws SyncServiceException.NodeNeverReadException,
                              SyncServiceException.NodeChangedException,
                              SyncServiceException.NodeNotFoundException,
                              ServiceNotAvailableException,
                              InterruptedException

      Write data to the node in the distributed database
      Parameters:
        `data` - bytes to be written
        `force` - if false, `setData` fails if data has changed since it was last read. true will ignore any changes made after it was last read and overwrites
      Throws:
        `SyncServiceException.NodeNeverReadException` - Node never read exception
        `SyncServiceException.NodeChangedException` - Node data changed exception
        `SyncServiceException.NodeNotFoundException` - Node not found exception
        `ServiceNotAvailableException` - Sync service is not UP
        `InterruptedException` - Thread interrupted exception

    - #### delete

          void delete(boolean force)
                      throws SyncServiceException.NodeNeverReadException,
                             ServiceNotAvailableException,
                             SyncServiceException.NodeHasChildrenException,
                             SyncServiceException.NodeNotFoundException,
                             SyncServiceException.NodeChangedException,
                             InterruptedException

      Delete node from distributed database
      Parameters:
        `force` - if false, `setData` fails if data has changed since it was last read. true will ignore any changes made after it was last read and overwrites
      Throws:
        `SyncServiceException.NodeNeverReadException` - Node never read exception
        `ServiceNotAvailableException` - Sync service is not UP
        `SyncServiceException.NodeHasChildrenException` - Node has children exception
        `SyncServiceException.NodeNotFoundException` - Node doesnt exist exception
        `SyncServiceException.NodeChangedException` - Node data changed exception
        `InterruptedException` - Operation interrupted exception

    - #### getChildren

          Collection<SyncServiceNode> getChildren()
                                                  throws ServiceNotAvailableException,
                                                         SyncServiceException.NodeNotFoundException,
                                                         InterruptedException

      Get child nodes for node
      Returns:
        Children for the node
      Throws:
        `ServiceNotAvailableException` - Sync service is not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception
        `InterruptedException` - Operation interrupted exception

    - #### getChildren

          Collection<SyncServiceNode> getChildren(SyncServiceUser watcher)
                                                  throws ServiceNotAvailableException,
                                                         SyncServiceException.NodeNotFoundException,
                                                         InterruptedException

      Get child nodes for node & register watch for changes to child nodes
      Parameters:
        `watcher` - Watcher object to be registered. Watch is triggered when a child node is created or deleted or the node itself is deleted
      Returns:
        Children for the node
      Throws:
        `ServiceNotAvailableException` - Sync service is not UP
        `SyncServiceException.NodeNotFoundException` - Node not found exception
        `InterruptedException` - Operation interrupted exception

    - #### syncPath

          boolean syncPath()
                           throws ServiceNotAvailableException,
                                  InterruptedException

      Sync the current node with other cluster zk instances
      Returns:
        boolean true - if sync successful, false - otherwise
      Throws:
        `InterruptedException` - Operation interrupted exception
        `ServiceNotAvailableException` - Service not Up

Copyright © 2014. All Rights Reserved.