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