Class TransformToken
- java.lang.Object
-
- org.apache.accumulo.server.conf.util.TransformToken
-
public class TransformToken extends Object
Provides a token used in property conversion. The token is used to limit the number of processes that try to create a property node and transform the legacy property format to the 2.1 encoded properties. Processes do not queue for a token (using a sequential node) - processes should look for the token to exist, and if present wait and then periodically re-check for the property node to be created by the process that created / has the token.Features
- Uses ephemeral node that will be removed if transform process terminates without completing
- Watcher not necessary - the existence of the node and uuid in data sufficient to detect changes.
-
-
Field Summary
Fields Modifier and Type Field Description static String
TRANSFORM_TOKEN
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TransformToken
createToken(@NonNull String path, ZooReaderWriter zrw)
Create a lock node in ZooKeeper using an ephemeral node.boolean
equals(Object o)
boolean
getTokenOwnership()
Create and try to establish ownership (hold the token).int
hashCode()
boolean
haveTokenOwnership()
Return the token ownership statusvoid
releaseToken()
If the token was created by this instance, the uuid of this instance and the uuid stored in the ZooKeeper data will match.String
toString()
boolean
validateToken()
Verify ownership is still valid while holding the token.
-
-
-
Field Detail
-
TRANSFORM_TOKEN
public static final String TRANSFORM_TOKEN
- See Also:
- Constant Field Values
-
-
Method Detail
-
createToken
public static TransformToken createToken(@NonNull String path, ZooReaderWriter zrw)
Create a lock node in ZooKeeper using an ephemeral node. Will not throw and exception except on an interrupt. If the lock node is created, the returned lock will be locked. If another lock already exists, the lock is unlocked and the caller can decide to either wait for the resource to be created by the thread that created the lock, or try calling tolock
to succeed- Parameters:
path
- the parent node of the legacy properties and the associated property children nodes.zrw
- a ZooReaderWriter- Returns:
- an TransformLock instance.
- Throws:
IllegalStateException
- is the lock creation fails due to an underlying ZooKeeper exception.
-
getTokenOwnership
public boolean getTokenOwnership()
Create and try to establish ownership (hold the token). Token ownership can be tested withhaveTokenOwnership
- Returns:
- true if able to get ownership, false otherwise.
-
haveTokenOwnership
public boolean haveTokenOwnership()
Return the token ownership status- Returns:
- true if this instance has ownership of the token, false otherwise.
-
validateToken
public boolean validateToken()
Verify ownership is still valid while holding the token.- Returns:
- true if token is still owned, false otherwise
-
releaseToken
public void releaseToken()
If the token was created by this instance, the uuid of this instance and the uuid stored in the ZooKeeper data will match.
-
-