hbase如何确定一条新数据写入到哪个regionserver

如题所述

HBase写记录过程中regionname查找简介:主要是看如何进行region选择,完成按domain域的数据散列,分摊至不同region上
|-->HTable table = new HTable(config, tablename);
|-->Put put = new Put(Bytes.toBytes("test2"));
|-->put.add(Bytes.toBytes(cfs[j]), Bytes.toBytes(String.valueOf(1)), Bytes.toBytes("value_3"));
|-->table.put(put);

HTable-->put() |利用HTable管理记录
|-->doPut(Arrays.asList(put));
|-->for (Put put : puts)
|-->writeBuffer.add(put);
|-->if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize)
|-->flushCommits();
|-->if (autoFlush || currentWriteBufferSize > writeBufferSize)
|-->flushCommits();

HTable-->flushCommits() |提交添加的记录,内存阀值可控制
|-->Object[] results = new Object[writeBuffer.size()];
|-->this.connection.processBatch(writeBuffer, tableName, pool, results);
|-->finally
|-->for (int i = results.length - 1; i>=0; i--)
|-->if (results[i] instanceof Result)
|-->writeBuffer.remove(i);
温馨提示:答案为网友推荐,仅供参考
相似回答