2019-05-10 11:55:44 +08:00
|
|
|
/*
|
|
|
|
* RestoreUtil.h
|
|
|
|
*
|
|
|
|
* 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 defines the commonly used data structure and functions
|
|
|
|
// that are used by both RestoreWorker and RestoreRoles(Master, Loader, and Applier)
|
|
|
|
|
|
|
|
#ifndef FDBSERVER_RESTOREUTIL_H
|
|
|
|
#define FDBSERVER_RESTOREUTIL_H
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "fdbclient/Tuple.h"
|
|
|
|
#include "flow/flow.h"
|
|
|
|
#include "flow/Stats.h"
|
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbrpc/IAsyncFile.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
|
|
|
|
|
|
|
enum class RestoreRole {Invalid = 0, Master = 1, Loader, Applier};
|
|
|
|
BINARY_SERIALIZABLE( RestoreRole );
|
2019-06-01 02:09:31 +08:00
|
|
|
std::string getRoleStr(RestoreRole role);
|
2019-05-10 11:55:44 +08:00
|
|
|
|
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-06-01 02:09:31 +08:00
|
|
|
// Fast restore operation configuration
|
|
|
|
// The initRestoreWorkerConfig function will reset the configuration params in simulation
|
|
|
|
struct FastRestoreOpConfig {
|
|
|
|
int num_loaders = 120;
|
|
|
|
int num_appliers = 40;
|
|
|
|
// transactionBatchSizeThreshold is used when applier applies multiple mutations in a transaction to DB
|
|
|
|
double transactionBatchSizeThreshold = 512; //512 in Bytes
|
|
|
|
};
|
|
|
|
extern FastRestoreOpConfig opConfig;
|
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
struct RestoreCommonReply {
|
|
|
|
UID id; // unique ID of the server who sends the reply
|
|
|
|
|
2019-05-30 04:42:35 +08:00
|
|
|
RestoreCommonReply() = default;
|
2019-05-25 00:51:58 +08:00
|
|
|
explicit RestoreCommonReply(UID id) : id(id) {}
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
std::stringstream ss;
|
2019-05-30 04:42:35 +08:00
|
|
|
ss << "ServerNodeID:" << id.toString();
|
2019-05-10 11:55:44 +08:00
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2019-05-30 04:42:35 +08:00
|
|
|
serializer(ar, id);
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RestoreSimpleRequest : TimedRequest {
|
|
|
|
ReplyPromise<RestoreCommonReply> reply;
|
|
|
|
|
2019-05-30 04:42:35 +08:00
|
|
|
RestoreSimpleRequest() = default;
|
2019-05-10 11:55:44 +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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //FDBSERVER_RESTOREUTIL_ACTOR_H
|