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);
}
}
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());
}
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());
}
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);
}
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);
}
Aggregations