15 package com.cloudera.impala.testutil;
17 import org.apache.commons.cli.BasicParser;
18 import org.apache.commons.cli.CommandLine;
19 import org.apache.commons.cli.OptionBuilder;
20 import org.apache.commons.cli.Options;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
35 private final static Logger
LOG =
36 LoggerFactory.getLogger(SentryServicePinger.class);
39 @SuppressWarnings(
"static-access")
40 public static
void main(String[] args) throws Exception {
42 Options options =
new Options();
43 options.addOption(OptionBuilder.withLongOpt(
"config_file")
44 .withDescription(
"Absolute path to a sentry-site.xml config file (string)")
46 .withArgName(
"CONFIG_FILE")
49 options.addOption(OptionBuilder.withLongOpt(
"num_pings")
50 .withDescription(
"Max number of pings to try before failing (int)")
53 .withArgName(
"NUM_PINGS")
55 options.addOption(OptionBuilder.withLongOpt(
"sleep_secs")
56 .withDescription(
"Time (s) to sleep between pings (int)")
58 .withArgName(
"SLEEP_SECS")
60 BasicParser optionParser =
new BasicParser();
61 CommandLine cmdArgs = optionParser.parse(options, args);
64 int numPings = Integer.parseInt(cmdArgs.getOptionValue(
"num_pings"));
65 int maxPings = numPings;
66 int sleepSecs = Integer.parseInt(cmdArgs.getOptionValue(
"sleep_secs"));
68 sentryConfig.loadConfig();
69 while (numPings > 0) {
72 policyService.listAllRoles(
new User(System.getProperty(
"user.name")));
73 LOG.info(
"Sentry Service ping succeeded.");
75 }
catch (Exception e) {
76 LOG.error(String.format(
"Error issing RPC to Sentry Service (attempt %d/%d): ",
77 maxPings - numPings + 1, maxPings), e);
78 Thread.sleep(sleepSecs * 1000);
static void main(String[] args)