Package com.Lomikel.HBaser
Class AsynchHBaseClient
- java.lang.Object
-
- com.Lomikel.DB.Client<org.apache.hadoop.hbase.client.Table,HBaseSchema>
-
- com.Lomikel.HBaser.HBaseClient
-
- com.Lomikel.HBaser.AsynchHBaseClient
-
- All Implemented Interfaces:
java.lang.Runnable
public class AsynchHBaseClient extends HBaseClient implements java.lang.Runnable
AsynchHBaseClient
providesHBaseClient
scanning asynchronously. Only some methods are available for asynchronous processing. Only one asynchronous scanningThread
is allowed.- Author:
- J.Hrivnac
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_doscan
protected int
_loopWait
protected AsynchHBaseProcessor
_processor
protected java.util.concurrent.ConcurrentLinkedQueue<java.util.Map<java.lang.String,java.lang.String>>
_queue
protected java.lang.String
_scanFilter
protected boolean
_scanIfkey
protected boolean
_scanIftime
protected java.lang.String
_scanKey
protected boolean
_scanning
protected java.lang.String
_scanSearch
protected long
_scanStart
protected long
_scanStop
private java.lang.Thread
_thread
private static org.apache.logging.log4j.Logger
log
Logging .
-
Constructor Summary
Constructors Constructor Description AsynchHBaseClient(java.lang.String url)
Create and connect to HBase.AsynchHBaseClient(java.lang.String zookeepers, int clientPort)
Create and connect to HBase.AsynchHBaseClient(java.lang.String zookeepers, java.lang.String clientPort)
Create and connect to HBase.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
poll()
Give next result (if available).java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
poll(int n)
Give next several results (when available).void
run()
java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>>
scan(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime, int timelimit)
Scan with timelimit.java.lang.String
scan2json(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime, int timelimit)
Start scan assynchronously.boolean
scanning()
Tell, whether it is actually scanning.void
setLoopWait(int t)
Set the time parallel thread waits between actions.void
setMaxQueueSize(int maxsize)
Set maximum size of the queue.int
size()
The actual size of the queue.void
startScan(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime)
Start scan assynchronously.void
stop()
Stop the scanning and remove all remaining results.void
stop(boolean keep)
Stop the scanning.-
Methods inherited from class com.Lomikel.HBaser.HBaseClient
addAlwaysColumns, addResult, addResult3D, clientPort, close, conf, connect, connect, connect, connect, create, dateFormat, delete, evaluator, isRangeScan, latests, processResults, put, put, repository, resultScanner, scan, scan3D, search3D, search3D, searchLimit, setAlwaysColumns, setDateFormat, setEvaluation, setEvaluation, setProcessor, setRangeScan, setRepository, setSearchLimit, setSearchOperator, setup, table, timeline, zookeepers
-
Methods inherited from class com.Lomikel.DB.Client
finalize, isReversed, limit, registerVertexType, rename, representation, representations, results2CVS, results2DF, results2List, results2String, scan, scan, scan, scan3D, scan3D, scan3D, schema, setLimit, setReversed, setSchema, setTableName, tableName
-
-
-
-
Field Detail
-
_queue
protected java.util.concurrent.ConcurrentLinkedQueue<java.util.Map<java.lang.String,java.lang.String>> _queue
-
_processor
protected AsynchHBaseProcessor _processor
-
_thread
private java.lang.Thread _thread
-
_scanKey
protected java.lang.String _scanKey
-
_scanSearch
protected java.lang.String _scanSearch
-
_scanFilter
protected java.lang.String _scanFilter
-
_scanStart
protected long _scanStart
-
_scanStop
protected long _scanStop
-
_scanIfkey
protected boolean _scanIfkey
-
_scanIftime
protected boolean _scanIftime
-
_doscan
protected boolean _doscan
-
_scanning
protected boolean _scanning
-
_loopWait
protected int _loopWait
-
log
private static org.apache.logging.log4j.Logger log
Logging .
-
-
Constructor Detail
-
AsynchHBaseClient
public AsynchHBaseClient(java.lang.String zookeepers, java.lang.String clientPort) throws LomikelException
Create and connect to HBase.- Parameters:
zookeepers
- The comma-separated list of zookeper ids.clientPort
- The client port.- Throws:
LomikelException
- If anything goes wrong.
-
AsynchHBaseClient
public AsynchHBaseClient(java.lang.String zookeepers, int clientPort) throws LomikelException
Create and connect to HBase.- Parameters:
zookeepers
- The comma-separated list of zookeper ids.clientPort
- The client port.- Throws:
LomikelException
- If anything goes wrong.
-
AsynchHBaseClient
public AsynchHBaseClient(java.lang.String url) throws LomikelException
Create and connect to HBase.- Parameters:
url
- The HBase url.- Throws:
LomikelException
- If anything goes wrong.
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
startScan
public void startScan(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime)
Start scan assynchronously.- Parameters:
key
- The row key. Disables other search terms. It can be null.search
- The search terms as family:column:value,.... Key can be searched with family:column = key:key "pseudo-name". key:startKey and key:stopKey van restrict search to a key interval.Comparator
can be chosen as family:column:value:comparator among exact,prefix,substring,regex. The default for key is prefix, the default for columns is substring. The randomiser can be added with random:random:chance. It can be null. All searches are executed as prefix searches.filter
- The names of required values as family:column,.... * = all.start
- The time period start timestamp in ms. 0 means since the beginning.stop
- The time period stop timestamp in ms. 0 means till now.ifkey
- Whether give also entries keys (as key:key).iftime
- Whether give also entries timestamps (as key:time).
-
scan2json
public java.lang.String scan2json(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime, int timelimit)
Start scan assynchronously. Present results as a JSON string.- Parameters:
key
- The row key. Disables other search terms. It can be null.search
- The search terms as family:column:value,.... Key can be searched with family:column = key:key "pseudo-name". key:startKey and key:stopKey van restrict search to a key interval.Comparator
can be chosen as family:column:value:comparator among exact,prefix,substring,regex. The default for key is prefix, the default for columns is substring. The randomiser can be added with random:random:chance. It can be null. All searches are executed as prefix searches.filter
- The names of required values as family:column,.... * = all.start
- The time period start timestamp in ms. 0 means since the beginning.stop
- The time period stop timestamp in ms. 0 means till now.ifkey
- Whether give also entries keys (as key:key).iftime
- Whether give also entries timestamps (as key:time).
-
scan
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> scan(java.lang.String key, java.lang.String search, java.lang.String filter, long start, long stop, boolean ifkey, boolean iftime, int timelimit)
Scan with timelimit.- Parameters:
key
- The row key. Disables other search terms. It can be null.search
- The search terms as family:column:value,.... Key can be searched with family:column = key:key "pseudo-name". key:startKey and key:stopKey van restrict search to a key interval.Comparator
can be chosen as family:column:value:comparator among exact,prefix,substring,regex. The default for key is prefix, the default for columns is substring. The randomiser can be added with random:random:chance. It can be null. All searches are executed as prefix searches.filter
- The names of required values as family:column,.... * = all.start
- The time period start timestamp in ms. 0 means since the beginning.stop
- The time period stop timestamp in ms. 0 means till now.ifkey
- Whether give also entries keys (as key:key).iftime
- Whether give also entries timestamps (as key:time).timelimit
- The scanning timelimit [s] after which the processus will be interrupted and only so far acquired results will be returned.- Returns:
- The
Map
ofMap
s of results as key-&t;{family:column->value}.
-
poll
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> poll()
Give next result (if available).- Returns:
- The available result.
-
poll
public java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> poll(int n)
Give next several results (when available).- Parameters:
n
- The number of requested results.- Returns:
- The available results.
-
size
public int size()
The actual size of the queue.- Returns:
- The number of available results.
-
scanning
public boolean scanning()
Tell, whether it is actually scanning.- Returns:
- Whether it is actually scanning.
-
setMaxQueueSize
public void setMaxQueueSize(int maxsize)
Set maximum size of the queue. Queue accumlation will stop till its size goes bellow this limit.- Parameters:
maxsize
- The maximum size of the queue. Default is 1000.
-
setLoopWait
public void setLoopWait(int t)
Set the time parallel thread waits between actions.- Parameters:
t
- The time parallel thread waits between actions (in ms). The default is 1000ms.
-
stop
public void stop()
Stop the scanning and remove all remaining results.
-
stop
public void stop(boolean keep)
Stop the scanning.- Parameters:
keep
- Whether to keep already accumulated results, or to remove them.
-
-