@Override public String getInstanceName() { if (instanceName == null) instanceName = InstanceOperationsImpl.lookupInstanceName(zooCache, UUID.fromString(getInstanceID())); return instanceName; }
@Override public List<String> getMasterLocations() { String masterLocPath = ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_LOCK; OpTimer timer = null; if (log.isTraceEnabled()) { log.trace("tid={} Looking up master location in zookeeper.", Thread.currentThread().getId()); timer = new OpTimer().start(); } byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath); if (timer != null) { timer.stop(); log.trace("tid={} Found master at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc, UTF_8)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS))); } if (loc == null) { return Collections.emptyList(); } return Collections.singletonList(new String(loc, UTF_8)); }
@Override public String getRootTabletLocation() { String zRootLocPath = ZooUtil.getRoot(getInstanceID()) + RootTable.ZROOT_TABLET_LOCATION; OpTimer timer = null; if (log.isTraceEnabled()) { log.trace("tid={} Looking up root tablet location in zookeeper.", Thread.currentThread().getId()); timer = new OpTimer().start(); } byte[] loc = zooCache.get(zRootLocPath); if (timer != null) { timer.stop(); log.trace("tid={} Found root tablet at {} in {}", Thread.currentThread().getId(), (loc == null ? "null" : new String(loc, UTF_8)), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS))); } if (loc == null) { return null; } return new String(loc, UTF_8).split("\\|")[0]; }
ZooKeeperInstance(ClientConfiguration config, ZooCacheFactory zcf) { checkArgument(config != null, "config is null"); // Enable singletons before before getting a zoocache SingletonManager.setMode(Mode.CONNECTOR); this.clientConf = config; this.instanceId = clientConf.get(ClientConfiguration.ClientProperty.INSTANCE_ID); this.instanceName = clientConf.get(ClientConfiguration.ClientProperty.INSTANCE_NAME); if ((instanceId == null) == (instanceName == null)) throw new IllegalArgumentException( "Expected exactly one of instanceName and instanceId to be set; " + (instanceName == null ? "neither" : "both") + " were set"); this.zooKeepers = clientConf.get(ClientConfiguration.ClientProperty.INSTANCE_ZK_HOST); this.zooKeepersSessionTimeOut = (int) ConfigurationTypeHelper .getTimeInMillis(clientConf.get(ClientConfiguration.ClientProperty.INSTANCE_ZK_TIMEOUT)); zooCache = zcf.getZooCache(zooKeepers, zooKeepersSessionTimeOut); if (instanceName != null) { // Validates that the provided instanceName actually exists getInstanceID(); } }
@Override public String getInstanceName() { if (instanceName == null) instanceName = InstanceOperationsImpl.lookupInstanceName(zooCache, UUID.fromString(getInstanceID())); return instanceName; }
public TCredentials getCredentials() throws D4mException { TCredentials tCred; try { // DH2015: Copied from // 1.6: org.apache.accumulo.core.security.Credentials#toThrift() // 1.7: org.apache.accumulo.core.client.impl.Credentials#toThrift() // in order to create compatibility to 1.6 and 1.7, since the Credentials class moved. // This may still break in later versions because Credentials is non-public API. tCred = new TCredentials(principal, token.getClass().getName(), ByteBuffer.wrap(AuthenticationToken.AuthenticationTokenSerializer.serialize(token)), instance.getInstanceID()); if (token.isDestroyed()) throw new RuntimeException("Token has been destroyed", new AccumuloSecurityException(principal, SecurityErrorCode.TOKEN_EXPIRED)); // tCred = this.creds.toThrift(this.instance); //.create(this.conn.getUser(), this.passwordToken, this.instance.getInstanceID() ); } catch (Exception e) { log.warn("",e); throw new D4mException(e); } return tCred; }
String uuid = new ZooKeeperInstance(cluster.getClientConfig()).getInstanceID();
String uuid = new ZooKeeperInstance(cluster.getClientConfig()).getInstanceID();
ZooKeeperInstance(Configuration config, ZooCacheFactory zcf) { checkArgument(config != null, "config is null"); if (config instanceof ClientConfiguration) { this.clientConf = (ClientConfiguration) config; } else { @SuppressWarnings("deprecation") ClientConfiguration cliConf = new ClientConfiguration(config); this.clientConf = cliConf; } this.instanceId = clientConf.get(ClientProperty.INSTANCE_ID); this.instanceName = clientConf.get(ClientProperty.INSTANCE_NAME); if ((instanceId == null) == (instanceName == null)) throw new IllegalArgumentException( "Expected exactly one of instanceName and instanceId to be set"); this.zooKeepers = clientConf.get(ClientProperty.INSTANCE_ZK_HOST); this.zooKeepersSessionTimeOut = (int) AccumuloConfiguration .getTimeInMillis(clientConf.get(ClientProperty.INSTANCE_ZK_TIMEOUT)); zooCache = zcf.getZooCache(zooKeepers, zooKeepersSessionTimeOut); if (null != instanceName) { // Validates that the provided instanceName actually exists getInstanceID(); } }