public class StateServerKey
extends java.lang.Object
implements java.io.Serializable, java.io.Externalizable
Constructor and Description |
---|
StateServerKey()
Create a new
StateServerKey instance suitable for deserialization. |
StateServerKey(byte[] keyValue)
Initialize this StateServerKey from an array of bytes.
|
StateServerKey(byte[] keyValue,
java.lang.String displayValue)
Initialize this StateServerKey from an array of bytes and associate the key with a
human-readable string for display purposes.
|
StateServerKey(int appId,
byte[] keyValue,
java.lang.String displayValue)
Initialize this StateServerKey from an array of bytes and associate the key with a
human-readable string for display purposes.
|
StateServerKey(int appId,
int[] objId32,
java.util.UUID extObjId)
Initialize extended key from appId, objId, and extObjId.
|
StateServerKey(StateServerKeyAdapter adapter) |
StateServerKey(java.lang.String appName,
byte[] keyValue,
java.lang.String displayValue)
Initialize this StateServerKey from an array of bytes and associate the key with a
human-readable string for display purposes.
|
StateServerKey(java.util.UUID uniqueId)
Initialize this StateServerKey from a universally-unique identifier value.
|
Modifier and Type | Method and Description |
---|---|
static int |
appNameToId(java.lang.String appName)
Return the application ID corresponding to the application name appName and optionally
register with StateServer for event callbacks for the specified application name.
|
static int |
appNameToId(java.lang.String appName,
boolean registerForEvents)
Return the application ID corresponding to the application name appName and optionally
register with StateServer for event callbacks for the specified application name.
|
void |
copyBytesTo(int srcPos,
byte[] dest,
int destPos,
int count) |
boolean |
equals(java.lang.Object obj) |
int |
getAppId() |
static int |
getDefaultAppId() |
int |
getKeySize() |
java.lang.String |
getKeyString()
Gets a key string for a SSK.
|
int |
hashCode() |
boolean |
hasKeyString()
Checks whether this SSK has an associated key string
|
static boolean |
isAppIdValid(int appId)
Checks whether an application id is valid.
|
boolean |
isChunkObject() |
void |
readExternal(java.io.ObjectInput in) |
void |
setChunkObject(boolean chunkObject) |
static void |
setDefaultAppId(int defaultAppId) |
void |
setKeyString(java.lang.String keyString)
Associates a keystring to the key.
|
void |
setUseKeyHashing(boolean keyHashing) |
byte[] |
toByteArray() |
java.lang.String |
toString() |
static void |
unregisterForEvents(int appId)
Unregister for StateServer event notifications for objects associated with the
application ID appId.
|
static void |
unregisterForEvents(java.lang.String appName) |
boolean |
useKeyHashing() |
void |
writeExternal(java.io.ObjectOutput out) |
public StateServerKey(int appId, int[] objId32, java.util.UUID extObjId) throws StateServerException
appId
- application ID of the keyobjId32
- objectIDextObjId
- the extended obj idStateServerException
- if an exception occurs when communicated with ScaleOut StateServer.public StateServerKey(java.util.UUID uniqueId) throws StateServerException
Initialize this StateServerKey from a universally-unique identifier value.
StateServerKeys created with this constructor are associated with a reserved, default application ID.uniqueId
- the UUID
value from which this StateServerKey is to be initialized.java.lang.NullPointerException
- if uniqueId is null
.StateServerException
- if an exception occurs when communicated with ScaleOut StateServer.public StateServerKey(byte[] keyValue) throws StateServerException
keyValue
- The byte array used to initialize the StateServerKey instance. The array's length
must be between 0 (exclusive) 32 (inclusive).StateServerException
- if an exception occurs when communicated with ScaleOut StateServer.java.lang.NullPointerException
- if bytes is null
.java.lang.IllegalArgumentException
- if bytes.length
is less than zero or greater than 32.public StateServerKey(byte[] keyValue, java.lang.String displayValue) throws StateServerException
keyValue
- The byte array used to initialize the StateServerKey instance. The array's length
must be between 0 (exclusive) 32 (inclusive).displayValue
- A human-readable string indicating the value of the key that is returned as the
toString value for this key. If displayValue is null, a hex representation of
keyValue will be used as this key's ToString value.StateServerException
- if an exception occurs when communicated with ScaleOut StateServer.java.lang.NullPointerException
- if bytes is null
.java.lang.IllegalArgumentException
- if bytes.length
is less than zero or greater than 32.public StateServerKey(java.lang.String appName, byte[] keyValue, java.lang.String displayValue) throws StateServerException
appName
- the name of the application (representing a namespace of StateServer objects)keyValue
- The byte array used to initialize the StateServerKey instance. The array's length
must be between 0 (exclusive) 32 (inclusive).displayValue
- A human-readable string indicating the value of the key that is returned as the
toString value for this key. If displayValue is null, a hex representation of
keyValue will be used as this key's ToString value.java.lang.IllegalArgumentException
- if bytes is null
or if appName is
null
.
Or if bytes.length
is less than zero or greater than 32.
Or if the appName's length is zero or greater than 280 characters.StateServerException
- if appName conflicts with a previously registered application name.public StateServerKey(int appId, byte[] keyValue, java.lang.String displayValue) throws StateServerException
appId
- a value obtained by looking up an application name via a call to
appNameToId(String)
. Allocation of application ID's is
coordinated by the StateServer across all StateServer clientskeyValue
- The byte array used to initialize the StateServerKey instance. The array's length
must be between 0 (exclusive) 32 (inclusive).displayValue
- A human-readable string indicating the value of the key that is returned as the
toString value for this key. If displayValue is null, a hex representation of
keyValue will be used as this key's ToString value.java.lang.IllegalArgumentException
- if bytes is null
or if appName is
null
.
Or if bytes.length
is less than zero or greater than 32. Or, if the
appName's length is zero or greater than 280 characters.StateServerException
- if appName conflicts with a previously registered application name.public StateServerKey(StateServerKeyAdapter adapter) throws StateServerException
StateServerException
public StateServerKey()
StateServerKey
instance suitable for deserialization. Until this
StateServerKey is deserialized, it is not usable for StateServer operations.Externalizable
public static int appNameToId(java.lang.String appName) throws StateServerException
Return the application ID corresponding to the application name appName and optionally register with StateServer for event callbacks for the specified application name.
Application names are used to group StateServer keys into distinct namespaces of keys. Identical key values refer to distinct objects if the objects are associated with different appNames. An AppID (the value returned from this method), is a handle to the namespace of objects represented by the appName.
Application ID's are managed by the StateServer across all StateServer clients. They survive client restarts.appName
- The name of the application to look up.StateServerException
- if an exception occurs when communicated with ScaleOut StateServer.public static int appNameToId(java.lang.String appName, boolean registerForEvents) throws StateServerException
Return the application ID corresponding to the application name appName and optionally register with StateServer for event callbacks for the specified application name.
Application names are used to group StateServer keys into distinct namespaces of keys. Identical key values refer to distinct objects if the objects are associated with different appNames. An AppID (the value returned from this method), is a handle to the namespace of objects represented by the appName.
Application ID's are managed by the StateServer across all StateServer clients. They survive client restarts.
Application names also form a grouping for StateServer's event notification facility. By setting registerForEvents to true you indicate that the currently executing application wants to be a potential recipient of StateServer event notifications for object with the collection identified by appName. To receive notifications, you must also register a handler for the DataAccessor.ObjectExpired event.appName
- The name of the application to look up.registerForEvents
- If true
, ensure that this client is registered with the
StateServer to receive event notifications (e.g. object expiration notifications)
for objects associated with appName. If false
, do not alter the
existing event notification status: if event notifications were previously
enabled, they remain enabled; if event notifications had never been enabled or
were previously disabled, they remain disabled. To unregister for event
notifications, see unregisterForEvents(int)
.StateServerException
- if registerForEvents is true and StateServer is inaccessiblepublic static int getDefaultAppId() throws StateServerException
StateServerException
public static void setDefaultAppId(int defaultAppId)
public static void unregisterForEvents(int appId) throws StateServerException
Unregister for StateServer event notifications for objects associated with the application ID appId.
If the current application is not registered to receive event notifications for appId then this method is a nop.appId
- the id of the application namespace to be unregistered. Notifications on objects
in that namespace will no longer be received by this host.StateServerException
- if StateServer is inaccessiblepublic static void unregisterForEvents(java.lang.String appName) throws StateServerException
StateServerException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int getAppId()
public int getKeySize()
public byte[] toByteArray()
public void copyBytesTo(int srcPos, byte[] dest, int destPos, int count)
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public static boolean isAppIdValid(int appId)
appId
- an application idpublic java.lang.String getKeyString() throws StateServerException
StateServerException
- reading a key string from server failedpublic void setKeyString(java.lang.String keyString)
keyString
- a key string to associate with this SSKpublic boolean hasKeyString()
public boolean useKeyHashing()
public void setUseKeyHashing(boolean keyHashing)
public boolean isChunkObject()
public void setChunkObject(boolean chunkObject)