com.h3c.dist.keystore

## Interface KeyValueNode

-     public interface KeyValueNode

  KeyValueNode represents a pair of an application. This interface allows the users of data store primitive to operate on data owned by them. Each KeyValueNode is uniquely identified by the owner application name and the Key. Key space is unique for an application. Application can perform operations like read data, alter data and delete the pair from KeyStore.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `delete(boolean force)` Delete a KeyValueNode stored by the application in distributed KeyStore.
    `String` | `getAppName()` Get the name of the application to which the pair belongs.
    `String` | `getKey()` Get the key string associated with the KeyStore entry.
    `byte[]` | `getLatestValue()` Get the byte stream stored in the KeyValueNode.
    `byte[]` | `getValue()` Get the byte stream stored in the KeyValueNode.
    `void` | `setValue(byte[] data, boolean force)` Write/rewrite the data associated with a KeyValueNode.

- - ### Method Detail

    - #### getAppName

          String getAppName()

      Get the name of the application to which the pair belongs.
      Returns:
        Application name

    - #### getKey

          String getKey()

      Get the key string associated with the KeyStore entry. Key value of an entry cannot be altered and shall be unique per application.
      Returns:
        key for this node

    - #### setValue

          void setValue(byte[] data,
                      boolean force)
                        throws KeyStoreException.KeyNotFoundException,
                               KeyStoreException.DataChangedException,
                               ServiceNotAvailableException,
                               InterruptedException

      Write/rewrite the data associated with a KeyValueNode. Application should serialize the data object into byte stream and pass the byte stream to this routine as data. If the data version of the KeyValueNode is newer while writing the data to it, set request is rejected with DataChangedException exception. Application can alter this behavior by setting the force flag to true.
      Parameters:
        `data` - Data to write
        `force` - if true, write even if node has changed
      Throws:
        `KeyStoreException.DataChangedException` - If the data version changed
        `KeyStoreException.KeyNotFoundException` - Entry no longer exist in distributed store
        `ServiceNotAvailableException` - Service not Up
        `InterruptedException` - Operation interrupted exception

    - #### getValue

          byte[] getValue()
                          throws KeyStoreException.KeyNotFoundException,
                                 ServiceNotAvailableException,
                                 InterruptedException

      Get the byte stream stored in the KeyValueNode. Retrieves the data associated with the version available locally. i.e., If the same key value is updated in another node, and read happens before the value is synced, older version of the data is expected to be read.
      Returns:
        byte[] fetched data or null otherwise
      Throws:
        `KeyStoreException.KeyNotFoundException` - Entry no longer exist in distributed store
        `InterruptedException` - Operation interrupted exception
        `ServiceNotAvailableException` - Service not Up

    - #### getLatestValue

          byte[] getLatestValue()
                                throws KeyStoreException.KeyNotFoundException,
                                       ServiceNotAvailableException,
                                       InterruptedException

      Get the byte stream stored in the KeyValueNode. The newest version of the key value available at the time of read is retrieved. It is suggested to lock the key before retrieving the value using this API to ensure that no other update occurs during the read.
      Returns:
        byte[] fetched data or null otherwise
      Throws:
        `KeyStoreException.KeyNotFoundException` - Entry no longer exist in distributed store
        `InterruptedException` - Operation interrupted exception
        `ServiceNotAvailableException` - Service not Up

    - #### delete

          void delete(boolean force)
                      throws KeyStoreException.KeyNotFoundException,
                             KeyStoreException.DataChangedException,
                             ServiceNotAvailableException,
                             InterruptedException

      Delete a KeyValueNode stored by the application in distributed KeyStore. This operation cannot be undone. If the data version of the KeyValueNode is newer while attempting to delete the node, operation is rejected with DataChangedException exception. Application can alter this behavior by setting the force flag to true.
      Parameters:
        `force` - if true, forces deletion
      Throws:
        `KeyStoreException.DataChangedException` - Entry never read or entry changed since last read
        `KeyStoreException.KeyNotFoundException` - Entry no longer exist in distributed store
        `InterruptedException` - Operation interrupted exception
        `ServiceNotAvailableException` - Service not Up

Copyright © 2014. All Rights Reserved.