Search in sources :

Example 11 with RyaDetailsRepository

use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.

the class AccumuloBatchUpdatePCJ method updatePCJMetadata.

private void updatePCJMetadata(final String ryaInstanceName, final String pcjId) throws RyaClientException {
    // Update the PCJ's metadata to indicate it was just batch updated.
    try {
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(super.getConnector(), ryaInstanceName);
        new RyaDetailsUpdater(detailsRepo).update(new RyaDetailsMutator() {

            @Override
            public RyaDetails mutate(final RyaDetails originalDetails) throws CouldNotApplyMutationException {
                // Update the original PCJ Details to indicate they were batch updated.
                final PCJDetails originalPCJDetails = originalDetails.getPCJIndexDetails().getPCJDetails().get(pcjId);
                final PCJDetails.Builder mutatedPCJDetails = PCJDetails.builder(originalPCJDetails).setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date());
                // Replace the old PCJ Details with the updated ones.
                final RyaDetails.Builder builder = RyaDetails.builder(originalDetails);
                builder.getPCJIndexDetails().addPCJDetails(mutatedPCJDetails);
                return builder.build();
            }
        });
    } catch (final RyaDetailsRepositoryException | CouldNotApplyMutationException e) {
        throw new RyaClientException("Could not update the PCJ's metadata.", e);
    }
}
Also used : RyaClientException(org.apache.rya.api.client.RyaClientException) RyaDetailsUpdater(org.apache.rya.api.instance.RyaDetailsUpdater) RyaDetailsMutator(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator) CouldNotApplyMutationException(org.apache.rya.api.instance.RyaDetailsUpdater.RyaDetailsMutator.CouldNotApplyMutationException) RyaDetails(org.apache.rya.api.instance.RyaDetails) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) Date(java.util.Date) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)

Example 12 with RyaDetailsRepository

use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.

the class AccumuloPcjStorageIT method createPCJ.

@Test
public void createPCJ() throws AccumuloException, AccumuloSecurityException, PCJStorageException, NotInitializedException, RyaDetailsRepositoryException {
    // Setup the PCJ storage that will be tested against.
    final Connector connector = super.getClusterInstance().getConnector();
    final String ryaInstanceName = super.getRyaInstanceName();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) {
        // Create a PCJ.
        final String pcjId = pcjStorage.createPcj("SELECT * WHERE { ?a <http://isA> ?b } ");
        // Ensure the Rya details have been updated to include the PCJ's ID.
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(connector, ryaInstanceName);
        final ImmutableMap<String, PCJDetails> detailsMap = detailsRepo.getRyaInstanceDetails().getPCJIndexDetails().getPCJDetails();
        final PCJDetails expectedDetails = PCJDetails.builder().setId(pcjId).build();
        assertEquals(expectedDetails, detailsMap.get(pcjId));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) Test(org.junit.Test)

Example 13 with RyaDetailsRepository

use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.

the class AccumuloPcjStorageIT method dropPCJ.

@Test
public void dropPCJ() throws AccumuloException, AccumuloSecurityException, PCJStorageException, NotInitializedException, RyaDetailsRepositoryException {
    // Setup the PCJ storage that will be tested against.
    final Connector connector = super.getClusterInstance().getConnector();
    final String ryaInstanceName = super.getRyaInstanceName();
    try (final PrecomputedJoinStorage pcjStorage = new AccumuloPcjStorage(connector, ryaInstanceName)) {
        // Create a PCJ.
        final String pcjId = pcjStorage.createPcj("SELECT * WHERE { ?a <http://isA> ?b } ");
        // Delete the PCJ that was just created.
        pcjStorage.dropPcj(pcjId);
        // Ensure the Rya details have been updated to no longer include the PCJ's ID.
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(connector, ryaInstanceName);
        final ImmutableMap<String, PCJDetails> detailsMap = detailsRepo.getRyaInstanceDetails().getPCJIndexDetails().getPCJDetails();
        assertFalse(detailsMap.containsKey(pcjId));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloPcjStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPcjStorage) PrecomputedJoinStorage(org.apache.rya.indexing.pcj.storage.PrecomputedJoinStorage) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails) Test(org.junit.Test)

Example 14 with RyaDetailsRepository

use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.

the class AccumuloRyaDetailsRepositoryIT method getRyaInstance_notInitialized.

@Test(expected = NotInitializedException.class)
public void getRyaInstance_notInitialized() throws AccumuloException, AccumuloSecurityException, NotInitializedException, RyaDetailsRepositoryException {
    // Setup the repository that will be tested using a mini instance of Accumulo.
    final Connector connector = getClusterInstance().getConnector();
    final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, getRyaInstanceName());
    // Try to fetch the details from the uninitialized repository.
    repo.getRyaInstanceDetails();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) Test(org.junit.Test)

Example 15 with RyaDetailsRepository

use of org.apache.rya.api.instance.RyaDetailsRepository in project incubator-rya by apache.

the class AccumuloRyaDetailsRepositoryIT method isInitialized_false.

@Test
public void isInitialized_false() throws AccumuloException, AccumuloSecurityException, RyaDetailsRepositoryException {
    // Setup the repository that will be tested using a mock instance of Accumulo.
    final Connector connector = getClusterInstance().getConnector();
    final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, getRyaInstanceName());
    // Ensure the repository reports that is has not been initialized.
    assertFalse(repo.isInitialized());
}
Also used : Connector(org.apache.accumulo.core.client.Connector) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) Test(org.junit.Test)

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