Search in sources :

Example 6 with GetInstanceDetails

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

the class AccumuloGetInstanceDetailsIT method getDetails_instanceDoesNotHaveDetails.

@Test
public void getDetails_instanceDoesNotHaveDetails() throws AccumuloException, AccumuloSecurityException, InstanceDoesNotExistException, RyaClientException, TableExistsException {
    // Mimic a pre-details rya install.
    final TableOperations tableOps = getConnector().tableOperations();
    final String spoTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
    final String ospTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
    final String poTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
    tableOps.create(spoTableName);
    tableOps.create(ospTableName);
    tableOps.create(poTableName);
    // Verify that the operation returns empty.
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final GetInstanceDetails getInstanceDetails = new AccumuloGetInstanceDetails(connectionDetails, getConnector());
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(getRyaInstanceName());
    assertFalse(details.isPresent());
}
Also used : TableOperations(org.apache.accumulo.core.client.admin.TableOperations) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) Test(org.junit.Test)

Example 7 with GetInstanceDetails

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

the class AccumuloGetInstanceDetailsIT method getDetails_instanceDoesNotExist.

@Test(expected = InstanceDoesNotExistException.class)
public void getDetails_instanceDoesNotExist() throws AccumuloException, AccumuloSecurityException, InstanceDoesNotExistException, RyaClientException {
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final GetInstanceDetails getInstanceDetails = new AccumuloGetInstanceDetails(connectionDetails, getConnector());
    getInstanceDetails.getDetails("instance_name_does_not_exist");
}
Also used : GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) Test(org.junit.Test)

Example 8 with GetInstanceDetails

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

the class RyaStreamsCommandsTest method printRyaStreamsDetails_configured.

@Test
public void printRyaStreamsDetails_configured() 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 have RyaStreamsDetails to print.
    final RyaDetails details = mock(RyaDetails.class);
    when(details.getRyaStreamsDetails()).thenReturn(Optional.of(new RyaStreamsDetails("localhost", 6)));
    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 = "Kafka Hostname: localhost, Kafka Port: 6";
    assertEquals(expected, message);
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) 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 9 with GetInstanceDetails

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

the class RyaAdminCommands method arePCJCommandsAvailable.

/**
 * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
 */
@CliAvailabilityIndicator({ CREATE_PCJ_CMD, DELETE_PCJ_CMD })
public boolean arePCJCommandsAvailable() {
    // 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) {
        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 10 with GetInstanceDetails

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

the class RyaAdminCommandsTest method getInstanceDetails.

@Test
public void getInstanceDetails() throws InstanceDoesNotExistException, RyaClientException {
    // This test is failed if the default timezone was not EST, so now it's fixed at EST.
    // If you get assert mismatch of EST!=EDT, try the deprecated getTimeZone("EST") instead.
    TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
    // Mock the object that performs the get operation.
    final GetInstanceDetails mockGetInstanceDetails = mock(GetInstanceDetails.class);
    final String instanceName = "test_instance";
    final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion("1.2.3.4").addUser("alice").addUser("bob").addUser("charlie").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(1252521351L))).addPCJDetails(PCJDetails.builder().setId("pcj 2").setUpdateStrategy(PCJUpdateStrategy.INCREMENTAL))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date(12525211L)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date(125221351L)))).build();
    when(mockGetInstanceDetails.getDetails(eq(instanceName))).thenReturn(Optional.of(details));
    final RyaClient mockCommands = mock(RyaClient.class);
    when(mockCommands.getGetInstanceDetails()).thenReturn(mockGetInstanceDetails);
    final SharedShellState state = new SharedShellState();
    state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands);
    state.connectedToInstance(instanceName);
    // Execute the command.
    final RyaAdminCommands commands = new RyaAdminCommands(state, mock(InstallPrompt.class), mock(SparqlPrompt.class), mock(UninstallPrompt.class));
    final String message = commands.printInstanceDetails();
    // Verify the values that were provided to the command were passed through to the GetInstanceDetails.
    verify(mockGetInstanceDetails).getDetails(eq(instanceName));
    // Verify a message is returned that includes the details.
    final String expected = "General Metadata:\n" + "  Instance Name: test_instance\n" + "  RYA Version: 1.2.3.4\n" + "  Users: alice, bob, charlie\n" + "Secondary Indicies:\n" + "  Entity Centric Index:\n" + "    Enabled: true\n" + // RYA-215"    Enabled: true\n" +
    "  Free Text Index:\n" + "    Enabled: true\n" + "  Temporal Index:\n" + "    Enabled: true\n" + "  PCJ Index:\n" + "    Enabled: true\n" + "    Fluo App Name: test_instance_rya_pcj_updater\n" + "    PCJs:\n" + "      ID: pcj 1\n" + "        Update Strategy: BATCH\n" + "        Last Update Time: Thu Jan 15 06:55:21 EST 1970\n" + "      ID: pcj 2\n" + "        Update Strategy: INCREMENTAL\n" + "        Last Update Time: unavailable\n" + "Statistics:\n" + "  Prospector:\n" + "    Last Update Time: Wed Dec 31 22:28:45 EST 1969\n" + "  Join Selectivity:\n" + "    Last Updated Time: Fri Jan 02 05:47:01 EST 1970\n";
    assertEquals(expected, message);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) UninstallPrompt(org.apache.rya.shell.util.UninstallPrompt) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) AccumuloConnectionDetails(org.apache.rya.api.client.accumulo.AccumuloConnectionDetails) SparqlPrompt(org.apache.rya.shell.util.SparqlPrompt) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) InstallPrompt(org.apache.rya.shell.util.InstallPrompt) 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