private void updateMetaLocation(RegionInfo regionInfo, ServerName serverName, State state) throws IOException { try { MetaTableLocator.setMetaLocation(master.getZooKeeper(), serverName, regionInfo.getReplicaId(), state); } catch (KeeperException e) { throw new IOException(e); } }
private RSGroupInfoManagerImpl(MasterServices masterServices) throws IOException { this.masterServices = masterServices; this.watcher = masterServices.getZooKeeper(); this.conn = masterServices.getConnection(); this.rsGroupStartupWorker = new RSGroupStartupWorker(); }
/** * Utility method that knows how to delete the old hbase-1.x table state znode. Used also by the * Mirroring subclass. * @deprecated Since 2.0.0. To be removed in hbase-3.0.0. */ @Deprecated protected void deleteZooKeeper(TableName tableName) { try { // Delete from ZooKeeper String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode, tableName.getNameAsString()); ZKUtil.deleteNodeFailSilent(this.master.getZooKeeper(), znode); } catch (KeeperException e) { LOG.warn("Failed deleting table state from zookeeper", e); } } }
protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException { int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000); try { if (MetaTableLocator.waitMetaRegionLocation(env.getMasterServices().getZooKeeper(), timeout) == null) { throw new NotAllMetaRegionsOnlineException(); } } catch (InterruptedException e) { throw (InterruptedIOException) new InterruptedIOException().initCause(e); } }
void letRegionServersShutdown() { long previousLogTime = 0; ServerName sn = master.getServerName(); ZKWatcher zkw = master.getZooKeeper(); int onlineServersCt; while ((onlineServersCt = onlineServers.size()) > 0){
.queryForTableStates(this.master.getZooKeeper()).entrySet()) { if (this.master.getTableDescriptors().get(entry.getKey()) == null) { deleteZooKeeper(entry.getKey());
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(FLUSH_WAKE_MILLIS_KEY, FLUSH_WAKE_MILLIS_DEFAULT); long timeoutMillis = conf.getLong(FLUSH_TIMEOUT_MILLIS_KEY, FLUSH_TIMEOUT_MILLIS_DEFAULT); int threads = conf.getInt(FLUSH_PROC_POOL_THREADS_KEY, FLUSH_PROC_POOL_THREADS_DEFAULT); // setup the procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, threads); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinator( master.getZooKeeper(), getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); }
@Override public void start(CoprocessorEnvironment env) throws IOException { if (!(env instanceof HasMasterServices)) { throw new IOException("Does not implement HMasterServices"); } master = ((HasMasterServices)env).getMasterServices(); groupInfoManager = RSGroupInfoManagerImpl.getInstance(master); groupAdminServer = new RSGroupAdminServer(master, groupInfoManager); Class<?> clazz = master.getConfiguration().getClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, null); if (!RSGroupableBalancer.class.isAssignableFrom(clazz)) { throw new IOException("Configured balancer does not support RegionServer groups."); } ZKWatcher zk = ((HasMasterServices)env).getMasterServices().getZooKeeper(); accessChecker = new AccessChecker(env.getConfiguration(), zk); // set the user-provider. this.userProvider = UserProvider.instantiate(env.getConfiguration()); }
private void updateZooKeeper(TableState tableState) throws IOException { if (tableState == null) { return; } String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode, tableState.getTableName().getNameAsString()); try { // Make sure znode exists. if (ZKUtil.checkExists(this.master.getZooKeeper(), znode) == -1) { ZKUtil.createAndFailSilent(this.master.getZooKeeper(), znode); } // Now set newState ZooKeeperProtos.DeprecatedTableState.Builder builder = ZooKeeperProtos.DeprecatedTableState.newBuilder(); builder.setState( ZooKeeperProtos.DeprecatedTableState.State.valueOf(tableState.getState().toString())); byte[] data = ProtobufUtil.prependPBMagic(builder.build().toByteArray()); ZKUtil.setData(this.master.getZooKeeper(), znode, data); } catch (KeeperException e) { // Only hbase1 clients suffer if this fails. LOG.warn("Failed setting table state to zookeeper mirrored for hbase-1.x clients", e); } }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.rootDir = master.getMasterFileSystem().getRootDir(); checkSnapshotSupport(master.getConfiguration(), master.getMasterFileSystem()); // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(SNAPSHOT_WAKE_MILLIS_KEY, SNAPSHOT_WAKE_MILLIS_DEFAULT); long timeoutMillis = Math.max(conf.getLong(SnapshotDescriptionUtils.SNAPSHOT_TIMEOUT_MILLIS_KEY, SnapshotDescriptionUtils.SNAPSHOT_TIMEOUT_MILLIS_DEFAULT), conf.getLong(SnapshotDescriptionUtils.MASTER_SNAPSHOT_TIMEOUT_MILLIS, SnapshotDescriptionUtils.DEFAULT_MAX_WAIT_TIME)); int opThreads = conf.getInt(SNAPSHOT_POOL_THREADS_KEY, SNAPSHOT_POOL_THREADS_DEFAULT); // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, opThreads); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinator( master.getZooKeeper(), SnapshotManager.ONLINE_SNAPSHOT_CONTROLLER_DESCRIPTION, name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); this.executorService = master.getExecutorService(); resetTempDir(); snapshotHandlerChoreCleanerTask = scheduleThreadPool.scheduleAtFixedRate(this::cleanupSentinels, 10, 10, TimeUnit.SECONDS); }
List<RegionInfo> regions; if (TableName.META_TABLE_NAME.equals(tableName)) { regions = MetaTableLocator.getMetaRegions(services.getZooKeeper()); } else { regions = MetaTableAccessor.getTableRegions(services.getConnection(), tableName);
public void start() throws IOException { // If the user doesn't want the quota support skip all the initializations. if (!QuotaUtil.isQuotaEnabled(masterServices.getConfiguration())) { LOG.info("Quota support disabled"); return; } // Create the quota table if missing if (!MetaTableAccessor.tableExists(masterServices.getConnection(), QuotaUtil.QUOTA_TABLE_NAME)) { LOG.info("Quota table not found. Creating..."); createQuotaTable(); } LOG.info("Initializing quota support"); namespaceLocks = new NamedLock<>(); tableLocks = new NamedLock<>(); userLocks = new NamedLock<>(); regionServerLocks = new NamedLock<>(); regionSizes = new ConcurrentHashMap<>(); namespaceQuotaManager = new NamespaceAuditor(masterServices); namespaceQuotaManager.start(); initialized = true; rpcThrottleStorage = new RpcThrottleStorage(masterServices.getZooKeeper(), masterServices.getConfiguration()); }
public void start() throws IOException, KeeperException { if (!running.compareAndSet(false, true)) { return; } LOG.trace("Starting assignment manager"); // Start the Assignment Thread startAssignmentThread(); // load meta region state ZKWatcher zkw = master.getZooKeeper(); // it could be null in some tests if (zkw != null) { RegionState regionState = MetaTableLocator.getMetaRegionState(zkw); RegionStateNode regionNode = regionStates.getOrCreateRegionStateNode(RegionInfoBuilder.FIRST_META_REGIONINFO); regionNode.lock(); try { regionNode.setRegionLocation(regionState.getServerName()); regionNode.setState(regionState.getState()); setMetaAssigned(regionState.getRegion(), regionState.getState() == State.OPEN); } finally { regionNode.unlock(); } } }
master.getZooKeeper()); } else { regionsAndLocations = MetaTableAccessor.getTableRegionsAndLocations(
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.done = false; // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, 1); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinator( master.getZooKeeper(), getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool); }
zk = ((HasMasterServices)mEnv).getMasterServices().getZooKeeper();
private RSGroupInfoManagerImpl(MasterServices masterServices) throws IOException { this.masterServices = masterServices; this.watcher = masterServices.getZooKeeper(); this.conn = masterServices.getClusterConnection(); }
private RSGroupInfoManagerImpl(MasterServices masterServices) throws IOException { this.masterServices = masterServices; this.watcher = masterServices.getZooKeeper(); this.conn = masterServices.getClusterConnection(); }
protected static void waitMetaRegions(final MasterProcedureEnv env) throws IOException { int timeout = env.getMasterConfiguration().getInt("hbase.client.catalog.timeout", 10000); try { if (env.getMasterServices().getMetaTableLocator().waitMetaRegionLocation( env.getMasterServices().getZooKeeper(), timeout) == null) { throw new NotAllMetaRegionsOnlineException(); } } catch (InterruptedException e) { throw (InterruptedIOException)new InterruptedIOException().initCause(e); } }
@Override public void initialize(MasterServices master, MetricsMaster metricsMaster) throws KeeperException, IOException, UnsupportedOperationException { this.master = master; this.done = false; // setup the default procedure coordinator String name = master.getServerName().toString(); ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, 1); ProcedureCoordinatorRpcs comms = new ZKProcedureCoordinator( master.getZooKeeper(), getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool); }