use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class RyaAdminCommands method listFluoQueries.
@CliCommand(value = LIST_INCREMENTAL_QUERIES, help = "Lists relevant information about all SPARQL queries maintained by the Fluo application.")
public String listFluoQueries() {
// 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 {
return commands.getListIncrementalQueries().get().listIncrementalQueries(ryaInstance);
} 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 list incremental queries. Provided reasons: " + e.getMessage(), e);
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class RyaAdminCommands method install.
@CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.")
public String install() {
// Fetch the commands that are connected to the store.
final RyaClient commands = state.getShellState().getConnectedCommands().get();
String instanceName = null;
InstallConfiguration installConfig = null;
try {
boolean verified = false;
while (!verified) {
// Use the install prompt to fetch the user's installation options.
instanceName = installPrompt.promptInstanceName();
installConfig = installPrompt.promptInstallConfiguration(instanceName);
// Verify the configuration is what the user actually wants to do.
verified = installPrompt.promptVerified(instanceName, installConfig);
}
// 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);
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class RyaAdminCommands method deletePcj.
@CliCommand(value = DELETE_PCJ_CMD, help = "Deletes and halts maintenance of a PCJ.")
public String deletePcj(@CliOption(key = { "pcjId" }, mandatory = true, help = "The ID of the PCJ that will be deleted.") final String pcjId) {
// 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 {
// Execute the command.
commands.getDeletePCJ().deletePCJ(ryaInstance, pcjId);
return "The PCJ has been deleted.";
} 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 PCJ could not be deleted. Provided reason: " + e.getMessage(), e);
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class RyaAdminCommands method createPcj.
@CliCommand(value = CREATE_PCJ_CMD, help = "Creates and starts the maintenance of a new PCJ using a Fluo application.")
public String createPcj(@CliOption(key = { "exportToRya" }, mandatory = false, help = "Indicates that results for the query should be exported to a Rya PCJ table.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean exportToRya, @CliOption(key = { "exportToKafka" }, mandatory = false, help = "Indicates that results for the query should be exported to a Kafka Topic.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final boolean exportToKafka) {
// 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 Set<ExportStrategy> strategies = new HashSet<>();
if (exportToRya) {
strategies.add(ExportStrategy.RYA);
}
if (exportToKafka) {
strategies.add(ExportStrategy.KAFKA);
}
if (strategies.isEmpty()) {
return "The user must specify at least one export strategy: (--exportToRya, --exportToKafka)";
}
// Prompt the user for the SPARQL.
final Optional<String> sparql = sparqlPrompt.getSparql();
if (sparql.isPresent()) {
// Execute the command.
final String pcjId = commands.getCreatePCJ().createPCJ(ryaInstance, sparql.get(), strategies);
// Return a message that indicates the ID of the newly created ID.
return String.format("The 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 PCJ. Provided reasons: " + e.getMessage(), e);
}
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class RyaAdminCommands method deletePeriodicPcj.
@CliCommand(value = DELETE_PERIODIC_PCJ_CMD, help = "Deletes and halts maintenance of a Periodic PCJ.")
public String deletePeriodicPcj(@CliOption(key = { "pcjId" }, mandatory = true, help = "The ID of the PCJ that will be deleted.") final String pcjId, @CliOption(key = { "topic" }, mandatory = true, help = "Kafka topic for registering a delete notice to remove a PeriodicNotification from 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 {
// Execute the command.
commands.getDeletePeriodicPCJ().get().deletePeriodicPCJ(ryaInstance, pcjId, topic, brokers);
return "The Periodic PCJ has been deleted.";
} 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 Periodic PCJ could not be deleted. Provided reason: " + e.getMessage(), e);
}
}
Aggregations