38
38
import org .apache .hadoop .hbase .client .RegionInfo ;
39
39
import org .apache .hadoop .hbase .client .RegionLocator ;
40
40
import org .apache .hadoop .hbase .client .Table ;
41
+ import org .apache .hadoop .hbase .master .procedure .ServerCrashProcedure ;
41
42
import org .apache .hadoop .hbase .testclassification .LargeTests ;
42
43
import org .apache .hadoop .hbase .testclassification .MasterTests ;
43
44
import org .apache .hadoop .hbase .util .Bytes ;
@@ -68,6 +69,7 @@ public class TestRollingRestart {
68
69
69
70
private static final Logger LOG = LoggerFactory .getLogger (TestRollingRestart .class );
70
71
72
+ private static HBaseTestingUtility TEST_UTIL ;
71
73
@ Rule
72
74
public TestName name = new TestName ();
73
75
@@ -89,7 +91,7 @@ public void testBasicRollingRestart() throws Exception {
89
91
Configuration conf = HBaseConfiguration .create ();
90
92
conf .setBoolean (HConstants .HBASE_SPLIT_WAL_COORDINATED_BY_ZK ,
91
93
splitWALCoordinatedByZK );
92
- HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility (conf );
94
+ TEST_UTIL = new HBaseTestingUtility (conf );
93
95
StartMiniClusterOption option = StartMiniClusterOption .builder ()
94
96
.numMasters (NUM_MASTERS ).numRegionServers (NUM_RS ).numDataNodes (NUM_RS ).build ();
95
97
TEST_UTIL .startMiniCluster (option );
@@ -220,6 +222,16 @@ public void testBasicRollingRestart() throws Exception {
220
222
TEST_UTIL .shutdownMiniCluster ();
221
223
}
222
224
225
+ /**
226
+ * Checks if the SCP of specific dead server has been executed.
227
+ * @return true if the SCP of specific serverName has been executed, false if not
228
+ */
229
+ private boolean isDeadServerSCPExecuted (ServerName serverName ) throws IOException {
230
+ return TEST_UTIL .getMiniHBaseCluster ().getMaster ().getProcedures ().stream ()
231
+ .anyMatch (p -> p instanceof ServerCrashProcedure
232
+ && ((ServerCrashProcedure ) p ).getServerName ().equals (serverName ));
233
+ }
234
+
223
235
private void waitForRSShutdownToStartAndFinish (MasterThread activeMaster ,
224
236
ServerName serverName ) throws InterruptedException , IOException {
225
237
ServerManager sm = activeMaster .getMaster ().getServerManager ();
@@ -230,6 +242,9 @@ private void waitForRSShutdownToStartAndFinish(MasterThread activeMaster,
230
242
}
231
243
log ("Server [" + serverName + "] marked as dead, waiting for it to " +
232
244
"finish dead processing" );
245
+
246
+ TEST_UTIL .waitFor (60000 , () -> isDeadServerSCPExecuted (serverName ));
247
+
233
248
while (sm .areDeadServersInProgress ()) {
234
249
log ("Server [" + serverName + "] still being processed, waiting" );
235
250
Thread .sleep (100 );
0 commit comments