2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* ClusterRecruitmentInterface.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48: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
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FDBSERVER_CLUSTERRECRUITMENTINTERFACE_H
|
|
|
|
#define FDBSERVER_CLUSTERRECRUITMENTINTERFACE_H
|
|
|
|
#pragma once
|
|
|
|
|
2019-05-08 05:44:40 +08:00
|
|
|
#include <vector>
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbclient/ClusterInterface.h"
|
|
|
|
#include "fdbclient/StorageServerInterface.h"
|
|
|
|
#include "fdbclient/MasterProxyInterface.h"
|
2018-04-09 12:24:05 +08:00
|
|
|
#include "fdbclient/DatabaseConfiguration.h"
|
2019-04-25 06:12:37 +08:00
|
|
|
#include "fdbserver/BackupInterface.h"
|
2018-12-14 05:31:37 +08:00
|
|
|
#include "fdbserver/DataDistributorInterface.h"
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbserver/MasterInterface.h"
|
|
|
|
#include "fdbserver/RecoveryState.h"
|
|
|
|
#include "fdbserver/TLogInterface.h"
|
2019-02-18 11:13:26 +08:00
|
|
|
#include "fdbserver/WorkerInterface.actor.h"
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbserver/Knobs.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// This interface and its serialization depend on slicing, since the client will deserialize only the first part of this structure
|
|
|
|
struct ClusterControllerFullInterface {
|
2019-01-30 03:51:37 +08:00
|
|
|
constexpr static FileIdentifier file_identifier =
|
|
|
|
ClusterControllerClientInterface::file_identifier;
|
2017-05-26 04:48:44 +08:00
|
|
|
ClusterInterface clientInterface;
|
|
|
|
RequestStream< struct RecruitFromConfigurationRequest > recruitFromConfiguration;
|
2017-09-08 06:32:08 +08:00
|
|
|
RequestStream< struct RecruitRemoteFromConfigurationRequest > recruitRemoteFromConfiguration;
|
2017-05-26 04:48:44 +08:00
|
|
|
RequestStream< struct RecruitStorageRequest > recruitStorage;
|
|
|
|
RequestStream< struct RegisterWorkerRequest > registerWorker;
|
|
|
|
RequestStream< struct GetWorkersRequest > getWorkers;
|
|
|
|
RequestStream< struct RegisterMasterRequest > registerMaster;
|
|
|
|
RequestStream< struct GetServerDBInfoRequest > getServerDBInfo;
|
|
|
|
|
|
|
|
UID id() const { return clientInterface.id(); }
|
|
|
|
bool operator == (ClusterControllerFullInterface const& r) const { return id() == r.id(); }
|
|
|
|
bool operator != (ClusterControllerFullInterface const& r) const { return id() != r.id(); }
|
|
|
|
|
2019-05-30 07:57:13 +08:00
|
|
|
bool hasMessage() {
|
|
|
|
return clientInterface.hasMessage() ||
|
|
|
|
recruitFromConfiguration.getFuture().isReady() ||
|
|
|
|
recruitRemoteFromConfiguration.getFuture().isReady() ||
|
|
|
|
recruitStorage.getFuture().isReady() ||
|
|
|
|
registerWorker.getFuture().isReady() ||
|
|
|
|
getWorkers.getFuture().isReady() ||
|
|
|
|
registerMaster.getFuture().isReady() ||
|
|
|
|
getServerDBInfo.getFuture().isReady();
|
|
|
|
}
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
void initEndpoints() {
|
|
|
|
clientInterface.initEndpoints();
|
2019-12-05 08:28:41 +08:00
|
|
|
recruitFromConfiguration.getEndpoint( TaskPriority::ClusterControllerRecruit );
|
|
|
|
recruitRemoteFromConfiguration.getEndpoint( TaskPriority::ClusterControllerRecruit );
|
2019-06-25 17:47:35 +08:00
|
|
|
recruitStorage.getEndpoint( TaskPriority::ClusterController );
|
2019-12-05 08:17:41 +08:00
|
|
|
registerWorker.getEndpoint( TaskPriority::ClusterControllerWorker );
|
2019-06-25 17:47:35 +08:00
|
|
|
getWorkers.getEndpoint( TaskPriority::ClusterController );
|
2019-12-05 08:28:41 +08:00
|
|
|
registerMaster.getEndpoint( TaskPriority::ClusterControllerRegister );
|
2019-06-25 17:47:35 +08:00
|
|
|
getServerDBInfo.getEndpoint( TaskPriority::ClusterController );
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class Ar>
|
2019-01-29 11:38:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
if constexpr (!is_fb_function<Ar>) {
|
2019-06-19 08:55:27 +08:00
|
|
|
ASSERT(ar.protocolVersion().isValid());
|
2019-01-29 11:38:13 +08:00
|
|
|
}
|
|
|
|
serializer(ar, clientInterface, recruitFromConfiguration, recruitRemoteFromConfiguration, recruitStorage,
|
|
|
|
registerWorker, getWorkers, registerMaster, getServerDBInfo);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-17 06:00:12 +08:00
|
|
|
struct RecruitFromConfigurationReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 2224085;
|
2019-05-22 05:03:11 +08:00
|
|
|
std::vector<WorkerInterface> backupWorkers;
|
2019-04-25 06:12:37 +08:00
|
|
|
std::vector<WorkerInterface> tLogs;
|
|
|
|
std::vector<WorkerInterface> satelliteTLogs;
|
|
|
|
std::vector<WorkerInterface> proxies;
|
|
|
|
std::vector<WorkerInterface> resolvers;
|
|
|
|
std::vector<WorkerInterface> storageServers;
|
|
|
|
std::vector<WorkerInterface> oldLogRouters;
|
2019-04-17 06:00:12 +08:00
|
|
|
Optional<Key> dcId;
|
|
|
|
bool satelliteFallback;
|
|
|
|
|
|
|
|
RecruitFromConfigurationReply() : satelliteFallback(false) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
2019-05-22 05:03:11 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, tLogs, satelliteTLogs, proxies, resolvers, storageServers, oldLogRouters, dcId,
|
|
|
|
satelliteFallback, backupWorkers);
|
2019-04-17 06:00:12 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct RecruitFromConfigurationRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 2023046;
|
2017-05-26 04:48:44 +08:00
|
|
|
DatabaseConfiguration configuration;
|
2017-09-15 08:06:00 +08:00
|
|
|
bool recruitSeedServers;
|
2018-03-30 06:12:38 +08:00
|
|
|
int maxOldLogRouters;
|
2017-05-26 04:48:44 +08:00
|
|
|
ReplyPromise< struct RecruitFromConfigurationReply > reply;
|
|
|
|
|
|
|
|
RecruitFromConfigurationRequest() {}
|
2018-03-30 06:12:38 +08:00
|
|
|
explicit RecruitFromConfigurationRequest(DatabaseConfiguration const& configuration, bool recruitSeedServers, int maxOldLogRouters)
|
|
|
|
: configuration(configuration), recruitSeedServers(recruitSeedServers), maxOldLogRouters(maxOldLogRouters) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, configuration, recruitSeedServers, maxOldLogRouters, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-17 06:00:12 +08:00
|
|
|
struct RecruitRemoteFromConfigurationReply {
|
|
|
|
constexpr static FileIdentifier file_identifier = 9091392;
|
2019-05-08 05:44:40 +08:00
|
|
|
std::vector<WorkerInterface> remoteTLogs;
|
|
|
|
std::vector<WorkerInterface> logRouters;
|
2017-09-08 06:32:08 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2019-04-17 06:00:12 +08:00
|
|
|
serializer(ar, remoteTLogs, logRouters);
|
2017-09-08 06:32:08 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RecruitRemoteFromConfigurationRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 3235995;
|
2017-09-08 06:32:08 +08:00
|
|
|
DatabaseConfiguration configuration;
|
|
|
|
Optional<Key> dcId;
|
2018-03-07 08:31:21 +08:00
|
|
|
int logRouterCount;
|
2019-03-19 03:17:59 +08:00
|
|
|
std::vector<UID> exclusionWorkerIds;
|
2017-09-08 06:32:08 +08:00
|
|
|
ReplyPromise< struct RecruitRemoteFromConfigurationReply > reply;
|
|
|
|
|
|
|
|
RecruitRemoteFromConfigurationRequest() {}
|
2019-03-19 03:17:59 +08:00
|
|
|
RecruitRemoteFromConfigurationRequest(DatabaseConfiguration const& configuration, Optional<Key> const& dcId, int logRouterCount, const std::vector<UID> &exclusionWorkerIds) : configuration(configuration), dcId(dcId), logRouterCount(logRouterCount), exclusionWorkerIds(exclusionWorkerIds){}
|
2017-09-08 06:32:08 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2019-03-19 03:17:59 +08:00
|
|
|
serializer(ar, configuration, dcId, logRouterCount, exclusionWorkerIds, reply);
|
2017-09-08 06:32:08 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct RecruitStorageReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 15877089;
|
2017-05-26 04:48:44 +08:00
|
|
|
WorkerInterface worker;
|
|
|
|
ProcessClass processClass;
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, worker, processClass);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RecruitStorageRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 905920;
|
2017-05-26 04:48:44 +08:00
|
|
|
std::vector<Optional<Standalone<StringRef>>> excludeMachines; //< Don't recruit any of these machines
|
|
|
|
std::vector<AddressExclusion> excludeAddresses; //< Don't recruit any of these addresses
|
2017-09-08 06:32:08 +08:00
|
|
|
std::vector<Optional<Standalone<StringRef>>> includeDCs;
|
2017-05-26 04:48:44 +08:00
|
|
|
bool criticalRecruitment; //< True if machine classes are to be ignored
|
|
|
|
ReplyPromise< RecruitStorageReply > reply;
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, excludeMachines, excludeAddresses, includeDCs, criticalRecruitment, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-15 05:57:37 +08:00
|
|
|
struct RegisterWorkerReply {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 16475696;
|
2017-11-15 05:57:37 +08:00
|
|
|
ProcessClass processClass;
|
2018-02-10 08:48:55 +08:00
|
|
|
ClusterControllerPriorityInfo priorityInfo;
|
2019-11-13 05:01:29 +08:00
|
|
|
Optional<uint16_t> storageCache;
|
2017-11-15 05:57:37 +08:00
|
|
|
|
2018-02-10 08:48:55 +08:00
|
|
|
RegisterWorkerReply() : priorityInfo(ProcessClass::UnsetFit, false, ClusterControllerPriorityInfo::FitnessUnknown) {}
|
2019-11-13 05:01:29 +08:00
|
|
|
RegisterWorkerReply(ProcessClass processClass, ClusterControllerPriorityInfo priorityInfo, Optional<uint16_t> storageCache) : processClass(processClass), priorityInfo(priorityInfo), storageCache(storageCache) {}
|
2017-11-15 05:57:37 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2019-11-13 05:01:29 +08:00
|
|
|
serializer(ar, processClass, priorityInfo, storageCache);
|
2017-11-15 05:57:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct RegisterWorkerRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 14332605;
|
2017-05-26 04:48:44 +08:00
|
|
|
WorkerInterface wi;
|
2017-10-05 08:11:12 +08:00
|
|
|
ProcessClass initialClass;
|
2018-02-10 08:48:55 +08:00
|
|
|
ProcessClass processClass;
|
|
|
|
ClusterControllerPriorityInfo priorityInfo;
|
2017-05-26 04:48:44 +08:00
|
|
|
Generation generation;
|
2019-01-29 03:29:39 +08:00
|
|
|
Optional<DataDistributorInterface> distributorInterf;
|
2019-02-15 08:24:46 +08:00
|
|
|
Optional<RatekeeperInterface> ratekeeperInterf;
|
2019-11-13 05:01:29 +08:00
|
|
|
Optional<std::pair<uint16_t,StorageServerInterface>> storageCacheInterf;
|
2017-11-15 05:57:37 +08:00
|
|
|
ReplyPromise<RegisterWorkerReply> reply;
|
2019-03-09 00:46:34 +08:00
|
|
|
bool degraded;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-03-09 00:46:34 +08:00
|
|
|
RegisterWorkerRequest() : priorityInfo(ProcessClass::UnsetFit, false, ClusterControllerPriorityInfo::FitnessUnknown), degraded(false) {}
|
2019-11-13 05:01:29 +08:00
|
|
|
RegisterWorkerRequest(WorkerInterface wi, ProcessClass initialClass, ProcessClass processClass, ClusterControllerPriorityInfo priorityInfo, Generation generation, Optional<DataDistributorInterface> ddInterf, Optional<RatekeeperInterface> rkInterf, Optional<std::pair<uint16_t,StorageServerInterface>> storageCacheInterf, bool degraded) :
|
|
|
|
wi(wi), initialClass(initialClass), processClass(processClass), priorityInfo(priorityInfo), generation(generation), distributorInterf(ddInterf), ratekeeperInterf(rkInterf), storageCacheInterf(storageCacheInterf), degraded(degraded) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize( Ar& ar ) {
|
2019-11-13 05:01:29 +08:00
|
|
|
serializer(ar, wi, initialClass, processClass, priorityInfo, generation, distributorInterf, ratekeeperInterf, storageCacheInterf, reply, degraded);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GetWorkersRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 1254174;
|
2017-10-25 03:58:54 +08:00
|
|
|
enum { TESTER_CLASS_ONLY = 0x1, NON_EXCLUDED_PROCESSES_ONLY = 0x2 };
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
int flags;
|
2019-03-09 00:25:07 +08:00
|
|
|
ReplyPromise<vector<WorkerDetails>> reply;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
GetWorkersRequest() : flags(0) {}
|
|
|
|
explicit GetWorkersRequest(int fl) : flags(fl) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, flags, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RegisterMasterRequest {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 10773445;
|
2017-05-26 04:48:44 +08:00
|
|
|
UID id;
|
|
|
|
LocalityData mi;
|
|
|
|
LogSystemConfig logSystemConfig;
|
2019-05-08 05:44:40 +08:00
|
|
|
std::vector<MasterProxyInterface> proxies;
|
|
|
|
std::vector<ResolverInterface> resolvers;
|
2017-05-26 04:48:44 +08:00
|
|
|
DBRecoveryCount recoveryCount;
|
|
|
|
int64_t registrationCount;
|
2017-09-23 07:59:24 +08:00
|
|
|
Optional<DatabaseConfiguration> configuration;
|
2019-05-08 05:44:40 +08:00
|
|
|
std::vector<UID> priorCommittedLogServers;
|
2018-05-09 08:17:17 +08:00
|
|
|
RecoveryState recoveryState;
|
2018-06-14 09:14:14 +08:00
|
|
|
bool recoveryStalled;
|
2018-05-09 08:17:17 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
ReplyPromise<Void> reply;
|
|
|
|
|
2019-06-01 07:14:58 +08:00
|
|
|
RegisterMasterRequest() : logSystemConfig(0) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2019-01-29 11:38:13 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
if constexpr (!is_fb_function<Ar>) {
|
2019-06-19 08:55:27 +08:00
|
|
|
ASSERT(ar.protocolVersion().isValid());
|
2019-01-29 11:38:13 +08:00
|
|
|
}
|
|
|
|
serializer(ar, id, mi, logSystemConfig, proxies, resolvers, recoveryCount, registrationCount, configuration,
|
|
|
|
priorCommittedLogServers, recoveryState, recoveryStalled, reply);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbserver/ServerDBInfo.h" // include order hack
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
#endif
|