org.apache.hadoop.tools.rumen.state
Class StatePool

java.lang.Object
  extended by org.apache.hadoop.tools.rumen.state.StatePool

public class StatePool
extends Object

A pool of states. States used by DataType's can be managed the StatePool. StatePool also supports persistence. Persistence is key to share states across multiple Anonymizer runs.


Nested Class Summary
static class StatePool.StatePair
          A wrapper class that binds the state implementation to its implementing class name.
 
Field Summary
static String DIR_CONFIG
           
static String PERSIST_CONFIG
           
static String RELOAD_CONFIG
           
 
Constructor Summary
StatePool()
           
 
Method Summary
 void addState(Class id, State state)
           
 State getState(Class clazz)
           
 HashMap<String,StatePool.StatePair> getStates()
          To be invoked only by the Jackson JSON serializer.
 long getVersion()
          To be invoked only by the Jackson JSON serializer.
 void initialize(org.apache.hadoop.conf.Configuration conf)
          Initialized the StatePool.
 boolean isUpdated()
           
 void persist()
          Persists the current state to the state directory.
 void setStates(HashMap<String,StatePool.StatePair> states)
          To be invoked only by the Jackson JSON deserializer.
 void setVersion(long version)
          To be invoked only by the Jackson JSON deserializer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_CONFIG

public static final String DIR_CONFIG
See Also:
Constant Field Values

RELOAD_CONFIG

public static final String RELOAD_CONFIG
See Also:
Constant Field Values

PERSIST_CONFIG

public static final String PERSIST_CONFIG
See Also:
Constant Field Values
Constructor Detail

StatePool

public StatePool()
Method Detail

addState

public void addState(Class id,
                     State state)

getState

public State getState(Class clazz)

isUpdated

public boolean isUpdated()

initialize

public void initialize(org.apache.hadoop.conf.Configuration conf)
                throws Exception
Initialized the StatePool. This API also reloads the previously persisted state. Note that the StatePool should be initialized only once.

Throws:
Exception

persist

public void persist()
             throws IOException
Persists the current state to the state directory. The state will be persisted to the 'latest' file in the state directory.

Throws:
IOException

getVersion

public long getVersion()
To be invoked only by the Jackson JSON serializer.


setVersion

public void setVersion(long version)
To be invoked only by the Jackson JSON deserializer.


getStates

public HashMap<String,StatePool.StatePair> getStates()
To be invoked only by the Jackson JSON serializer.


setStates

public void setStates(HashMap<String,StatePool.StatePair> states)
To be invoked only by the Jackson JSON deserializer.



Copyright © 2013 Apache Software Foundation. All Rights Reserved.