options.addOption(OPTION_INPUT_PATH); options.addOption(OPTION_HTABLE_NAME); options.addOption(OPTION_CUBE_NAME); parseOptions(options, args); StringtableName= getOptionValue(OPTION_HTABLE_NAME); // /tmp/kylin-3f150b00-3332-41ca-9d3d-652f67f044d7/test_kylin_cube_with_slr_ready_2_segments/hfile/ // end with "/" Stringinput= getOptionValue(OPTION_INPUT_PATH); Configurationconf= HBaseConnection.getCurrentHBaseConfiguration(); FsShellshell=newFsShell(conf); intexitCode= -1; intretryCount=10; // 给上面的hfile文件赋予读权限 while (exitCode != 0 && retryCount >= 1) { exitCode = shell.run(newString[] { "-chmod", "-R", "777", input }); retryCount--; Thread.sleep(5000); } if (exitCode != 0) { logger.error("Failed to change the file permissions: " + input); thrownewIOException("Failed to change the file permissions: " + input); } String[] newArgs = newString[2]; newArgs[0] = input; newArgs[1] = tableName; logger.debug("Start to run LoadIncrementalHFiles"); //将Hfile输出格式的输出加载到现有表中的工具。 intret= ToolRunner.run(newLoadIncrementalHFiles(conf), newArgs); logger.debug("End to run LoadIncrementalHFiles"); return ret; }
可以看到,最后调用的是Hbase包的类LoadIncrementalHFiles,这是一个工具类,官方解释是“Tool to load the output of HFileOutputFormat into an existing table.” 。对于这个类的解释可以参考这个文章 HBase 写优化之 BulkLoad 实现数据快速入库