use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class AccumuloLoadStatementsFileIT method loadTurtleFile.
@Test
public void loadTurtleFile() throws Exception {
// Install an instance of Rya.
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(false).setEnableEntityCentricIndex(false).setEnableFreeTextIndex(false).setEnableTemporalIndex(false).setEnablePcjIndex(false).setEnableGeoIndex(false).setFluoPcjAppName("fluo_app_name").build();
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(getUsername(), getPassword().toCharArray(), getInstanceName(), getZookeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, getConnector());
final Install install = ryaClient.getInstall();
install.install(getRyaInstanceName(), installConfig);
// Load the test statement file.
ryaClient.getLoadStatementsFile().loadStatements(getRyaInstanceName(), Paths.get("src/test/resources/example.ttl"), RDFFormat.TURTLE);
// Verify that the statements were loaded.
final ValueFactory vf = new ValueFactoryImpl();
final List<Statement> expected = new ArrayList<>();
expected.add(vf.createStatement(vf.createURI("http://example#alice"), vf.createURI("http://example#talksTo"), vf.createURI("http://example#bob")));
expected.add(vf.createStatement(vf.createURI("http://example#bob"), vf.createURI("http://example#talksTo"), vf.createURI("http://example#charlie")));
expected.add(vf.createStatement(vf.createURI("http://example#charlie"), vf.createURI("http://example#likes"), vf.createURI("http://example#icecream")));
final List<Statement> statements = new ArrayList<>();
final WholeRowTripleResolver tripleResolver = new WholeRowTripleResolver();
final Scanner scanner = getConnector().createScanner(getRyaInstanceName() + "spo", new Authorizations());
final Iterator<Entry<Key, Value>> it = scanner.iterator();
while (it.hasNext()) {
final Entry<Key, Value> next = it.next();
final Key key = next.getKey();
final byte[] row = key.getRow().getBytes();
final byte[] columnFamily = key.getColumnFamily().getBytes();
final byte[] columnQualifier = key.getColumnQualifier().getBytes();
final TripleRow tripleRow = new TripleRow(row, columnFamily, columnQualifier);
final RyaStatement ryaStatement = tripleResolver.deserialize(TABLE_LAYOUT.SPO, tripleRow);
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// Filter out the rya version statement if it is present.
if (!isRyaMetadataStatement(vf, statement)) {
statements.add(statement);
}
}
assertEquals(expected, statements);
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoUninstallIT method uninstall.
@Test
public void uninstall() throws MongoException, RyaClientException {
// Install an instance of Rya.
final String instanceName = "testInstance_";
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).setFluoPcjAppName("fluo_app_name").build();
final RyaClient ryaClient = MongoRyaClientFactory.build(getConnectionDetails(), getMongoClient());
final Install install = ryaClient.getInstall();
install.install(instanceName, installConfig);
// Show that the instance exists.
final InstanceExists instanceExists = ryaClient.getInstanceExists();
assertTrue(instanceExists.exists(instanceName));
// Uninstall the instance
final Uninstall uninstall = ryaClient.getUninstall();
uninstall.uninstall(instanceName);
// Check that the instance no longer exists.
assertFalse(instanceExists.exists(instanceName));
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class FluoITBase method setupRya.
/**
* Sets up a Rya instance.
*/
protected RyaSailRepository setupRya() throws AccumuloException, AccumuloSecurityException, RepositoryException, RyaDAOException, NumberFormatException, UnknownHostException, InferenceEngineException, AlreadyInitializedException, RyaDetailsRepositoryException, DuplicateInstanceNameException, RyaClientException, SailException {
checkNotNull(instanceName);
checkNotNull(zookeepers);
// Setup Rya configuration values.
conf.setTablePrefix(getRyaInstanceName());
conf.setDisplayQueryPlan(true);
conf.setBoolean(ConfigUtils.USE_MOCK_INSTANCE, false);
conf.set(ConfigUtils.CLOUDBASE_USER, clusterInstance.getUsername());
conf.set(ConfigUtils.CLOUDBASE_PASSWORD, clusterInstance.getPassword());
conf.set(ConfigUtils.CLOUDBASE_INSTANCE, clusterInstance.getInstanceName());
conf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, clusterInstance.getZookeepers());
conf.set(ConfigUtils.USE_PCJ, "true");
conf.set(ConfigUtils.FLUO_APP_NAME, getRyaInstanceName());
conf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinStorageType.ACCUMULO.toString());
conf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinIndexerConfig.PrecomputedJoinUpdaterType.FLUO.toString());
conf.set(ConfigUtils.CLOUDBASE_AUTHS, "");
// Install the test instance of Rya.
final Install install = new AccumuloInstall(createConnectionDetails(), accumuloConn);
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setEnableGeoIndex(true).setFluoPcjAppName(getRyaInstanceName()).build();
install.install(getRyaInstanceName(), installConfig);
// Connect to the instance of Rya that was just installed.
final Sail sail = RyaSailFactory.getInstance(conf);
final RyaSailRepository ryaRepo = new RyaSailRepository(sail);
return ryaRepo;
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoCreatePCJIT method createPCJ_invalidSparql.
@Test(expected = RyaClientException.class)
public void createPCJ_invalidSparql() throws DuplicateInstanceNameException, RyaClientException {
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);
// Create a PCJ.
final String sparql = "not valid sparql";
createPCJ.createPCJ(conf.getRyaInstanceName(), sparql);
}
use of org.apache.rya.api.client.Install.InstallConfiguration in project incubator-rya by apache.
the class MongoCreatePCJIT method createPCJ.
@Test
public void createPCJ() 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);
// 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);
assertEquals(pcjId, pcjDetails.getId());
assertFalse(pcjDetails.getLastUpdateTime().isPresent());
try (final PrecomputedJoinStorage pcjStorage = new MongoPcjStorage(getMongoClient(), conf.getRyaInstanceName())) {
final PcjMetadata pcjMetadata = pcjStorage.getPcjMetadata(pcjId);
// confirm that the pcj was added to the pcj store.
assertEquals(sparql, pcjMetadata.getSparql());
assertEquals(0L, pcjMetadata.getCardinality());
}
}
Aggregations