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);
}
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);
}
}
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);
}
}
}
}
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);
}
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());
}
}
Aggregations