/** * @param config * Client configuration for specifying connection options. See * {@link ClientConfiguration} which extends Configuration with convenience methods * specific to Accumulo. * @since 1.9.0 */ public ZooKeeperInstance(ClientConfiguration config) { this(config, new ZooCacheFactory()); }
public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path) { this(new ZooCacheFactory().getZooCache(zookeepers, timeInMillis), ZooReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path); }
/** * Return the cached ZooCache for provided context. ZooCache is initially created with a watcher * that will clear the TableMap cache for that instance when WatchedEvent occurs. */ private static ZooCache getZooCache(final ClientContext context) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(TABLES_PERMISSION); } final String uuid = context.getInstanceID(); try { return instanceToZooCache.get(uuid, () -> { final String zks = context.getZooKeepers(); final int timeOut = context.getZooKeepersSessionTimeOut(); return new ZooCacheFactory().getZooCache(zks, timeOut, watchedEvent -> instanceToMapCache.invalidate(uuid)); }); } catch (ExecutionException e) { throw new RuntimeException(e); } }
ServerInfo(SiteConfiguration siteConfig, String instanceName, String zooKeepers, int zooKeepersSessionTimeOut) { SingletonManager.setMode(Mode.SERVER); this.siteConfig = siteConfig; this.hadoopConf = new Configuration(); this.instanceName = instanceName; this.zooKeepers = zooKeepers; this.zooKeepersSessionTimeOut = zooKeepersSessionTimeOut; try { volumeManager = VolumeManagerImpl.get(siteConfig, hadoopConf); } catch (IOException e) { throw new IllegalStateException(e); } zooCache = new ZooCacheFactory().getZooCache(zooKeepers, zooKeepersSessionTimeOut); String instanceNamePath = Constants.ZROOT + Constants.ZINSTANCES + "/" + instanceName; byte[] iidb = zooCache.get(instanceNamePath); if (iidb == null) { throw new RuntimeException("Instance name " + instanceName + " does not exist in zookeeper. " + "Run \"accumulo org.apache.accumulo.server.util.ListInstances\" to see a list."); } instanceID = new String(iidb, UTF_8); if (zooCache.get(Constants.ZROOT + "/" + instanceID) == null) { if (instanceName == null) { throw new RuntimeException("Instance id " + instanceID + " does not exist in zookeeper"); } throw new RuntimeException("Instance id " + instanceID + " pointed to by the name " + instanceName + " does not exist in zookeeper"); } }
ServerInfo(SiteConfiguration config) { SingletonManager.setMode(Mode.SERVER); siteConfig = config; hadoopConf = new Configuration(); try { volumeManager = VolumeManagerImpl.get(siteConfig, hadoopConf); } catch (IOException e) { throw new IllegalStateException(e); } Path instanceIdPath = ServerUtil.getAccumuloInstanceIdPath(volumeManager); instanceID = ZooUtil.getInstanceIDFromHdfs(instanceIdPath, config, hadoopConf); zooKeepers = config.get(Property.INSTANCE_ZK_HOST); zooKeepersSessionTimeOut = (int) config.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT); zooCache = new ZooCacheFactory().getZooCache(zooKeepers, zooKeepersSessionTimeOut); instanceName = InstanceOperationsImpl.lookupInstanceName(zooCache, UUID.fromString(instanceID)); }
/** * @param config * Client configuration for specifying connection options. See * {@link ClientConfiguration} which extends Configuration with convenience methods * specific to Accumulo. * @since 1.9.0 */ public ZooKeeperInstance(ClientConfiguration config) { this(config, new ZooCacheFactory()); }
RootTabletLocator(TabletServerLockChecker lockChecker) { this(lockChecker, new ZooCacheFactory()); }
ZookeeperLockChecker(Instance instance) { this(instance, new ZooCacheFactory()); }
public ClientContext(SingletonReservation reservation, ClientInfo info, AccumuloConfiguration serverConf) { this.info = info; this.hadoopConf = info.getHadoopConf(); zooCache = new ZooCacheFactory().getZooCache(info.getZooKeepers(), info.getZooKeepersSessionTimeOut()); this.serverConf = serverConf; timeoutSupplier = memoizeWithExpiration( () -> getConfiguration().getTimeInMillis(Property.GENERAL_RPC_TIMEOUT)); sslSupplier = memoizeWithExpiration(() -> SslConnectionParams.forClient(getConfiguration())); saslSupplier = memoizeWithExpiration( () -> SaslConnectionParams.from(getConfiguration(), getCredentials().getToken())); this.singletonReservation = Objects.requireNonNull(reservation); this.tableops = new TableOperationsImpl(this); this.namespaceops = new NamespaceOperationsImpl(this, tableops); }
/** * @param config * Client configuration for specifying connection options. See * {@link ClientConfiguration} which extends Configuration with convenience methods * specific to Accumulo. * @since 1.6.0 * @deprecated since 1.9.0; will be removed in 2.0.0 to eliminate commons config leakage into * Accumulo API; use {@link #ZooKeeperInstance(ClientConfiguration)} instead. */ @Deprecated public ZooKeeperInstance(Configuration config) { this(config, new ZooCacheFactory()); }
/** * Gets a configuration object for the given instance with the given parent. Repeated calls will * return the same object. * * @param inst * instance; if null, instance is determined from HDFS * @param parent * parent configuration (required) * @return configuration */ public ZooConfiguration getInstance(Instance inst, AccumuloConfiguration parent) { return getInstance(inst, new ZooCacheFactory(), parent); } }
private static ZooCache getZooCache(Instance instance) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(TABLES_PERMISSION); } return new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); }
public ZooLock(String zookeepers, int timeInMillis, String scheme, byte[] auth, String path) { this(new ZooCacheFactory().getZooCache(zookeepers, timeInMillis), ZooReaderWriter.getInstance(zookeepers, timeInMillis, scheme, auth), path); }
@Override public ZooCache call() { final String zks = instance.getZooKeepers(); final int timeOut = instance.getZooKeepersSessionTimeOut(); return new ZooCacheFactory().getZooCache(zks, timeOut, new Watcher() { @Override public void process(WatchedEvent watchedEvent) { instanceToMapCache.invalidate(uuid); } }); } });
private HdfsZooInstance() { zooCache = new ZooCacheFactory().getZooCache(site.get(Property.INSTANCE_ZK_HOST), (int) site.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT)); }
@Override public List<String> getTabletServers() { Instance instance = context.getInstance(); ZooCache cache = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; List<String> results = new ArrayList<>(); for (String candidate : cache.getChildren(path)) { List<String> children = cache.getChildren(path + "/" + candidate); if (children != null && children.size() > 0) { List<String> copy = new ArrayList<>(children); Collections.sort(copy); byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0)); if (data != null && !"master".equals(new String(data, UTF_8))) { results.add(candidate); } } } return results; }
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); } }
ZooCache zc = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); for (String tserver : zc.getChildren(ZooUtil.getRoot(instance) + Constants.ZTSERVERS)) {
private static void stopTabletServer(final ClientContext context, List<String> servers, final boolean force) throws AccumuloException, AccumuloSecurityException { if (context.getInstance().getMasterLocations().size() == 0) { log.info("No masters running. Not attempting safe unload of tserver."); return; } final Instance instance = context.getInstance(); final String zTServerRoot = getTServersZkPath(instance); final ZooCache zc = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); for (String server : servers) { for (int port : context.getConfiguration().getPort(Property.TSERV_CLIENTPORT)) { HostAndPort address = AddressUtil.parseAddress(server, port); final String finalServer = qualifyWithZooKeeperSessionId(zTServerRoot, zc, address.toString()); log.info("Stopping server " + finalServer); MasterClient.execute(context, new ClientExec<MasterClientService.Client>() { @Override public void execute(MasterClientService.Client client) throws Exception { client.shutdownTabletServer(Tracer.traceInfo(), context.rpcCreds(), finalServer, force); } }); } } }
LockID lid = new LockID(ZooUtil.getRoot(instance) + Constants.ZTSERVERS, sessionId.lockId); ZooCacheFactory zcf = new ZooCacheFactory(); while (true) { if (!ZooLock.isLockHeld(