use of org.apache.accumulo.minicluster.MiniAccumuloConfig in project hive by apache.
the class AccumuloTestSetup method setupWithHiveConf.
private void setupWithHiveConf(HiveConf conf) throws Exception {
if (null == miniCluster) {
String testTmpDir = System.getProperty("test.tmp.dir");
File tmpDir = new File(testTmpDir, "accumulo");
if (tmpDir.exists()) {
FileUtils.deleteDirectory(tmpDir);
}
MiniAccumuloConfig cfg = new MiniAccumuloConfig(tmpDir, PASSWORD);
cfg.setNumTservers(1);
miniCluster = new MiniAccumuloCluster(cfg);
appendZooKeeperConf(EXTRA_ZOOKEEPER_CONFIG, tmpDir);
miniCluster.start();
createAccumuloTable(miniCluster.getConnector("root", PASSWORD));
}
updateConf(conf);
}
use of org.apache.accumulo.minicluster.MiniAccumuloConfig in project incubator-rya by apache.
the class QueryBenchmarkRunIT method setup.
@BeforeClass
public static void setup() throws Exception {
// Squash loud logs.
Logger.getLogger(ClientCnxn.class).setLevel(Level.ERROR);
// Setup the Mini Accumulo Cluster.
final File miniDataDir = com.google.common.io.Files.createTempDir();
final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, ACCUMULO_PASSWORD);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
// Create a Rya Client connected to the Mini Accumulo Cluster.
final AccumuloConnectionDetails connDetails = new AccumuloConnectionDetails(ACCUMULO_USER, ACCUMULO_PASSWORD.toCharArray(), cluster.getInstanceName(), cluster.getZooKeepers());
final Connector connector = cluster.getConnector(ACCUMULO_USER, ACCUMULO_PASSWORD);
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connDetails, connector);
// Install an instance of Rya on the mini cluster.
installRya(ryaClient);
// Get a Sail object that is backed by the Rya store that is on the mini cluster.
final AccumuloRdfConfiguration ryaConf = new AccumuloRdfConfiguration();
ryaConf.setTablePrefix(RYA_INSTANCE_NAME);
ryaConf.set(ConfigUtils.CLOUDBASE_USER, ACCUMULO_USER);
ryaConf.set(ConfigUtils.CLOUDBASE_PASSWORD, ACCUMULO_PASSWORD);
ryaConf.set(ConfigUtils.CLOUDBASE_ZOOKEEPERS, cluster.getZooKeepers());
ryaConf.set(ConfigUtils.CLOUDBASE_INSTANCE, cluster.getInstanceName());
ryaConf.set(ConfigUtils.USE_PCJ, "true");
ryaConf.set(ConfigUtils.PCJ_STORAGE_TYPE, PrecomputedJoinStorageType.ACCUMULO.toString());
ryaConf.set(ConfigUtils.PCJ_UPDATER_TYPE, PrecomputedJoinUpdaterType.NO_UPDATE.toString());
sail = RyaSailFactory.getInstance(ryaConf);
// Load some data into the cluster that will match the query we're testing against.
loadTestStatements();
// Add a PCJ to the application that summarizes the query.
createTestPCJ(ryaClient);
}
use of org.apache.accumulo.minicluster.MiniAccumuloConfig in project incubator-rya by apache.
the class RyaClientExample method main.
public static void main(final String[] args) throws Exception {
final String accumuloUsername = "root";
final String accumuloPassword = "password";
MiniAccumuloCluster cluster = null;
MiniFluo fluo = null;
Sail ryaSail = null;
try {
// Setup a Mini Accumulo Cluster to host the Rya instance.
log.info("Setting up the Mini Accumulo Cluster used by this example.");
final File miniDataDir = Files.createTempDir();
final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, accumuloPassword);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
// Setup a Mini Fluo application that will be used to incrementally update the PCJ indicies.
log.info("Setting up the Mini Fluo application used by this example.");
final String fluoAppName = "demoInstance_pcjUpdater";
fluo = makeMiniFluo(accumuloUsername, accumuloPassword, cluster.getInstanceName(), cluster.getZooKeepers(), fluoAppName);
// Give the root user the 'U' authorizations.
final Connector connector = cluster.getConnector(accumuloUsername, accumuloPassword);
connector.securityOperations().changeUserAuthorizations(accumuloUsername, new Authorizations("U"));
// Setup a Rya Client that is able to interact with the mini cluster.
final AccumuloConnectionDetails connectionDetails = new AccumuloConnectionDetails(accumuloUsername, accumuloPassword.toCharArray(), cluster.getInstanceName(), cluster.getZooKeepers());
final RyaClient ryaClient = AccumuloRyaClientFactory.build(connectionDetails, connector);
// Install an instance of Rya that has all of the secondary indexers turned on.
final String ryaInstanceName = "demoInstance_";
final InstallConfiguration installConfig = InstallConfiguration.builder().setEnableTableHashPrefix(true).setEnableEntityCentricIndex(true).setEnableGeoIndex(true).setEnableFreeTextIndex(true).setEnableTemporalIndex(true).setEnablePcjIndex(true).setFluoPcjAppName(fluoAppName).build();
ryaClient.getInstall().install(ryaInstanceName, installConfig);
// Add a PCJ index.
final String sparql = "SELECT ?patron ?employee " + "WHERE { " + "?patron <http://talksTo> ?employee. " + "?employee <http://worksAt> <http://CoffeeShop>. " + "}";
// Load some statements into the Rya instance.
final AccumuloIndexingConfiguration conf = AccumuloIndexingConfiguration.builder().setAuths("U").setAccumuloUser(accumuloUsername).setAccumuloPassword(accumuloPassword).setAccumuloInstance(cluster.getInstanceName()).setAccumuloZooKeepers(cluster.getZooKeepers()).setRyaPrefix(ryaInstanceName).setPcjUpdaterFluoAppName(fluoAppName).build();
ryaSail = RyaSailFactory.getInstance(conf);
final ValueFactory vf = ryaSail.getValueFactory();
final List<Statement> statements = Lists.newArrayList(vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://talksTo"), vf.createURI("http://Charlie")), vf.createStatement(vf.createURI("http://David"), vf.createURI("http://talksTo"), vf.createURI("http://Alice")), vf.createStatement(vf.createURI("http://Alice"), vf.createURI("http://worksAt"), vf.createURI("http://CoffeeShop")), vf.createStatement(vf.createURI("http://Bob"), vf.createURI("http://worksAt"), vf.createURI("http://CoffeeShop")), vf.createStatement(vf.createURI("http://George"), vf.createURI("http://talksTo"), vf.createURI("http://Frank")), vf.createStatement(vf.createURI("http://Frank"), vf.createURI("http://worksAt"), vf.createURI("http://CoffeeShop")), vf.createStatement(vf.createURI("http://Eve"), vf.createURI("http://talksTo"), vf.createURI("http://Bob")), vf.createStatement(vf.createURI("http://Charlie"), vf.createURI("http://worksAt"), vf.createURI("http://CoffeeShop")));
SailConnection ryaConn = ryaSail.getConnection();
log.info("");
log.info("Loading the following statements:");
ryaConn.begin();
for (final Statement statement : statements) {
log.info(" " + statement.toString());
ryaConn.addStatement(statement.getSubject(), statement.getPredicate(), statement.getObject());
}
log.info("");
ryaConn.close();
fluo.waitForObservers();
// Execute the SPARQL query and print the results.
log.info("Executing the following query: ");
prettyLogSparql(sparql);
log.info("");
final ParsedQuery parsedQuery = new SPARQLParser().parseQuery(sparql, null);
ryaConn = ryaSail.getConnection();
final CloseableIteration<? extends BindingSet, QueryEvaluationException> result = ryaConn.evaluate(parsedQuery.getTupleExpr(), null, null, false);
log.info("Results:");
while (result.hasNext()) {
log.info(" " + result.next());
}
log.info("");
} finally {
if (ryaSail != null) {
log.info("Shutting down the Rya Sail instance.");
ryaSail.shutDown();
}
if (fluo != null) {
try {
log.info("Shutting down the Mini Fluo instance.");
fluo.close();
} catch (final Exception e) {
log.error("Could not shut down the Mini Fluo instance.", e);
}
}
if (cluster != null) {
log.info("Sutting down the Mini Accumulo Cluster.");
cluster.stop();
}
}
}
use of org.apache.accumulo.minicluster.MiniAccumuloConfig in project incubator-rya by apache.
the class MiniAccumuloClusterInstance method startMiniAccumulo.
/**
* Start the {@link MiniAccumuloCluster}.
*/
public void startMiniAccumulo() throws IOException, InterruptedException, AccumuloException, AccumuloSecurityException {
final File miniDataDir = Files.createTempDir();
// Setup and start the Mini Accumulo.
final MiniAccumuloConfig cfg = new MiniAccumuloConfig(miniDataDir, PASSWORD);
cluster = new MiniAccumuloCluster(cfg);
cluster.start();
}
use of org.apache.accumulo.minicluster.MiniAccumuloConfig in project Gaffer by gchq.
the class MiniAccumuloClusterProvider method createCluster.
private static void createCluster() throws IOException, InterruptedException, AccumuloSecurityException, AccumuloException {
if (tempFolder.exists()) {
FileUtils.cleanDirectory(tempFolder);
}
final MiniAccumuloConfig miniAccumuloConfig = new MiniAccumuloConfig(tempFolder, PASSWORD);
cluster = new MiniAccumuloCluster(miniAccumuloConfig);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
cluster.stop();
tempFolder.delete();
} catch (final IOException | InterruptedException e) {
throw new RuntimeException(e);
}
}
});
cluster.start();
// Create user USER with permissions to create a table
cluster.getConnector(ROOT, PASSWORD).securityOperations().createLocalUser(USER, new PasswordToken(PASSWORD));
cluster.getConnector(ROOT, PASSWORD).securityOperations().createLocalUser(USER_NO_GRANTED_PERMISSION, new PasswordToken(PASSWORD));
cluster.getConnector(ROOT, PASSWORD).securityOperations().grantSystemPermission(USER, SystemPermission.CREATE_TABLE);
// Create properties
accumuloProperties = new AccumuloProperties();
accumuloProperties.setStoreClass(AccumuloStore.class);
accumuloProperties.setInstance(cluster.getInstanceName());
accumuloProperties.setZookeepers(cluster.getZooKeepers());
accumuloProperties.setUser(MiniAccumuloClusterProvider.USER);
accumuloProperties.setPassword(MiniAccumuloClusterProvider.PASSWORD);
accumuloProperties.setOperationDeclarationPaths("sparkAccumuloOperationsDeclarations.json");
}
Aggregations