Examples of HConnectionPool


Examples of org.apache.hadoop.hbase.hbql.client.HConnectionPool

        // For each connection in a connection pool, assign an HTablePool max size of 25 references per table
        HConnectionPoolManager.setMaxPoolReferencesPerTablePerConnection(25);

        // Create connection pool with max of 25 connections and prime it with 5 initial connections
        HConnectionPool connectionPool = HConnectionPoolManager.newConnectionPool(5, 25);

        // Create Query Executor Pool named execPool if it doesn't already exist.
        if (!QueryExecutorPoolManager.queryExecutorPoolExists("execPool"))
            QueryExecutorPoolManager.newQueryExecutorPool("execPool", 5, 5, 10, Long.MAX_VALUE, true, 100);

        // Take a connection from the connection pool
        HConnection conn = connectionPool.takeConnection();

        // Assign the connection a query executor pool name to use for queries
        conn.setQueryExecutorPoolName("execPool");

        // Do something with the connection
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.client.HConnectionPool

    }

    @Test
    public void randomConcurrentTest() throws HBqlException, InterruptedException {

        final HConnectionPool connectionPool = HConnectionPoolManager.newConnectionPool(1, 4);

        final int queryPoolCnt = 5;
        for (int p = 1; p <= queryPoolCnt; p++) {
            final String poolName = "execPool" + p;
            System.out.println("Creating query executor pool: " + poolName);
            QueryExecutorPoolManager.newQueryExecutorPool(poolName,
                                                          Utils.getRandomPositiveInt(5),
                                                          Utils.getRandomPositiveInt(2),
                                                          Utils.getRandomPositiveInt(5),
                                                          Long.MAX_VALUE,
                                                          Utils.getRandomBoolean(),
                                                          Utils.getRandomPositiveInt(10));
        }

        final int poolSize = Utils.getRandomPositiveInt(10);
        final ExecutorService threadPool = Executors.newFixedThreadPool(poolSize);

        final int repeats = 10;

        for (int i = 0; i < repeats; i++) {
            final int totalJobs = Utils.getRandomPositiveInt(50);
            final int keyCount = Utils.getRandomPositiveInt(50);
            final CountDownLatch latch = new CountDownLatch(totalJobs);

            for (int tj = 0; tj < totalJobs; tj++) {
                final int jobNum = tj;
                threadPool.submit(
                        new Runnable() {
                            public void run() {

                                HConnection conn = null;
                                try {
                                    conn = connectionPool.takeConnection();

                                    conn.setQueryExecutorPoolName("execPool" + Utils.getRandomPositiveInt(queryPoolCnt));

                                    conn.execute("CREATE TEMP MAPPING tab3 FOR TABLE table20"
                                                 + "("
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.