@@ -61,54 +61,53 @@ public void test() throws Exception {
61
61
UTIL .waitFor (60000 , () -> UTIL .getMiniHBaseCluster ().getMaster ().isInitialized ());
62
62
// wait for all SCPs finished
63
63
UTIL .waitFor (60000 , () -> UTIL .getHBaseCluster ().getMaster ().getProcedures ().stream ()
64
- .noneMatch (p -> p instanceof ServerCrashProcedure ));
64
+ .noneMatch (p -> p instanceof ServerCrashProcedure ));
65
65
TableName tableName = TABLES [0 ];
66
66
ServerName testServer = UTIL .getHBaseCluster ().getRegionServer (0 ).getServerName ();
67
67
UTIL .waitFor (30000 , () -> getServerStateNode (testServer ) != null );
68
68
ServerStateNode serverNode = getServerStateNode (testServer );
69
69
Assert .assertNotNull (serverNode );
70
70
Assert .assertTrue ("serverNode should be ONLINE when cluster runs normally" ,
71
- serverNode .isInState (ServerState .ONLINE ));
71
+ serverNode .isInState (ServerState .ONLINE ));
72
72
UTIL .createMultiRegionTable (tableName , FAMILY );
73
73
UTIL .waitTableEnabled (tableName );
74
74
Table table = UTIL .getConnection ().getTable (tableName );
75
75
for (int i = 0 ; i < 100 ; i ++) {
76
76
UTIL .loadTable (table , FAMILY );
77
77
}
78
78
List <Integer > ports =
79
- UTIL .getHBaseCluster ().getMaster ().getServerManager ().getOnlineServersList ().stream ()
80
- .map (serverName -> serverName .getPort ()).collect (Collectors .toList ());
79
+ UTIL .getHBaseCluster ().getMaster ().getServerManager ().getOnlineServersList ().stream ()
80
+ .map (serverName -> serverName .getPort ()).collect (Collectors .toList ());
81
81
LOG .info ("Shutting down cluster" );
82
82
UTIL .getHBaseCluster ().killAll ();
83
83
UTIL .getHBaseCluster ().waitUntilShutDown ();
84
84
LOG .info ("Starting cluster the second time" );
85
85
UTIL .restartHBaseCluster (3 , ports );
86
86
UTIL .waitFor (30000 , () -> UTIL .getHBaseCluster ().getMaster ().isInitialized ());
87
87
serverNode = UTIL .getHBaseCluster ().getMaster ().getAssignmentManager ().getRegionStates ()
88
- .getServerNode (testServer );
89
- Assert .assertNotNull ("serverNode should not be null when restart whole cluster" , serverNode );
90
- Assert .assertFalse (serverNode .isInState (ServerState .ONLINE ));
91
- LOG .info ("start to find the procedure of SCP for the severName we choose" );
92
- UTIL .waitFor (60000 ,
93
- () -> UTIL .getHBaseCluster ().getMaster ().getProcedures ().stream ()
94
- .anyMatch (procedure -> (procedure instanceof ServerCrashProcedure ) &&
95
- ((ServerCrashProcedure ) procedure ).getServerName ().equals (testServer )));
96
- Assert .assertFalse ("serverNode should not be ONLINE during SCP processing" ,
97
- serverNode .isInState (ServerState .ONLINE ));
98
- LOG .info ("start to submit the SCP for the same serverName {} which should fail" , testServer );
99
- Assert
100
- .assertFalse (UTIL .getHBaseCluster ().getMaster ().getServerManager ().expireServer (testServer ));
101
- Procedure <?> procedure = UTIL .getHBaseCluster ().getMaster ().getProcedures ().stream ()
102
- .filter (p -> (p instanceof ServerCrashProcedure ) &&
103
- ((ServerCrashProcedure ) p ).getServerName ().equals (testServer ))
104
- .findAny ().get ();
105
- UTIL .waitFor (60000 , () -> procedure .isFinished ());
106
- LOG .info ("even when the SCP is finished, the duplicate SCP should not be scheduled for {}" ,
107
- testServer );
108
- Assert
109
- .assertFalse (UTIL .getHBaseCluster ().getMaster ().getServerManager ().expireServer (testServer ));
110
- serverNode = UTIL .getHBaseCluster ().getMaster ().getAssignmentManager ().getRegionStates ()
111
- .getServerNode (testServer );
112
- Assert .assertNull ("serverNode should be deleted after SCP finished" , serverNode );
88
+ .getServerNode (testServer );
89
+ if (serverNode != null ) {
90
+ Assert .assertFalse (serverNode .isInState (ServerState .ONLINE ));
91
+ LOG .info ("start to find the procedure of SCP for the severName we choose" );
92
+ Procedure <?> procedure = UTIL .getHBaseCluster ().getMaster ().getProcedures ().stream ().filter (
93
+ p -> (p instanceof ServerCrashProcedure ) &&
94
+ ((ServerCrashProcedure ) p ).getServerName ().equals (testServer )).findAny ().get ();
95
+ if (procedure != null ) {
96
+ Assert .assertFalse ("serverNode should not be ONLINE during SCP processing" ,
97
+ serverNode .isInState (ServerState .ONLINE ));
98
+ LOG .info ("start to submit the SCP for the same serverName {} which should fail" ,
99
+ testServer );
100
+ Assert .assertFalse (
101
+ UTIL .getHBaseCluster ().getMaster ().getServerManager ().expireServer (testServer ));
102
+ UTIL .waitFor (60000 , () -> procedure .isFinished ());
103
+ LOG .info ("even when the SCP is finished, the duplicate SCP should not be scheduled for {}" ,
104
+ testServer );
105
+ Assert .assertFalse (
106
+ UTIL .getHBaseCluster ().getMaster ().getServerManager ().expireServer (testServer ));
107
+ }
108
+ serverNode = UTIL .getHBaseCluster ().getMaster ().getAssignmentManager ().getRegionStates ()
109
+ .getServerNode (testServer );
110
+ Assert .assertNull ("serverNode should be deleted after SCP finished" , serverNode );
111
+ }
113
112
}
114
113
}
0 commit comments