|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.id.uuid.state.ReadOnlyResourceStateImpl
public class ReadOnlyResourceStateImpl
The ReadOnlyResourceStateImpl
is an implementation of the
State
interface. This implementation provides better guarantees
that no duplicate UUID's will be generated; however since the only stateful
information provided is the IEEE 802 address the generator should use a
better choice is to use an implementation that also writes to persistent
storage each time the state is loaded a new clock sequence is used. If the
system time is adjusted backwards there is a possibility that a UUID generated
with the same clock sequence and time could be generated.
Field Summary | |
---|---|
static java.lang.String |
CONFIG_FILENAME_KEY
The key to use in locating the uuid configuration xml file from System properties. |
Fields inherited from interface org.apache.commons.id.uuid.state.State |
---|
DEFAULT_STATE_IMPL |
Constructor Summary | |
---|---|
ReadOnlyResourceStateImpl()
Constructs a ReadOnlyResouceStateImpl. |
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()
Loads the System.property "commons.uuid.configFileName" (default is "uuid.conf") using commons.discovery. |
protected void |
parse(java.io.InputStream in)
Parses the XML configuration into the Node s and places
into this instances node collection. |
void |
store(java.util.Set nodeSet)
Stores the state information. |
void |
store(java.util.Set nodeSet,
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 |
Field Detail |
---|
public static final java.lang.String CONFIG_FILENAME_KEY
Constructor Detail |
---|
public ReadOnlyResourceStateImpl()
Constructs a ReadOnlyResouceStateImpl.
Method Detail |
---|
public void load() throws java.lang.Exception
Loads the System.property "commons.uuid.configFileName" (default is "uuid.conf") using commons.discovery.
The uuid-[n].conf file is an xml file with the following syntax:
]>
See the documentation for further information on configuration tasks.
load
in interface State
java.lang.IllegalStateException
- if the "commons.uuid.configFileName"
system property is not set or the resource cannot be loaded.
org.xml.sax.SAXException
- if an xml parsing error occurs
ParserConfigurationException
- if the parser cannot be loaded
java.io.IOException
- if an error occurs reading the file
java.lang.Exception
State.load()
public long getSynchInterval()
State
Returns the number of milliseconds to wait between writing to stable storage.
getSynchInterval
in interface State
State.getSynchInterval()
public java.util.Set getNodes()
State
Returns the collection of Nodes
for this uuid state
information.
getNodes
in interface State
Nodes
for this uuid state.State.getNodes()
public void store(java.util.Set nodeSet) throws java.io.IOException
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.
store
in interface State
nodeSet
- a Collection of Node
s to store.
java.io.IOException
- - an input/output Exception perhaps due to StringBuffer#appendState.store(java.util.Set)
public void store(java.util.Set nodeSet, long timestamp)
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.
store
in interface State
nodeSet
- a Collection of Node
s to store.timestamp
- the timestamp to write all Node
s last timestamp as.State.store(java.util.Set, long)
protected void parse(java.io.InputStream in) throws java.lang.Exception
Parses the XML configuration into the Node
s and places
into this instances node collection.
in
- the XML input stream to parse.
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |