发生情景:
启动多个线程共用table连接,
HTable table = new HTable(conf, "tablename"); @Test public void insert_multithread() throws InterruptedException { for (int k = 1; k <= 10; k++){ final int j = k; new Thread(new Runnable() { public void run() { try { // Configuration conf = new Configuration(); // conf.set("hbase.zookeeper.quorum", "192.168.1.160"); // HTable table = new HTable(conf,"wf:error"); errorTable.setAutoFlushTo(false); long t1 = System.currentTimeMillis(); for (int i = 0; i < 10000; i++){ String uuid = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 8); Put put = new Put(Bytes.toBytes( uuid + "_" +"2015070" + j )); put.add(fBytes,Bytes.toBytes("stacktrace"),Bytes.toBytes("java.io.IOException:file not found" + UUID.randomUUID().toString())); // puts.add(put); errorTable.put(put); if (i % 10000 == 0) { errorTable.flushCommits(); } } // table.close(); long t2 = System.currentTimeMillis(); System.out.println(Thread.currentThread() + ",t2-t1=" + (t2 - t1)); }catch (IOException e){ } } }).start(); } System.out.println("waiting....."); Thread.sleep(1000 * 60 * 10); System.out.println("completing......."); } HTable table = new HTable(co