use of org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails in project incubator-rya by apache.
the class MongoRyaDetailsRepositoryIT method initialize_alreadyInitialized.
@Test(expected = AlreadyInitializedException.class)
public void initialize_alreadyInitialized() 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, instanceName);
// Initialize the repository
repo.initialize(details);
// Initialize it again.
repo.initialize(details);
}
use of org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails in project incubator-rya by apache.
the class MongoRyaDetailsRepositoryIT method update_outOfDate.
@Test(expected = ConcurrentUpdateException.class)
public void update_outOfDate() 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);
// Create a new state for the details.
final RyaDetails wrongOriginal = new RyaDetails.Builder(details).setTemporalIndexDetails(new TemporalIndexDetails(false)).build();
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(wrongOriginal, updated);
}
use of org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails 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);
}
use of org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails 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());
}
use of org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails in project incubator-rya by apache.
the class MongoDetailsAdapter method toRyaDetails.
/**
* Converts a MongoDB {@link DBObject} into its {@link RyaDetails} equivalent.
*
* @param mongoObj - The MongoDB object to convert. (not null)
* @return The equivalent {@link RyaDetails} object.
* @throws MalformedRyaDetailsException The MongoDB object could not be converted.
*/
public static RyaDetails toRyaDetails(final DBObject mongoObj) throws MalformedRyaDetailsException {
requireNonNull(mongoObj);
final BasicDBObject basicObj = (BasicDBObject) mongoObj;
try {
final RyaDetails.Builder builder = RyaDetails.builder().setRyaInstanceName(basicObj.getString(INSTANCE_KEY)).setRyaVersion(basicObj.getString(VERSION_KEY)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(basicObj.getBoolean(ENTITY_DETAILS_KEY))).setPCJIndexDetails(getPCJIndexDetails(basicObj)).setTemporalIndexDetails(new TemporalIndexDetails(basicObj.getBoolean(TEMPORAL_DETAILS_KEY))).setFreeTextDetails(new FreeTextIndexDetails(basicObj.getBoolean(FREETEXT_DETAILS_KEY))).setProspectorDetails(new ProspectorDetails(Optional.<Date>fromNullable(basicObj.getDate(PROSPECTOR_DETAILS_KEY)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>fromNullable(basicObj.getDate(JOIN_SELECTIVITY_DETAILS_KEY))));
// If the Rya Streams Details are present, then add them.
if (basicObj.containsField(RYA_STREAMS_DETAILS_KEY)) {
final BasicDBObject streamsObject = (BasicDBObject) basicObj.get(RYA_STREAMS_DETAILS_KEY);
final String hostname = streamsObject.getString(RYA_STREAMS_HOSTNAME_KEY);
final int port = streamsObject.getInt(RYA_STREAMS_PORT_KEY);
builder.setRyaStreamsDetails(new RyaStreamsDetails(hostname, port));
}
return builder.build();
} catch (final Exception e) {
throw new MalformedRyaDetailsException("Failed to make RyaDetail from Mongo Object, it is malformed.", e);
}
}
Aggregations