YARN-6604. Allow metric TTL for Application table to be specified through cmd (Haibo Chen via Varun Saxena)

This commit is contained in:
Varun Saxena 2017-06-07 21:51:07 +05:30
parent 5ec71639cf
commit 0b7bff706e
1 changed files with 26 additions and 10 deletions

View File

@ -60,9 +60,10 @@ public final class TimelineSchemaCreator {
final static String NAME = TimelineSchemaCreator.class.getSimpleName(); final static String NAME = TimelineSchemaCreator.class.getSimpleName();
private static final Log LOG = LogFactory.getLog(TimelineSchemaCreator.class); private static final Log LOG = LogFactory.getLog(TimelineSchemaCreator.class);
private static final String SKIP_EXISTING_TABLE_OPTION_SHORT = "s"; 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_TABLE_NAME_SHORT = "a";
private static final String APP_TO_FLOW_TABLE_NAME_SHORT = "a2f"; 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 ENTITY_TABLE_NAME_SHORT = "e";
private static final String HELP_SHORT = "h"; private static final String HELP_SHORT = "h";
private static final String CREATE_TABLES_SHORT = "c"; private static final String CREATE_TABLES_SHORT = "c";
@ -87,12 +88,12 @@ public final class TimelineSchemaCreator {
if (StringUtils.isNotBlank(entityTableName)) { if (StringUtils.isNotBlank(entityTableName)) {
hbaseConf.set(EntityTable.TABLE_NAME_CONF_NAME, entityTableName); hbaseConf.set(EntityTable.TABLE_NAME_CONF_NAME, entityTableName);
} }
// Grab the TTL argument // Grab the entity metrics TTL
String entityTableTTLMetrics =commandLine.getOptionValue( String entityTableMetricsTTL = commandLine.getOptionValue(
TTL_OPTION_SHORT); ENTITY_METRICS_TTL_OPTION_SHORT);
if (StringUtils.isNotBlank(entityTableTTLMetrics)) { if (StringUtils.isNotBlank(entityTableMetricsTTL)) {
int metricsTTL = Integer.parseInt(entityTableTTLMetrics); int entityMetricsTTL = Integer.parseInt(entityTableMetricsTTL);
new EntityTable().setMetricsTTL(metricsTTL, hbaseConf); new EntityTable().setMetricsTTL(entityMetricsTTL, hbaseConf);
} }
// Grab the appToflowTableName argument // Grab the appToflowTableName argument
String appToflowTableName = commandLine.getOptionValue( String appToflowTableName = commandLine.getOptionValue(
@ -107,6 +108,13 @@ public final class TimelineSchemaCreator {
hbaseConf.set(ApplicationTable.TABLE_NAME_CONF_NAME, hbaseConf.set(ApplicationTable.TABLE_NAME_CONF_NAME,
applicationTableName); 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 // create all table schemas in hbase
final boolean skipExisting = commandLine.hasOption( final boolean skipExisting = commandLine.hasOption(
@ -145,9 +153,9 @@ public final class TimelineSchemaCreator {
o.setRequired(false); o.setRequired(false);
options.addOption(o); 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"); "TTL for metrics column family");
o.setArgName("metricsTTL"); o.setArgName("entityMetricsTTL");
o.setRequired(false); o.setRequired(false);
options.addOption(o); options.addOption(o);
@ -163,6 +171,12 @@ public final class TimelineSchemaCreator {
o.setRequired(false); o.setRequired(false);
options.addOption(o); 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 // Options without an argument
// No need to set arg name since we do not need an argument here // No need to set arg name since we do not need an argument here
o = new Option(SKIP_EXISTING_TABLE_OPTION_SHORT, "skipExistingTable", o = new Option(SKIP_EXISTING_TABLE_OPTION_SHORT, "skipExistingTable",
@ -193,12 +207,14 @@ public final class TimelineSchemaCreator {
usage.append("The Optional options for creating tables include: \n"); usage.append("The Optional options for creating tables include: \n");
usage.append("[-entityTableName <Entity Table Name>] " + usage.append("[-entityTableName <Entity Table Name>] " +
"The name of the Entity table\n"); "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"); " TTL for metrics in the Entity table\n");
usage.append("[-appToflowTableName <AppToflow Table Name>]" + usage.append("[-appToflowTableName <AppToflow Table Name>]" +
" The name of the AppToFlow table\n"); " The name of the AppToFlow table\n");
usage.append("[-applicationTableName <Application Table Name>]" + usage.append("[-applicationTableName <Application Table Name>]" +
" The name of the Application table\n"); " 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" + usage.append("[-skipExistingTable] Whether to skip existing" +
" hbase tables\n"); " hbase tables\n");
System.out.println(usage.toString()); System.out.println(usage.toString());