Add catch throwable logic in ClusterStateManager to detect fatal error when loading SPI

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
Eric Zhao 2019-01-25 13:48:31 +08:00
parent 83f6de90b0
commit 8e72211db9
1 changed files with 16 additions and 11 deletions

View File

@ -224,17 +224,22 @@ public final class ClusterStateManager {
if (state == mode) {
return true;
}
switch (state) {
case CLUSTER_CLIENT:
return setToClient();
case CLUSTER_SERVER:
return setToServer();
case CLUSTER_NOT_STARTED:
setStop();
return true;
default:
RecordLog.warn("[ClusterStateManager] Ignoring unknown cluster state: " + state);
return false;
try {
switch (state) {
case CLUSTER_CLIENT:
return setToClient();
case CLUSTER_SERVER:
return setToServer();
case CLUSTER_NOT_STARTED:
setStop();
return true;
default:
RecordLog.warn("[ClusterStateManager] Ignoring unknown cluster state: " + state);
return false;
}
} catch (Throwable t) {
RecordLog.warn("[ClusterStateManager] Fatal error when applying state: " + state, t);
return false;
}
}