/** * If in a running state, creates the specified subprocedure for handling a backup procedure. * @return Subprocedure to submit to the ProcedureMemeber. */ public Subprocedure buildSubprocedure(byte[] data) { // don't run a backup if the parent is stop(ping) if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start backup procedure on RS: " + rss.getServerName() + ", because stopping/stopped!"); } LOG.info("Attempting to run a roll log procedure for backup."); ForeignExceptionDispatcher errorDispatcher = new ForeignExceptionDispatcher(); Configuration conf = rss.getConfiguration(); long timeoutMillis = conf.getLong(BACKUP_TIMEOUT_MILLIS_KEY, BACKUP_TIMEOUT_MILLIS_DEFAULT); long wakeMillis = conf.getLong(BACKUP_REQUEST_WAKE_MILLIS_KEY, BACKUP_REQUEST_WAKE_MILLIS_DEFAULT); LogRollBackupSubprocedurePool taskManager = new LogRollBackupSubprocedurePool(rss.getServerName().toString(), conf); return new LogRollBackupSubprocedure(rss, member, errorDispatcher, wakeMillis, timeoutMillis, taskManager, data); }
byte[] encodedNameBytes = regionInfo.getEncodedNameAsBytes(); String regionName = regionInfo.getRegionNameAsString(); Region onlineRegion = rs.getRegion(encodedName); if (onlineRegion != null) { LOG.warn("Received OPEN for the region:{}, which is already online", regionName); Boolean previous = rs.getRegionsInTransitionInRS().putIfAbsent(encodedNameBytes, Boolean.TRUE); if (previous != null) { if (previous) { "Receiving OPEN for the region:{}, which we are trying to close, try again after {}ms", regionName, backoff); rs.getExecutorService().delayedSubmit(this, backoff, TimeUnit.MILLISECONDS); try { TableDescriptor htd = tableDesc != null ? tableDesc : rs.getTableDescriptors().get(regionInfo.getTable()); if (htd == null) { throw new IOException("Missing table descriptor for " + regionName); region = HRegion.openHRegion(regionInfo, htd, rs.getWAL(regionInfo), rs.getConfiguration(), rs, null); } catch (IOException e) { rs.postOpenDeployTasks(new PostOpenDeployContext(region, masterSystemTime)); rs.addRegion(region); LOG.info("Opened {}", regionName); Boolean current = rs.getRegionsInTransitionInRS().remove(regionInfo.getEncodedNameAsBytes()); if (current == null) {
@Override public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit, Durability durability) throws IOException { if (put.getAttribute(DO_ABORT) != null) { // TODO: Change this so it throws a CP Abort Exception instead. RegionServerServices rss = ((HasRegionServerServices)c.getEnvironment()).getRegionServerServices(); String str = "Aborting for test"; LOG.info(str + " " + rss.getServerName()); rss.abort(str, new Throwable(str)); } }
public RegionServerRpcQuotaManager(final RegionServerServices rsServices) { this.rsServices = rsServices; rpcThrottleStorage = new RpcThrottleStorage(rsServices.getZooKeeper(), rsServices.getConfiguration()); }
public RegionSizeReportingChore(RegionServerServices rsServices) { super( RegionSizeReportingChore.class.getSimpleName(), rsServices, getPeriod(rsServices.getConfiguration()), getInitialDelay(rsServices.getConfiguration()), getTimeUnit(rsServices.getConfiguration())); this.rsServices = rsServices; this.metrics = rsServices.getMetrics(); }
public void start() throws IOException { stopped = false; // TODO: This will be replaced once we have the notification bus ready. Configuration conf = rsServices.getConfiguration(); int period = conf.getInt(REFRESH_CONF_KEY, REFRESH_DEFAULT_PERIOD); refreshChore = new QuotaRefresherChore(period, this); rsServices.getChoreService().scheduleChore(refreshChore); }
/** * Initialize this region server flush procedure manager * Uses a zookeeper based member controller. * @param rss region server * @throws KeeperException if the zookeeper cannot be reached */ @Override public void initialize(RegionServerServices rss) throws KeeperException { this.rss = rss; ZKWatcher zkw = rss.getZooKeeper(); this.memberRpcs = new ZKProcedureMemberRpcs(zkw, MasterFlushTableProcedureManager.FLUSH_TABLE_PROCEDURE_SIGNATURE); Configuration conf = rss.getConfiguration(); long keepAlive = conf.getLong(FLUSH_TIMEOUT_MILLIS_KEY, FLUSH_TIMEOUT_MILLIS_DEFAULT); int opThreads = conf.getInt(FLUSH_REQUEST_THREADS_KEY, FLUSH_REQUEST_THREADS_DEFAULT); // create the actual flush table procedure member ThreadPoolExecutor pool = ProcedureMember.defaultPool(rss.getServerName().toString(), opThreads, keepAlive); this.member = new ProcedureMember(memberRpcs, pool, new FlushTableSubprocedureBuilder()); }
/** * Create a mocked region server service instance */ private RegionServerServices getRegionServer(ServerName name) { RegionServerServices mockedServer = mock(RegionServerServices.class); when(mockedServer.getConfiguration()).thenReturn(TEST_UTIL.getConfiguration()); when(mockedServer.getServerName()).thenReturn(name); when(mockedServer.getZooKeeper()).thenReturn(zkw); when(mockedServer.isStopped()).thenReturn(false); when(mockedServer.getExecutorService()).thenReturn(executorService); return mockedServer; }
when(rss.getServerName()).thenReturn(ServerName.valueOf("foo", 1, 1)); when(rss.getConfiguration()).thenReturn(CONF); when(rss.getRegionServerAccounting()).thenReturn(new RegionServerAccounting(CONF)); String string = org.apache.hadoop.hbase.executor.EventType.RS_COMPACTED_FILES_DISCHARGER .toString(); es.startExecutorService( string+"-"+string, 1); when(rss.getExecutorService()).thenReturn(es); primaryRegion = HRegion.createHRegion(primaryHri, rootDir, CONF, htd, walPrimary); primaryRegion.close(); List<HRegion> regions = new ArrayList<>(); regions.add(primaryRegion); Mockito.doReturn(regions).when(rss).getRegions();
RegionServerServices rs = Mockito.mock(RegionServerServices.class); ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null); Mockito.when(rs.getRegionServerAccounting()).thenReturn(rsAccounting); Mockito.when(rs.isAborted()).thenReturn(false); Mockito.when(rs.getNonceManager()).thenReturn(null); Mockito.when(rs.getServerName()).thenReturn(ServerName .valueOf("test", 0, 111));
RegionServerServices mockRS = Mockito.mock(RegionServerServices.class); Mockito.when(mockRS.getWAL()).thenReturn(wal); RegionServerAccounting rsa = Mockito.mock(RegionServerAccounting.class); Mockito.when(mockRS.getRegionServerAccounting()).thenReturn(rsa); ServerName mockServerName = Mockito.mock(ServerName.class); Mockito.when(mockServerName.getServerName()).thenReturn(tableNameStr + "-server-1234"); Mockito.when(mockRS.getServerName()).thenReturn(mockServerName); HRegion region = new HRegion(basedir, wal, this.fs, this.conf, hri, htd, mockRS); long seqid = region.initialize(); Mockito.verify(mockRS, Mockito.times(1)).abort(Mockito.anyString(), Mockito.any(Exception.class)); region.close(true);
@Override public ServerName getServerName() { return this.services.getServerName(); }
@Override public Void call() throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("DRPC started: " + rss.getServerName()); AbstractFSWAL<?> fsWAL = (AbstractFSWAL<?>) rss.getWAL(null); long filenum = fsWAL.getFilenum(); List<WAL> wals = rss.getWALs(); long highest = -1; for (WAL wal : wals) { + " highest: " + highest + " on " + rss.getServerName()); ((HRegionServer) rss).getWalRoller().requestRollAll(); long start = EnvironmentEdgeManager.currentTime(); + " on " + rss.getServerName()); Connection connection = rss.getConnection(); try (final BackupSystemTable table = new BackupSystemTable(connection)) { String host = rss.getServerName().getHostname(); int port = rss.getServerName().getPort(); String server = host + ":" + port; Long sts = serverTimestampMap.get(host);
@Override public void initialize(RegionServerServices rss) throws KeeperException { this.rss = rss; ZKWatcher zkw = rss.getZooKeeper(); this.memberRpcs = new ZKProcedureMemberRpcs(zkw, getProcedureSignature()); ThreadPoolExecutor pool = ProcedureMember.defaultPool(rss.getServerName().toString(), 1); this.member = new ProcedureMember(memberRpcs, pool, new SimleSubprocedureBuilder()); LOG.info("Initialized: " + rss.getServerName().toString()); }
this.rsServices.getWAL(this.regionInfo), this.server.getConfiguration(), this.rsServices,
try { final RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; String serverName = env.getRegionServerServices().getServerName().getServerName(); if (env.getConfiguration().getBoolean(CHECK_VERSION_CONF_KEY, true)) { if (errormsg != null) { IOException ioe = new IOException(errormsg); env.getRegionServerServices().abort(errormsg, ioe); throw ioe; log = env.getRegionServerServices().getWAL();
/** * Start accepting backup procedure requests. */ @Override public void start() { if (!BackupManager.isBackupEnabled(rss.getConfiguration())) { LOG.warn("Backup is not enabled. Check your " + BackupRestoreConstants.BACKUP_ENABLE_KEY + " setting"); return; } this.memberRpcs.start(rss.getServerName().toString(), member); started = true; LOG.info("Started region server backup manager."); }
this.rsServices.getWAL(), this.server.getConfiguration(), this.rsServices, new CancelableProgressable() { this.rsServices.getRegionServerAccounting(); if (rsAccounting != null) { rsAccounting.rollbackRegionReplayEditsSize(this.regionInfo.getRegionName());
Mockito.doReturn(false).when(rsServices).isAborted(); when(rsServices.getServerName()).thenReturn(ServerName.valueOf("foo", 10, 10)); Configuration customConf = new Configuration(this.conf); customConf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY, LOG.info("Expected simulated exception when flushing region, {}", e.getMessage()); Mockito.doReturn(true).when(rsServices).isAborted(); region.setClosing(false); // region normally does not accept writes after Mockito.doReturn(false).when(rsServices).isAborted(); HRegion region2 = HRegion.openHRegion(this.hbaseRootDir, hri, htd, wal2, this.conf, rsServices, null);
@Override protected void handleException(Throwable t) { LOG.warn("Fatal error occured while closing region {}, aborting...", encodedName, t); getServer().abort("Failed to close region " + encodedName + " and can not recover", t); }