2019-06-07 06:02:26 +08:00
|
|
|
/*
|
2019-09-26 14:19:42 +08:00
|
|
|
* RestoreWorkerInterface.actor.h
|
2019-06-07 06:02:26 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This file declare and define the interface for RestoreWorker and restore roles
|
2020-07-17 06:30:27 +08:00
|
|
|
// which are RestoreController, RestoreLoader, and RestoreApplier
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
#pragma once
|
2019-09-26 15:18:37 +08:00
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBCLIENT_RESTORE_WORKER_INTERFACE_ACTOR_G_H)
|
|
|
|
#define FDBCLIENT_RESTORE_WORKER_INTERFACE_ACTOR_G_H
|
|
|
|
#include "fdbclient/RestoreWorkerInterface.actor.g.h"
|
2019-09-26 15:39:31 +08:00
|
|
|
#elif !defined(FDBCLIENT_RESTORE_WORKER_INTERFACE_ACTOR_H)
|
|
|
|
#define FDBCLIENT_RESTORE_WORKER_INTERFACE_ACTOR_H
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
#include <sstream>
|
2020-02-04 03:11:31 +08:00
|
|
|
#include <string>
|
2019-07-26 01:46:11 +08:00
|
|
|
#include "flow/flow.h"
|
2019-06-07 06:02:26 +08:00
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbrpc/Locality.h"
|
2020-07-11 06:06:34 +08:00
|
|
|
#include "fdbrpc/Stats.h"
|
2019-06-07 06:02:26 +08:00
|
|
|
#include "fdbclient/FDBTypes.h"
|
|
|
|
#include "fdbclient/CommitTransaction.h"
|
|
|
|
#include "fdbserver/CoordinationInterface.h"
|
|
|
|
#include "fdbserver/Knobs.h"
|
|
|
|
#include "fdbserver/RestoreUtil.h"
|
2019-09-26 14:19:42 +08:00
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-03 07:09:38 +08:00
|
|
|
class RestoreConfigFR;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
struct RestoreCommonReply;
|
|
|
|
struct RestoreRecruitRoleRequest;
|
|
|
|
struct RestoreSysInfoRequest;
|
|
|
|
struct RestoreLoadFileRequest;
|
|
|
|
struct RestoreVersionBatchRequest;
|
2019-11-13 08:28:09 +08:00
|
|
|
struct RestoreSendMutationsToAppliersRequest;
|
2019-12-11 09:22:51 +08:00
|
|
|
struct RestoreSendVersionedMutationsRequest;
|
2019-06-07 06:02:26 +08:00
|
|
|
struct RestoreSysInfo;
|
|
|
|
struct RestoreApplierInterface;
|
2020-01-17 08:19:51 +08:00
|
|
|
struct RestoreFinishRequest;
|
2020-08-05 14:04:38 +08:00
|
|
|
struct RestoreSamplesRequest;
|
2020-09-22 23:14:23 +08:00
|
|
|
struct RestoreUpdateRateRequest;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-07-25 07:59:05 +08:00
|
|
|
// RestoreSysInfo includes information each (type of) restore roles should know.
|
|
|
|
// At this moment, it only include appliers. We keep the name for future extension.
|
|
|
|
// TODO: If it turns out this struct only has appliers in the final version, we will rename it to a more specific name, e.g., AppliersMap
|
2019-06-07 06:02:26 +08:00
|
|
|
struct RestoreSysInfo {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 68098739;
|
2019-06-07 06:02:26 +08:00
|
|
|
std::map<UID, RestoreApplierInterface> appliers;
|
|
|
|
|
|
|
|
RestoreSysInfo() = default;
|
2019-07-25 07:59:05 +08:00
|
|
|
explicit RestoreSysInfo(const std::map<UID, RestoreApplierInterface> appliers) : appliers(appliers) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, appliers);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreWorkerInterface {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 99601798;
|
2019-06-07 06:02:26 +08:00
|
|
|
UID interfID;
|
|
|
|
|
|
|
|
RequestStream<RestoreSimpleRequest> heartbeat;
|
|
|
|
RequestStream<RestoreRecruitRoleRequest> recruitRole;
|
|
|
|
RequestStream<RestoreSimpleRequest> terminateWorker;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
bool operator==(RestoreWorkerInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator!=(RestoreWorkerInterface const& r) const { return id() != r.id(); }
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
UID id() const { return interfID; } // cmd.getEndpoint().token;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
NetworkAddress address() const { return recruitRole.getEndpoint().addresses.address; }
|
|
|
|
|
|
|
|
void initEndpoints() {
|
2019-08-02 08:00:13 +08:00
|
|
|
heartbeat.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
recruitRole.getEndpoint(TaskPriority::LoadBalancedEndpoint); // Q: Why do we need this?
|
|
|
|
terminateWorker.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-07-26 01:46:11 +08:00
|
|
|
interfID = deterministicRandom()->randomUniqueID();
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-05-23 07:35:01 +08:00
|
|
|
//To change this serialization, ProtocolVersion::RestoreWorkerInterfaceValue must be updated, and downgrades need to be considered
|
2019-06-07 06:02:26 +08:00
|
|
|
template <class Ar>
|
2019-08-02 08:00:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
2019-07-25 07:59:05 +08:00
|
|
|
serializer(ar, interfID, heartbeat, recruitRole, terminateWorker);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreRoleInterface {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 62531339;
|
2019-06-07 06:02:26 +08:00
|
|
|
UID nodeID;
|
|
|
|
RestoreRole role;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
RestoreRoleInterface() { role = RestoreRole::Invalid; }
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
explicit RestoreRoleInterface(RestoreRoleInterface const& interf) : nodeID(interf.nodeID), role(interf.role){};
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
UID id() const { return nodeID; }
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "Role:" << getRoleStr(role) << " interfID:" << nodeID.toString();
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
2019-08-02 08:00:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
2019-06-07 06:02:26 +08:00
|
|
|
serializer(ar, nodeID, role);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreLoaderInterface : RestoreRoleInterface {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 84244651;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
RequestStream<RestoreSimpleRequest> heartbeat;
|
2019-07-25 07:59:05 +08:00
|
|
|
RequestStream<RestoreSysInfoRequest> updateRestoreSysInfo;
|
2019-06-07 06:02:26 +08:00
|
|
|
RequestStream<RestoreLoadFileRequest> loadFile;
|
2019-11-13 08:28:09 +08:00
|
|
|
RequestStream<RestoreSendMutationsToAppliersRequest> sendMutations;
|
2019-06-07 06:02:26 +08:00
|
|
|
RequestStream<RestoreVersionBatchRequest> initVersionBatch;
|
2020-02-27 05:43:30 +08:00
|
|
|
RequestStream<RestoreVersionBatchRequest> finishVersionBatch;
|
2019-11-13 08:28:09 +08:00
|
|
|
RequestStream<RestoreSimpleRequest> collectRestoreRoleInterfaces;
|
2020-01-17 08:19:51 +08:00
|
|
|
RequestStream<RestoreFinishRequest> finishRestore;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
bool operator==(RestoreWorkerInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator!=(RestoreWorkerInterface const& r) const { return id() != r.id(); }
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
RestoreLoaderInterface() {
|
2019-06-07 06:02:26 +08:00
|
|
|
role = RestoreRole::Loader;
|
2019-07-26 01:46:11 +08:00
|
|
|
nodeID = deterministicRandom()->randomUniqueID();
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NetworkAddress address() const { return heartbeat.getEndpoint().addresses.address; }
|
|
|
|
|
|
|
|
void initEndpoints() {
|
2020-06-17 13:48:28 +08:00
|
|
|
// Endpoint in a later restore phase has higher priority
|
2019-08-02 08:00:13 +08:00
|
|
|
heartbeat.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
updateRestoreSysInfo.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
initVersionBatch.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2020-06-17 13:48:28 +08:00
|
|
|
loadFile.getEndpoint(TaskPriority::RestoreLoaderLoadFiles);
|
|
|
|
sendMutations.getEndpoint(TaskPriority::RestoreLoaderSendMutations);
|
|
|
|
finishVersionBatch.getEndpoint(TaskPriority::RestoreLoaderFinishVersionBatch);
|
2019-08-02 08:00:13 +08:00
|
|
|
collectRestoreRoleInterfaces.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
finishRestore.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
2019-08-02 08:00:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
2019-11-13 09:17:00 +08:00
|
|
|
serializer(ar, *(RestoreRoleInterface*)this, heartbeat, updateRestoreSysInfo, loadFile, sendMutations,
|
2020-02-27 05:43:30 +08:00
|
|
|
initVersionBatch, finishVersionBatch, collectRestoreRoleInterfaces, finishRestore);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreApplierInterface : RestoreRoleInterface {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 54253048;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
RequestStream<RestoreSimpleRequest> heartbeat;
|
2019-12-11 09:22:51 +08:00
|
|
|
RequestStream<RestoreSendVersionedMutationsRequest> sendMutationVector;
|
2019-06-07 06:02:26 +08:00
|
|
|
RequestStream<RestoreVersionBatchRequest> applyToDB;
|
|
|
|
RequestStream<RestoreVersionBatchRequest> initVersionBatch;
|
|
|
|
RequestStream<RestoreSimpleRequest> collectRestoreRoleInterfaces;
|
2020-01-17 08:19:51 +08:00
|
|
|
RequestStream<RestoreFinishRequest> finishRestore;
|
2020-09-22 23:14:23 +08:00
|
|
|
RequestStream<RestoreUpdateRateRequest> updateRate;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
bool operator==(RestoreWorkerInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator!=(RestoreWorkerInterface const& r) const { return id() != r.id(); }
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
RestoreApplierInterface() {
|
|
|
|
role = RestoreRole::Applier;
|
2019-07-26 01:46:11 +08:00
|
|
|
nodeID = deterministicRandom()->randomUniqueID();
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NetworkAddress address() const { return heartbeat.getEndpoint().addresses.address; }
|
|
|
|
|
|
|
|
void initEndpoints() {
|
2020-06-17 13:48:28 +08:00
|
|
|
// Endpoint in a later restore phase has higher priority
|
2019-08-02 08:00:13 +08:00
|
|
|
heartbeat.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2020-06-17 13:48:28 +08:00
|
|
|
sendMutationVector.getEndpoint(TaskPriority::RestoreApplierReceiveMutations);
|
|
|
|
applyToDB.getEndpoint(TaskPriority::RestoreApplierWriteDB);
|
2019-08-02 08:00:13 +08:00
|
|
|
initVersionBatch.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
collectRestoreRoleInterfaces.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
|
|
|
finishRestore.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2020-09-22 23:14:23 +08:00
|
|
|
updateRate.getEndpoint(TaskPriority::LoadBalancedEndpoint);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
2019-08-02 08:00:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, *(RestoreRoleInterface*)this, heartbeat, sendMutationVector, applyToDB, initVersionBatch,
|
2020-09-22 23:14:23 +08:00
|
|
|
collectRestoreRoleInterfaces, finishRestore, updateRate);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const { return nodeID.toString(); }
|
2019-06-07 06:02:26 +08:00
|
|
|
};
|
|
|
|
|
2020-08-04 06:06:15 +08:00
|
|
|
struct RestoreControllerInterface : RestoreRoleInterface {
|
|
|
|
constexpr static FileIdentifier file_identifier = 54253047;
|
|
|
|
|
2020-08-05 14:04:38 +08:00
|
|
|
RequestStream<RestoreSamplesRequest> samples;
|
2020-08-04 06:06:15 +08:00
|
|
|
|
|
|
|
bool operator==(RestoreWorkerInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator!=(RestoreWorkerInterface const& r) const { return id() != r.id(); }
|
|
|
|
|
|
|
|
RestoreControllerInterface() {
|
|
|
|
role = RestoreRole::Controller;
|
|
|
|
nodeID = deterministicRandom()->randomUniqueID();
|
|
|
|
}
|
|
|
|
|
|
|
|
NetworkAddress address() const { return samples.getEndpoint().addresses.address; }
|
|
|
|
|
|
|
|
void initEndpoints() { samples.getEndpoint(TaskPriority::LoadBalancedEndpoint); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, *(RestoreRoleInterface*)this, samples);
|
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const { return nodeID.toString(); }
|
2020-08-05 04:35:36 +08:00
|
|
|
};
|
2020-08-04 06:06:15 +08:00
|
|
|
|
2019-12-20 08:50:39 +08:00
|
|
|
// RestoreAsset uniquely identifies the work unit done by restore roles;
|
|
|
|
// It is used to ensure exact-once processing on restore loader and applier;
|
|
|
|
// By combining all RestoreAssets across all verstion batches, restore should process all mutations in
|
|
|
|
// backup range and log files up to the target restore version.
|
|
|
|
struct RestoreAsset {
|
2020-06-19 01:35:41 +08:00
|
|
|
UID uid;
|
|
|
|
|
2019-12-20 08:50:39 +08:00
|
|
|
Version beginVersion, endVersion; // Only use mutation in [begin, end) versions;
|
|
|
|
KeyRange range; // Only use mutations in range
|
|
|
|
|
|
|
|
int fileIndex;
|
2020-02-18 06:36:09 +08:00
|
|
|
// Partition ID for mutation log files, which is also encoded in the filename of mutation logs.
|
|
|
|
int partitionId = -1;
|
2019-12-23 09:16:40 +08:00
|
|
|
std::string filename;
|
2019-12-20 08:50:39 +08:00
|
|
|
int64_t offset;
|
|
|
|
int64_t len;
|
|
|
|
|
2020-06-19 01:35:41 +08:00
|
|
|
Key addPrefix;
|
|
|
|
Key removePrefix;
|
2020-01-06 09:54:44 +08:00
|
|
|
|
2020-08-26 00:31:34 +08:00
|
|
|
int batchIndex; // for progress tracking and performance investigation
|
|
|
|
|
2020-01-08 04:46:51 +08:00
|
|
|
RestoreAsset() = default;
|
2019-12-20 08:50:39 +08:00
|
|
|
|
2020-06-19 01:35:41 +08:00
|
|
|
// Q: Can we simply use uid for == and use different comparison rule for less than operator.
|
|
|
|
// The ordering of RestoreAsset may change, will that affect correctness or performance?
|
2019-12-20 08:50:39 +08:00
|
|
|
bool operator==(const RestoreAsset& r) const {
|
2020-08-26 00:31:34 +08:00
|
|
|
return batchIndex == r.batchIndex && beginVersion == r.beginVersion && endVersion == r.endVersion &&
|
|
|
|
range == r.range && fileIndex == r.fileIndex && partitionId == r.partitionId && filename == r.filename &&
|
2020-06-19 01:35:41 +08:00
|
|
|
offset == r.offset && len == r.len && addPrefix == r.addPrefix && removePrefix == r.removePrefix;
|
2019-12-20 08:50:39 +08:00
|
|
|
}
|
|
|
|
bool operator!=(const RestoreAsset& r) const {
|
2020-02-18 06:36:09 +08:00
|
|
|
return !(*this == r);
|
2019-12-20 08:50:39 +08:00
|
|
|
}
|
|
|
|
bool operator<(const RestoreAsset& r) const {
|
2020-08-26 00:31:34 +08:00
|
|
|
return std::make_tuple(batchIndex, fileIndex, filename, offset, len, beginVersion, endVersion, range.begin,
|
|
|
|
range.end, addPrefix, removePrefix) <
|
|
|
|
std::make_tuple(r.batchIndex, r.fileIndex, r.filename, r.offset, r.len, r.beginVersion, r.endVersion,
|
|
|
|
r.range.begin, r.range.end, r.addPrefix, r.removePrefix);
|
2019-12-20 08:50:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-06-19 01:35:41 +08:00
|
|
|
serializer(ar, uid, beginVersion, endVersion, range, filename, fileIndex, partitionId, offset, len, addPrefix,
|
2020-08-26 00:31:34 +08:00
|
|
|
removePrefix, batchIndex);
|
2019-12-20 08:50:39 +08:00
|
|
|
}
|
|
|
|
|
2020-06-23 10:47:14 +08:00
|
|
|
std::string toString() const {
|
2019-12-20 08:50:39 +08:00
|
|
|
std::stringstream ss;
|
2020-01-08 03:50:29 +08:00
|
|
|
ss << "UID:" << uid.toString() << " begin:" << beginVersion << " end:" << endVersion
|
|
|
|
<< " range:" << range.toString() << " filename:" << filename << " fileIndex:" << fileIndex
|
2020-06-19 01:35:41 +08:00
|
|
|
<< " partitionId:" << partitionId << " offset:" << offset << " len:" << len
|
2020-08-26 00:31:34 +08:00
|
|
|
<< " addPrefix:" << addPrefix.toString() << " removePrefix:" << removePrefix.toString()
|
|
|
|
<< " BatchIndex:" << batchIndex;
|
2019-12-20 08:50:39 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
2019-12-23 09:16:40 +08:00
|
|
|
|
2020-06-22 13:18:07 +08:00
|
|
|
bool hasPrefix() const { return addPrefix.size() > 0 || removePrefix.size() > 0; }
|
|
|
|
|
2020-01-06 09:54:44 +08:00
|
|
|
// RestoreAsset and VersionBatch both use endVersion as exclusive in version range
|
2019-12-23 09:16:40 +08:00
|
|
|
bool isInVersionRange(Version commitVersion) const {
|
|
|
|
return commitVersion >= beginVersion && commitVersion < endVersion;
|
|
|
|
}
|
2020-04-05 13:38:02 +08:00
|
|
|
|
|
|
|
// Is mutation's begin and end keys are in RestoreAsset's range
|
|
|
|
bool isInKeyRange(MutationRef mutation) const {
|
2020-06-22 13:18:07 +08:00
|
|
|
if (hasPrefix()) {
|
|
|
|
Key begin = range.begin; // Avoid creating new keys if we do not have addPrefix or removePrefix
|
|
|
|
Key end = range.end;
|
|
|
|
begin = begin.removePrefix(removePrefix).withPrefix(addPrefix);
|
|
|
|
end = end.removePrefix(removePrefix).withPrefix(addPrefix);
|
|
|
|
if (isRangeMutation(mutation)) {
|
|
|
|
// Range mutation's right side is exclusive
|
|
|
|
return mutation.param1 >= begin && mutation.param2 <= end;
|
|
|
|
} else {
|
|
|
|
return mutation.param1 >= begin && mutation.param1 < end;
|
|
|
|
}
|
2020-04-05 13:38:02 +08:00
|
|
|
} else {
|
2020-06-22 13:18:07 +08:00
|
|
|
if (isRangeMutation(mutation)) {
|
|
|
|
// Range mutation's right side is exclusive
|
|
|
|
return mutation.param1 >= range.begin && mutation.param2 <= range.end;
|
|
|
|
} else {
|
|
|
|
return mutation.param1 >= range.begin && mutation.param1 < range.end;
|
|
|
|
}
|
2020-04-05 13:38:02 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-20 08:50:39 +08:00
|
|
|
};
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
struct LoadingParam {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 17023837;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
bool isRangeFile;
|
|
|
|
Key url;
|
2020-01-10 03:31:27 +08:00
|
|
|
Optional<Version> rangeVersion; // range file's version
|
2019-12-20 08:50:39 +08:00
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
int64_t blockSize;
|
2019-12-20 08:50:39 +08:00
|
|
|
RestoreAsset asset;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-12-04 04:58:11 +08:00
|
|
|
LoadingParam() = default;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
// TODO: Compare all fields for loadingParam
|
2019-12-20 08:50:39 +08:00
|
|
|
bool operator==(const LoadingParam& r) const { return isRangeFile == r.isRangeFile && asset == r.asset; }
|
|
|
|
bool operator!=(const LoadingParam& r) const { return isRangeFile != r.isRangeFile || asset != r.asset; }
|
2019-08-02 08:00:13 +08:00
|
|
|
bool operator<(const LoadingParam& r) const {
|
2019-12-20 08:50:39 +08:00
|
|
|
return (isRangeFile < r.isRangeFile) || (isRangeFile == r.isRangeFile && asset < r.asset);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-02-18 06:36:09 +08:00
|
|
|
bool isPartitionedLog() const {
|
|
|
|
return !isRangeFile && asset.partitionId >= 0;
|
|
|
|
}
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-08 04:46:51 +08:00
|
|
|
serializer(ar, isRangeFile, url, rangeVersion, blockSize, asset);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream str;
|
2020-01-08 04:46:51 +08:00
|
|
|
str << "isRangeFile:" << isRangeFile << " url:" << url.toString()
|
2020-01-10 03:31:27 +08:00
|
|
|
<< " rangeVersion:" << (rangeVersion.present() ? rangeVersion.get() : -1) << " blockSize:" << blockSize
|
|
|
|
<< " RestoreAsset:" << asset.toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
return str.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreRecruitRoleReply : TimedRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 30310092;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
UID id;
|
|
|
|
RestoreRole role;
|
|
|
|
Optional<RestoreLoaderInterface> loader;
|
|
|
|
Optional<RestoreApplierInterface> applier;
|
|
|
|
|
|
|
|
RestoreRecruitRoleReply() = default;
|
2019-08-02 08:00:13 +08:00
|
|
|
explicit RestoreRecruitRoleReply(UID id, RestoreRole role, RestoreLoaderInterface const& loader)
|
|
|
|
: id(id), role(role), loader(loader) {}
|
|
|
|
explicit RestoreRecruitRoleReply(UID id, RestoreRole role, RestoreApplierInterface const& applier)
|
|
|
|
: id(id), role(role), applier(applier) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2019-06-07 06:02:26 +08:00
|
|
|
serializer(ar, id, role, loader, applier);
|
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "roleInterf role:" << getRoleStr(role) << " replyID:" << id.toString();
|
|
|
|
if (loader.present()) {
|
2019-08-02 08:00:13 +08:00
|
|
|
ss << "loader:" << loader.get().toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
if (applier.present()) {
|
|
|
|
ss << "applier:" << applier.get().toString();
|
|
|
|
}
|
2019-08-02 08:00:13 +08:00
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreRecruitRoleRequest : TimedRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 87022360;
|
|
|
|
|
2020-08-04 06:06:15 +08:00
|
|
|
RestoreControllerInterface ci;
|
2019-06-07 06:02:26 +08:00
|
|
|
RestoreRole role;
|
|
|
|
int nodeIndex; // Each role is a node
|
|
|
|
|
|
|
|
ReplyPromise<RestoreRecruitRoleReply> reply;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
RestoreRecruitRoleRequest() : role(RestoreRole::Invalid) {}
|
2020-08-04 06:06:15 +08:00
|
|
|
explicit RestoreRecruitRoleRequest(RestoreControllerInterface ci, RestoreRole role, int nodeIndex)
|
|
|
|
: ci(ci), role(role), nodeIndex(nodeIndex) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-08-04 06:06:15 +08:00
|
|
|
serializer(ar, ci, role, nodeIndex, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string printable() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
2020-08-04 06:06:15 +08:00
|
|
|
ss << "RestoreRecruitRoleRequest Role:" << getRoleStr(role) << " NodeIndex:" << nodeIndex
|
2020-08-05 04:35:36 +08:00
|
|
|
<< " RestoreController:" << ci.id().toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const { return printable(); }
|
2019-06-07 06:02:26 +08:00
|
|
|
};
|
|
|
|
|
2020-01-16 05:39:06 +08:00
|
|
|
// Static info. across version batches
|
2019-06-07 06:02:26 +08:00
|
|
|
struct RestoreSysInfoRequest : TimedRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 75960741;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
RestoreSysInfo sysInfo;
|
2020-04-16 04:32:52 +08:00
|
|
|
Standalone<VectorRef<std::pair<KeyRangeRef, Version>>> rangeVersions;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
|
|
|
RestoreSysInfoRequest() = default;
|
2020-04-16 04:32:52 +08:00
|
|
|
explicit RestoreSysInfoRequest(RestoreSysInfo sysInfo,
|
|
|
|
Standalone<VectorRef<std::pair<KeyRangeRef, Version>>> rangeVersions)
|
|
|
|
: sysInfo(sysInfo), rangeVersions(rangeVersions) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-04-16 04:32:52 +08:00
|
|
|
serializer(ar, sysInfo, rangeVersions, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
2020-04-16 04:32:52 +08:00
|
|
|
ss << "RestoreSysInfoRequest "
|
|
|
|
<< "rangeVersions.size:" << rangeVersions.size();
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-05 04:35:36 +08:00
|
|
|
struct RestoreSamplesRequest : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 34077901;
|
|
|
|
UID id; // deduplicate data
|
|
|
|
int batchIndex;
|
|
|
|
SampledMutationsVec samples; // sampled mutations
|
|
|
|
|
2020-08-05 14:04:38 +08:00
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
2020-08-05 04:35:36 +08:00
|
|
|
RestoreSamplesRequest() = default;
|
|
|
|
explicit RestoreSamplesRequest(UID id, int batchIndex, SampledMutationsVec samples)
|
|
|
|
: id(id), batchIndex(batchIndex), samples(samples) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-08-05 14:04:38 +08:00
|
|
|
serializer(ar, id, batchIndex, samples, reply);
|
2020-08-05 04:35:36 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2020-08-05 04:35:36 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "ID:" << id.toString() << " BatchIndex:" << batchIndex << " samples:" << samples.size();
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-03 06:33:31 +08:00
|
|
|
struct RestoreLoadFileReply : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 34077902;
|
|
|
|
|
|
|
|
LoadingParam param;
|
2020-01-22 06:49:13 +08:00
|
|
|
bool isDuplicated; // true if loader thinks the request is a duplicated one
|
2019-12-03 06:33:31 +08:00
|
|
|
|
|
|
|
RestoreLoadFileReply() = default;
|
2020-08-05 04:35:36 +08:00
|
|
|
explicit RestoreLoadFileReply(LoadingParam param, bool isDuplicated) : param(param), isDuplicated(isDuplicated) {}
|
2019-12-03 06:33:31 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-08-05 04:35:36 +08:00
|
|
|
serializer(ar, param, isDuplicated);
|
2019-12-03 06:33:31 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-12-03 06:33:31 +08:00
|
|
|
std::stringstream ss;
|
2020-08-05 04:35:36 +08:00
|
|
|
ss << "LoadingParam:" << param.toString() << " isDuplicated:" << isDuplicated;
|
2019-12-03 06:33:31 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
// Sample_Range_File and Assign_Loader_Range_File, Assign_Loader_Log_File
|
|
|
|
struct RestoreLoadFileRequest : TimedRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 26557364;
|
|
|
|
|
2020-01-16 05:39:06 +08:00
|
|
|
int batchIndex;
|
2019-06-07 06:02:26 +08:00
|
|
|
LoadingParam param;
|
|
|
|
|
2019-12-03 06:33:31 +08:00
|
|
|
ReplyPromise<RestoreLoadFileReply> reply;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
RestoreLoadFileRequest() = default;
|
2020-01-16 05:39:06 +08:00
|
|
|
explicit RestoreLoadFileRequest(int batchIndex, LoadingParam& param) : batchIndex(batchIndex), param(param){};
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2020-08-16 09:33:24 +08:00
|
|
|
bool operator<(RestoreLoadFileRequest const& rhs) const { return batchIndex > rhs.batchIndex; }
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-16 05:39:06 +08:00
|
|
|
serializer(ar, batchIndex, param, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
2020-01-16 05:39:06 +08:00
|
|
|
ss << "RestoreLoadFileRequest batchIndex:" << batchIndex << " param:" << param.toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-11-13 08:28:09 +08:00
|
|
|
struct RestoreSendMutationsToAppliersRequest : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 68827305;
|
|
|
|
|
2020-01-15 06:18:41 +08:00
|
|
|
int batchIndex; // version batch index
|
2019-11-13 08:28:09 +08:00
|
|
|
std::map<Key, UID> rangeToApplier;
|
2019-11-13 10:23:14 +08:00
|
|
|
bool useRangeFile; // Send mutations parsed from range file?
|
2019-11-13 08:28:09 +08:00
|
|
|
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
|
|
|
RestoreSendMutationsToAppliersRequest() = default;
|
2020-01-15 06:18:41 +08:00
|
|
|
explicit RestoreSendMutationsToAppliersRequest(int batchIndex, std::map<Key, UID> rangeToApplier, bool useRangeFile)
|
|
|
|
: batchIndex(batchIndex), rangeToApplier(rangeToApplier), useRangeFile(useRangeFile) {}
|
2019-11-13 08:28:09 +08:00
|
|
|
|
2020-08-16 09:33:24 +08:00
|
|
|
bool operator<(RestoreSendMutationsToAppliersRequest const& rhs) const { return batchIndex > rhs.batchIndex; }
|
|
|
|
|
2019-11-13 08:28:09 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-28 10:13:14 +08:00
|
|
|
serializer(ar, batchIndex, rangeToApplier, useRangeFile, reply);
|
2019-11-13 08:28:09 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-11-13 08:28:09 +08:00
|
|
|
std::stringstream ss;
|
2020-01-28 10:13:14 +08:00
|
|
|
ss << "RestoreSendMutationsToAppliersRequest batchIndex:" << batchIndex
|
2020-01-28 10:13:20 +08:00
|
|
|
<< " keyToAppliers.size:" << rangeToApplier.size() << " useRangeFile:" << useRangeFile;
|
2019-11-13 08:28:09 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-12-11 09:22:51 +08:00
|
|
|
struct RestoreSendVersionedMutationsRequest : TimedRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 69764565;
|
|
|
|
|
2020-01-15 06:18:41 +08:00
|
|
|
int batchIndex; // version batch index
|
2019-12-20 08:50:39 +08:00
|
|
|
RestoreAsset asset; // Unique identifier for the current restore asset
|
|
|
|
|
2020-04-12 13:31:55 +08:00
|
|
|
Version msgIndex; // Monitonically increasing index of mutation messages
|
2019-06-07 06:02:26 +08:00
|
|
|
bool isRangeFile;
|
2020-04-22 13:29:57 +08:00
|
|
|
VersionedMutationsVec versionedMutations; // Versioned mutations may be at different versions parsed by one loader
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
2019-12-11 09:22:51 +08:00
|
|
|
RestoreSendVersionedMutationsRequest() = default;
|
2020-04-12 13:31:55 +08:00
|
|
|
explicit RestoreSendVersionedMutationsRequest(int batchIndex, const RestoreAsset& asset, Version msgIndex,
|
2020-04-22 13:04:42 +08:00
|
|
|
bool isRangeFile, VersionedMutationsVec versionedMutations)
|
|
|
|
: batchIndex(batchIndex), asset(asset), msgIndex(msgIndex), isRangeFile(isRangeFile),
|
|
|
|
versionedMutations(versionedMutations) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
2020-08-18 11:34:33 +08:00
|
|
|
ss << "VersionBatchIndex:" << batchIndex << " msgIndex:" << msgIndex << " isRangeFile:" << isRangeFile
|
|
|
|
<< " versionedMutations.size:" << versionedMutations.size() << " RestoreAsset:" << asset.toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-04-22 13:04:42 +08:00
|
|
|
serializer(ar, batchIndex, asset, msgIndex, isRangeFile, versionedMutations, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreVersionBatchRequest : TimedRequest {
|
2020-02-19 05:55:00 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 97223537;
|
2019-07-26 01:46:11 +08:00
|
|
|
|
2020-01-15 06:18:41 +08:00
|
|
|
int batchIndex;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
|
|
|
RestoreVersionBatchRequest() = default;
|
2020-01-15 06:18:41 +08:00
|
|
|
explicit RestoreVersionBatchRequest(int batchIndex) : batchIndex(batchIndex) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-01-15 06:18:41 +08:00
|
|
|
serializer(ar, batchIndex, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2019-06-07 06:02:26 +08:00
|
|
|
std::stringstream ss;
|
2020-01-15 06:18:41 +08:00
|
|
|
ss << "RestoreVersionBatchRequest batchIndex:" << batchIndex;
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-01-17 08:19:51 +08:00
|
|
|
struct RestoreFinishRequest : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 13018413;
|
|
|
|
|
2020-01-28 10:13:20 +08:00
|
|
|
bool terminate; // role exits if terminate = true
|
2020-01-17 08:19:51 +08:00
|
|
|
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
|
|
|
RestoreFinishRequest() = default;
|
|
|
|
explicit RestoreFinishRequest(bool terminate) : terminate(terminate) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, terminate, reply);
|
|
|
|
}
|
|
|
|
|
2020-08-19 06:49:44 +08:00
|
|
|
std::string toString() const {
|
2020-01-17 08:19:51 +08:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "RestoreFinishRequest terminate:" << terminate;
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-09-22 23:14:23 +08:00
|
|
|
struct RestoreUpdateRateReply : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 13018414;
|
|
|
|
|
|
|
|
UID id;
|
|
|
|
double remainMB; // remaining data in MB to write to DB;
|
|
|
|
|
|
|
|
RestoreUpdateRateReply() = default;
|
|
|
|
explicit RestoreUpdateRateReply(UID id, double remainMB) : id(id), remainMB(remainMB) {}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "RestoreUpdateRateReply NodeID:" << id.toString() << " remainMB:" << remainMB;
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, id, remainMB);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreUpdateRateRequest : TimedRequest {
|
|
|
|
constexpr static FileIdentifier file_identifier = 13018415;
|
|
|
|
|
|
|
|
int batchIndex;
|
|
|
|
double writeMB;
|
|
|
|
|
|
|
|
ReplyPromise<RestoreUpdateRateReply> reply;
|
|
|
|
|
|
|
|
RestoreUpdateRateRequest() = default;
|
|
|
|
explicit RestoreUpdateRateRequest(int batchIndex, double writeMB) : batchIndex(batchIndex), writeMB(writeMB) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, batchIndex, writeMB, reply);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "RestoreUpdateRateRequest batchIndex:" << batchIndex << " writeMB:" << writeMB;
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
struct RestoreRequest {
|
2019-07-26 01:46:11 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 49589770;
|
|
|
|
|
2019-06-07 06:02:26 +08:00
|
|
|
int index;
|
|
|
|
Key tagName;
|
|
|
|
Key url;
|
|
|
|
Version targetVersion;
|
|
|
|
KeyRange range;
|
|
|
|
UID randomUid;
|
|
|
|
|
2020-06-19 01:35:41 +08:00
|
|
|
// Every key in backup will first removePrefix and then addPrefix;
|
|
|
|
// Simulation testing does not cover when both addPrefix and removePrefix exist yet.
|
|
|
|
Key addPrefix;
|
|
|
|
Key removePrefix;
|
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
ReplyPromise<struct RestoreCommonReply> reply;
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-12-11 14:55:40 +08:00
|
|
|
RestoreRequest() = default;
|
2020-05-04 11:57:09 +08:00
|
|
|
explicit RestoreRequest(const int index, const Key& tagName, const Key& url, Version targetVersion,
|
2020-06-19 01:35:41 +08:00
|
|
|
const KeyRange& range, const UID& randomUid, Key& addPrefix, Key removePrefix)
|
|
|
|
: index(index), tagName(tagName), url(url), targetVersion(targetVersion), range(range), randomUid(randomUid),
|
|
|
|
addPrefix(addPrefix), removePrefix(removePrefix) {}
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2020-05-23 07:35:01 +08:00
|
|
|
//To change this serialization, ProtocolVersion::RestoreRequestValue must be updated, and downgrades need to be considered
|
2019-06-07 06:02:26 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-06-19 01:35:41 +08:00
|
|
|
serializer(ar, index, tagName, url, targetVersion, range, randomUid, addPrefix, removePrefix, reply);
|
2019-06-07 06:02:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
2019-08-02 08:00:13 +08:00
|
|
|
ss << "index:" << std::to_string(index) << " tagName:" << tagName.contents().toString()
|
2020-05-04 11:57:09 +08:00
|
|
|
<< " url:" << url.contents().toString() << " targetVersion:" << std::to_string(targetVersion)
|
2020-06-19 01:35:41 +08:00
|
|
|
<< " range:" << range.toString() << " randomUid:" << randomUid.toString()
|
|
|
|
<< " addPrefix:" << addPrefix.toString() << " removePrefix:" << removePrefix.toString();
|
2019-06-07 06:02:26 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string getRoleStr(RestoreRole role);
|
|
|
|
|
|
|
|
////--- Interface functions
|
2019-09-26 14:19:42 +08:00
|
|
|
ACTOR Future<Void> _restoreWorker(Database cx, LocalityData locality);
|
2020-02-04 03:11:31 +08:00
|
|
|
ACTOR Future<Void> restoreWorker(Reference<ClusterConnectionFile> ccf, LocalityData locality, std::string coordFolder);
|
2019-06-07 06:02:26 +08:00
|
|
|
|
2019-09-26 14:19:42 +08:00
|
|
|
#include "flow/unactorcompiler.h"
|
|
|
|
#endif
|