use of org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ArgumentsException in project incubator-rya by apache.
the class PcjAdminClient method main.
public static void main(final String[] args) {
log.trace("Starting up the PCJ Admin Client.");
// If no command provided or the command isn't recognized, then print the usage.
if (args.length == 0 || !commands.containsKey(args[0])) {
System.out.println(usage);
System.exit(-1);
}
// Load the properties file.
final Properties props = new Properties();
try (InputStream pin = Files.newInputStream(PROPERTIES_FILE)) {
props.load(pin);
} catch (final IOException e) {
throw new RuntimeException("Could not load properties file: " + PROPERTIES_FILE, e);
}
// Fetch the command that will be executed.
final String command = args[0];
final String[] commandArgs = Arrays.copyOfRange(args, 1, args.length);
final PcjAdminClientCommand pcjCommand = commands.get(command);
RyaSailRepository rya = null;
FluoClient fluo = null;
try {
// Connect to Accumulo, Rya, and Fluo.
final PcjAdminClientProperties clientProps = new PcjAdminClientProperties(props);
final Connector accumulo = createAccumuloConnector(clientProps);
rya = makeRyaRepository(clientProps, accumulo);
fluo = createFluoClient(clientProps);
// Execute the command.
pcjCommand.execute(accumulo, clientProps.getRyaTablePrefix(), rya, fluo, commandArgs);
} catch (final AccumuloException | AccumuloSecurityException e) {
System.err.println("Could not connect to the Accumulo instance that hosts the export PCJ tables.");
e.printStackTrace();
System.exit(-1);
} catch (final RepositoryException e) {
System.err.println("Could not connect to the Rya instance that hosts the historic RDF statements.");
e.printStackTrace();
System.exit(-1);
} catch (final ArgumentsException e) {
System.err.println(pcjCommand.getUsage());
System.exit(-1);
} catch (final ExecutionException e) {
System.err.println("Could not execute the command.");
e.printStackTrace();
System.exit(-1);
} catch (UnsupportedQueryException e) {
System.err.println("Could not execute the command because the query is invalid.");
e.printStackTrace();
} finally {
log.trace("Shutting down the PCJ Admin Client.");
if (rya != null) {
try {
rya.shutDown();
} catch (final RepositoryException e) {
System.err.println("Problem while shutting down the Rya connection.");
e.printStackTrace();
}
}
if (fluo != null) {
fluo.close();
}
}
}
Aggregations