Search in sources :

Example 36 with ZooKeeperInstance

use of org.apache.accumulo.core.client.ZooKeeperInstance in project incubator-rya by apache.

the class MRReasoningUtils method getRepository.

/**
 * Get a Repository from the configuration variables
 */
static RyaSailRepository getRepository(Configuration conf) throws AccumuloException, AccumuloSecurityException {
    boolean mock = conf.getBoolean(MRUtils.AC_MOCK_PROP, false);
    String instance = conf.get(MRUtils.AC_INSTANCE_PROP, "instance");
    String username = conf.get(MRUtils.AC_USERNAME_PROP, "root");
    String password = conf.get(MRUtils.AC_PWD_PROP, "root");
    Instance accumulo;
    if (mock) {
        accumulo = new MockInstance(instance);
    } else {
        String zookeepers = conf.get(MRUtils.AC_ZK_PROP, "zoo");
        accumulo = new ZooKeeperInstance(instance, zookeepers);
    }
    Connector connector = accumulo.getConnector(username, new PasswordToken(password));
    AccumuloRdfConfiguration aconf = new AccumuloRdfConfiguration(conf);
    aconf.setTablePrefix(conf.get(MRUtils.TABLE_PREFIX_PROPERTY, RdfCloudTripleStoreConstants.TBL_PRFX_DEF));
    AccumuloRyaDAO dao = new AccumuloRyaDAO();
    dao.setConnector(connector);
    dao.setConf(aconf);
    RdfCloudTripleStore store = new RdfCloudTripleStore();
    store.setRyaDAO(dao);
    return new RyaSailRepository(store);
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) 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) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 37 with ZooKeeperInstance

use of org.apache.accumulo.core.client.ZooKeeperInstance in project accumulo by apache.

the class ReplicationIT method waitForGCLock.

private void waitForGCLock(Connector conn) throws InterruptedException {
    // Check if the GC process has the lock before wasting our retry attempts
    ZooKeeperInstance zki = (ZooKeeperInstance) conn.getInstance();
    ZooCacheFactory zcf = new ZooCacheFactory();
    ZooCache zcache = zcf.getZooCache(zki.getZooKeepers(), zki.getZooKeepersSessionTimeOut());
    String zkPath = ZooUtil.getRoot(conn.getInstance()) + Constants.ZGC_LOCK;
    log.info("Looking for GC lock at {}", zkPath);
    byte[] data = ZooLock.getLockData(zcache, zkPath, null);
    while (null == data) {
        log.info("Waiting for GC ZooKeeper lock to be acquired");
        Thread.sleep(1000);
        data = ZooLock.getLockData(zcache, zkPath, null);
    }
}
Also used : ZooCacheFactory(org.apache.accumulo.fate.zookeeper.ZooCacheFactory) ZooCache(org.apache.accumulo.fate.zookeeper.ZooCache) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 38 with ZooKeeperInstance

use of org.apache.accumulo.core.client.ZooKeeperInstance in project accumulo by apache.

the class MiniAccumuloClusterImpl method getMasterMonitorInfo.

/**
 * Get programmatic interface to information available in a normal monitor. XXX the returned structure won't contain information about the metadata table
 * until there is data in it. e.g. if you want to see the metadata table you should create a table.
 *
 * @since 1.6.1
 */
public MasterMonitorInfo getMasterMonitorInfo() throws AccumuloException, AccumuloSecurityException {
    MasterClientService.Iface client = null;
    while (true) {
        try {
            Instance instance = new ZooKeeperInstance(getClientConfig());
            ClientContext context = new ClientContext(instance, new Credentials("root", new PasswordToken("unchecked")), getClientConfig());
            client = MasterClient.getConnectionWithRetry(context);
            return client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
        } catch (ThriftSecurityException exception) {
            throw new AccumuloSecurityException(exception);
        } catch (ThriftNotActiveServiceException e) {
            // Let it loop, fetching a new location
            log.debug("Contacted a Master which is no longer active, retrying");
            sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
        } catch (TException exception) {
            throw new AccumuloException(exception);
        } finally {
            if (client != null) {
                MasterClient.close(client);
            }
        }
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) ThriftNotActiveServiceException(org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException) Instance(org.apache.accumulo.core.client.Instance) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance) ClientContext(org.apache.accumulo.core.client.impl.ClientContext) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) Credentials(org.apache.accumulo.core.client.impl.Credentials) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 39 with ZooKeeperInstance

use of org.apache.accumulo.core.client.ZooKeeperInstance in project accumulo by apache.

the class ShellSetInstanceTest method testSetInstance_ZKInstance.

private void testSetInstance_ZKInstance(boolean dashZ) throws Exception {
    ClientConfiguration clientConf = createMock(ClientConfiguration.class);
    ShellOptionsJC opts = createMock(ShellOptionsJC.class);
    expect(opts.isFake()).andReturn(false);
    expect(opts.getClientConfiguration()).andReturn(clientConf);
    expect(opts.isHdfsZooInstance()).andReturn(false);
    expect(clientConf.getKeys()).andReturn(Arrays.asList(ClientProperty.INSTANCE_NAME.getKey(), ClientProperty.INSTANCE_ZK_HOST.getKey()).iterator());
    expect(clientConf.getString(Property.GENERAL_SECURITY_CREDENTIAL_PROVIDER_PATHS.getKey())).andReturn(null);
    if (dashZ) {
        expect(clientConf.withInstance("foo")).andReturn(clientConf);
        expect(clientConf.getString(ClientProperty.INSTANCE_NAME.getKey())).andReturn("foo");
        expect(clientConf.withZkHosts("host1,host2")).andReturn(clientConf);
        expect(clientConf.getString(ClientProperty.INSTANCE_ZK_HOST.getKey())).andReturn("host1,host2");
        List<String> zl = new java.util.ArrayList<>();
        zl.add("foo");
        zl.add("host1,host2");
        expect(opts.getZooKeeperInstance()).andReturn(zl);
        expectLastCall().anyTimes();
    } else {
        expect(clientConf.withInstance("bar")).andReturn(clientConf);
        expect(clientConf.getString(ClientProperty.INSTANCE_NAME.getKey())).andReturn("bar");
        expect(clientConf.withZkHosts("host3,host4")).andReturn(clientConf);
        expect(clientConf.getString(ClientProperty.INSTANCE_ZK_HOST.getKey())).andReturn("host3,host4");
        expect(opts.getZooKeeperInstance()).andReturn(Collections.emptyList());
        expect(opts.getZooKeeperInstanceName()).andReturn("bar");
        expect(opts.getZooKeeperHosts()).andReturn("host3,host4");
    }
    replay(clientConf);
    replay(opts);
    ZooKeeperInstance theInstance = createMock(ZooKeeperInstance.class);
    expectNew(ZooKeeperInstance.class, new Class<?>[] { ClientConfiguration.class }, clientConf).andReturn(theInstance);
    replay(theInstance, ZooKeeperInstance.class);
    shell.setInstance(opts);
    verify(theInstance, ZooKeeperInstance.class);
}
Also used : BeforeClass(org.junit.BeforeClass) AfterClass(org.junit.AfterClass) ClientConfiguration(org.apache.accumulo.core.client.ClientConfiguration) ZooKeeperInstance(org.apache.accumulo.core.client.ZooKeeperInstance)

Example 40 with ZooKeeperInstance

use of org.apache.accumulo.core.client.ZooKeeperInstance in project accumulo by apache.

the class IMMLGBenchmark method main.

public static void main(String[] args) throws Exception {
    ZooKeeperInstance zki = new ZooKeeperInstance(ClientConfiguration.create().withInstance("test16").withZkHosts("localhost"));
    Connector conn = zki.getConnector("root", new PasswordToken("secret"));
    int numlg = Integer.parseInt(args[0]);
    ArrayList<byte[]> cfset = new ArrayList<>();
    for (int i = 0; i < 32; i++) {
        cfset.add(String.format("%04x", i).getBytes());
    }
    Map<String, Stat> stats = new TreeMap<>();
    for (int i = 0; i < 5; i++) {
        runTest(conn, numlg, cfset, i > 1 ? stats : null);
        System.out.println();
    }
    for (Entry<String, Stat> entry : stats.entrySet()) {
        System.out.printf("%20s : %6.2f\n", entry.getKey(), entry.getValue().getAverage());
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Stat(org.apache.accumulo.core.util.Stat) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) 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