FastRestore:Change vb state to class from enum
This commit is contained in:
parent
d77177367c
commit
fe8b8bbbff
|
@ -115,7 +115,7 @@ ACTOR static Future<Void> handleSendMutationVectorRequest(RestoreSendVersionedMu
|
|||
.detail("ProcessedFileVersion", curFilePos.get())
|
||||
.detail("Request", req.toString())
|
||||
.detail("CurrentMemory", getSystemStatistics().processMemory)
|
||||
.detail("PreviousVersionBatchState", batchData->vbState);
|
||||
.detail("PreviousVersionBatchState", batchData->vbState.get());
|
||||
|
||||
wait(isSchedulable(self, req.batchIndex, __FUNCTION__));
|
||||
|
||||
|
@ -442,7 +442,7 @@ ACTOR static Future<Void> handleApplyToDBRequest(RestoreVersionBatchRequest req,
|
|||
.detail("BatchIndex", req.batchIndex)
|
||||
.detail("FinishedBatch", self->finishedBatch.get())
|
||||
.detail("HasStarted", batchData->dbApplier.present())
|
||||
.detail("PreviousVersionBatchState", batchData->vbState);
|
||||
.detail("PreviousVersionBatchState", batchData->vbState.get());
|
||||
batchData->vbState = ApplierVersionBatchState::WRITE_TO_DB;
|
||||
if (self->finishedBatch.get() == req.batchIndex - 1) {
|
||||
ASSERT(batchData.isValid());
|
||||
|
|
|
@ -202,7 +202,15 @@ struct StagingKeyRange {
|
|||
};
|
||||
|
||||
// Applier state in each verion batch
|
||||
enum class ApplierVersionBatchState : RoleVersionBatchState { NOT_INIT = 0, INIT = 1, RECEIVE_MUTATIONS = 2, WRITE_TO_DB = 3, INVALID = 4 };
|
||||
class ApplierVersionBatchState : RoleVersionBatchState {
|
||||
static const int NOT_INIT = 0;
|
||||
static const int INIT = 1;
|
||||
static const int RECEIVE_MUTATIONS = 2;
|
||||
static const int WRITE_TO_DB = 3;
|
||||
static const int INVALID = 4;
|
||||
|
||||
explicit ApplierVersionBatchState(int newState) : vbState(newState) {}
|
||||
};
|
||||
|
||||
struct ApplierBatchData : public ReferenceCounted<ApplierBatchData> {
|
||||
// processedFileState: key: RestoreAsset; value: largest version of mutation received on the applier
|
||||
|
@ -351,18 +359,15 @@ struct RestoreApplierData : RestoreRoleData, public ReferenceCounted<RestoreAppl
|
|||
|
||||
~RestoreApplierData() = default;
|
||||
|
||||
RoleVersionBatchState getVersionBatchState(int batchIndex) {
|
||||
std::map<int, Reference<ApplierBatchData>>::iterator item = batch.find(batchIndex);
|
||||
if ( item == batch.end()) {
|
||||
return ApplierVersionBatchState::INVALID;
|
||||
} else {
|
||||
return item->second->vbState;
|
||||
}
|
||||
}
|
||||
void setVersionBatchState(int batchIndex, RoleVersionBatchState vbState) {
|
||||
int getVersionBatchState(int batchIndex) {
|
||||
std::map<int, Reference<ApplierBatchData>>::iterator item = batch.find(batchIndex);
|
||||
ASSERT(item != batch.end());
|
||||
item->second->vbState = (ApplierVersionBatchState) vbState;
|
||||
return item->second->vbState.get();
|
||||
}
|
||||
void setVersionBatchState(int batchIndex, int vbState) {
|
||||
std::map<int, Reference<ApplierBatchData>>::iterator item = batch.find(batchIndex);
|
||||
ASSERT(item != batch.end());
|
||||
item->second->vbState = vbState;
|
||||
}
|
||||
|
||||
void initVersionBatch(int batchIndex) {
|
||||
|
|
|
@ -42,12 +42,25 @@
|
|||
|
||||
#include "flow/actorcompiler.h" // has to be last include
|
||||
|
||||
enum class LoaderVersionBatchState : RoleVersionBatchState {
|
||||
NOT_INIT,
|
||||
INIT,
|
||||
LOAD_FILE,
|
||||
SEND_MUTATIONS,
|
||||
INVALID
|
||||
class LoaderVersionBatchState : RoleVersionBatchState {
|
||||
static const int NOT_INIT = 0;
|
||||
static const int INIT = 1;
|
||||
static const int LOAD_FILE = 2;
|
||||
static const int SEND_MUTATIONS = 3;
|
||||
static const int INVALID = 4;
|
||||
|
||||
explicit LoaderVersionBatchState(int newState) : vbState(newState) {}
|
||||
|
||||
// static std::string getVersionBatchState(int vbState) {
|
||||
// switch(vbSTate) {
|
||||
// case NOT_INIT: return "NOT_INIT";
|
||||
// case INIT: return "INIT";
|
||||
// case LOAD_FILE: return "LOAD_FILE";
|
||||
// case SEND_MUTATIONS: return "SEND_MUTATIONS";
|
||||
// case INVALID: return "INVALID";
|
||||
// default: return "UNKNOWN";
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
struct LoaderBatchData : public ReferenceCounted<LoaderBatchData> {
|
||||
|
@ -139,13 +152,10 @@ struct RestoreLoaderData : RestoreRoleData, public ReferenceCounted<RestoreLoade
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
RoleVersionBatchState getVersionBatchState(int batchIndex) {
|
||||
std::string getVersionBatchState(int batchIndex) {
|
||||
std::map<int, Reference<LoaderBatchData>>::iterator item = batch.find(batchIndex);
|
||||
if ( item == batch.end()) {
|
||||
return LoaderVersionBatchState::INVALID;
|
||||
} else {
|
||||
return item->second->vbState;
|
||||
}
|
||||
ASSERT(item != batch.end());
|
||||
return item->second->vbState;
|
||||
}
|
||||
void setVersionBatchState(int batchIndex, RoleVersionBatchState vbState) {
|
||||
std::map<int, Reference<LoaderBatchData>>::iterator item = batch.find(batchIndex);
|
||||
|
|
|
@ -157,10 +157,10 @@ struct RestoreMasterData : RestoreRoleData, public ReferenceCounted<RestoreMaste
|
|||
|
||||
~RestoreMasterData() = default;
|
||||
|
||||
RoleVersionBatchState getVersionBatchState(int batchIndex) {
|
||||
int getVersionBatchState(int batchIndex) {
|
||||
return RoleVersionBatchState::INVALID;
|
||||
}
|
||||
void setVersionBatchState(int batchIndex, RoleVersionBatchState vbState) {
|
||||
void setVersionBatchState(int batchIndex, int vbState) {
|
||||
}
|
||||
|
||||
void initVersionBatch(int batchIndex) {
|
||||
|
|
|
@ -105,7 +105,22 @@ struct BackupStringRefReader {
|
|||
Error failure_error;
|
||||
};
|
||||
|
||||
enum class RoleVersionBatchState {INVALID};
|
||||
class RoleVersionBatchState {
|
||||
public:
|
||||
static const int INVALID = -1;
|
||||
|
||||
int get() {
|
||||
return vbState;
|
||||
}
|
||||
|
||||
operator = (int newState) {
|
||||
vbState = newState;
|
||||
}
|
||||
|
||||
explicit RoleVersionBatchState(int newState) : vbState(newState) {}
|
||||
|
||||
int vbState;
|
||||
};
|
||||
|
||||
struct RestoreRoleData : NonCopyable, public ReferenceCounted<RestoreRoleData> {
|
||||
public:
|
||||
|
@ -136,8 +151,8 @@ public:
|
|||
|
||||
virtual void initVersionBatch(int batchIndex) = 0;
|
||||
virtual void resetPerRestoreRequest() = 0;
|
||||
virtual RoleVersionBatchState getVersionBatchState(int batchIndex);
|
||||
virtual void setVersionBatchState(int batchIndex, RoleVersionBatchState vbState);
|
||||
virtual int getVersionBatchState(int batchIndex);
|
||||
virtual void setVersionBatchState(int batchIndex, int vbState);
|
||||
|
||||
void clearInterfaces() {
|
||||
loadersInterf.clear();
|
||||
|
|
Loading…
Reference in New Issue