2019-05-07 07:56:49 +08:00
|
|
|
/*
|
2019-05-13 12:53:09 +08:00
|
|
|
* RestoreLoader.h
|
2019-05-07 07:56:49 +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.
|
|
|
|
*/
|
|
|
|
|
2019-05-13 12:53:09 +08:00
|
|
|
// This file declares the actors used by the RestoreLoader role
|
2019-05-07 07:56:49 +08:00
|
|
|
|
|
|
|
#pragma once
|
2019-05-13 12:53:09 +08:00
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBSERVER_RESTORE_LOADER_G_H)
|
|
|
|
#define FDBSERVER_RESTORE_LOADER_G_H
|
2019-05-07 07:56:49 +08:00
|
|
|
#include "fdbserver/RestoreLoader.actor.g.h"
|
2019-05-13 12:53:09 +08:00
|
|
|
#elif !defined(FDBSERVER_RESTORE_LOADER_H)
|
|
|
|
#define FDBSERVER_RESTORE_LOADER_H
|
2019-05-07 07:56:49 +08:00
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include "flow/Stats.h"
|
|
|
|
#include "fdbclient/FDBTypes.h"
|
|
|
|
#include "fdbclient/CommitTransaction.h"
|
|
|
|
#include "fdbrpc/fdbrpc.h"
|
|
|
|
#include "fdbserver/CoordinationInterface.h"
|
|
|
|
#include "fdbrpc/Locality.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
#include "fdbserver/RestoreUtil.h"
|
|
|
|
#include "fdbserver/RestoreCommon.actor.h"
|
|
|
|
#include "fdbserver/RestoreRoleCommon.actor.h"
|
2019-05-23 04:30:33 +08:00
|
|
|
#include "fdbserver/RestoreWorkerInterface.actor.h"
|
2019-05-10 11:55:44 +08:00
|
|
|
#include "fdbclient/BackupContainer.h"
|
2019-05-07 07:56:49 +08:00
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
#include "flow/actorcompiler.h" // has to be last include
|
|
|
|
|
|
|
|
struct RestoreLoaderData : RestoreRoleData, public ReferenceCounted<RestoreLoaderData> {
|
2019-05-28 09:39:30 +08:00
|
|
|
std::map<LoadingParam, Future<Void>> processedFileParams;
|
|
|
|
|
2019-05-10 11:55:44 +08:00
|
|
|
// range2Applier is in master and loader node. Loader node uses this to determine which applier a mutation should be sent
|
|
|
|
std::map<Standalone<KeyRef>, UID> range2Applier; // KeyRef is the inclusive lower bound of the key range the applier (UID) is responsible for
|
|
|
|
std::map<Standalone<KeyRef>, int> keyOpsCount; // The number of operations per key which is used to determine the key-range boundary for appliers
|
|
|
|
int numSampledMutations; // The total number of mutations received from sampled data.
|
|
|
|
|
|
|
|
Reference<IBackupContainer> bc; // Backup container is used to read backup files
|
|
|
|
Key bcUrl; // The url used to get the bc
|
|
|
|
|
|
|
|
void addref() { return ReferenceCounted<RestoreLoaderData>::addref(); }
|
|
|
|
void delref() { return ReferenceCounted<RestoreLoaderData>::delref(); }
|
|
|
|
|
2019-05-15 06:04:07 +08:00
|
|
|
explicit RestoreLoaderData(UID loaderInterfID, int assignedIndex) {
|
2019-05-11 07:48:01 +08:00
|
|
|
nodeID = loaderInterfID;
|
2019-05-15 06:04:07 +08:00
|
|
|
nodeIndex = assignedIndex;
|
2019-05-11 07:48:01 +08:00
|
|
|
role = RestoreRole::Loader;
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
|
|
|
|
2019-07-25 07:59:05 +08:00
|
|
|
~RestoreLoaderData() = default;
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
std::string describeNode() {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << "[Role: Loader] [NodeID:" << nodeID.toString().c_str()
|
|
|
|
<< "] [NodeIndex:" << std::to_string(nodeIndex) << "]";
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
void resetPerVersionBatch() {
|
2019-06-05 13:17:08 +08:00
|
|
|
TraceEvent("FastRestore").detail("ResetPerVersionBatchOnLoader", nodeID);
|
2019-05-10 11:55:44 +08:00
|
|
|
RestoreRoleData::resetPerVersionBatch();
|
|
|
|
range2Applier.clear();
|
|
|
|
keyOpsCount.clear();
|
|
|
|
numSampledMutations = 0;
|
2019-05-28 09:39:30 +08:00
|
|
|
processedFileParams.clear();
|
2019-05-10 11:55:44 +08:00
|
|
|
}
|
|
|
|
|
2019-06-05 13:17:08 +08:00
|
|
|
// Only get the appliers that are responsible for a range
|
2019-05-10 11:55:44 +08:00
|
|
|
std::vector<UID> getWorkingApplierIDs() {
|
|
|
|
std::vector<UID> applierIDs;
|
|
|
|
for ( auto &applier : range2Applier ) {
|
|
|
|
applierIDs.push_back(applier.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT( !applierIDs.empty() );
|
|
|
|
return applierIDs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void initBackupContainer(Key url) {
|
|
|
|
if ( bcUrl == url && bc.isValid() ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bcUrl = url;
|
|
|
|
bc = IBackupContainer::openContainer(url.toString());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-07-25 07:59:05 +08:00
|
|
|
ACTOR Future<Void> restoreLoaderCore(RestoreLoaderInterface loaderInterf, int nodeIndex, Database cx);
|
2019-05-10 11:55:44 +08:00
|
|
|
|
|
|
|
#include "flow/unactorcompiler.h"
|
2019-05-07 07:56:49 +08:00
|
|
|
#endif
|