Search in sources :

Example 11 with ZooKeeperInstance

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;
}
Also used : AccumuloInstanceDriver(org.apache.rya.accumulo.mr.merge.util.AccumuloInstanceDriver) AccumuloException(org.apache.accumulo.core.client.AccumuloException) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) InstanceType(org.apache.rya.accumulo.mr.merge.common.InstanceType) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 12 with ZooKeeperInstance

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);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) AccumuloPeriodicQueryResultStorage(org.apache.rya.indexing.pcj.storage.accumulo.AccumuloPeriodicQueryResultStorage) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 13 with ZooKeeperInstance

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");
    }
}
Also used : MockInstance(org.apache.accumulo.core.client.mock.MockInstance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 14 with ZooKeeperInstance

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);
        }
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) InferenceEngine(org.apache.rya.rdftriplestore.inference.InferenceEngine) PigServer(org.apache.pig.PigServer) AccumuloRdfEvalStatsDAO(org.apache.rya.accumulo.AccumuloRdfEvalStatsDAO) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 15 with ZooKeeperInstance

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()));
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Aggregations

ZooKeeperInstance (org.apache.accumulo.core.client.ZooKeeperInstance)52 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)35 Instance (org.apache.accumulo.core.client.Instance)24 Connector (org.apache.accumulo.core.client.Connector)17 AccumuloException (org.apache.accumulo.core.client.AccumuloException)15 MockInstance (org.apache.accumulo.core.client.mock.MockInstance)15 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)13 IOException (java.io.IOException)8 Test (org.junit.Test)8 ClientConfiguration (org.apache.accumulo.core.client.ClientConfiguration)7 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)7 Range (org.apache.accumulo.core.data.Range)6 ArrayList (java.util.ArrayList)5 MiniAccumuloCluster (org.apache.accumulo.minicluster.MiniAccumuloCluster)5 Text (org.apache.hadoop.io.Text)5 File (java.io.File)4 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)4 Pair (org.apache.accumulo.core.util.Pair)4 AccumuloConnectionParameters (org.apache.hadoop.hive.accumulo.AccumuloConnectionParameters)4