Search in sources :

Example 26 with RyaClientException

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

the class RyaAdminCommands method removeUser.

@CliCommand(value = REMOVE_USER_CMD, help = "Removes an authorized user from the Rya instance.")
public void removeUser(@CliOption(key = { "username" }, mandatory = true, help = "The username of the user whose access will be revoked.") final String username) {
    // Fetch the Rya client that is connected to the store.
    final ShellState shellState = state.getShellState();
    final RyaClient ryaClient = shellState.getConnectedCommands().get();
    final String ryaInstance = shellState.getRyaInstanceName().get();
    try {
        ryaClient.getRemoveUser().get().removeUser(ryaInstance, username);
    } catch (final InstanceDoesNotExistException e) {
        throw new RuntimeException(String.format("A Rya instance named '%s' does not exist.", ryaInstance), e);
    } catch (final RyaClientException e) {
        throw new RuntimeException("The user's access could not be revoked. Provided reason: " + 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) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 27 with RyaClientException

use of org.apache.rya.api.client.RyaClientException 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 28 with RyaClientException

use of org.apache.rya.api.client.RyaClientException 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 29 with RyaClientException

use of org.apache.rya.api.client.RyaClientException 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 30 with RyaClientException

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

the class RyaAdminCommands method arePCJCommandsAvailable.

/**
 * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
 */
@CliAvailabilityIndicator({ CREATE_PCJ_CMD, DELETE_PCJ_CMD })
public boolean arePCJCommandsAvailable() {
    // The PCJ commands are only available if the Shell is connected to an instance of Rya
    // that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
    final ShellState shellState = state.getShellState();
    if (shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE) {
        final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
        final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
        try {
            final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails(ryaInstanceName);
            if (instanceDetails.isPresent()) {
                return instanceDetails.get().getPCJIndexDetails().isEnabled();
            }
        } catch (final RyaClientException e) {
            return false;
        }
    }
    return false;
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) ShellState(org.apache.rya.shell.SharedShellState.ShellState) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) CliAvailabilityIndicator(org.springframework.shell.core.annotation.CliAvailabilityIndicator)

Aggregations

RyaClientException (org.apache.rya.api.client.RyaClientException)48 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)27 RyaClient (org.apache.rya.api.client.RyaClient)18 CliCommand (org.springframework.shell.core.annotation.CliCommand)18 RyaDetails (org.apache.rya.api.instance.RyaDetails)17 ShellState (org.apache.rya.shell.SharedShellState.ShellState)14 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)13 SailException (org.openrdf.sail.SailException)13 AccumuloException (org.apache.accumulo.core.client.AccumuloException)12 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)12 IOException (java.io.IOException)11 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)11 Sail (org.openrdf.sail.Sail)10 PCJStorageException (org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)9 RepositoryException (org.openrdf.repository.RepositoryException)9 InferenceEngineException (org.apache.rya.rdftriplestore.inference.InferenceEngineException)8 MalformedQueryException (org.openrdf.query.MalformedQueryException)8 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)7 SailRepository (org.openrdf.repository.sail.SailRepository)7 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)7