/** * Shutdown the table manager, internally it shuts down all tables */ public void close() { tableContexts.values().forEach(ctx -> ctx.tableProvider.close()); }
/** * Get a table instance * @param tableId Id of the table * @return table instance */ public Table getTable(String tableId) { Preconditions.checkState(initialized, "TableManager has not been initialized."); TableCtx ctx = tableContexts.get(tableId); Preconditions.checkNotNull(ctx, "Unknown tableId " + tableId); if (ctx.table == null) { ctx.table = ctx.tableProvider.getTable(); } return ctx.table; } }
/** * Initialize table providers with container and task contexts * @param context context for the task */ public void init(Context context) { tableContexts.values().forEach(ctx -> ctx.tableProvider.init(context)); initialized = true; }
/** * Generate table configurations given a list of table specs * @param config the job configuration * @param tableSpecs the list of tableSpecs * @return configuration for the tables */ static public Map<String, String> generateConfigsForTableSpecs(Config config, List<TableSpec> tableSpecs) { Map<String, String> tableConfigs = new HashMap<>(); tableSpecs.forEach(tableSpec -> { // Add table provider factory config tableConfigs.put(String.format(JavaTableConfig.TABLE_PROVIDER_FACTORY, tableSpec.getId()), tableSpec.getTableProviderFactoryClassName()); // Generate additional configuration TableProviderFactory tableProviderFactory = Util.getObj(tableSpec.getTableProviderFactoryClassName(), TableProviderFactory.class); TableProvider tableProvider = tableProviderFactory.getTableProvider(tableSpec); tableConfigs.putAll(tableProvider.generateConfig(config, tableConfigs)); }); LOG.info("TableConfigGenerator has generated configs {}", tableConfigs); return tableConfigs; }
/** * Generate table configurations given a list of table specs * @param config the job configuration * @param tableSpecs the list of tableSpecs * @return configuration for the tables */ static public Map<String, String> generateConfigsForTableSpecs(Config config, List<TableSpec> tableSpecs) { Map<String, String> tableConfigs = new HashMap<>(); tableSpecs.forEach(tableSpec -> { // Add table provider factory config tableConfigs.put(String.format(JavaTableConfig.TABLE_PROVIDER_FACTORY, tableSpec.getId()), tableSpec.getTableProviderFactoryClassName()); // Generate additional configuration TableProviderFactory tableProviderFactory = Util.getObj(tableSpec.getTableProviderFactoryClassName(), TableProviderFactory.class); TableProvider tableProvider = tableProviderFactory.getTableProvider(tableSpec); tableConfigs.putAll(tableProvider.generateConfig(config, tableConfigs)); }); LOG.info("TableConfigGenerator has generated configs {}", tableConfigs); return tableConfigs; }
/** * Initialize table providers with container and task contexts * @param context context for the task */ public void init(Context context) { tableContexts.values().forEach(ctx -> ctx.tableProvider.init(context)); initialized = true; }
/** * Shutdown the table manager, internally it shuts down all tables */ public void close() { tableContexts.values().forEach(ctx -> ctx.tableProvider.close()); }
/** * Get a table instance * @param tableId Id of the table * @return table instance */ public Table getTable(String tableId) { Preconditions.checkState(initialized, "TableManager has not been initialized."); TableCtx ctx = tableContexts.get(tableId); Preconditions.checkNotNull(ctx, "Unknown tableId " + tableId); if (ctx.table == null) { ctx.table = ctx.tableProvider.getTable(); } return ctx.table; } }
/** * Generate table configurations given a list of table specs * @param config the job configuration * @param tableSpecs the list of tableSpecs * @return configuration for the tables */ static public Map<String, String> generateConfigsForTableSpecs(Config config, List<TableSpec> tableSpecs) { Map<String, String> tableConfigs = new HashMap<>(); tableSpecs.forEach(tableSpec -> { // Add table provider factory config tableConfigs.put(String.format(JavaTableConfig.TABLE_PROVIDER_FACTORY, tableSpec.getId()), tableSpec.getTableProviderFactoryClassName()); // Generate additional configuration TableProviderFactory tableProviderFactory = Util.getObj(tableSpec.getTableProviderFactoryClassName(), TableProviderFactory.class); TableProvider tableProvider = tableProviderFactory.getTableProvider(tableSpec); tableConfigs.putAll(tableProvider.generateConfig(config, tableConfigs)); }); LOG.info("TableConfigGenerator has generated configs {}", tableConfigs); return tableConfigs; }
/** * Initialize table providers with container and task contexts * @param context context for the task */ public void init(Context context) { tableContexts.values().forEach(ctx -> ctx.tableProvider.init(context)); initialized = true; }
/** * Shutdown the table manager, internally it shuts down all tables */ public void close() { tableContexts.values().forEach(ctx -> ctx.tableProvider.close()); }
/** * Get a table instance * @param tableId Id of the table * @return table instance */ public Table getTable(String tableId) { Preconditions.checkState(initialized, "TableManager has not been initialized."); TableCtx ctx = tableContexts.get(tableId); Preconditions.checkNotNull(ctx, "Unknown tableId " + tableId); if (ctx.table == null) { ctx.table = ctx.tableProvider.getTable(); } return ctx.table; } }
/** * Generate table configurations given a list of table specs * @param config the job configuration * @param tableSpecs the list of tableSpecs * @return configuration for the tables */ static public Map<String, String> generateConfigsForTableSpecs(Config config, List<TableSpec> tableSpecs) { Map<String, String> tableConfigs = new HashMap<>(); tableSpecs.forEach(tableSpec -> { // Add table provider factory config tableConfigs.put(String.format(JavaTableConfig.TABLE_PROVIDER_FACTORY, tableSpec.getId()), tableSpec.getTableProviderFactoryClassName()); // Generate additional configuration TableProviderFactory tableProviderFactory = Util.getObj(tableSpec.getTableProviderFactoryClassName(), TableProviderFactory.class); TableProvider tableProvider = tableProviderFactory.getTableProvider(tableSpec); tableConfigs.putAll(tableProvider.generateConfig(config, tableConfigs)); }); LOG.info("TableConfigGenerator has generated configs {}", tableConfigs); return tableConfigs; }
/** * Initialize table providers with container and task contexts * @param context context for the task */ public void init(Context context) { tableContexts.values().forEach(ctx -> ctx.tableProvider.init(context)); initialized = true; }
/** * Shutdown the table manager, internally it shuts down all tables */ public void close() { tableContexts.values().forEach(ctx -> ctx.tableProvider.close()); }
/** * Get a table instance * @param tableId Id of the table * @return table instance */ public Table getTable(String tableId) { Preconditions.checkState(initialized, "TableManager has not been initialized."); TableCtx ctx = tableContexts.get(tableId); Preconditions.checkNotNull(ctx, "Unknown tableId " + tableId); if (ctx.table == null) { ctx.table = ctx.tableProvider.getTable(); } return ctx.table; } }