@Test(expectedExceptions = IllegalArgumentException.class, timeOut = 20_000) public void testExceptionIsThrownWhenSpecifyingAWrongCommand() throws Throwable { String[] args = new String[]{"non-recognized-command"}; OmidTableManager omidTableManager = new OmidTableManager(args); omidTableManager.executeActionsOnHBase(hbaseConf); }
public void executeActionsOnHBase(Configuration hbaseConf) throws IOException { HBaseLogin.loginIfNeeded(mainConfig.loginFlags); try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) { byte[][] tableFamilies; byte[][] splitKeys = new byte[0][0]; String tableName; LOG.info("----------------------------------------------------------------------------------------------"); switch (commandLine.getParsedCommand()) { case COMMIT_TABLE_COMMAND_NAME: LOG.info("Performing actions related to COMMIT TABLE"); tableName = commitTableCommand.tableName; tableFamilies = commitTableFamilies; if (commitTableCommand.numRegions > 1) { splitKeys = splitInUniformRegions(hbaseConf, commitTableCommand.numRegions); } break; case TIMESTAMP_TABLE_COMMAND_NAME: LOG.info("Performing actions related to TIMESTAMP TABLE"); tableName = timestampTableCommand.tableName; tableFamilies = timestampTableFamilies; break; default: LOG.error("Unknown command: {}", commandLine.getParsedCommand()); commandLine.usage(); return; } createTable(hBaseAdmin, tableName, tableFamilies, splitKeys, 1); LOG.info("----------------------------------------------------------------------------------------------"); } }
OmidTableManager { public void executeActionsOnHBase(Configuration hbaseConf) throws IOException { HBaseLogin.loginIfNeeded(mainConfig.loginFlags); try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) { byte[][] tableFamilies; byte[][] splitKeys = new byte[0][0]; String tableName; LOG.info("----------------------------------------------------------------------------------------------"); switch (commandLine.getParsedCommand()) { case COMMIT_TABLE_COMMAND_NAME: LOG.info("Performing actions related to COMMIT TABLE"); tableName = commitTableCommand.tableName; tableFamilies = commitTableFamilies; if (commitTableCommand.numRegions > 1) { splitKeys = splitInUniformRegions(hbaseConf, commitTableCommand.numRegions); } break; case TIMESTAMP_TABLE_COMMAND_NAME: LOG.info("Performing actions related to TIMESTAMP TABLE"); tableName = timestampTableCommand.tableName; tableFamilies = timestampTableFamilies; break; default: LOG.error("Unknown command: {}", commandLine.getParsedCommand()); commandLine.usage(); return; } createTable(hBaseAdmin, tableName, tableFamilies, splitKeys, 1); LOG.info("----------------------------------------------------------------------------------------------"); } } }
OmidTableManager { public void executeActionsOnHBase(Configuration hbaseConf) throws IOException { HBaseLogin.loginIfNeeded(mainConfig.loginFlags); try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) { byte[][] tableFamilies; byte[][] splitKeys = new byte[0][0]; String tableName; LOG.info("----------------------------------------------------------------------------------------------"); switch (commandLine.getParsedCommand()) { case COMMIT_TABLE_COMMAND_NAME: LOG.info("Performing actions related to COMMIT TABLE"); tableName = commitTableCommand.tableName; tableFamilies = commitTableFamilies; if (commitTableCommand.numRegions > 1) { splitKeys = splitInUniformRegions(hbaseConf, commitTableCommand.numRegions); } break; case TIMESTAMP_TABLE_COMMAND_NAME: LOG.info("Performing actions related to TIMESTAMP TABLE"); tableName = timestampTableCommand.tableName; tableFamilies = timestampTableFamilies; break; default: LOG.error("Unknown command: {}", commandLine.getParsedCommand()); commandLine.usage(); return; } createTable(hBaseAdmin, tableName, tableFamilies, splitKeys, 1); LOG.info("----------------------------------------------------------------------------------------------"); } } OmidTableManager(String... args); }
OmidTableManager { public void executeActionsOnHBase(Configuration hbaseConf) throws IOException { HBaseLogin.loginIfNeeded(mainConfig.loginFlags); try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) { byte[][] tableFamilies; byte[][] splitKeys = new byte[0][0]; String tableName; LOG.info("----------------------------------------------------------------------------------------------"); switch (commandLine.getParsedCommand()) { case COMMIT_TABLE_COMMAND_NAME: LOG.info("Performing actions related to COMMIT TABLE"); tableName = commitTableCommand.tableName; tableFamilies = commitTableFamilies; if (commitTableCommand.numRegions > 1) { splitKeys = splitInUniformRegions(hbaseConf, commitTableCommand.numRegions); } break; case TIMESTAMP_TABLE_COMMAND_NAME: LOG.info("Performing actions related to TIMESTAMP TABLE"); tableName = timestampTableCommand.tableName; tableFamilies = timestampTableFamilies; break; default: LOG.error("Unknown command: {}", commandLine.getParsedCommand()); commandLine.usage(); return; } createTable(hBaseAdmin, tableName, tableFamilies, splitKeys, 1); LOG.info("----------------------------------------------------------------------------------------------"); } } OmidTableManager(String... args); void executeActionsOnHBase(Configuration hbaseConf); static void main(String... args); }
OmidTableManager { public void executeActionsOnHBase(Configuration hbaseConf) throws IOException { HBaseLogin.loginIfNeeded(mainConfig.loginFlags); try (HBaseAdmin hBaseAdmin = new HBaseAdmin(hbaseConf)) { byte[][] tableFamilies; byte[][] splitKeys = new byte[0][0]; String tableName; LOG.info("----------------------------------------------------------------------------------------------"); switch (commandLine.getParsedCommand()) { case COMMIT_TABLE_COMMAND_NAME: LOG.info("Performing actions related to COMMIT TABLE"); tableName = commitTableCommand.tableName; tableFamilies = commitTableFamilies; if (commitTableCommand.numRegions > 1) { splitKeys = splitInUniformRegions(hbaseConf, commitTableCommand.numRegions); } break; case TIMESTAMP_TABLE_COMMAND_NAME: LOG.info("Performing actions related to TIMESTAMP TABLE"); tableName = timestampTableCommand.tableName; tableFamilies = timestampTableFamilies; break; default: LOG.error("Unknown command: {}", commandLine.getParsedCommand()); commandLine.usage(); return; } createTable(hBaseAdmin, tableName, tableFamilies, splitKeys, 1); LOG.info("----------------------------------------------------------------------------------------------"); } } OmidTableManager(String... args); void executeActionsOnHBase(Configuration hbaseConf); static void main(String... args); static final String COMMIT_TABLE_COMMAND_NAME; }