seqnum

## Class SequenceNumber

- java.lang.Object
- - seqnum.SequenceNumber

-     public class SequenceNumber
      extends Object

  A simple implementation of a Sequence Number Generator. Numbers are unique and monotonically incremented in the domain determined by key. This is a simple implementation intended to demonstrate the concept. It may not scale well in the face of a large number of concurrent accesses. Use the KVStore instance name, host and port for running this program:

       java seqnum.SequenceNumber -store <instance name> \
                                  -host  <host name>     \
                                  -port  <port number>

  For all examples the default instance name is kvstore, the default host name is localhost and the default port number is 5000. These defaults match the defaults for running kvlite, so the simplest way to run the examples along with kvlite is to omit all parameters.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SequenceNumber(KVStore store, Key key, int noOfRetries, long initialValue)` Creates an instance of the sequence number generator.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `long` | `incrementAndGet()` Returns the next number in the sequence after it synchronizes with the store, making a maximum of noOfRetries atempts. There are three possible outcomes when calling this method: - the next number in the sequence is returned. - the maximum number of retries is reached for trying to synchronize with the store and a RuntimeException is thrown - other exception if thrown by the store
    `static void` | `main(String[] args)`

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

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

- - ### Constructor Detail

    - #### SequenceNumber

          public SequenceNumber(KVStore store,
                        Key key,
                        int noOfRetries,
                        long initialValue)

      Creates an instance of the sequence number generator.
      Parameters:
        `store` - The store name.
        `key` - The key determining the domain of the sequence
        `noOfRetries` - The number of attempts to synchronize with the store
        `initialValue` - The starting value of the sequence (the first value returned will be an increment of this one.

  - ### Method Detail

    - #### incrementAndGet

          public long incrementAndGet()

      Returns the next number in the sequence after it synchronizes with the store, making a maximum of noOfRetries atempts.
      There are three possible outcomes when calling this method:
      - the next number in the sequence is returned.
      - the maximum number of retries is reached for trying to synchronize with the store and a RuntimeException is thrown
      - other exception if thrown by the store
      Returns:
        the next number in the sequence
      Throws:
        `java.lang.RuntimeException,` - oracle.kv.DurabilityException oracle.kv.RequestTimeoutException oracle.kv.FaultException oracle.kv.ConsistencyException

    - #### main

          public static void main(String[] args)

Copyright (c) 2011, 2014 Oracle and/or its affiliates. All rights reserved.