/** * 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); }
/** * 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; }
if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start flush region subprocedure on RS: " + rss.getServerName() + ", because stopping/stopped!");
if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start snapshot on RS: " + rss.getServerName() + ", because stopping/stopped!");
/** * If in a running state, creates the specified subprocedure for handling a procedure. * @return Subprocedure to submit to the ProcedureMemeber. */ public Subprocedure buildSubprocedure(String name) { // don't run a procedure if the parent is stop(ping) if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start procedure on RS: " + rss.getServerName() + ", because stopping/stopped!"); } LOG.info("Attempting to run a procedure."); ForeignExceptionDispatcher errorDispatcher = new ForeignExceptionDispatcher(); Configuration conf = rss.getConfiguration(); SimpleSubprocedurePool taskManager = new SimpleSubprocedurePool(rss.getServerName().toString(), conf); return new SimpleSubprocedure(rss, member, errorDispatcher, taskManager, name); }
/** * Test that a regionserver is able to abort properly, even when a coprocessor * throws an exception in preStopRegionServer(). */ @Test public void testAbortFromRPC() throws Exception { TableName tableName = TableName.valueOf("testAbortFromRPC"); // create a test table Table table = testUtil.createTable(tableName, FAMILY_BYTES); // write some edits testUtil.loadTable(table, FAMILY_BYTES); LOG.info("Wrote data"); // force a flush cluster.flushcache(tableName); LOG.info("Flushed table"); // Send a poisoned put to trigger the abort Put put = new Put(new byte[]{0, 0, 0, 0}); put.addColumn(FAMILY_BYTES, Bytes.toBytes("c"), new byte[]{}); put.setAttribute(StopBlockingRegionObserver.DO_ABORT, new byte[]{1}); List<HRegion> regions = cluster.findRegionsForTable(tableName); HRegion firstRegion = cluster.findRegionsForTable(tableName).get(0); table.put(put); // Verify that the regionserver is stopped assertNotNull(firstRegion); assertNotNull(firstRegion.getRegionServerServices()); LOG.info("isAborted = " + firstRegion.getRegionServerServices().isAborted()); assertTrue(firstRegion.getRegionServerServices().isAborted()); LOG.info("isStopped = " + firstRegion.getRegionServerServices().isStopped()); assertTrue(firstRegion.getRegionServerServices().isStopped()); }
/** * 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; }
if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start snapshot on RS: " + rss.getServerName() + ", because stopping/stopped!");
if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start flush region subprocedure on RS: " + rss.getServerName() + ", because stopping/stopped!");
/** * If in a running state, creates the specified subprocedure for handling a procedure. * @return Subprocedure to submit to the ProcedureMemeber. */ public Subprocedure buildSubprocedure(String name) { // don't run a procedure if the parent is stop(ping) if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start procedure on RS: " + rss.getServerName() + ", because stopping/stopped!"); } LOG.info("Attempting to run a procedure."); ForeignExceptionDispatcher errorDispatcher = new ForeignExceptionDispatcher(); Configuration conf = rss.getConfiguration(); SimpleSubprocedurePool taskManager = new SimpleSubprocedurePool(rss.getServerName().toString(), conf); return new SimpleSubprocedure(rss, member, errorDispatcher, taskManager, name); }
if (rss.isStopping() || rss.isStopped()) { throw new IllegalStateException("Can't start snapshot on RS: " + rss.getServerName() + ", because stopping/stopped!");
/** * Test that a regionserver is able to abort properly, even when a coprocessor * throws an exception in preStopRegionServer(). */ @Test public void testAbortFromRPC() throws Exception { TableName tableName = TableName.valueOf("testAbortFromRPC"); // create a test table Table table = testUtil.createTable(tableName, FAMILY_BYTES); // write some edits testUtil.loadTable(table, FAMILY_BYTES); LOG.info("Wrote data"); // force a flush cluster.flushcache(tableName); LOG.info("Flushed table"); // Send a poisoned put to trigger the abort Put put = new Put(new byte[]{0, 0, 0, 0}); put.addColumn(FAMILY_BYTES, Bytes.toBytes("c"), new byte[]{}); put.setAttribute(StopBlockingRegionObserver.DO_ABORT, new byte[]{1}); List<HRegion> regions = cluster.findRegionsForTable(tableName); HRegion firstRegion = cluster.findRegionsForTable(tableName).get(0); table.put(put); // Verify that the regionserver is stopped assertNotNull(firstRegion); assertNotNull(firstRegion.getRegionServerServices()); LOG.info("isAborted = " + firstRegion.getRegionServerServices().isAborted()); assertTrue(firstRegion.getRegionServerServices().isAborted()); LOG.info("isStopped = " + firstRegion.getRegionServerServices().isStopped()); assertTrue(firstRegion.getRegionServerServices().isStopped()); }