|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.opentsdb.uid.UniqueId
public final class UniqueId
Thread-safe implementation of the UniqueIdInterface.
Don't attempt to use equals() or hashCode() on
this class.
UniqueIdInterface| Constructor Summary | |
|---|---|
UniqueId(org.hbase.async.HBaseClient client,
byte[] table,
String kind,
int width)
Constructor. |
|
| Method Summary | |
|---|---|
int |
cacheHits()
The number of times we avoided reading from HBase thanks to the cache. |
int |
cacheMisses()
The number of times we had to read from HBase and populate the cache. |
int |
cacheSize()
Returns the number of elements stored in the internal cache. |
byte[] |
getId(String name)
Finds the ID associated with a given name. |
String |
getName(byte[] id)
Finds the name associated with a given ID. |
byte[] |
getOrCreateId(String name)
Finds the ID associated with a given name or creates it. |
String |
kind()
Returns what kind of Unique ID is served by this instance. |
void |
rename(String oldname,
String newname)
Reassigns the UID to a different name (non-atomic). |
List<String> |
suggest(String search)
Attempts to find suggestions of names given a search term. |
String |
toString()
Returns a human readable string representation of the object. |
short |
width()
Returns the number of bytes on which each Unique ID is encoded. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public UniqueId(org.hbase.async.HBaseClient client,
byte[] table,
String kind,
int width)
client - The HBase client to use.table - The name of the HBase table to use.kind - The kind of Unique ID this instance will deal with.width - The number of bytes on which Unique IDs should be encoded.
IllegalArgumentException - if width is negative or too small/large
or if kind is an empty string.| Method Detail |
|---|
public int cacheHits()
public int cacheMisses()
public int cacheSize()
public String kind()
UniqueIdInterface
kind in interface UniqueIdInterfacepublic short width()
UniqueIdInterface
width in interface UniqueIdInterface
public String getName(byte[] id)
throws NoSuchUniqueId,
org.hbase.async.HBaseException
UniqueIdInterface
getName in interface UniqueIdInterfaceid - The ID associated with that name.
NoSuchUniqueId - if the given ID is not assigned.
org.hbase.async.HBaseException - if there is a problem communicating with HBase.UniqueIdInterface.getId(String),
UniqueIdInterface.getOrCreateId(String)
public byte[] getId(String name)
throws NoSuchUniqueName,
org.hbase.async.HBaseException
UniqueIdInterfaceThe length of the byte array is fixed in advance by the implementation.
getId in interface UniqueIdInterfacename - The name to lookup in the table.
byte[] array.
NoSuchUniqueName - if the name requested doesn't have an ID assigned.
org.hbase.async.HBaseException - if there is a problem communicating with HBase.UniqueIdInterface.getName(byte[])
public byte[] getOrCreateId(String name)
throws org.hbase.async.HBaseException
UniqueIdInterfaceThe length of the byte array is fixed in advance by the implementation.
getOrCreateId in interface UniqueIdInterfacename - The name to lookup in the table or to assign an ID to.
org.hbase.async.HBaseException - if there is a problem communicating with HBase.
public List<String> suggest(String search)
throws org.hbase.async.HBaseException
search - The search term (possibly empty).
org.hbase.async.HBaseException - if there was a problem getting suggestions from
HBase.
public void rename(String oldname,
String newname)
Whatever was the UID of oldname will be given to newname.
oldname will no longer be assigned a UID.
Beware that the assignment change is not atommic. If two threads or processes attempt to rename the same UID differently, the result is unspecified and might even be inconsistent. This API is only here for administrative purposes, not for normal programmatic interactions.
oldname - The old name to rename.newname - The new name.
NoSuchUniqueName - if oldname wasn't assigned.
IllegalArgumentException - if newname was already assigned.
org.hbase.async.HBaseException - if there was a problem with HBase while trying to
update the mapping.public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||