Search in sources :

Example 6 with RyaDetailsRepository

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

the class MongoRyaDetailsRepositoryIT method initializeAndGet.

@Test
public void initializeAndGet() 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, instanceName);
    // Initialize the repository
    repo.initialize(details);
    // Fetch the stored details.
    final RyaDetails stored = repo.getRyaInstanceDetails();
    // Ensure the fetched object is equivalent to what was stored.
    assertEquals(details, stored);
}
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 7 with RyaDetailsRepository

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

the class MongoRyaDetailsRepositoryIT method isInitialized_true.

@Test
public void isInitialized_true() 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).setFluoDetails(new FluoDetails("test_instance_rya_pcj_updater")).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);
    // Ensure the repository reports that it has been initialized.
    assertTrue(repo.isInitialized());
}
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) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 8 with RyaDetailsRepository

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

the class MongoRyaDetailsRepositoryIT method isInitialized_false.

@Test
public void isInitialized_false() throws RyaDetailsRepositoryException {
    // Setup the repository that will be tested using a mock instance of MongoDB.
    final RyaDetailsRepository repo = new MongoRyaInstanceDetailsRepository(client, "testInstance");
    // Ensure the repository reports that is has not been initialized.
    assertFalse(repo.isInitialized());
}
Also used : RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) Test(org.junit.Test)

Example 9 with RyaDetailsRepository

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

the class MongoBatchUpdatePCJ method updatePCJMetadata.

private void updatePCJMetadata(final String ryaInstanceName, final String pcjId, final MongoClient client) throws RyaClientException {
    // Update the PCJ's metadata to indicate it was just batch updated.
    try {
        final RyaDetailsRepository detailsRepo = new MongoRyaInstanceDetailsRepository(client, 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) MongoRyaInstanceDetailsRepository(org.apache.rya.mongodb.instance.MongoRyaInstanceDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) 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 10 with RyaDetailsRepository

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

the class AccumuloBatchUpdatePCJ method verifyPCJState.

private void verifyPCJState(final String ryaInstanceName, final String pcjId) throws RyaClientException {
    try {
        // Fetch the Rya instance's details.
        final RyaDetailsRepository detailsRepo = new AccumuloRyaInstanceDetailsRepository(super.getConnector(), 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 + "'.");
        }
        // Ensure the PCJ is not already being incrementally updated.
        final PCJDetails pcjDetails = ryaDetails.getPCJIndexDetails().getPCJDetails().get(pcjId);
        final Optional<PCJUpdateStrategy> updateStrategy = pcjDetails.getUpdateStrategy();
        if (updateStrategy.isPresent() && updateStrategy.get() == PCJUpdateStrategy.INCREMENTAL) {
            throw new RyaClientException("The PCJ with id '" + pcjId + "' is already being updated incrementally.");
        }
    } 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 : PCJUpdateStrategy(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails.PCJUpdateStrategy) 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) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaDetailsRepositoryException(org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException) InstanceDoesNotExistException(org.apache.rya.api.client.InstanceDoesNotExistException) AccumuloRyaInstanceDetailsRepository(org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository) PCJDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)

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