Search in sources :

Example 6 with RyaStreamsDetails

use of org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails 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);
    }
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) JoinSelectivityDetails(org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails) Date(java.util.Date) 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)

Example 7 with RyaStreamsDetails

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

the class MongoDetailsAdapter method toDBObject.

/**
 * Converts a {@link RyaDetails} object into its MongoDB {@link DBObject} equivalent.
 *
 * @param details - The details to convert. (not null)
 * @return The MongoDB {@link DBObject} equivalent.
 */
public static BasicDBObject toDBObject(final RyaDetails details) {
    requireNonNull(details);
    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start().add(INSTANCE_KEY, details.getRyaInstanceName()).add(VERSION_KEY, details.getRyaVersion()).add(ENTITY_DETAILS_KEY, details.getEntityCentricIndexDetails().isEnabled()).add(PCJ_DETAILS_KEY, toDBObject(details.getPCJIndexDetails())).add(TEMPORAL_DETAILS_KEY, details.getTemporalIndexDetails().isEnabled()).add(FREETEXT_DETAILS_KEY, details.getFreeTextIndexDetails().isEnabled());
    if (details.getProspectorDetails().getLastUpdated().isPresent()) {
        builder.add(PROSPECTOR_DETAILS_KEY, details.getProspectorDetails().getLastUpdated().get());
    }
    if (details.getJoinSelectivityDetails().getLastUpdated().isPresent()) {
        builder.add(JOIN_SELECTIVITY_DETAILS_KEY, details.getJoinSelectivityDetails().getLastUpdated().get());
    }
    // If the Rya Streams Details are present, then add them.
    if (details.getRyaStreamsDetails().isPresent()) {
        final RyaStreamsDetails ryaStreamsDetails = details.getRyaStreamsDetails().get();
        // The embedded object that holds onto the fields.
        final DBObject ryaStreamsFields = BasicDBObjectBuilder.start().add(RYA_STREAMS_HOSTNAME_KEY, ryaStreamsDetails.getHostname()).add(RYA_STREAMS_PORT_KEY, ryaStreamsDetails.getPort()).get();
        // Add them to the main builder.
        builder.add(RYA_STREAMS_DETAILS_KEY, ryaStreamsFields);
    }
    return (BasicDBObject) builder.get();
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) BasicDBObjectBuilder(com.mongodb.BasicDBObjectBuilder) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject)

Example 8 with RyaStreamsDetails

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

the class AccumuloSetRyaStreamsConfigurationIT method updatesRyaDetails.

@Test
public void updatesRyaDetails() throws Exception {
    final String ryaInstance = getRyaInstanceName();
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
    // Install an instance of Rya.
    final Install installRya = ryaClient.getInstall();
    final InstallConfiguration installConf = InstallConfiguration.builder().build();
    installRya.install(ryaInstance, installConf);
    // Fetch its details and show they do not have any RyaStreamsDetails.
    com.google.common.base.Optional<RyaStreamsDetails> streamsDetails = ryaClient.getGetInstanceDetails().getDetails(ryaInstance).get().getRyaStreamsDetails();
    assertFalse(streamsDetails.isPresent());
    // Set the details.
    final RyaStreamsDetails details = new RyaStreamsDetails("localhost", 6);
    ryaClient.getSetRyaStreamsConfiguration().setRyaStreamsConfiguration(ryaInstance, details);
    // Fetch its details again and show that they are now filled in.
    streamsDetails = ryaClient.getGetInstanceDetails().getDetails(ryaInstance).get().getRyaStreamsDetails();
    assertEquals(details, streamsDetails.get());
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) RyaClient(org.apache.rya.api.client.RyaClient) Install(org.apache.rya.api.client.Install) InstallConfiguration(org.apache.rya.api.client.Install.InstallConfiguration) Test(org.junit.Test)

Example 9 with RyaStreamsDetails

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

the class AccumuloSetRyaStreamsConfigurationIT method instanceDoesNotExist.

@Test(expected = InstanceDoesNotExistException.class)
public void instanceDoesNotExist() throws Exception {
    final String ryaInstance = getRyaInstanceName();
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
    // Skip the install step to create error causing situation.
    final RyaStreamsDetails details = new RyaStreamsDetails("localhost", 6);
    ryaClient.getSetRyaStreamsConfiguration().setRyaStreamsConfiguration(ryaInstance, details);
}
Also used : RyaStreamsDetails(org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 10 with RyaStreamsDetails

use of org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails 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());
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) 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) 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)

Aggregations

RyaStreamsDetails (org.apache.rya.api.instance.RyaDetails.RyaStreamsDetails)16 Test (org.junit.Test)11 RyaClient (org.apache.rya.api.client.RyaClient)9 Date (java.util.Date)6 RyaDetails (org.apache.rya.api.instance.RyaDetails)6 EntityCentricIndexDetails (org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails)6 FreeTextIndexDetails (org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails)6 JoinSelectivityDetails (org.apache.rya.api.instance.RyaDetails.JoinSelectivityDetails)6 ProspectorDetails (org.apache.rya.api.instance.RyaDetails.ProspectorDetails)6 TemporalIndexDetails (org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails)6 BasicDBObject (com.mongodb.BasicDBObject)4 FluoDetails (org.apache.rya.api.instance.RyaDetails.PCJIndexDetails.FluoDetails)4 RyaClientException (org.apache.rya.api.client.RyaClientException)3 CliCommand (org.springframework.shell.core.annotation.CliCommand)3 DBObject (com.mongodb.DBObject)2 Install (org.apache.rya.api.client.Install)2 InstallConfiguration (org.apache.rya.api.client.Install.InstallConfiguration)2 AccumuloConnectionDetails (org.apache.rya.api.client.accumulo.AccumuloConnectionDetails)2 ConsolePrinter (org.apache.rya.shell.util.ConsolePrinter)2 SparqlPrompt (org.apache.rya.shell.util.SparqlPrompt)2