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.";
}
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);
}
}
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);
}
}
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));
}
}
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);
}
}
Aggregations