use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class DemoDriver method setupRya.
/**
* Format a Mini Accumulo to be a Rya repository.
*
* @param accumulo - The Mini Accumulo cluster Rya will sit on top of. (not null)
* @return The Rya repository sitting on top of the Mini Accumulo.
*/
private static RyaSailRepository setupRya(final MiniAccumuloCluster accumulo) throws AccumuloException, AccumuloSecurityException, RepositoryException, AlreadyInitializedException, RyaDetailsRepositoryException {
checkNotNull(accumulo);
// Setup the Rya Repository that will be used to create Repository Connections.
final RdfCloudTripleStore ryaStore = new RdfCloudTripleStore();
final AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
crdfdao.setConnector(accumuloConn);
// Setup Rya configuration values.
final String ryaInstanceName = "demo_";
final AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix("demo_");
conf.setDisplayQueryPlan(true);
conf.setBoolean(USE_MOCK_INSTANCE, true);
conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, RYA_TABLE_PREFIX);
conf.set(CLOUDBASE_USER, "root");
conf.set(CLOUDBASE_PASSWORD, "password");
conf.set(CLOUDBASE_INSTANCE, accumulo.getInstanceName());
crdfdao.setConf(conf);
ryaStore.setRyaDAO(crdfdao);
final RyaSailRepository ryaRepo = new RyaSailRepository(ryaStore);
ryaRepo.initialize();
// Create Rya Details for the instance name.
final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(accumuloConn, ryaInstanceName);
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(ryaInstanceName).setRyaVersion("0.0.0.0").setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).build();
detailsRepo.initialize(details);
return ryaRepo;
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class RyaDetailsFormatterTest method format_mongo.
@Test
public void format_mongo() {
// This test failed if the default timezone was not EST, so now it's fixed at EST.
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
// Create the object that will be formatted.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName("test_instance").setRyaVersion("1.2.3.4").setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setProspectorDetails(new ProspectorDetails(Optional.absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.absent())).build();
final String formatted = new RyaDetailsFormatter().format(StorageType.MONGO, details);
// Verify the created object matches the expected result.
final String expected = "General Metadata:\n" + " Instance Name: test_instance\n" + " RYA Version: 1.2.3.4\n" + "Secondary Indicies:\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" + " PCJs:\n" + " No PCJs have been added yet.\n";
assertEquals(expected, formatted);
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class RyaDetailsFormatterTest method format_accumulo.
@Test
public void format_accumulo() {
// This test failed if the default timezone was not EST, so now it's fixed at EST.
TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
// Create the object that will be formatted.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName("test_instance").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();
final String formatted = new RyaDetailsFormatter().format(StorageType.ACCUMULO, details);
// Verify the created object matches the expected result.
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, formatted);
}
use of org.apache.rya.api.instance.RyaDetails 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.instance.RyaDetails 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;
}
Aggregations