2019-05-10 11:55:44 +08:00
|
|
|
/*
|
|
|
|
* RestoreUtil.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
2022-03-22 04:36:23 +08:00
|
|
|
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
|
2019-05-10 11:55:44 +08:00
|
|
|
*
|
|
|
|
* 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 defines the commonly used data structure and functions
|
2020-07-17 06:30:27 +08:00
|
|
|
// that are used by both RestoreWorker and RestoreRoles(Controller, Loader, and Applier)
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
#ifndef FDBSERVER_RESTOREUTIL_H
|
|
|
|
#define FDBSERVER_RESTOREUTIL_H
|
2020-06-24 05:33:13 +08:00
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "fdbclient/Tuple.h"
|
2019-12-05 03:22:44 +08:00
|
|
|
#include "fdbclient/CommitTransaction.h"
|
2021-05-31 02:51:47 +08:00
|
|
|
#include "fdbclient/RestoreInterface.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
#include "flow/flow.h"
|
2019-08-02 04:32:24 +08:00
|
|
|
#include "fdbrpc/TimedRequest.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbrpc/IAsyncFile.h"
|
2020-07-11 06:06:34 +08:00
|
|
|
#include "fdbrpc/Stats.h"
|
2019-05-12 14:55:20 +08:00
|
|
|
#include <cstdint>
|
2019-05-16 12:15:15 +08:00
|
|
|
#include <cstdarg>
|
2019-05-10 11:55:44 +08:00
|
|
|
|
2020-06-24 01:48:56 +08:00
|
|
|
#define SevFRMutationInfo SevVerbose
|
|
|
|
//#define SevFRMutationInfo SevInfo
|
2019-11-05 08:10:08 +08:00
|
|
|
|
2020-06-25 13:10:54 +08:00
|
|
|
#define SevFRDebugInfo SevVerbose
|
|
|
|
//#define SevFRDebugInfo SevInfo
|
|
|
|
|
2020-04-30 13:06:17 +08:00
|
|
|
struct VersionedMutation {
|
|
|
|
MutationRef mutation;
|
|
|
|
LogMessageVersion version;
|
|
|
|
|
|
|
|
VersionedMutation() = default;
|
|
|
|
explicit VersionedMutation(MutationRef mutation, LogMessageVersion version)
|
|
|
|
: mutation(mutation), version(version) {}
|
|
|
|
explicit VersionedMutation(Arena& arena, const VersionedMutation& vm)
|
|
|
|
: mutation(arena, vm.mutation), version(vm.version) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, mutation, version);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-08-05 04:35:36 +08:00
|
|
|
struct SampledMutation {
|
|
|
|
KeyRef key;
|
|
|
|
long size;
|
|
|
|
|
|
|
|
explicit SampledMutation(KeyRef key, long size) : key(key), size(size) {}
|
2020-08-05 14:04:38 +08:00
|
|
|
explicit SampledMutation(Arena& arena, const SampledMutation& sm) : key(arena, sm.key), size(sm.size) {}
|
2020-08-05 04:35:36 +08:00
|
|
|
SampledMutation() = default;
|
|
|
|
|
|
|
|
int totalSize() { return key.size() + sizeof(size); }
|
2020-08-05 14:04:38 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, key, size);
|
|
|
|
}
|
2020-08-05 04:35:36 +08:00
|
|
|
};
|
|
|
|
|
2019-12-05 09:11:40 +08:00
|
|
|
using MutationsVec = Standalone<VectorRef<MutationRef>>;
|
2020-04-12 13:31:55 +08:00
|
|
|
using LogMessageVersionVec = Standalone<VectorRef<LogMessageVersion>>;
|
2020-04-22 13:04:42 +08:00
|
|
|
using VersionedMutationsVec = Standalone<VectorRef<VersionedMutation>>;
|
2020-08-05 04:35:36 +08:00
|
|
|
using SampledMutationsVec = Standalone<VectorRef<SampledMutation>>;
|
2019-12-05 03:22:44 +08:00
|
|
|
|
2020-07-17 06:30:27 +08:00
|
|
|
enum class RestoreRole { Invalid = 0, Controller = 1, Loader, Applier };
|
2019-06-01 02:09:31 +08:00
|
|
|
std::string getRoleStr(RestoreRole role);
|
2019-05-12 14:55:20 +08:00
|
|
|
extern const std::vector<std::string> RestoreRoleStr;
|
2019-05-10 11:55:44 +08:00
|
|
|
extern int numRoles;
|
|
|
|
|
2019-09-04 06:50:21 +08:00
|
|
|
std::string getHexString(StringRef input);
|
|
|
|
|
2020-04-08 06:57:03 +08:00
|
|
|
bool debugFRMutation(const char* context, Version version, MutationRef const& mutation);
|
2020-04-06 06:00:36 +08:00
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
struct RestoreSimpleRequest : TimedRequest {
|
2020-07-15 07:26:16 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 16448937;
|
2019-07-26 01:46:11 +08:00
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
2019-05-30 04:42:35 +08:00
|
|
|
RestoreSimpleRequest() = default;
|
2019-05-10 11:55:44 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2019-05-30 04:42:35 +08:00
|
|
|
serializer(ar, reply);
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
2019-06-05 02:40:23 +08:00
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "RestoreSimpleRequest";
|
|
|
|
return ss.str();
|
|
|
|
}
|
2019-05-10 11:55:44 +08:00
|
|
|
};
|
|
|
|
|
2019-12-20 08:50:39 +08:00
|
|
|
bool isRangeMutation(MutationRef m);
|
|
|
|
|
2020-11-15 11:22:04 +08:00
|
|
|
#endif // FDBSERVER_RESTOREUTIL_H
|