Using a shared HBaseConfiguration has the same result.  With the default
30 connections I would expect to see all 20 threads return a response
instead of just the first 10.

The following is an updated test case:
--

import java.io.IOException;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

// create 'fc_test', {NAME => 'json', VERSIONS => 1}, {NAME => 'data',
VERSIONS =>1, COMPRESSION => 'lzo' }
// put 'fc_test', 'testing123', 'json:', "[1,2,3]"

public class TableTest extends Thread {
    static HBaseConfiguration hbaseConfiguration = null;

    public void run() {
        try {
            String key = "testing123";
            HTable table = new HTable(hbaseConfiguration, "fc_test");
            Get get = new Get(Bytes.toBytes(key));
            get.addFamily(Bytes.toBytes("json"));
            Result result = table.get(get);
            KeyValue[] kvs = result.raw();

            System.out.println(Bytes.toString(kvs[0].getValue()));
        } catch (Exception e) {
            System.out.println(e.toString());
        }

        try {
            Thread.currentThread().sleep(1000);
        } catch (Exception e) {
        }

    }

    public static void main(String args[]) throws IOException {
        Thread t = null;
        int i;
    
        hbaseConfiguration = new HBaseConfiguration();

        for (i = 0; i< 20; i++) {
            t = new TableTest();
            t.start();
        }

        // wait for last thread
        try {
            t.join();
        } catch (InterruptedException e) {
        }
    }
}


stack wrote:
> Try making the HBaseConfiguration once only (Create it in a Constructor or
> pass it in from the main).
>
> ZooKeeper has an upper bound on the number of connections from any one IP
> (30 by default IIRC) to protect against DoS.
>
> HBase HTable internally will create a new connection each time if the
> HBaseConfiguration is new each time; otherwise, the HBase Connection object
> is shared amongst HTables.
>
> St.Ack
>
>
>   

Reply via email to