org.apache.commons.id.uuid.state
Interface State

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
InMemoryStateImpl, ReadOnlyResourceStateImpl, ReadWriteFileStateImpl

public interface State
extends java.io.Serializable

The State interface. Implementors are responsible for storing UUIDGenerator stateful information. Each node contains the last timestamp, the last clock sequence used, and the node identifier bytes. The implementor should be prepared to load, store, and return the Nodes from some stateful storage.

Version:
$Id: State.java 480488 2006-11-29 08:57:26Z bayard $
Author:
Commons-Id team

Field Summary
static java.lang.String DEFAULT_STATE_IMPL
          The default State implementation class name if not configured.
 
Method Summary
 java.util.Set getNodes()
          Returns the collection of Nodes for this uuid state information.
 long getSynchInterval()
          Returns the number of milliseconds to wait between writing to stable storage.
 void load()
          Method loads the Systems node identifier information usually from some stateful storage area.
 void store(java.util.Set nodes)
          Stores the state information.
 void store(java.util.Set nodes, long timestamp)
          Stores the state information using a predetermined timestamp.
 

Field Detail

DEFAULT_STATE_IMPL

static final java.lang.String DEFAULT_STATE_IMPL
The default State implementation class name if not configured.

See Also:
Constant Field Values
Method Detail

load

void load()
          throws java.lang.Exception

Method loads the Systems node identifier information usually from some stateful storage area.

Note each JVM instance should have a separate configuration since a system wide Mutex is not feasible, then in a system with multiple concurrent jvm instances running - each instance should utilize a different configuration with distinct node identifiers.

Throws:
java.lang.IllegalStateException - likely the system is not configured or the state of the system is incorrect.
java.lang.Exception

getNodes

java.util.Set getNodes()

Returns the collection of Nodes for this uuid state information.

Returns:
the collection of Nodes for this uuid state.

store

void store(java.util.Set nodes)
           throws java.io.IOException

Stores the state information.

To increase the quality of the UUID uniqueness, a system that may write to stable storage SHOULD perist the state of the UUIDGenerator in order to reduce the likelihood of duplicate identifiers and increase the quality of the identifiers generated.

Parameters:
nodes - a Collection of Nodes to store.
Throws:
java.io.IOException - - an input/output Exception perhaps due to StringBuffer#append

store

void store(java.util.Set nodes,
           long timestamp)

Stores the state information using a predetermined timestamp. This timestamp should be a time in the future but a shorter period than what the java virtual machine can restart within. This is normally linked to the sychInterval.

Using a point in time in the near future reduces unnecessary I/O, while allowing for the persistent state to be stored periodically, in an efficient manner.

Parameters:
nodes - a Collection of Nodes to store.
timestamp - the timestamp to write all Nodes last timestamp as.

getSynchInterval

long getSynchInterval()

Returns the number of milliseconds to wait between writing to stable storage.

Returns:
the number of milliseconds to wait between writing to stable storage.


Copyright 2003-2008 The Apache Software Foundation. All Rights Reserved.