org.apache.commons.id.uuid.state
Class InMemoryStateImpl

java.lang.Object
  extended by org.apache.commons.id.uuid.state.InMemoryStateImpl
All Implemented Interfaces:
java.io.Serializable, State

public class InMemoryStateImpl
extends java.lang.Object
implements State

The InMemoryStateImpl is an implementation of the State interface.

This implementation is the worst-case scenario and provides the least guarantee of no UUID duplication. This implementation is provided for systems that truly have no other means of writing to or reading from stable storage.

Version:
$Id: InMemoryStateImpl.java 480488 2006-11-29 08:57:26Z bayard $
Author:
Commons-Id team
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.commons.id.uuid.state.State
DEFAULT_STATE_IMPL
 
Constructor Summary
InMemoryStateImpl()
           
 
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 nodesCollection)
          Stores the state information.
 void store(java.util.Set nodesCollection, long timestamp)
          Stores the state information using a predetermined timestamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InMemoryStateImpl

public InMemoryStateImpl()
Method Detail

load

public void load()
Description copied from interface: State

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.

Specified by:
load in interface State
See Also:
State.load()

getNodes

public java.util.Set getNodes()
Description copied from interface: State

Returns the collection of Nodes for this uuid state information.

Specified by:
getNodes in interface State
Returns:
the collection of Nodes for this uuid state.
See Also:
State.getNodes()

store

public void store(java.util.Set nodesCollection)
Description copied from interface: State

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.

Specified by:
store in interface State
Parameters:
nodesCollection - a Collection of Nodes to store.
See Also:
State.store(Set)

store

public void store(java.util.Set nodesCollection,
                  long timestamp)
Description copied from interface: State

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.

Specified by:
store in interface State
Parameters:
nodesCollection - a Collection of Nodes to store.
timestamp - the timestamp to write all Nodes last timestamp as.
See Also:
State.store(Set, long)

getSynchInterval

public long getSynchInterval()
Description copied from interface: State

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

Specified by:
getSynchInterval in interface State
Returns:
the number of milliseconds to wait between writing to stable storage.
See Also:
State.getSynchInterval()


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