Search in sources :

Example 16 with InstanceDoesNotExistException

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

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

the class RyaAdminCommands method printInstanceDetails.

@CliCommand(value = PRINT_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.")
public String printInstanceDetails() {
    // 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 {
        final Optional<RyaDetails> details = commands.getGetInstanceDetails().getDetails(ryaInstance);
        if (details.isPresent()) {
            return new RyaDetailsFormatter().format(shellState.getStorageType().get(), details.get());
        } else {
            return "This instance of Rya does not have a Rya Details table. Consider migrating to a newer version of Rya.";
        }
    } 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("Could not get the instance details. Reason: " + e.getMessage(), e);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) ShellState(org.apache.rya.shell.SharedShellState.ShellState) RyaDetailsFormatter(org.apache.rya.shell.util.RyaDetailsFormatter) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 18 with InstanceDoesNotExistException

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

the class RyaAdminCommands method addUser.

@CliCommand(value = ADD_USER_CMD, help = "Adds an authorized user to the Rya instance.")
public void addUser(@CliOption(key = { "username" }, mandatory = true, help = "The username of the user that will be granted access.") 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.getAddUser().get().addUser(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 granted. 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 19 with InstanceDoesNotExistException

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

the class AccumuloListIncrementalQueries method listIncrementalQueries.

@Override
public String listIncrementalQueries(String instanceName) throws RyaClientException {
    requireNonNull(instanceName);
    final Optional<RyaDetails> ryaDetailsHolder = getInstanceDetails.getDetails(instanceName);
    final boolean ryaInstanceExists = ryaDetailsHolder.isPresent();
    if (!ryaInstanceExists) {
        throw new InstanceDoesNotExistException(String.format("The '%s' instance of Rya does not exist.", instanceName));
    }
    final PCJIndexDetails pcjIndexDetails = ryaDetailsHolder.get().getPCJIndexDetails();
    final boolean pcjIndexingEnabeld = pcjIndexDetails.isEnabled();
    if (!pcjIndexingEnabeld) {
        throw new RyaClientException(String.format("The '%s' instance of Rya does not have PCJ Indexing enabled.", instanceName));
    }
    // If a Fluo application is being used, task it with updating the PCJ.
    final Optional<FluoDetails> fluoDetailsHolder = pcjIndexDetails.getFluoDetails();
    if (fluoDetailsHolder.isPresent()) {
        final String fluoAppName = fluoDetailsHolder.get().getUpdateAppName();
        try {
            return getFluoQueryString(instanceName, fluoAppName);
        } catch (Exception e) {
            throw new RyaClientException("Problem while creating Fluo Query Strings.", e);
        }
    } else {
        throw new RyaClientException(String.format("The '%s' instance of Rya does not have Fluo incremental updating enabled.", instanceName));
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetails(org.apache.rya.api.instance.RyaDetails) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) RyaClientException(org.apache.rya.api.client.RyaClientException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Example 20 with InstanceDoesNotExistException

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

the class MongoDeletePCJ method deletePCJ.

@Override
public void deletePCJ(final String ryaInstanceName, final String pcjId) throws InstanceDoesNotExistException, RyaClientException {
    requireNonNull(ryaInstanceName);
    requireNonNull(pcjId);
    // Ensure the Rya Instance exists.
    if (!instanceExists.exists(ryaInstanceName)) {
        throw new InstanceDoesNotExistException(String.format("There is no Rya instance named '%s'.", ryaInstanceName));
    }
    try (final MongoPcjStorage pcjStore = new MongoPcjStorage(mongoClient, ryaInstanceName)) {
        pcjStore.dropPcj(pcjId);
    } catch (final PCJStorageException e) {
        throw new RyaClientException("Unable to drop PCJ : " + pcjId, e);
    }
}
Also used : MongoPcjStorage(org.apache.rya.indexing.pcj.storage.mongo.MongoPcjStorage) RyaClientException(org.apache.rya.api.client.RyaClientException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) PCJStorageException(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage.PCJStorageException)

Aggregations

InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)27 RyaClientException (org.apache.rya.api.client.RyaClientException)27 RyaClient (org.apache.rya.api.client.RyaClient)9 ShellState (org.apache.rya.shell.SharedShellState.ShellState)9 CliCommand (org.springframework.shell.core.annotation.CliCommand)9 RyaDetails (org.apache.rya.api.instance.RyaDetails)8 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)8 RepositoryException (org.openrdf.repository.RepositoryException)8 SailException (org.openrdf.sail.SailException)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)6 InferenceEngineException (org.apache.rya.rdftriplestore.inference.InferenceEngineException)6 SailRepository (org.openrdf.repository.sail.SailRepository)6 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)6 Sail (org.openrdf.sail.Sail)6 IOException (java.io.IOException)5 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)5 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)5 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)5