@Before public void setUp() throws Exception { util = new HBaseTestingUtility(); this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder() .setUncaughtExceptionHandler((t, e) -> LOG.warn("Uncaught: ", e)).build()); setupConfiguration(util.getConfiguration()); master = new MockMasterServices(util.getConfiguration(), this.regionsToRegionServers); rsDispatcher = new MockRSProcedureDispatcher(master); master.start(NSERVERS, rsDispatcher); newRsAdded = 0; am = master.getAssignmentManager(); assignProcMetrics = am.getAssignmentManagerMetrics().getAssignProcMetrics(); unassignProcMetrics = am.getAssignmentManagerMetrics().getUnassignProcMetrics(); setUpMeta(); }
@Override public void abortProcess() { abort("The Procedure Store lost the lease", null); } });
Path rootdir = this.masterServices.getMasterFileSystem().getRootDir(); Path storedir = HStore.getStoreHomedir(tabledir, parent, td.getColumnFamilies()[0].getName()); Path storeArchive = HFileArchiveUtil.getStoreArchivePath(this.masterServices.getConfiguration(), parent, tabledir, td.getColumnFamilies()[0].getName()); LOG.debug("Table dir:" + tabledir); Path parentDir = new Path(tabledir, parent.getEncodedName()); ProcedureTestingUtility.waitAllProcedures(masterServices.getMasterProcedureExecutor()); assertTrue(!fs.exists(parentDir)); LOG.debug("Finished cleanup of parent region");
@Before public void setup() throws IOException, KeeperException { setRootDirAndCleanIt(HTU, this.name.getMethodName()); NavigableMap<ServerName, SortedSet<byte []>> regionsToRegionServers = new ConcurrentSkipListMap<ServerName, SortedSet<byte []>>(); this.masterServices = new MockMasterServices(HTU.getConfiguration(), regionsToRegionServers); this.masterServices.start(10, null); this.janitor = new CatalogJanitor(masterServices); }
Path rootdir = this.masterServices.getMasterFileSystem().getRootDir(); Path tabledir = FSUtils.getTableDir(rootdir, td.getTableName()); Path parentdir = new Path(tabledir, parent.getEncodedName()); FileSystem fs = this.masterServices.getMasterFileSystem().getFileSystem(); Path path = ref.write(fs, p); assertTrue(fs.exists(path)); ProcedureTestingUtility.waitAllProcedures(masterServices.getMasterProcedureExecutor()); assertTrue(fs.exists(parentdir)); assertTrue(this.janitor.cleanParent(parent, r)); ProcedureTestingUtility.waitAllProcedures(masterServices.getMasterProcedureExecutor()); assertTrue(!fs.exists(parentdir));
protected Future<byte[]> submitProcedure(final Procedure<MasterProcedureEnv> proc) { return ProcedureSyncWait.submitProcedure(master.getMasterProcedureExecutor(), proc); }
@Before public void before() throws IOException { String methodName = this.name.getMethodName(); this.ms = new MockMasterServices(HTU.getConfiguration(), null); this.mch = new MasterCoprocessorHost(this.ms, HTU.getConfiguration()); this.mch.preMasterInitialization(); }
HConnectionTestingUtility.getMockedConnectionAndDecorate(getConfiguration(), Mockito.mock(AdminProtos.AdminService.BlockingInterface.class), ri, MOCK_MASTER_SERVERNAME, RegionInfoBuilder.FIRST_META_REGIONINFO); Path rootdir = FSUtils.getRootDir(getConfiguration()); FSUtils.setRootDir(getConfiguration(), rootdir); Mockito.mock(AdminProtos.AdminService.BlockingInterface.class);
protected void doCrash(final ServerName serverName) { this.master.getServerManager().moveFromOnlineToDeadServers(serverName); this.am.submitServerCrash(serverName, false/* No WALs here */); // add a new server to avoid killing all the region servers which may hang the UTs ServerName newSn = ServerName.valueOf("localhost", 10000 + newRsAdded, 1); newRsAdded++; try { this.master.getServerManager().regionServerReport(newSn, ServerMetricsBuilder.of(newSn)); } catch (YouAreDeadException e) { // should not happen throw new UncheckedIOException(e); } }
private void stopProcedureExecutor() { if (this.procedureEnv != null) { this.procedureEnv.getRemoteDispatcher().stop(); } if (this.procedureExecutor != null) { this.procedureExecutor.stop(); } if (this.procedureStore != null) { this.procedureStore.stop(isAborted()); } }
protected void doRestart(final ServerName serverName) { try { this.master.restartRegionServer(serverName); } catch (IOException e) { LOG.warn("Can not restart RS with new startcode"); } }
@Override protected boolean waitServerReportEvent(ServerName serverName, Procedure proc) { // Make a report with current state of the server 'serverName' before we call wait.. SortedSet<byte []> regions = regionsToRegionServers.get(serverName); try { getAssignmentManager().reportOnlineRegions(serverName, regions == null? new HashSet<byte []>(): regions); } catch (YouAreDeadException e) { throw new RuntimeException(e); } return super.waitServerReportEvent(serverName, proc); } };
protected byte[] waitOnFuture(final Future<byte[]> future) throws Exception { try { return future.get(3, TimeUnit.MINUTES); } catch (ExecutionException e) { LOG.info("ExecutionException", e); Exception ee = (Exception) e.getCause(); if (ee instanceof InterruptedIOException) { for (Procedure<?> p : this.master.getMasterProcedureExecutor().getProcedures()) { LOG.info(p.toStringDetails()); } } throw (Exception) e.getCause(); } }
@Before public void setup() throws IOException, KeeperException { setRootDirAndCleanIt(HTU, this.name.getMethodName()); NavigableMap<ServerName, SortedSet<byte []>> regionsToRegionServers = new ConcurrentSkipListMap<ServerName, SortedSet<byte []>>(); this.masterServices = new MockMasterServices(HTU.getConfiguration(), regionsToRegionServers); this.masterServices.start(10, null); this.janitor = new CatalogJanitor(masterServices); }
Path rootdir = this.masterServices.getMasterFileSystem().getRootDir(); Path tabledir = FSUtils.getTableDir(rootdir, td.getTableName()); Path parentdir = new Path(tabledir, parent.getEncodedName()); FileSystem fs = this.masterServices.getMasterFileSystem().getFileSystem(); Path path = ref.write(fs, p); assertTrue(fs.exists(path)); ProcedureTestingUtility.waitAllProcedures(masterServices.getMasterProcedureExecutor()); assertTrue(fs.exists(parentdir)); assertTrue(this.janitor.cleanParent(parent, r)); ProcedureTestingUtility.waitAllProcedures(masterServices.getMasterProcedureExecutor()); assertTrue(!fs.exists(parentdir));
/** * Test the new prepare step. * If cluster is down, procedure should skip the assign by returning NO_MORE_STATE */ @Test public void testPrepareWithNoCluster() throws ProcedureSuspendedException, ProcedureYieldException, InterruptedException, IOException { RecoverMetaProcedure rmp = new RecoverMetaProcedure(); MasterProcedureEnv env = Mockito.mock(MasterProcedureEnv.class); MasterServices masterServices = new MockMasterServices(UTIL.getConfiguration(), null) { @Override public boolean isClusterUp() { return false; } }; Mockito.when(env.getMasterServices()).thenReturn(masterServices); assertEquals(StateMachineProcedure.Flow.NO_MORE_STATE, rmp.executeFromState(env, rmp.getInitialState())); } }
private void startProcedureExecutor(final RSProcedureDispatcher remoteDispatcher) throws IOException { final Configuration conf = getConfiguration(); this.procedureStore = new NoopProcedureStore(); this.procedureStore.registerListener(new ProcedureStoreListener() { @Override public void abortProcess() { abort("The Procedure Store lost the lease", null); } }); this.procedureEnv = new MasterProcedureEnv(this, remoteDispatcher != null ? remoteDispatcher : new RSProcedureDispatcher(this)); this.procedureExecutor = new ProcedureExecutor<>(conf, procedureEnv, procedureStore, procedureEnv.getProcedureScheduler()); final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, Math.max(Runtime.getRuntime().availableProcessors(), MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS)); final boolean abortOnCorruption = conf.getBoolean( MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION, MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION); this.procedureStore.start(numThreads); ProcedureTestingUtility.initAndStartWorkers(procedureExecutor, numThreads, abortOnCorruption); this.procedureEnv.getRemoteDispatcher().start(); }
@Override public ExecuteProceduresResponse sendRequest(ServerName server, ExecuteProceduresRequest req) throws IOException { // SocketTimeoutException should be a temporary problem // unless the server will be declared dead. if (sockTimeoutRetries++ < maxSocketTimeoutRetries) { if (sockTimeoutRetries == 1) { assertNotEquals(lastServer, server); } lastServer = server; LOG.debug("Socket timeout for server=" + server + " retries=" + sockTimeoutRetries); throw new SocketTimeoutException("simulate socket timeout"); } else if (serverRetries++ < maxServerRetries) { LOG.info("Mark server=" + server + " as dead. serverRetries=" + serverRetries); master.getServerManager().moveFromOnlineToDeadServers(server); sockTimeoutRetries = 0; throw new SocketTimeoutException("simulate socket timeout"); } else { return super.sendRequest(server, req); } } }
private void stopProcedureExecutor() { if (this.procedureEnv != null) { this.procedureEnv.getRemoteDispatcher().stop(); } if (this.procedureExecutor != null) { this.procedureExecutor.stop(); } if (this.procedureStore != null) { this.procedureStore.stop(isAborted()); } }
private void doRestart(final ServerName serverName) { try { this.master.restartRegionServer(serverName); } catch (IOException e) { LOG.warn("Can not restart RS with new startcode"); } }