Search in sources :

Example 1 with GetInstanceDetails

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

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

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

the class RyaStreamsCommandsTest method printRyaStreamsDetails_noRyaDetails.

@Test
public void printRyaStreamsDetails_noRyaDetails() 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 are not found.
    when(getDetails.getDetails(eq("unitTest"))).thenReturn(Optional.absent());
    // 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 does not have any Rya Details, so it is unable to be connected to the 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) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 4 with GetInstanceDetails

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

the class MongoGetInstanceDetailsIT method getDetails.

@Test
public void getDetails() throws MongoException, RyaClientException {
    final String instanceName = "instance";
    // Install an instance of Rya.
    final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).build();
    final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
    final Install install = ryaClient.getInstall();
    install.install(instanceName, installConfig);
    // Verify the correct details were persisted.
    final GetInstanceDetails getInstanceDetails = ryaClient.getGetInstanceDetails();
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(instanceName);
    final RyaDetails expectedDetails = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion(details.get().getRyaVersion()).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
    assertEquals(expectedDetails, details.get());
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) Install(org.apache.rya.api.client.Install) Test(org.junit.Test)

Example 5 with GetInstanceDetails

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

the class MongoGetInstanceDetailsIT method getDetails_instanceDoesNotHaveDetails.

@Test
public void getDetails_instanceDoesNotHaveDetails() throws MongoException, TableExistsException, RyaClientException {
    // Mimic a pre-details rya install.
    final String instanceName = "instance_name";
    getMongoClient().getDatabase(instanceName).createCollection("rya_triples");
    // Verify that the operation returns empty.
    final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
    final GetInstanceDetails getInstanceDetails = ryaClient.getGetInstanceDetails();
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(instanceName);
    assertFalse(details.isPresent());
}
Also used : 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)

Aggregations

GetInstanceDetails (org.apache.rya.api.client.GetInstanceDetails)12 Test (org.junit.Test)10 RyaDetails (org.apache.rya.api.instance.RyaDetails)9 RyaClient (org.apache.rya.api.client.RyaClient)7 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)4 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)4 Date (java.util.Date)3 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)3 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)3 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)3 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)3 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)3 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)3 Install (org.apache.rya.api.client.Install)2 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)2 RyaClientException (org.apache.rya.api.client.RyaClientException)2 ShellState (org.apache.rya.shell.SharedShellState.ShellState)2 CliAvailabilityIndicator (org.springframework.shell.core.annotation.CliAvailabilityIndicator)2 TableOperations (org.apache.accumulo.core.client.admin.TableOperations)1 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)1