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