2019-05-10 11:55:44 +08:00
|
|
|
/*
|
|
|
|
* RestoreRoleCommon.actor.cpp
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fdbclient/NativeAPI.actor.h"
|
|
|
|
#include "fdbclient/MutationList.h"
|
2019-05-30 04:26:17 +08:00
|
|
|
#include "fdbclient/ReadYourWrites.h"
|
|
|
|
#include "fdbclient/RunTransaction.actor.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
#include "fdbserver/RestoreUtil.h"
|
|
|
|
#include "fdbserver/RestoreRoleCommon.actor.h"
|
|
|
|
#include "fdbserver/RestoreLoader.actor.h"
|
|
|
|
#include "fdbserver/RestoreApplier.actor.h"
|
|
|
|
#include "fdbserver/RestoreMaster.actor.h"
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
class Database;
|
|
|
|
struct RestoreWorkerData;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
// id is the id of the worker to be monitored
|
2019-05-10 11:55:44 +08:00
|
|
|
// This actor is used for both restore loader and restore applier
|
|
|
|
ACTOR Future<Void> handleHeartbeat(RestoreSimpleRequest req, UID id) {
|
2019-08-02 08:00:13 +08:00
|
|
|
wait(delayJittered(5.0)); // Random jitter reduces heat beat monitor's pressure
|
2019-05-30 04:42:35 +08:00
|
|
|
req.reply.send(RestoreCommonReply(id));
|
2019-05-10 11:55:44 +08:00
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2019-10-25 03:47:51 +08:00
|
|
|
void handleFinishRestoreRequest(const RestoreVersionBatchRequest& req, Reference<RestoreRoleData> self) {
|
2019-08-02 08:00:13 +08:00
|
|
|
if (self->versionBatchStart) {
|
2019-05-30 04:26:17 +08:00
|
|
|
self->versionBatchStart = false;
|
|
|
|
}
|
2019-06-05 02:40:23 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
TraceEvent("FastRestore")
|
|
|
|
.detail("FinishRestoreRequest", req.batchID)
|
|
|
|
.detail("Role", getRoleStr(self->role))
|
|
|
|
.detail("Node", self->id());
|
2019-06-05 02:40:23 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
req.reply.send(RestoreCommonReply(self->id()));
|
|
|
|
}
|
2019-05-12 08:34:31 +08:00
|
|
|
|
2019-10-25 04:54:44 +08:00
|
|
|
void handleInitVersionBatchRequest(const RestoreVersionBatchRequest& req, Reference<RestoreRoleData> self) {
|
2019-10-20 08:40:48 +08:00
|
|
|
self->resetPerVersionBatch();
|
2019-08-02 08:00:13 +08:00
|
|
|
TraceEvent("FastRestore")
|
|
|
|
.detail("InitVersionBatch", req.batchID)
|
|
|
|
.detail("Role", getRoleStr(self->role))
|
|
|
|
.detail("Node", self->id());
|
2019-05-10 11:55:44 +08:00
|
|
|
|
2019-05-30 04:42:35 +08:00
|
|
|
req.reply.send(RestoreCommonReply(self->id()));
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------Helper functions
|
|
|
|
std::string getHexString(StringRef input) {
|
|
|
|
std::stringstream ss;
|
2019-08-02 08:00:13 +08:00
|
|
|
for (int i = 0; i < input.size(); i++) {
|
|
|
|
if (i % 4 == 0) ss << " ";
|
|
|
|
if (i == 12) { // The end of 12bytes, which is the version size for value
|
2019-05-10 11:55:44 +08:00
|
|
|
ss << "|";
|
|
|
|
}
|
2019-08-02 08:00:13 +08:00
|
|
|
if (i == (12 + 12)) { // The end of version + header
|
2019-05-10 11:55:44 +08:00
|
|
|
ss << "@";
|
|
|
|
}
|
2019-08-02 08:00:13 +08:00
|
|
|
ss << std::setfill('0') << std::setw(2) << std::hex
|
|
|
|
<< (int)input[i]; // [] operator moves the pointer in step of unit8
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
|
|
|
return ss.str();
|
|
|
|
}
|