Search in sources :

Example 51 with RyaDetails

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);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) BasicDBObject(com.mongodb.BasicDBObject) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 52 with RyaDetails

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);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) BasicDBObject(com.mongodb.BasicDBObject) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 53 with RyaDetails

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());
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) BasicDBObject(com.mongodb.BasicDBObject) RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Test(org.junit.Test)

Example 54 with RyaDetails

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ValidatingObjectInputStream(org.apache.commons.io.serialization.ValidatingObjectInputStream) RyaDetails(org.apache.rya.api.instance.RyaDetails) IOException(java.io.IOException)

Example 55 with RyaDetails

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);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) Connector(org.apache.accumulo.core.client.Connector) RyaDetails(org.apache.rya.api.instance.RyaDetails) Date(java.util.Date) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) 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) FluoDetails(org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails) Test(org.junit.Test)

Aggregations

RyaDetails (org.apache.rya.api.instance.RyaDetails)57 Test (org.junit.Test)30 Date (java.util.Date)25 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)25 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)25 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)25 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)25 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)25 RyaDetailsRepository (org.apache.rya.api.instance.RyaDetailsRepository)21 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)18 RyaClientException (org.apache.rya.api.client.RyaClientException)17 RyaClient (org.apache.rya.api.client.RyaClient)14 RyaDetailsRepositoryException (org.apache.rya.api.instance.RyaDetailsRepository.RyaDetailsRepositoryException)10 AccumuloRyaInstanceDetailsRepository (org.apache.rya.accumulo.instance.AccumuloRyaInstanceDetailsRepository)9 GetInstanceDetails (org.apache.rya.api.client.GetInstanceDetails)9 PCJIndexDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails)9 InstanceDoesNotExistException (org.apache.rya.api.client.InstanceDoesNotExistException)8 PCJDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.PCJDetails)8 RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)6 BasicDBObject (com.mongodb.BasicDBObject)5