use of org.apache.rya.api.instance.RyaDetails.ProspectorDetails in project incubator-rya by apache.
the class RyaDetailsTest method constructor.
@Test
public void constructor() {
final RyaDetails originalDetails = RyaDetails.builder().setRyaInstanceName("test_instance").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").setUpdateStrategy(PCJUpdateStrategy.INCREMENTAL))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date()))).setRyaStreamsDetails(new RyaStreamsDetails("localhost", 5)).build();
// Create a new Builder using another RyaDetails object.
final RyaDetails.Builder builder = new RyaDetails.Builder(originalDetails);
// Show it builds the object that was passed into it.
assertEquals(originalDetails, builder.build());
}
use of org.apache.rya.api.instance.RyaDetails.ProspectorDetails in project incubator-rya by apache.
the class RyaDetailsTest method equals.
@Test
public void equals() {
final RyaDetails.Builder builder = RyaDetails.builder();
builder.setRyaInstanceName("test_instance").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").setUpdateStrategy(PCJUpdateStrategy.INCREMENTAL))).setProspectorDetails(new ProspectorDetails(Optional.of(new Date()))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.of(new Date()))).setRyaStreamsDetails(new RyaStreamsDetails("localhost", 5));
final RyaDetails details1 = builder.build();
final RyaDetails details2 = builder.build();
assertEquals(details1, details2);
}
use of org.apache.rya.api.instance.RyaDetails.ProspectorDetails in project incubator-rya by apache.
the class RyaDetailsUpdaterTest method update_concurrentUpdateEncountered.
@Test
public void update_concurrentUpdateEncountered() throws NotInitializedException, RyaDetailsRepositoryException, CouldNotApplyMutationException {
// Setup initial details and mock a repository that returns them.
final RyaDetails originalDetails = RyaDetails.builder().setRyaInstanceName("instanceName").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();
final RyaDetails otherUsersUpdate = RyaDetails.builder(originalDetails).setRyaVersion("1.1.1.1").build();
// The first time get detail is called, we get the original state for the details.
// When the mutator tries to update using those, it throws an exception.
// The second iteration, the other user's state is updated.
// When the mutator tries to update again, it succeeds.
final RyaDetailsRepository detailsRepo = mock(RyaDetailsRepository.class);
when(detailsRepo.getRyaInstanceDetails()).thenReturn(originalDetails).thenReturn(otherUsersUpdate);
doThrow(ConcurrentUpdateException.class).when(detailsRepo).update(eq(originalDetails), any(RyaDetails.class));
// Run the test.
new RyaDetailsUpdater(detailsRepo).update(new RyaDetailsMutator() {
@Override
public RyaDetails mutate(final RyaDetails old) {
return RyaDetails.builder(old).setTemporalIndexDetails(new TemporalIndexDetails(false)).build();
}
});
// Verify the intended mutation eventually gets committed.
final RyaDetails finalDetails = RyaDetails.builder(originalDetails).setRyaVersion("1.1.1.1").setTemporalIndexDetails(new TemporalIndexDetails(false)).build();
verify(detailsRepo, times(1)).update(eq(otherUsersUpdate), eq(finalDetails));
}
use of org.apache.rya.api.instance.RyaDetails.ProspectorDetails in project incubator-rya by apache.
the class AccumuloRyaDetailsRepositoryIT method update_outOfDate.
@Test(expected = ConcurrentUpdateException.class)
public void update_outOfDate() throws AccumuloException, AccumuloSecurityException, AlreadyInitializedException, RyaDetailsRepositoryException {
final String instanceName = getRyaInstanceName();
// 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 mini instance of Accumulo.
final Connector connector = getClusterInstance().getConnector();
final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
// 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();
// Try to execute the update where the old state is not the currently stored state.
repo.update(updated, updated);
}
use of org.apache.rya.api.instance.RyaDetails.ProspectorDetails in project incubator-rya by apache.
the class AccumuloRyaDetailsRepositoryIT method initialize_alreadyInitialized.
@Test(expected = AlreadyInitializedException.class)
public void initialize_alreadyInitialized() throws AlreadyInitializedException, RyaDetailsRepositoryException, AccumuloException, AccumuloSecurityException {
final String instanceName = getRyaInstanceName();
// 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 mini instance of Accumulo.
final Connector connector = getClusterInstance().getConnector();
final RyaDetailsRepository repo = new AccumuloRyaInstanceDetailsRepository(connector, instanceName);
// Initialize the repository
repo.initialize(details);
// Initialize it again.
repo.initialize(details);
}
Aggregations