use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloRemoveUserIT method removedUserNotInDetails.
/**
* Ensure that when a user is removed from a Rya instance that its details are updated to no longer include the user.
*/
@Test
public void removedUserNotInDetails() throws Exception {
final String adminUser = testInstance.createUniqueUser();
final String user = testInstance.createUniqueUser();
final SecurityOperations secOps = super.getConnector().securityOperations();
// Create the user that will install the instance of Rya.
secOps.createLocalUser(adminUser, new PasswordToken(adminUser));
secOps.grantSystemPermission(adminUser, SystemPermission.CREATE_TABLE);
final RyaClient userAClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(adminUser, adminUser.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(adminUser, adminUser));
// Create the user that will be added to the instance of Rya.
secOps.createLocalUser(user, new PasswordToken(user));
final RyaClient userBClient = AccumuloRyaClientFactory.build(new AccumuloConnectionDetails(user, user.toCharArray(), getInstanceName(), getZookeepers()), super.getClusterInstance().getCluster().getConnector(user, user));
// Install the instance of Rya.
userAClient.getInstall().install(getRyaInstanceName(), InstallConfiguration.builder().build());
// Add userB.
userAClient.getAddUser().get().addUser(getRyaInstanceName(), user);
// Remove userA.
userBClient.getRemoveUser().get().removeUser(getRyaInstanceName(), adminUser);
// Ensure the Rya instance's details have been updated to include the added user.
final ImmutableList<String> expectedUsers = ImmutableList.<String>builder().add(user).build();
final RyaDetails details = userBClient.getGetInstanceDetails().getDetails(getRyaInstanceName()).get();
assertEquals(expectedUsers, details.getUsers());
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class AccumuloUninstallIT method uninstall.
@Test
public void uninstall() throws Exception {
// Install an instance of Rya.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).build();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
ryaClient.getInstall().install(getRyaInstanceName(), installConfig);
// Check that the instance exists.
assertTrue(ryaClient.getInstanceExists().exists(getRyaInstanceName()));
// Uninstall the instance of Rya.
ryaClient.getUninstall().uninstall(getRyaInstanceName());
// Verify that it no longer exists.
assertFalse(ryaClient.getInstanceExists().exists(getRyaInstanceName()));
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoDeletePCJIT method deletePCJ.
@Test
public void deletePCJ() throws Exception {
final MongoConnectionDetails connectionDetails = getConnectionDetails();
final RyaClient ryaClient = MongoRyaClientFactory.build(connectionDetails, getMongoClient());
// Initialize the commands that will be used by this test.
final CreatePCJ createPCJ = ryaClient.getCreatePCJ();
final Install installRya = ryaClient.getInstall();
final InstallConfiguration installConf = InstallConfiguration.builder().setEnablePcjIndex(true).build();
installRya.install(conf.getRyaInstanceName(), installConf);
System.out.println(getMongoClient().getDatabase(conf.getRyaInstanceName()).getCollection("instance_details").find().first().toJson());
// Create a PCJ.
final String sparql = "SELECT ?x " + "WHERE { " + "?x <http://talksTo> <http://Eve>. " + "?x <http://worksAt> <http://TacoJoint>." + "}";
final String pcjId = createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
final DeletePCJ deletePCJ = ryaClient.getDeletePCJ();
deletePCJ.deletePCJ(conf.getRyaInstanceName(), pcjId);
// Verify the RyaDetails were updated to include the new PCJ.
final Optional<RyaDetails> ryaDetails = ryaClient.getGetInstanceDetails().getDetails(conf.getRyaInstanceName());
final ImmutableMap<String, PCJDetails> details = ryaDetails.get().getPCJIndexDetails().getPCJDetails();
final PCJDetails pcjDetails = details.get(pcjId);
assertNull(pcjDetails);
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoGetInstanceDetailsIT method getDetails.
@Test
public void getDetails() throws MongoException, RyaClientException {
final String instanceName = "instance";
// Install an instance of Rya.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).build();
final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
final Install install = ryaClient.getInstall();
install.install(instanceName, installConfig);
// Verify the correct details were persisted.
final GetInstanceDetails getInstanceDetails = ryaClient.getGetInstanceDetails();
final Optional<RyaDetails> details = getInstanceDetails.getDetails(instanceName);
final RyaDetails expectedDetails = RyaDetails.builder().setRyaInstanceName(instanceName).setRyaVersion(details.get().getRyaVersion()).setTemporalIndexDetails(new TemporalIndexDetails(true)).setFreeTextDetails(new FreeTextIndexDetails(true)).setEntityCentricIndexDetails(new EntityCentricIndexDetails(false)).setPCJIndexDetails(PCJIndexDetails.builder().setEnabled(true)).setProspectorDetails(new ProspectorDetails(Optional.<Date>absent())).setJoinSelectivityDetails(new JoinSelectivityDetails(Optional.<Date>absent())).build();
assertEquals(expectedDetails, details.get());
}
use of org.apache.rya.api.client.RyaClient in project incubator-rya by apache.
the class MongoGetInstanceDetailsIT method getDetails_instanceDoesNotHaveDetails.
@Test
public void getDetails_instanceDoesNotHaveDetails() throws MongoException, TableExistsException, RyaClientException {
// Mimic a pre-details rya install.
final String instanceName = "instance_name";
getMongoClient().getDatabase(instanceName).createCollection("rya_triples");
// Verify that the operation returns empty.
final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
final GetInstanceDetails getInstanceDetails = ryaClient.getGetInstanceDetails();
final Optional<RyaDetails> details = getInstanceDetails.getDetails(instanceName);
assertFalse(details.isPresent());
}
Aggregations