Class AsynchHBaseClient

  • All Implemented Interfaces:
    java.lang.Runnable

    public class AsynchHBaseClient
    extends HBaseClient
    implements java.lang.Runnable
    AsynchHBaseClient provides HBaseClient scanning asynchronously. Only some methods are available for asynchronous processing. Only one asynchronous scanning Thread is allowed.
    Author:
    J.Hrivnac
    • 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.
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.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 of Maps 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.