use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class CopyTool method createChildInstance.
private Instance createChildInstance(final Configuration config) throws Exception {
Instance instance = null;
String instanceTypeProp = config.get(CREATE_CHILD_INSTANCE_TYPE_PROP);
final String childAuth = config.get(MRUtils.AC_AUTH_PROP + MergeTool.CHILD_SUFFIX);
// Default to distribution cluster if not specified
if (StringUtils.isBlank(instanceTypeProp)) {
instanceTypeProp = InstanceType.DISTRIBUTION.toString();
}
final InstanceType instanceType = InstanceType.fromName(instanceTypeProp);
switch(instanceType) {
case DISTRIBUTION:
if (childInstance == null) {
throw new IllegalArgumentException("Must specify instance name for distributed mode");
} else if (childZk == null) {
throw new IllegalArgumentException("Must specify ZooKeeper hosts for distributed mode");
}
instance = new ZooKeeperInstance(childInstance, childZk);
break;
case MINI:
childAccumuloInstanceDriver = new AccumuloInstanceDriver("Child", false, true, false, false, childUserName, childPwd, childInstance, childTablePrefix, childAuth);
childAccumuloInstanceDriver.setUpInstance();
childAccumuloInstanceDriver.setUpTables();
childZk = childAccumuloInstanceDriver.getZooKeepers();
MergeTool.setDuplicateKeysForProperty(config, MRUtils.AC_ZK_PROP + MergeTool.CHILD_SUFFIX, childZk);
instance = new ZooKeeperInstance(childInstance, childZk);
break;
case MOCK:
instance = new MockInstance(childInstance);
break;
default:
throw new AccumuloException("Unexpected instance type: " + instanceType);
}
return instance;
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class PeriodicNotificationApplicationFactory method getPeriodicQueryResultStorage.
private static PeriodicQueryResultStorage getPeriodicQueryResultStorage(final PeriodicNotificationApplicationConfiguration conf) throws AccumuloException, AccumuloSecurityException {
final Instance instance = new ZooKeeperInstance(conf.getAccumuloInstance(), conf.getAccumuloZookeepers());
final Connector conn = instance.getConnector(conf.getAccumuloUser(), new PasswordToken(conf.getAccumuloPassword()));
final String ryaInstance = conf.getTablePrefix();
return new AccumuloPeriodicQueryResultStorage(conn, ryaInstance);
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class ProspectorUtils method instance.
public static Instance instance(final Configuration conf) {
assert conf != null;
final String instance_str = conf.get(INSTANCE);
final String zookeepers = conf.get(ZOOKEEPERS);
final String mock = conf.get(MOCK);
if (Boolean.parseBoolean(mock)) {
return new MockInstance(instance_str);
} else if (zookeepers != null) {
return new ZooKeeperInstance(instance_str, zookeepers);
} else {
throw new IllegalArgumentException("Must specify either mock or zookeepers");
}
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class SparqlQueryPigEngine method init.
public void init() throws Exception {
Preconditions.checkNotNull(sparqlToPigTransformVisitor, "Sparql To Pig Transform Visitor must not be null");
logger.info("Initializing Sparql Query Pig Engine");
if (hadoopDir != null) {
// set hadoop dir property
System.setProperty("HADOOPDIR", hadoopDir);
}
if (pigServer == null) {
pigServer = new PigServer(execType);
}
if (inference || stats) {
final String instance = sparqlToPigTransformVisitor.getInstance();
final String zoo = sparqlToPigTransformVisitor.getZk();
final String user = sparqlToPigTransformVisitor.getUser();
final String pass = sparqlToPigTransformVisitor.getPassword();
final Connector connector = new ZooKeeperInstance(instance, zoo).getConnector(user, new PasswordToken(pass.getBytes(StandardCharsets.UTF_8)));
final String tablePrefix = sparqlToPigTransformVisitor.getTablePrefix();
conf.setTablePrefix(tablePrefix);
if (inference) {
logger.info("Using inference");
inferenceEngine = new InferenceEngine();
ryaDAO = new AccumuloRyaDAO();
ryaDAO.setConf(conf);
ryaDAO.setConnector(connector);
ryaDAO.init();
inferenceEngine.setRyaDAO(ryaDAO);
inferenceEngine.setConf(conf);
inferenceEngine.setSchedule(false);
inferenceEngine.init();
}
if (stats) {
logger.info("Using stats");
rdfEvalStatsDAO = new AccumuloRdfEvalStatsDAO();
rdfEvalStatsDAO.setConf(conf);
rdfEvalStatsDAO.setConnector(connector);
// rdfEvalStatsDAO.setEvalTable(tablePrefix + RdfCloudTripleStoreConstants.TBL_EVAL_SUFFIX);
rdfEvalStatsDAO.init();
rdfCloudTripleStoreEvaluationStatistics = new RdfCloudTripleStoreEvaluationStatistics<AccumuloRdfConfiguration>(conf, rdfEvalStatsDAO);
}
}
}
use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.
the class PcjAdminClient method createAccumuloConnector.
private static Connector createAccumuloConnector(final PcjAdminClientProperties clientProps) throws AccumuloException, AccumuloSecurityException {
checkNotNull(clientProps);
// Connect to the Zookeepers.
final String instanceName = clientProps.getAccumuloInstance();
final String zooServers = clientProps.getAccumuloZookeepers();
final Instance inst = new ZooKeeperInstance(instanceName, zooServers);
// Create a connector to the Accumulo that hosts the PCJ export tables.
return inst.getConnector(clientProps.getAccumuloUsername(), new PasswordToken(clientProps.getAccumuloPassword()));
}
Aggregations