use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class MongoRyaDetailsRepositoryIT method getRyaInstance_notInitialized.
@Test(expected = NotInitializedException.class)
public void getRyaInstance_notInitialized() throws NotInitializedException, RyaDetailsRepositoryException {
// Setup the repository that will be tested using a mock instance of Accumulo.
final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
// Try to fetch the details from the uninitialized repository.
repo.getRyaInstanceDetails();
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class MongoRyaDetailsRepositoryIT method update.
@Test
public void update() throws AlreadyInitializedException, RyaDetailsRepositoryException {
final String instanceName = "testInstance";
// Create the metadata object the repository will be initialized with.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion("1.2.3.4").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).addPCJDetails(PCJDetails.builder().setId("pcj 1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date())).addPCJDetails(PCJDetails.builder().setId("pcj 2"))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date()))).build();
// Setup the repository that will be tested using a mock instance of MongoDB.
final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
// Initialize the repository
repo.initialize(details);
// Create a new state for the details.
final RyaDetails updated = new RyaDetails.Builder(details).setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).build();
// Execute the update.
repo.update(details, updated);
// Show the new state that is stored matches the updated state.
final RyaDetails fetched = repo.getRyaInstanceDetails();
assertEquals(updated, fetched);
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class RyaTableNames method getTableNames.
/**
* Get the the Accumulo table names that are used by an instance of Rya.
*
* @param ryaInstanceName - The name of the Rya instance. (not null)
* @param conn - A connector to the host Accumulo instance. (not null)
* @return The Accumulo table names that are used by the Rya instance.
* @throws NotInitializedException The instance's Rya Details have not been initialized.
* @throws RyaDetailsRepositoryException General problem with the Rya Details repository.
* @throws PCJStorageException General problem with the PCJ storage.
*/
public List<String> getTableNames(final String ryaInstanceName, final Connector conn) throws NotInitializedException, RyaDetailsRepositoryException, PCJStorageException {
// Build the list of tables that may be present within the Rya instance.
final List<String> tables = new ArrayList<>();
// Core Rya tables.
final TableLayoutStrategy coreTableNames = new TablePrefixLayoutStrategy(ryaInstanceName);
tables.add(coreTableNames.getSpo());
tables.add(coreTableNames.getPo());
tables.add(coreTableNames.getOsp());
tables.add(coreTableNames.getEval());
tables.add(coreTableNames.getNs());
tables.add(coreTableNames.getProspects());
tables.add(coreTableNames.getSelectivity());
// Rya Details table.
tables.add(AccumuloRyaInstanceDetailsRepository.makeTableName(ryaInstanceName));
// Secondary Indexer Tables.
final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(conn, ryaInstanceName);
final RyaDetails details = detailsRepo.getRyaInstanceDetails();
if (details.getEntityCentricIndexDetails().isEnabled()) {
tables.add(EntityCentricIndex.makeTableName(ryaInstanceName));
}
if (details.getFreeTextIndexDetails().isEnabled()) {
tables.addAll(AccumuloFreeTextIndexer.makeTableNames(ryaInstanceName));
}
if (details.getTemporalIndexDetails().isEnabled()) {
tables.add(AccumuloTemporalIndexer.makeTableName(ryaInstanceName));
}
if (details.getPCJIndexDetails().isEnabled()) {
try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(conn, ryaInstanceName)) {
final List<String> pcjIds = pcjStorage.listPcjs();
final PcjTableNameFactory tableNameFactory = new PcjTableNameFactory();
for (final String pcjId : pcjIds) {
tables.add(tableNameFactory.makeTableName(ryaInstanceName, pcjId));
}
}
}
// Verify they actually exist. If any don't, remove them from the list.
final TableOperations tableOps = conn.tableOperations();
final Iterator<String> tablesIt = tables.iterator();
while (tablesIt.hasNext()) {
final String table = tablesIt.next();
if (!tableOps.exists(table)) {
tablesIt.remove();
}
}
return tables;
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class MongoBatchUpdatePCJ method verifyPCJState.
private void verifyPCJState(final String ryaInstanceName, final String pcjId, final MongoClient client) throws RyaClientException {
try {
// Fetch the Rya instance's details.
final RyaDetailsRepository detailsRepo = new MongoRyaInstanceDetailsRepository(client, ryaInstanceName);
final RyaDetails ryaDetails = detailsRepo.getRyaInstanceDetails();
// Ensure PCJs are enabled.
if (!ryaDetails.getPCJIndexDetails().isEnabled()) {
throw new RyaClientException("PCJs are not enabled for the Rya instance named '" + ryaInstanceName + "'.");
}
// Ensure the PCJ exists.
if (!ryaDetails.getPCJIndexDetails().getPCJDetails().containsKey(pcjId)) {
throw new PCJDoesNotExistException("The PCJ with id '" + pcjId + "' does not exist within Rya instance '" + ryaInstanceName + "'.");
}
} catch (final NotInitializedException e) {
throw new InstanceDoesNotExistException("No RyaDetails are initialized for the Rya instance named '" + ryaInstanceName + "'.", e);
} catch (final RyaDetailsRepositoryException e) {
throw new RyaClientException("Could not fetch the RyaDetails for the Rya instance named '" + ryaInstanceName + "'.", e);
}
}
use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.
the class MongoInstall method initializeRyaDetails.
/**
* Initializes the {@link RyaDetails} and stores them for the new instance.
*
* @param instanceName - The name of the instance that is being created. (not null)
* @param installConfig - The instance's install configuration. (not null)
* @return The {@link RyaDetails} that were stored.
* @throws AlreadyInitializedException Could not be initialized because a table with this instance name has already
* exists and is holding the details.
* @throws RyaDetailsRepositoryException Something caused the initialization operation to fail.
*/
private RyaDetails initializeRyaDetails(final String instanceName, final InstallConfiguration installConfig) throws AlreadyInitializedException, RyaDetailsRepositoryException {
final RyaDetailsRepository detailsRepo = new MongoRyaInstanceDetailsRepository(adminClient, instanceName);
if (installConfig.getFluoPcjAppName().isPresent()) {
log.warn("Mongo does not have fluo support, use ignoring the configured fluo application name: " + installConfig.getFluoPcjAppName().get());
}
// Build the PCJ Index details.
final PCJIndexDetails.Builder pcjDetailsBuilder = PCJIndexDetails.builder().setEnabled(installConfig.isPcjIndexEnabled());
final RyaDetails details = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion(getVersion()).setTemporalIndexDetails(new TemporalIndexDetails(installConfig.isTemporalIndexEnabled())).setFreeTextDetails(new FreeTextIndexDetails(installConfig.isFreeTextIndexEnabled())).setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).setPCJIndexDetails(pcjDetailsBuilder).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
// Initialize the table.
detailsRepo.initialize(details);
return details;
}
Aggregations