kudu中tablet replica的状态机为:
// NOT_INITIALIZED -> INITIALIZED -> BOOTSTRAPPING -> RUNNING -> STOPPING -> STOPPED -> SHUTDOWN
// | | | ^ ^ ^
// | | | | | |
// | | +------------------+ | |
// | +-------------------------------------+ |
// +------------------------------------------------------+
代码如下:
void TabletReplica::set_state(TabletStatePB new_state) {
switch (new_state) {
case NOT_INITIALIZED:
LOG(FATAL) << "Cannot transition to NOT_INITIALIZED state";
return;
case INITIALIZED:
CHECK_EQ(NOT_INITIALIZED, state_);
break;
case BOOTSTRAPPING:
CHECK_EQ(INITIALIZED, state_);
break;
case RUNNING:
CHECK_EQ(BOOTSTRAPPING, state_);
break;
case STOPPING:
CHECK_NE(STOPPED, state_);
CHECK_NE(SHUTDOWN, state_);
break;
case STOPPED:
CHECK_EQ(STOPPING, state_);
break;
case SHUTDOWN: FALLTHROUGH_INTENDED;
case FAILED:
CHECK_EQ(STOPPED, state_) << TabletStatePB_Name(state_);
break;
default:
break;
}
state_ = new_state;
}
网友评论