0

CDH4 (現在は 4.5) によって管理されるアプリケーション ログを格納するために HBase を使用していますが、cdh 4.6 (4.7 と同じ) にアップグレードした後、挿入が非常に遅くなります。クライアントがリージョンサーバーに接続していて、すぐに接続を閉じることがわかりました(CDh 4.5を使用しても同じ問題は発生していません)

RegionServer ログ:

13:46:08,428 INFO org.apache.zookeeper.ZooKeeper: Initiating client connection, connectString=ZK03:2181,ZK02:2181,ZK01:2181 sessionTimeout=60000 watcher=hconnection
13:46:08,429 INFO org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper: The identifier of this process is 19573@NODE01
13:46:08,429 INFO org.apache.zookeeper.ClientCnxn: Opening socket connection to server ZK03/10.1.243.170:2181. Will not attempt to authenticate using SASL (java.lang.SecurityException: Unable to locate a login configuration)
13:46:08,429 INFO org.apache.zookeeper.ClientCnxn: Socket connection established to ZK03/10.1.243.170:2181, initiating session
13:46:08,431 INFO org.apache.zookeeper.ClientCnxn: Session establishment complete on server ZK03/10.1.243.170:2181, sessionid = 0x146a9fec35171f0, negotiated timeout = 60000
13:46:08,538 INFO org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation: Closed zookeeper sessionid=0x146a9fec35171f0
13:46:08,540 INFO org.apache.zookeeper.ZooKeeper: Session: 0x146a9fec35171f0 closed
13:46:08,540 INFO org.apache.zookeeper.ClientCnxn: EventThread shut down

クライアント接続クラス:

private void initConnection(Configuration hConf) throws RuntimeException {
    try {
        //HConnectionManager.create(hConf);
        hConnection = HConnectionManager.createConnection(hConf);
    } catch (ZooKeeperConnectionException e) {
        logAndThrow("Failed to init connection " + e.getMessage());
    }
}

public Connection(Configuration hConf) {
    initConnection(hConf);
}

public void closeConnection() throws IOException {
    hConnection.close();
}

public HTableInterface getHTableInterface(String tableName) throws IOException {
    HTableInterface htable = hConnection.getTable(tableName);
    htable.setAutoFlush(false, true);
    htable.setWriteBufferSize(1024*1024*12);
    return htable;
}

輸入:

Put put = new Put(rowKey.get(), tsWhole);
mainTableBuffer.add(put);
if(cfg_.maxBatchBufferSize <= mainTableBuffer.size()) {
    mainTableInterface_.batch(mainTableBuffer);
    mainTableBuffer.clear();
}
4

1 に答える 1

0

問題が見つかったようです。セカンダリ インデックスを作成するとき、それはコプロセッサにありました。これは、secondaryIndexTable に挿入するための実際のコードでした

 public void postBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp) throws IOException {

        HTableInterface searchTableInterface = c.getEnvironment().getTable(tableName);
        try {
            searchTableInterface.batch(mutationsBuffer);
        } catch (InterruptedException e) {
            logger.error("Caught exception while executing batch on table " + currSearchTName, e);
        } finally {
            searchTableInterface.close();
        }
}

問題は、挿入に環境接続を使用しているようです。起動時に接続が作成されます

hConnection = HConnectionManager.createConnection(hConf);

postBarchMutate では、テーブルを取得するために使用されます

HTableInterface htable = hConnection.getTable(tableName);

現在は機能していますが、環境接続を使用するのがなぜ間違っているのか、接続が常に閉じる理由はまだわかりません

于 2014-07-15T13:09:59.153 に答える