Search in sources :

Example 1 with ArgumentsException

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();
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) FluoClient(org.apache.fluo.api.client.FluoClient) ArgumentsException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ArgumentsException) InputStream(java.io.InputStream) UnsupportedQueryException(org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) RepositoryException(org.openrdf.repository.RepositoryException) IOException(java.io.IOException) Properties(java.util.Properties) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ExecutionException(org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ExecutionException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 Connector (org.apache.accumulo.core.client.Connector)1 FluoClient (org.apache.fluo.api.client.FluoClient)1 UnsupportedQueryException (org.apache.rya.indexing.pcj.fluo.app.query.UnsupportedQueryException)1 ArgumentsException (org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ArgumentsException)1 ExecutionException (org.apache.rya.indexing.pcj.fluo.client.PcjAdminClientCommand.ExecutionException)1 RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)1 RepositoryException (org.openrdf.repository.RepositoryException)1