Search in sources :

Example 21 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails 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 22 with RyaDetails

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

the class AccumuloAddUserIT method addUserTwice.

/**
 * Ensure nothing happens if you try to add a user that is already there.
 */
@Test
public void addUserTwice() throws Exception {
    final String user = testInstance.createUniqueUser();
    final SecurityOperations secOps = super.getConnector().securityOperations();
    final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(ADMIN_USER, ADMIN_USER.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(ADMIN_USER, ADMIN_USER));
    // Create the user that will not be added to the instance of Rya, but will try to scan it.
    secOps.createLocalUser(user, new PasswordToken(user));
    // Install the instance of Rya.
    userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
    // Add the user.
    userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
    userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
    // Ensure the Rya instance's details only contain the username of the user who installed the instance.
    final ImmutableList<String> expectedUsers = ImmutableList.<String>builder().add(ADMIN_USER).add(user).build();
    final RyaDetails details = userAClient.getGetInstanceDetails().getDetails(getRyaInstanceName()).get();
    assertEquals(expectedUsers, details.getUsers());
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) RyaDetails(org.apache.rya.api.instance.RyaDetails) RyaClient(org.apache.rya.api.client.RyaClient) Test(org.junit.Test)

Example 23 with RyaDetails

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

the class AccumuloGetInstanceDetailsIT method getDetails_instanceDoesNotHaveDetails.

@Test
public void getDetails_instanceDoesNotHaveDetails() throws AccumuloException, AccumuloSecurityException, InstanceDoesNotExistException, RyaClientException, TableExistsException {
    // Mimic a pre-details rya install.
    final TableOperations tableOps = getConnector().tableOperations();
    final String spoTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX;
    final String ospTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX;
    final String poTableName = getRyaInstanceName() + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX;
    tableOps.create(spoTableName);
    tableOps.create(ospTableName);
    tableOps.create(poTableName);
    // Verify that the operation returns empty.
    final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
    final GetInstanceDetails getInstanceDetails = new AccumuloGetInstanceDetails(connectionDetails, getConnector());
    final Optional<RyaDetails> details = getInstanceDetails.getDetails(getRyaInstanceName());
    assertFalse(details.isPresent());
}
Also used : TableOperations(org.apache.accumulo.core.client.admin.TableOperations) GetInstanceDetails(org.apache.rya.api.client.GetInstanceDetails) RyaDetails(org.apache.rya.api.instance.RyaDetails) Test(org.junit.Test)

Example 24 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails 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);
}
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)

Example 25 with RyaDetails

use of org.apache.rya.api.instance.RyaDetails 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);
}
Also used : ProspectorDetails(org.apache.rya.api.instance.RyaDetails.ProspectorDetails) EntityCentricIndexDetails(org.apache.rya.api.instance.RyaDetails.EntityCentricIndexDetails) Connector(org.apache.accumulo.core.client.Connector) TemporalIndexDetails(org.apache.rya.api.instance.RyaDetails.TemporalIndexDetails) FreeTextIndexDetails(org.apache.rya.api.instance.RyaDetails.FreeTextIndexDetails) RyaDetailsRepository(org.apache.rya.api.instance.RyaDetailsRepository) RyaDetails(org.apache.rya.api.instance.RyaDetails) 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

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