YARN-6604. Allow metric TTL for Application table to be specified through cmd (Haibo Chen via Varun Saxena)
(cherry picked from commit 0b7bff706e9a5c4a17e0f46deceb2521168d25b9) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c4f042d4 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c4f042d4 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c4f042d4 Branch: refs/heads/branch-2 Commit: c4f042d4c1964dccbe85f0e8cd98243a26d31e42 Parents: 48d2e4f Author: Varun Saxena <[email protected]> Authored: Wed Jun 7 21:51:07 2017 +0530 Committer: Varun Saxena <[email protected]> Committed: Tue Oct 17 23:36:38 2017 +0530 ---------------------------------------------------------------------- .../storage/TimelineSchemaCreator.java | 36 ++++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c4f042d4/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineSchemaCreator.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineSchemaCreator.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineSchemaCreator.java index a9c74d2..f93c977 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineSchemaCreator.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase/src/main/java/org/apache/hadoop/yarn/server/timelineservice/storage/TimelineSchemaCreator.java @@ -61,9 +61,10 @@ public final class TimelineSchemaCreator { final static String NAME = TimelineSchemaCreator.class.getSimpleName(); private static final Log LOG = LogFactory.getLog(TimelineSchemaCreator.class); private static final String SKIP_EXISTING_TABLE_OPTION_SHORT = "s"; + private static final String APP_METRICS_TTL_OPTION_SHORT = "ma"; private static final String APP_TABLE_NAME_SHORT = "a"; private static final String APP_TO_FLOW_TABLE_NAME_SHORT = "a2f"; - private static final String TTL_OPTION_SHORT = "m"; + private static final String ENTITY_METRICS_TTL_OPTION_SHORT = "me"; private static final String ENTITY_TABLE_NAME_SHORT = "e"; private static final String HELP_SHORT = "h"; private static final String CREATE_TABLES_SHORT = "c"; @@ -91,12 +92,12 @@ public final class TimelineSchemaCreator { if (StringUtils.isNotBlank(entityTableName)) { hbaseConf.set(EntityTable.TABLE_NAME_CONF_NAME, entityTableName); } - // Grab the TTL argument - String entityTableTTLMetrics =commandLine.getOptionValue( - TTL_OPTION_SHORT); - if (StringUtils.isNotBlank(entityTableTTLMetrics)) { - int metricsTTL = Integer.parseInt(entityTableTTLMetrics); - new EntityTable().setMetricsTTL(metricsTTL, hbaseConf); + // Grab the entity metrics TTL + String entityTableMetricsTTL = commandLine.getOptionValue( + ENTITY_METRICS_TTL_OPTION_SHORT); + if (StringUtils.isNotBlank(entityTableMetricsTTL)) { + int entityMetricsTTL = Integer.parseInt(entityTableMetricsTTL); + new EntityTable().setMetricsTTL(entityMetricsTTL, hbaseConf); } // Grab the appToflowTableName argument String appToflowTableName = commandLine.getOptionValue( @@ -111,6 +112,13 @@ public final class TimelineSchemaCreator { hbaseConf.set(ApplicationTable.TABLE_NAME_CONF_NAME, applicationTableName); } + // Grab the application metrics TTL + String applicationTableMetricsTTL = commandLine.getOptionValue( + APP_METRICS_TTL_OPTION_SHORT); + if (StringUtils.isNotBlank(applicationTableMetricsTTL)) { + int appMetricsTTL = Integer.parseInt(applicationTableMetricsTTL); + new ApplicationTable().setMetricsTTL(appMetricsTTL, hbaseConf); + } // create all table schemas in hbase final boolean skipExisting = commandLine.hasOption( @@ -149,9 +157,9 @@ public final class TimelineSchemaCreator { o.setRequired(false); options.addOption(o); - o = new Option(TTL_OPTION_SHORT, "metricsTTL", true, + o = new Option(ENTITY_METRICS_TTL_OPTION_SHORT, "entityMetricsTTL", true, "TTL for metrics column family"); - o.setArgName("metricsTTL"); + o.setArgName("entityMetricsTTL"); o.setRequired(false); options.addOption(o); @@ -167,6 +175,12 @@ public final class TimelineSchemaCreator { o.setRequired(false); options.addOption(o); + o = new Option(APP_METRICS_TTL_OPTION_SHORT, "applicationMetricsTTL", true, + "TTL for metrics column family"); + o.setArgName("applicationMetricsTTL"); + o.setRequired(false); + options.addOption(o); + // Options without an argument // No need to set arg name since we do not need an argument here o = new Option(SKIP_EXISTING_TABLE_OPTION_SHORT, "skipExistingTable", @@ -197,12 +211,14 @@ public final class TimelineSchemaCreator { usage.append("The Optional options for creating tables include: \n"); usage.append("[-entityTableName <Entity Table Name>] " + "The name of the Entity table\n"); - usage.append("[-metricsTTL <Entity Table Metrics TTL>]" + + usage.append("[-entityMetricsTTL <Entity Table Metrics TTL>]" + " TTL for metrics in the Entity table\n"); usage.append("[-appToflowTableName <AppToflow Table Name>]" + " The name of the AppToFlow table\n"); usage.append("[-applicationTableName <Application Table Name>]" + " The name of the Application table\n"); + usage.append("[-applicationMetricsTTL <Application Table Metrics TTL>]" + + " TTL for metrics in the Application table\n"); usage.append("[-skipExistingTable] Whether to skip existing" + " hbase tables\n"); System.out.println(usage.toString()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
