in phoenix-queryserver-orchestrator/src/main/java/org/apache/phoenix/tool/PhoenixCanaryTool.java [295:381]
public int run(String[] args) throws Exception {
try {
Namespace cArgs = parseArgs(args);
if (cArgs == null) {
LOGGER.error("Argument parsing failed.");
throw new RuntimeException("Argument parsing failed");
}
final String hostName = cArgs.getString("hostname");
final String port = cArgs.getString("port");
final String timeout = cArgs.getString("timeout");
final String conString = cArgs.getString("constring");
final String testSchemaName = cArgs.getString("testschema");
final String testTableName = cArgs.getString("testtable");
final String logSinkClass = cArgs.getString("logsinkclass");
TEST_TABLE_NAME = testTableName;
TEST_SCHEMA_NAME = testSchemaName;
FQ_TABLE_NAME = testSchemaName + "." + testTableName;
// Check if at least one from host+port or con string is provided.
if ((hostName == null || port == null) && conString == null) {
throw new RuntimeException("Provide at least one from host+port or constring");
}
int timeoutVal = Integer.parseInt(timeout);
// Dynamically load a class for sink
sink = (Sink) ClassLoader.getSystemClassLoader().loadClass(logSinkClass).newInstance();
long startTime = System.currentTimeMillis();
String connectionURL = (conString != null) ? conString :
"jdbc:phoenix:thin:serialization=PROTOBUF;url=" + hostName + ":" + port;
appInfo.setTestName("appInfo");
appInfo.setMiscellaneous(connectionURL);
connection = getConnectionWithRetry(connectionURL);
if (connection == null) {
LOGGER.error("Failed to get connection after multiple retries; the connection is null");
}
ExecutorService executor = Executors.newFixedThreadPool(1);
Future<Void> future = executor.submit(new Callable<Void>() {
public Void call() {
sink.clearResults();
// Execute tests
LOGGER.info("Starting UpsertTableTest");
sink.updateResults(new UpsertTableTest().runTest(connection));
LOGGER.info("Starting ReadTableTest");
sink.updateResults(new ReadTableTest().runTest(connection));
return null;
}
});
try {
future.get(timeoutVal, TimeUnit.SECONDS);
} catch (InterruptedException|TimeoutException e) {
future.cancel(true);
throw e;
}
long estimatedTime = System.currentTimeMillis() - startTime;
appInfo.setExecutionTime(estimatedTime);
appInfo.setSuccessful(true);
} catch (Exception e) {
LOGGER.error("error running tests", e);
appInfo.setMessage(getStackTrace(e));
appInfo.setSuccessful(false);
} finally {
sink.updateResults(appInfo);
sink.publishResults();
connection.close();
}
return 0;
}