/** * @return server name */ public ServerName getServerName() { return master.getServerName(); } }
@Override public ServerName getServerName() { return this.services.getServerName(); }
RSGroupStartupWorker() { super(RSGroupStartupWorker.class.getName() + "-" + masterServices.getServerName()); setDaemon(true); }
public void shutdownCluster() { String statusStr = "Cluster shutdown requested of master=" + this.master.getServerName(); LOG.info(statusStr); this.clusterShutdown.set(true); if (onlineServers.isEmpty()) { // we do not synchronize here so this may cause a double stop, but not a big deal master.stop("OnlineServer=0 right after cluster shutdown set"); } }
private void startAssignmentThread() { // Get Server Thread name. Sometimes the Server is mocked so may not implement HasThread. // For example, in tests. String name = master instanceof HasThread? ((HasThread)master).getName(): master.getServerName().toShortString(); assignThread = new Thread(name) { @Override public void run() { while (isRunning()) { processAssignQueue(); } pendingAssignQueue.clear(); } }; assignThread.setDaemon(true); assignThread.start(); }
@Override public void run() { setName(ServerEventsListenerThread.class.getName() + "-" + masterServices.getServerName()); SortedSet<Address> prevDefaultServers = new TreeSet<>(); while (isMasterRunning(masterServices)) { try { LOG.info("Updating default servers."); SortedSet<Address> servers = RSGroupInfoManagerImpl.this.getDefaultServers(); if (!servers.equals(prevDefaultServers)) { RSGroupInfoManagerImpl.this.updateDefaultServers(servers); prevDefaultServers = servers; LOG.info("Updated with servers: " + servers.size()); } try { synchronized (this) { while (!changed) { wait(); } changed = false; } } catch (InterruptedException e) { LOG.warn("Interrupted", e); } } catch (IOException e) { LOG.warn("Failed to update default servers", e); } } } }
@Override public void setMasterServices(MasterServices masterServices) { masterServerName = masterServices.getServerName(); this.services = masterServices; if (useRegionFinder) { this.regionFinder.setServices(masterServices); } if (this.services.isInMaintenanceMode()) { this.maintenanceMode = true; } }
CatalogJanitor(final MasterServices services) { super("CatalogJanitor-" + services.getServerName().toShortString(), services, services.getConfiguration().getInt("hbase.catalogjanitor.interval", 300000)); this.services = services; this.connection = services.getConnection(); }
@Override public void cancel(String why) { if (finished) return; this.finished = true; LOG.info("Stop taking snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) + " because: " + why); CancellationException ce = new CancellationException(why); monitor.receive(new ForeignException(master.getServerName().toString(), ce)); }
/** * @param sn * @return Admin interface for the remote regionserver named <code>sn</code> * @throws IOException * @throws RetriesExhaustedException wrapping a ConnectException if failed */ public AdminService.BlockingInterface getRsAdmin(final ServerName sn) throws IOException { AdminService.BlockingInterface admin = this.rsAdmins.get(sn); if (admin == null) { LOG.debug("New admin connection to " + sn.toString()); if (sn.equals(master.getServerName()) && master instanceof HRegionServer) { // A master is also a region server now, see HBASE-10569 for details admin = ((HRegionServer)master).getRSRpcServices(); } else { admin = this.connection.getAdmin(sn); } this.rsAdmins.put(sn, admin); } return admin; }
void letRegionServersShutdown() { long previousLogTime = 0; ServerName sn = master.getServerName(); ZKWatcher zkw = master.getZooKeeper(); int onlineServersCt;
@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 initialize(MasterServices master, MetricsMaster metricsMaster) throws IOException, UnsupportedOperationException { this.master = master; this.done = false; // setup the default procedure coordinator String name = master.getServerName().toString(); // get the configuration for the coordinator Configuration conf = master.getConfiguration(); long wakeFrequency = conf.getInt(BACKUP_WAKE_MILLIS_KEY, BACKUP_WAKE_MILLIS_DEFAULT); long timeoutMillis = conf.getLong(BACKUP_TIMEOUT_MILLIS_KEY,BACKUP_TIMEOUT_MILLIS_DEFAULT); int opThreads = conf.getInt(BACKUP_POOL_THREAD_NUMBER_KEY, BACKUP_POOL_THREAD_NUMBER_DEFAULT); // setup the default procedure coordinator ThreadPoolExecutor tpool = ProcedureCoordinator.defaultPool(name, opThreads); ProcedureCoordinationManager coordManager = new ZKProcedureCoordinationManager(master); ProcedureCoordinatorRpcs comms = coordManager.getProcedureCoordinatorRpcs(getProcedureSignature(), name); this.coordinator = new ProcedureCoordinator(comms, tpool, timeoutMillis, wakeFrequency); }
@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); }
master.getServerName().toShortString(); this.choreService = new ChoreService(name + ".splitLogManager.");
if (serverName.equals(master.getServerName())) { if (!(master.isAborted() || master.isStopped())) { master.stop("We lost our znode?"); LOG.info("Processing expiration of " + serverName + " on " + this.master.getServerName()); long pid = master.getAssignmentManager().submitServerCrash(serverName, true); if(pid <= 0) {
@BeforeClass public static void beforeAllTests() throws Exception { Configuration conf = HBaseConfiguration.create(); conf.setClass("hbase.util.ip.to.rack.determiner", MockMapping.class, DNSToSwitchMapping.class); loadBalancer = new MockBalancer(); loadBalancer.setConf(conf); MasterServices st = Mockito.mock(MasterServices.class); Mockito.when(st.getServerName()).thenReturn(master); loadBalancer.setMasterServices(st); // Set up the rack topologies (5 machines per rack) rackManager = Mockito.mock(RackManager.class); for (int i = 0; i < NUM_SERVERS; i++) { servers[i] = ServerName.valueOf("foo"+i+":1234",-1); if (i < 5) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack1"); } if (i >= 5 && i < 10) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack2"); } if (i >= 10) { Mockito.when(rackManager.getRack(servers[i])).thenReturn("rack3"); } } }
public SwitchRpcThrottleResponse switchRpcThrottle(SwitchRpcThrottleRequest request) throws IOException { boolean rpcThrottle = request.getRpcThrottleEnabled(); if (initialized) { masterServices.getMasterCoprocessorHost().preSwitchRpcThrottle(rpcThrottle); boolean oldRpcThrottle = rpcThrottleStorage.isRpcThrottleEnabled(); if (rpcThrottle != oldRpcThrottle) { LOG.info("{} switch rpc throttle from {} to {}", masterServices.getClientIdAuditPrefix(), oldRpcThrottle, rpcThrottle); ProcedurePrepareLatch latch = ProcedurePrepareLatch.createBlockingLatch(); SwitchRpcThrottleProcedure procedure = new SwitchRpcThrottleProcedure(rpcThrottleStorage, rpcThrottle, masterServices.getServerName(), latch); masterServices.getMasterProcedureExecutor().submitProcedure(procedure); latch.await(); } else { LOG.warn("Skip switch rpc throttle to {} because it's the same with old value", rpcThrottle); } SwitchRpcThrottleResponse response = SwitchRpcThrottleResponse.newBuilder() .setPreviousRpcThrottleEnabled(oldRpcThrottle).build(); masterServices.getMasterCoprocessorHost().postSwitchRpcThrottle(oldRpcThrottle, rpcThrottle); return response; } else { LOG.warn("Skip switch rpc throttle to {} because rpc quota is disabled", rpcThrottle); return SwitchRpcThrottleResponse.newBuilder().setPreviousRpcThrottleEnabled(false).build(); } }
@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); }
LOG.error(msg, e); monitorException.receive( new ForeignException(env.getMasterServices().getServerName().toString(), e)); throw new IOException(msg, e);