Search in sources :

Example 56 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommands method createPeriodicPcj.

@CliCommand(value = CREATE_PERIODIC_PCJ_CMD, help = "Creates and starts the maintenance of a new Periodic PCJ and registers the associated Periodic Notification with Kafka.")
public String createPeriodicPcj(@CliOption(key = { "topic" }, mandatory = true, help = "Kafka topic for registering new PeriodicNotifications.  This topic is monitored by the Periodic Notification Service.") final String topic, @CliOption(key = { "brokers" }, mandatory = true, help = "Comma delimited list of host/port pairs to establish the initial connection to the Kafka cluster.") final String brokers) {
    // Fetch the command that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient commands = shellState.getConnectedCommands().get();
    final String ryaInstance = shellState.getRyaInstanceName().get();
    try {
        // Prompt the user for the SPARQL.
        final Optional<String> sparql = sparqlPrompt.getSparql();
        if (sparql.isPresent()) {
            // Execute the command.
            final String pcjId = commands.getCreatePeriodicPCJ().get().createPeriodicPCJ(ryaInstance, sparql.get(), topic, brokers);
            // Return a message that indicates the ID of the newly created ID.
            return String.format("The Periodic PCJ has been created. Its ID is '%s'.", pcjId);
        } else {
            // user aborted the SPARQL prompt.
            return "";
        }
    } catch (final InstanceDoesNotExistException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
    } catch (final IOException | RyaClientException e) {
        throw new RuntimeException("Could not create the Periodic PCJ. Provided reasons: " + e.getMessage(), e);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) IOException(java.io.IOException) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 57 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommands method installWithAccumuloParameters.

@CliCommand(value = INSTALL_ACCUMULO_PARAMETERS_CMD, help = "Create a new Accumulo instance of Rya with command line parameters.")
public String installWithAccumuloParameters(@CliOption(key = { "instanceName" }, mandatory = true, help = "The name of the Rya instance to create.") final String instanceName, @CliOption(key = { "enableTableHashPrefix" }, mandatory = false, help = "Use Shard Balancing (improves streamed input write speeds).", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableTableHashPrefix, @CliOption(key = { "enableEntityCentricIndex" }, mandatory = false, help = "Use Entity Centric Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableEntityCentricIndex, @CliOption(key = { "enableFreeTextIndex" }, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableFreeTextIndex, @CliOption(key = { "enableTemporalIndex" }, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableTemporalIndex, @CliOption(key = { "enablePcjIndex" }, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enablePcjIndex, @CliOption(key = { "fluoPcjAppName" }, mandatory = false, help = "Fluo Application Name for PCJ Index Updater (fluo app must be initialized and enablePcjIndex=true).") final String fluoPcjAppName) {
    // Fetch the commands that are connected to the store.
    final RyaClient commands = state.getShellState().getConnectedCommands().get();
    try {
        final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(enableTableHashPrefix).setEnableEntityCentricIndex(enableEntityCentricIndex).setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).setFluoPcjAppName(fluoPcjAppName).build();
        // Verify the configuration is what the user actually wants to do.
        if (!installPrompt.promptVerified(instanceName, installConfig)) {
            return "Skipping Installation.";
        }
        // Execute the command.
        commands.getInstall().install(instanceName, installConfig);
        return String.format("The Rya instance named '%s' has been installed.", instanceName);
    } catch (final DuplicateInstanceNameException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
    } catch (final IOException | RyaClientException e) {
        throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
    }
}
Also used : DuplicateInstanceNameException(org.apache.rya.api.client.Install.DuplicateInstanceNameException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaClient(org.apache.rya.api.client.RyaClient) IOException(java.io.IOException) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 58 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommands method uninstall.

@CliCommand(value = UNINSTALL_CMD, help = "Uninstall an instance of Rya.")
public String uninstall() {
    // Fetch the command that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient commands = shellState.getConnectedCommands().get();
    final String ryaInstanceName = shellState.getRyaInstanceName().get();
    try {
        // Make sure the user meant to uninstall the Rya instance.
        if (!uninstallPrompt.promptAreYouSure(ryaInstanceName)) {
            return "Cancelled.";
        }
        // Perform the uninstall.
        commands.getUninstall().uninstall(ryaInstanceName);
    } catch (final InstanceDoesNotExistException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstanceName), e);
    } catch (final IOException | RyaClientException e) {
        throw new RuntimeException("The Rya instance could not be uninstalled. Provided reason: " + e.getMessage(), e);
    }
    return "The Rya instance named '" + ryaInstanceName + "' has been uninstalled.";
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) IOException(java.io.IOException) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 59 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommands method listInstances.

@CliCommand(value = LIST_INSTANCES_CMD, help = "List the names of the installed Rya instances.")
public String listInstances() {
    // Fetch the command that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient commands = shellState.getConnectedCommands().get();
    final Optional<String> ryaInstance = shellState.getRyaInstanceName();
    try {
        final List<String> instanceNames = commands.getListInstances().listInstances();
        // Return a special message when there are no instances installed.
        if (instanceNames.isEmpty()) {
            return "There are no Rya instances installed on this storage.";
        }
        // Sort the names alphabetically.
        Collections.sort(instanceNames);
        // Return a pretty print of the instances that have been installed.
        final String report;
        final InstanceNamesFormatter formatter = new InstanceNamesFormatter();
        if (ryaInstance.isPresent()) {
            report = formatter.format(instanceNames, ryaInstance.get());
        } else {
            report = formatter.format(instanceNames);
        }
        return report;
    } catch (final RyaClientException e) {
        throw new RuntimeException("Can not list the Rya instances. Reason: " + e.getMessage(), e);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) InstanceNamesFormatter(org.apache.rya.shell.util.InstanceNamesFormatter) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaClient(org.apache.rya.api.client.RyaClient) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 60 with RyaClient

use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.

the class RyaAdminCommands method installWithMongoParameters.

@CliCommand(value = INSTALL_MONGO_PARAMETERS_CMD, help = "Create a new MongoDB instance of Rya with command line parameters.")
public String installWithMongoParameters(@CliOption(key = { "instanceName" }, mandatory = true, help = "The name of the Rya instance to create.") final String instanceName, @CliOption(key = { "enableFreeTextIndex" }, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableFreeTextIndex, @CliOption(key = { "enableTemporalIndex" }, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enableTemporalIndex, @CliOption(key = { "enablePcjIndex" }, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean enablePcjIndex) {
    // Fetch the commands that are connected to the store.
    final RyaClient commands = state.getShellState().getConnectedCommands().get();
    try {
        final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableFreeTextIndex(enableFreeTextIndex).setEnableTemporalIndex(enableTemporalIndex).setEnablePcjIndex(enablePcjIndex).build();
        // Verify the configuration is what the user actually wants to do.
        if (!installPrompt.promptVerified(instanceName, installConfig)) {
            return "Skipping Installation.";
        }
        // Execute the command.
        commands.getInstall().install(instanceName, installConfig);
        return String.format("The Rya instance named '%s' has been installed.", instanceName);
    } catch (final DuplicateInstanceNameException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e);
    } catch (final IOException | RyaClientException e) {
        throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e);
    }
}
Also used : DuplicateInstanceNameException(org.apache.rya.api.client.Install.DuplicateInstanceNameException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaClient(org.apache.rya.api.client.RyaClient) IOException(java.io.IOException) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Aggregations

RyaClient (org.apache.rya.api.client.RyaClient)105 Test (org.junit.Test)76 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)41 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)29 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)26 CliCommand (org.springframework.shell.core.annotation.CliCommand)20 RyaClientException (org.apache.rya.api.client.RyaClientException)18 Install (org.apache.rya.api.client.Install)17 ShellState (org.apache.rya.shell.SharedShellState.ShellState)16 InstallPrompt (org.apache.rya.shell.util.InstallPrompt)16 UninstallPrompt (org.apache.rya.shell.util.UninstallPrompt)16 RyaDetails (org.apache.rya.api.instance.RyaDetails)14 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)13 IOException (java.io.IOException)11 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)9 Sail (org.openrdf.sail.Sail)9 ValueFactory (org.openrdf.model.ValueFactory)8 HashSet (java.util.HashSet)7 Connector (org.apache.accumulo.core.client.Connector)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7