Search in sources :

Example 1 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class AccumuloInstall method install.

@Override
public void install(final String instanceName, final InstallConfiguration installConfig) throws DuplicateInstanceNameException, RyaClientException {
    requireNonNull(instanceName);
    requireNonNull(installConfig);
    // Check to see if a Rya instance has already been installed with this name.
    if (instanceExists.exists(instanceName)) {
        throw new DuplicateInstanceNameException("An instance of Rya has already been installed to this Rya storage " + "with the name '" + instanceName + "'. Try again with a different name.");
    }
    // Initialize the Rya Details table.
    RyaDetails details;
    try {
        details = initializeRyaDetails(instanceName, installConfig, getConnector().whoami());
    } catch (final AlreadyInitializedException e) {
        // This can only happen if somebody else installs an instance of Rya with the name between the check and now.
        throw new DuplicateInstanceNameException("An instance of Rya has already been installed to this Rya storage " + "with the name '" + instanceName + "'. Try again with a different name.");
    } catch (final RyaDetailsRepositoryException e) {
        throw new RyaClientException("The RyaDetails couldn't be initialized. Details: " + e.getMessage(), e);
    }
    // Initialize the rest of the tables used by the Rya instance.
    final AccumuloRdfConfiguration ryaConfig = makeRyaConfig(getAccumuloConnectionDetails(), details);
    try {
        final Sail ryaSail = RyaSailFactory.getInstance(ryaConfig);
        ryaSail.shutDown();
    } catch (final AccumuloException | AccumuloSecurityException | RyaDAOException | InferenceEngineException e) {
        throw new RyaClientException("Could not initialize all of the tables for the new Rya instance. " + "This instance may be left in a bad state.", e);
    } catch (final SailException e) {
        throw new RyaClientException("Problem shutting down the Sail object used to install Rya.", e);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetails(org.apache.rya.api.instance.RyaDetails) InferenceEngineException(org.apache.rya.rdftriplestore.inference.InferenceEngineException) SailException(org.openrdf.sail.SailException) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) AlreadyInitializedException(org.apache.rya.api.instance.RyaDetailsRepository.AlreadyInitializedException) Sail(org.openrdf.sail.Sail) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 2 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class RyaAdminCommands method arePeriodicPCJCommandsAvailable.

/**
 * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
 */
@CliAvailabilityIndicator({ CREATE_PERIODIC_PCJ_CMD, DELETE_PERIODIC_PCJ_CMD, LIST_INCREMENTAL_QUERIES })
public boolean arePeriodicPCJCommandsAvailable() {
    // 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 && shellState.getStorageType().get() == StorageType.ACCUMULO) {
        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)

Example 3 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class RyaStreamsCommands method printRyaStreamsDetails.

@CliCommand(value = STREAMS_DETAILS_CMD, help = "Print information about which Rya Streams subsystem the Rya instance is connected to.")
public String printRyaStreamsDetails() {
    final String ryaInstance = state.getShellState().getRyaInstanceName().get();
    final RyaClient client = state.getShellState().getConnectedCommands().get();
    try {
        // Handle the case where the instance does not have Rya Details.
        final Optional<RyaDetails> details = client.getGetInstanceDetails().getDetails(ryaInstance);
        if (!details.isPresent()) {
            return "This instance does not have any Rya Details, so it is unable to be connected to the Rya Streams subsystem.";
        }
        // Print a message based on if the instance is connected to Rya Streams.
        final Optional<RyaStreamsDetails> streamsDetails = details.get().getRyaStreamsDetails();
        if (!streamsDetails.isPresent()) {
            return "This instance of Rya has not been configured to use a Rya Streams subsystem.";
        }
        // Print the details about which Rya Streams subsystem is being used.
        return "Kafka Hostname: " + streamsDetails.get().getHostname() + ", Kafka Port: " + streamsDetails.get().getPort();
    } catch (final RyaClientException e) {
        throw new RuntimeException("Could not fetch the Rya Details for this Rya instance.", e);
    }
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Example 4 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class RyaStreamsCommandsTest method printRyaStreamsDetails_notConfigured.

@Test
public void printRyaStreamsDetails_notConfigured() throws Exception {
    // Mock the object that performs the configure operation.
    final RyaClient mockCommands = mock(RyaClient.class);
    final GetInstanceDetails getDetails = mock(GetInstanceDetails.class);
    when(mockCommands.getGetInstanceDetails()).thenReturn(getDetails);
    // When getting the instance details, ensure they do not have RyaStreamsDetails to print.
    final RyaDetails details = mock(RyaDetails.class);
    when(details.getRyaStreamsDetails()).thenReturn(Optional.absent());
    when(getDetails.getDetails(eq("unitTest"))).thenReturn(Optional.of(details));
    // Mock a shell state and connect it to a Rya instance.
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance("unitTest");
    // Execute the command.
    final RyaStreamsCommands commands = new RyaStreamsCommands(state, mock(SparqlPrompt.class), mock(ConsolePrinter.class));
    final String message = commands.printRyaStreamsDetails();
    final String expected = "This instance of Rya has not been configured to use a Rya Streams subsystem.";
    assertEquals(expected, message);
}
Also used : ConsolePrinter(org.apache.rya.shell.util.ConsolePrinter) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 5 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.

the class RyaConnectionCommands method connectToInstance.

@CliCommand(value = CONNECT_INSTANCE_CMD, help = "Connect to a specific Rya instance")
public void connectToInstance(@CliOption(key = { "instance" }, mandatory = true, help = "The name of the Rya instance the shell will interact with.") final String ryaInstance) {
    final RyaClient ryaClient = sharedState.getShellState().getConnectedCommands().get();
    try {
        final InstanceExists instanceExists = ryaClient.getInstanceExists();
        // Make sure the requested instance exists.
        if (!instanceExists.exists(ryaInstance)) {
            throw new RuntimeException(String.format("'%s' does not match an existing Rya instance.", ryaInstance));
        }
        // Store the instance name in the shared state.
        sharedState.connectedToInstance(ryaInstance);
        // If the Rya instance is configured to interact with Rya Streams, then connect the
        // Rya Streams client to the shared state.
        final com.google.common.base.Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(ryaInstance);
        if (ryaDetails.isPresent()) {
            final com.google.common.base.Optional<RyaStreamsDetails> streamsDetails = ryaDetails.get().getRyaStreamsDetails();
            if (streamsDetails.isPresent()) {
                final String kafkaHostname = streamsDetails.get().getHostname();
                final int kafkaPort = streamsDetails.get().getPort();
                final RyaStreamsClient streamsClient = KafkaRyaStreamsClientFactory.make(ryaInstance, kafkaHostname, kafkaPort);
                sharedState.connectedToRyaStreams(streamsClient);
            }
        }
    } catch (final RyaClientException e) {
        throw new RuntimeException("Could not connect to Rya instance. Reason: " + e.getMessage(), e);
    }
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) RyaStreamsClient(org.apache.rya.streams.api.RyaStreamsClient) InstanceExists(org.apache.rya.api.client.InstanceExists) CliCommand(org.springframework.shell.core.annotation.CliCommand)

Aggregations

RyaDetails (org.apache.rya.api.instance.RyaDetails)57 Test (org.junit.Test)30 Date (java.util.Date)25 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)25 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)25 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)25 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)25 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)25 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)21 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)18 RyaClientException (org.apache.rya.api.client.RyaClientException)17 RyaClient (org.apache.rya.api.client.RyaClient)14 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)10 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)9 GetInstanceDetails (org.apache.rya.api.client.GetInstanceDetails)9 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)9 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)8 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)8 RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)6 BasicDBObject (com.mongodb.BasicDBObject)5