Search in sources :

Example 21 with RyaDetailsRepository

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();
}
Also used : RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) Test(org.junit.Test)

Example 22 with RyaDetailsRepository

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);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 23 with RyaDetailsRepository

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;
}
Also used : TableLayoutStrategy(org.apache.rya.api.layout.TableLayoutStrategy) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) ArrayList(java.util.ArrayList) RyaDetails(org.apache.rya.api.instance.RyaDetails) PcjTableNameFactory(org.apache.rya.indexing.pcj.storage.accumulo.PcjTableNameFactory) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TablePrefixLayoutStrategy(org.apache.rya.api.layout.TablePrefixLayoutStrategy) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository)

Example 24 with RyaDetailsRepository

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);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) NotInitializedException(org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException) PCJDoesNotExistException(org.apache.rya.api.client.PCJDoesNotExistException) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) MongoRyaInstanceDetailsRepository(org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException)

Example 25 with RyaDetailsRepository

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;
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) MongoRyaInstanceDetailsRepository(org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) PCJIndexDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)

Aggregations

RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)31 RyaDetails (org.apache.rya.api.instance.RyaDetails)22 Date (java.util.Date)16 Test (org.junit.Test)16 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)15 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)15 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)15 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)15 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)15 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)11 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)10 Connector (org.apache.accumulo.core.client.Connector)9 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)9 RyaClientException (org.apache.rya.api.client.RyaClientException)7 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)6 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)5 MongoRyaInstanceDetailsRepository (org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository)5 NotInitializedException (org.apache.rya.api.instance.RyaDetailsRepository.NotInitializedException)4 RyaDetailsUpdater (org.apache.rya.api.instance.RyaDetailsUpdater)4 CouldNotApplyMutationException (org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException)4