Class ClusteredHashTable

  • All Implemented Interfaces:

    public class ClusteredHashTable
    extends Object
    implements Serializable
    Provides access to an IBM i highly available Clustered Hash Table. A Clustered Hash Table is represented as an IBM i server job. A Clustered Hash Table is a container for small to medium-sized non-persistent data that is replicated to the Clustered Hash Table domain. The Clustered Hash Table domain is comprised of nodes defined in a cluster. The Clustered Hash Table domain is defined using the STRCHTSVR CL command.

    For further details on a cluster, see the Cluster Resource Services APIs and the Clustering topic in the IBM i Information Center.

    The purpose of this class is to provide interfaces to the Clustered Hash Table APIs. An instance of this class can be used to put() and get() keyed entries from the Clustered Hash Table. The entries stored in the Clustered Hash Table are replicated to cluster nodes defined in the Clustered Hash Table domain.

    A connection to the Clustered Hash Table server is required to access the Clustered Hash Table. Call open() to obtain the connection. After the open() is complete, entries defined by the ClusteredHashTableEntry class can be put into the table or retrieved from the table, using the methods put() or get(). A key is required to put() an entry in the Clustered Hash Table. Use generateKey() to generate a universally unique key. The elements() method will return a list of all that keys in the clustered hash table. It is recommended to close() the active connection when done to release system resources that are no longer needed.

    This class uses the ClusteredHashTableEntry class for the get(), elements() and put() methods.

    Example Usage:

    import java.util.*;

    public class MyFile extends Object
    public static void main(String args[]) {

    ClusteredHashTableEntry myEntry = null;
    String myData = new String("This is my data");

    AS400 the400 = new AS400();

    // CHTSVR01 is the clustered hash table server name
    ClusteredHashTable cht = new ClusteredHashTable(the400,"CHTSVR01");; // make a connection

    byte[] key = null;
    key = cht.generateKey(); // get a key to access data with

    // key is the key generated to access the data with
    // myData is a byte array of data to be stored
    // 2400 is the time to live in seconds
    // ENTRY_AUTHORITY_ANY_USER indicates any user can access the data
    // DUPLICATE_KEY_FAIL indicates if the key already exists in the hash table to not allow the request to succeed.
    myEntry = new ClusteredHashTableEntry(key,myData.getBytes(),2400,ClusteredHashTableEntry.ENTRY_AUTHORITY_ANY_USER,ClusteredHashTableEntry.DUPLICATE_KEY_FAIL);

    cht.put(myEntry); // store the entry in the hash table

    ClusteredHashTableEntry output = cht.get(key); // retrieve the data

    catch(Exception e){}


    Note: This class uses APIs that are available only when connecting to systems running OS/400 V5R2M0 or later.

    See Also:
    Serialized Form