Database Reference
In-Depth Information
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HConnection;
import org.apache.hadoop.hbase.client.HConnectionManager;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
public class UserInsert2 {
static String tableName = "users";
static String familyName = "info";
public static void main(String[] args) throws Exception {
Configuration config = HBaseConfiguration.create();
// change the following to connect to remote clusters
// config.set("hbase.zookeeper.quorum", "localhost");
long t1a = System.currentTimeMillis();
HConnection hConnection = HConnectionManager.
createConnection(config);
long t1b = System.currentTimeMillis();
System.out.println ("Connection manager in : " +
(t1b-t1a) + " ms");
// simulate the first 'connection'
long t2a = System.currentTimeMillis();
HTableInterface htable = hConnection.getTable(tableName) ;
long t2b = System.currentTimeMillis();
System.out.println ("first connection in : " + (t2b-t2a) +
" ms");
// second connection
long t3a = System.currentTimeMillis();
HTableInterface htable2 = hConnection.getTable(tableName)
;
long t3b = System.currentTimeMillis();
System.out.println ("second connection : " + (t3b-t3a) +
" ms");
int total = 100;
long t4a = System.currentTimeMillis();
 
Search WWH ::




Custom Search