use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class MongoDetailsAdapterTest method absentOptionalToRyaDetailsTest.
@Test
public void absentOptionalToRyaDetailsTest() throws MalformedRyaDetailsException {
// Convert the Mongo object into a RyaDetails.
final BasicDBObject mongo = (BasicDBObject) JSON.parse("{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + // RYA-215 + "geoDetails : false,"
"pcjDetails : {" + "enabled : false," + "pcjs : [ " + "{" + "id : \"pcj_1\"," + "}" + "]" + "}," + "temporalDetails : false," + "freeTextDetails : true," + "prospectorDetails : null," + "joinSelectivitiyDetails : null" + "}");
final RyaDetails actual = MongoDetailsAdapter.toRyaDetails(mongo);
// Ensure it matches the expected object.
final RyaDetails expected = RyaDetails.builder().setRyaInstanceName("test").setRyaVersion("1").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(false)).setTemporalIndexDetails(new TemporalIndexDetails(false)).setFreeTextDetails(new FreeTextIndexDetails(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
assertEquals(expected, actual);
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class MongoDetailsAdapterTest method mongoToRyaDetailsTest.
@Test
public void mongoToRyaDetailsTest() throws MalformedRyaDetailsException {
// Convert the Mongo object into a RyaDetails.
final BasicDBObject mongo = (BasicDBObject) JSON.parse("{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + // RYA-215 + "geoDetails : true,"
"pcjDetails : {" + "enabled : true ," + "fluoName : \"fluo\"," + "pcjs : [ " + "{" + "id : \"pcj_0\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.000Z\"}" + "}," + "{" + "id : \"pcj_1\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.001Z\"}" + "}]" + "}," + "temporalDetails : true," + "freeTextDetails : true," + "prospectorDetails : { $date : \"1970-01-01T00:00:00.000Z\"}," + "joinSelectivitiyDetails : { $date : \"1970-01-01T00:00:00.001Z\"}," + "ryaStreamsDetails : { hostname : \"localhost\" , port : 6}" + "}");
final RyaDetails actual = MongoDetailsAdapter.toRyaDetails(mongo);
// Ensure it matches the expected object.
final RyaDetails expected = RyaDetails.builder().setRyaInstanceName("test").setRyaVersion("1").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).addPCJDetails(PCJDetails.builder().setId("pcj_0").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(0L))).addPCJDetails(PCJDetails.builder().setId("pcj_1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(1L)))).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>fromNullable(new Date(0L)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>fromNullable(new Date(1L)))).setRyaStreamsDetails(new RyaStreamsDetails("localhost", 6)).build();
assertEquals(expected, actual);
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class MongoDetailsAdapterTest method ryaDetailsToMongoTest.
@Test
public void ryaDetailsToMongoTest() {
// Convert the Details into a Mongo DB OBject.
final RyaDetails details = RyaDetails.builder().setRyaInstanceName("test").setRyaVersion("1").setEntityCentricIndexDetails(new EntityCentricIndexDetails(true)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true).setFluoDetails(new FluoDetails("fluo")).addPCJDetails(PCJDetails.builder().setId("pcj_0").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(0L))).addPCJDetails(PCJDetails.builder().setId("pcj_1").setUpdateStrategy(PCJUpdateStrategy.BATCH).setLastUpdateTime(new Date(1L)))).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setProspectorDetails(new ProspectorDetails(Optional.fromNullable(new Date(0L)))).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.fromNullable(new Date(1L)))).setRyaStreamsDetails(new RyaStreamsDetails("localhost", 6)).build();
final BasicDBObject actual = MongoDetailsAdapter.toDBObject(details);
// Ensure it matches the expected object.
final DBObject expected = (DBObject) JSON.parse("{ " + "instanceName : \"test\"," + "version : \"1\"," + "entityCentricDetails : true," + // RYA-215 + "geoDetails : true,"
"pcjDetails : {" + "enabled : true ," + "pcjs : [ " + "{" + "id : \"pcj_0\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.000Z\"}" + "}," + "{" + "id : \"pcj_1\"," + "updateStrategy : \"BATCH\"," + "lastUpdate : { $date : \"1970-01-01T00:00:00.001Z\"}" + "}]" + "}," + "temporalDetails : true," + "freeTextDetails : true," + "prospectorDetails : { $date : \"1970-01-01T00:00:00.000Z\"}," + "joinSelectivitiyDetails : { $date : \"1970-01-01T00:00:00.001Z\"}," + "ryaStreamsDetails : { hostname : \"localhost\" , port : 6}" + "}");
assertEquals(expected.toString(), actual.toString());
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class RyaDetailsSerializer method deserialize.
/**
* Deserializes an instance of {@link RyaDetails}.
*
* @param bytes - The serialized for of a {@link RyaDetails}. (not null)
* @return The deserialized object.
*/
public RyaDetails deserialize(final byte[] bytes) throws SerializationException {
requireNonNull(bytes);
try (//
final ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
final ValidatingObjectInputStream vois = new ValidatingObjectInputStream(stream)) // // this is how you find classes that you missed in the accept list
// { @Override protected void invalidClassNameFound(String className) throws java.io.InvalidClassException {
// System.out.println("vois.accept(" + className + ".class, ");};};
{
vois.accept(RyaDetails.class, //
com.google.common.base.Optional.class, //
java.util.Date.class, java.lang.Enum.class);
//
vois.accept(//
"com.google.common.base.Present", //
"com.google.common.base.Absent", //
"com.google.common.collect.ImmutableMap$SerializedForm", //
"com.google.common.collect.ImmutableBiMap$SerializedForm", //
"com.google.common.collect.ImmutableList$SerializedForm", "[Ljava.lang.Object;");
vois.accept(Pattern.compile("org\\.apache\\.rya\\.api\\.instance\\.RyaDetails.*"));
final Object o = vois.readObject();
if (!(o instanceof RyaDetails)) {
throw new SerializationException("Wrong type of object was deserialized. Class: " + o.getClass().getName());
}
return (RyaDetails) o;
} catch (final ClassNotFoundException | IOException e) {
throw new SerializationException("Could not deserialize an instance of RyaDetails.", e);
}
}
use of org.apache.rya.api.instance.RyaDetails in project incubator-rya by apache.
the class AccumuloRyaDetailsRepositoryIT method update.
@Test
public void update() 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);
// 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);
}
Aggregations