2017-05-26 04:48:44 +08:00
|
|
|
/*
|
2019-02-18 09:38:13 +08:00
|
|
|
* ManagementAPI.actor.h
|
2017-05-26 04:48:44 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-02-18 09:38:13 +08:00
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBCLIENT_MANAGEMENT_API_ACTOR_G_H)
|
2021-03-11 02:06:03 +08:00
|
|
|
#define FDBCLIENT_MANAGEMENT_API_ACTOR_G_H
|
|
|
|
#include "fdbclient/ManagementAPI.actor.g.h"
|
2019-02-18 09:38:13 +08:00
|
|
|
#elif !defined(FDBCLIENT_MANAGEMENT_API_ACTOR_H)
|
2021-03-11 02:06:03 +08:00
|
|
|
#define FDBCLIENT_MANAGEMENT_API_ACTOR_H
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
/* This file defines "management" interfaces for configuration, coordination changes, and
|
|
|
|
the inclusion and exclusion of servers. It is used to implement fdbcli management commands
|
|
|
|
and by test workloads that simulate such. It isn't exposed to C clients or anywhere outside
|
|
|
|
our code base and doesn't need to be versioned. It doesn't do anything you can't do with the
|
|
|
|
standard API and some knowledge of the contents of the system key space.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2019-02-18 07:41:16 +08:00
|
|
|
#include "fdbclient/NativeAPI.actor.h"
|
2018-10-20 01:30:13 +08:00
|
|
|
#include "fdbclient/Status.h"
|
|
|
|
#include "fdbclient/ReadYourWrites.h"
|
|
|
|
#include "fdbclient/DatabaseConfiguration.h"
|
|
|
|
#include "fdbclient/MonitorLeader.h"
|
2019-02-18 09:38:13 +08:00
|
|
|
#include "flow/actorcompiler.h" // has to be last include
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// ConfigurationResult enumerates normal outcomes of changeConfig() and various error
|
|
|
|
// conditions specific to it. changeConfig may also throw an Error to report other problems.
|
2020-09-28 02:52:18 +08:00
|
|
|
enum class ConfigurationResult {
|
|
|
|
NO_OPTIONS_PROVIDED,
|
|
|
|
CONFLICTING_OPTIONS,
|
|
|
|
UNKNOWN_OPTION,
|
|
|
|
INCOMPLETE_CONFIGURATION,
|
|
|
|
INVALID_CONFIGURATION,
|
|
|
|
DATABASE_ALREADY_CREATED,
|
|
|
|
DATABASE_CREATED,
|
|
|
|
DATABASE_UNAVAILABLE,
|
|
|
|
STORAGE_IN_UNKNOWN_DCID,
|
|
|
|
REGION_NOT_FULLY_REPLICATED,
|
|
|
|
MULTIPLE_ACTIVE_REGIONS,
|
|
|
|
REGIONS_CHANGED,
|
|
|
|
NOT_ENOUGH_WORKERS,
|
|
|
|
REGION_REPLICATION_MISMATCH,
|
|
|
|
DCID_MISSING,
|
|
|
|
LOCKED_NOT_NEW,
|
|
|
|
SUCCESS,
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
2020-09-28 02:52:18 +08:00
|
|
|
enum class CoordinatorsResult {
|
|
|
|
INVALID_NETWORK_ADDRESSES,
|
|
|
|
SAME_NETWORK_ADDRESSES,
|
|
|
|
NOT_COORDINATORS, // FIXME: not detected
|
|
|
|
DATABASE_UNREACHABLE, // FIXME: not detected
|
|
|
|
BAD_DATABASE_STATE,
|
|
|
|
COORDINATOR_UNREACHABLE,
|
|
|
|
NOT_ENOUGH_MACHINES,
|
|
|
|
SUCCESS
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ConfigureAutoResult {
|
|
|
|
std::map<NetworkAddress, ProcessClass> address_class;
|
|
|
|
int32_t processes;
|
|
|
|
int32_t machines;
|
|
|
|
|
|
|
|
std::string old_replication;
|
2020-09-11 08:44:15 +08:00
|
|
|
int32_t old_commit_proxies;
|
2020-08-06 15:01:57 +08:00
|
|
|
int32_t old_grv_proxies;
|
2017-05-26 04:48:44 +08:00
|
|
|
int32_t old_resolvers;
|
|
|
|
int32_t old_logs;
|
|
|
|
int32_t old_processes_with_transaction;
|
|
|
|
int32_t old_machines_with_transaction;
|
|
|
|
|
|
|
|
std::string auto_replication;
|
2020-09-11 08:44:15 +08:00
|
|
|
int32_t auto_commit_proxies;
|
2020-08-06 15:01:57 +08:00
|
|
|
int32_t auto_grv_proxies;
|
2017-05-26 04:48:44 +08:00
|
|
|
int32_t auto_resolvers;
|
|
|
|
int32_t auto_logs;
|
|
|
|
int32_t auto_processes_with_transaction;
|
|
|
|
int32_t auto_machines_with_transaction;
|
|
|
|
|
2020-09-11 08:44:15 +08:00
|
|
|
int32_t desired_commit_proxies;
|
2020-08-06 15:01:57 +08:00
|
|
|
int32_t desired_grv_proxies;
|
2017-05-26 04:48:44 +08:00
|
|
|
int32_t desired_resolvers;
|
|
|
|
int32_t desired_logs;
|
|
|
|
|
2020-08-06 15:01:57 +08:00
|
|
|
ConfigureAutoResult()
|
2020-09-11 08:44:15 +08:00
|
|
|
: processes(-1), machines(-1), old_commit_proxies(-1), old_grv_proxies(-1), old_resolvers(-1), old_logs(-1),
|
|
|
|
old_processes_with_transaction(-1), old_machines_with_transaction(-1), auto_commit_proxies(-1),
|
|
|
|
auto_grv_proxies(-1), auto_resolvers(-1), auto_logs(-1), auto_processes_with_transaction(-1),
|
|
|
|
auto_machines_with_transaction(-1), desired_commit_proxies(-1), desired_grv_proxies(-1), desired_resolvers(-1),
|
|
|
|
desired_logs(-1) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
bool isValid() const { return processes != -1; }
|
|
|
|
};
|
|
|
|
|
2020-09-28 02:52:18 +08:00
|
|
|
ConfigurationResult buildConfiguration(
|
|
|
|
std::vector<StringRef> const& modeTokens,
|
|
|
|
std::map<std::string, std::string>& outConf); // Accepts a vector of configuration tokens
|
|
|
|
ConfigurationResult buildConfiguration(
|
|
|
|
std::string const& modeString,
|
|
|
|
std::map<std::string, std::string>& outConf); // Accepts tokens separated by spaces in a single string
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool isCompleteConfiguration(std::map<std::string, std::string> const& options);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// All versions of changeConfig apply the given set of configuration tokens to the database, and return a
|
|
|
|
// ConfigurationResult (or error).
|
|
|
|
Future<ConfigurationResult> changeConfig(Database const& cx,
|
|
|
|
std::string const& configMode,
|
2020-09-28 02:52:18 +08:00
|
|
|
bool force); // Accepts tokens separated by spaces in a single string
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ConfigureAutoResult parseConfig(StatusObject const& status);
|
|
|
|
Future<ConfigurationResult> changeConfig(Database const& cx,
|
|
|
|
std::vector<StringRef> const& modes,
|
2020-09-28 02:52:18 +08:00
|
|
|
Optional<ConfigureAutoResult> const& conf,
|
|
|
|
bool force); // Accepts a vector of configuration tokens
|
|
|
|
ACTOR Future<ConfigurationResult> changeConfig(
|
2021-03-11 02:06:03 +08:00
|
|
|
Database cx,
|
|
|
|
std::map<std::string, std::string> m,
|
2019-02-18 09:38:13 +08:00
|
|
|
bool force); // Accepts a full configuration in key/value format (from buildConfiguration)
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-18 09:38:13 +08:00
|
|
|
ACTOR Future<DatabaseConfiguration> getDatabaseConfiguration(Database cx);
|
|
|
|
ACTOR Future<Void> waitForFullReplication(Database cx);
|
2018-04-09 12:24:05 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct IQuorumChange : ReferenceCounted<IQuorumChange> {
|
|
|
|
virtual ~IQuorumChange() {}
|
2020-09-28 02:52:18 +08:00
|
|
|
virtual Future<vector<NetworkAddress>> getDesiredCoordinators(Transaction* tr,
|
|
|
|
vector<NetworkAddress> oldCoordinators,
|
|
|
|
Reference<ClusterConnectionFile>,
|
|
|
|
CoordinatorsResult&) = 0;
|
2020-10-16 01:39:38 +08:00
|
|
|
virtual std::string getDesiredClusterKeyName() const { return std::string(); }
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// Change to use the given set of coordination servers
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Optional<CoordinatorsResult>> changeQuorumChecker(Transaction* tr,
|
|
|
|
Reference<IQuorumChange> change,
|
2021-02-17 05:01:37 +08:00
|
|
|
std::vector<NetworkAddress>* desiredCoordinators);
|
2020-09-28 02:52:18 +08:00
|
|
|
ACTOR Future<CoordinatorsResult> changeQuorum(Database cx, Reference<IQuorumChange> change);
|
2017-05-26 04:48:44 +08:00
|
|
|
Reference<IQuorumChange> autoQuorumChange(int desired = -1);
|
|
|
|
Reference<IQuorumChange> noQuorumChange();
|
|
|
|
Reference<IQuorumChange> specifiedQuorumChange(vector<NetworkAddress> const&);
|
|
|
|
Reference<IQuorumChange> nameQuorumChange(std::string const& name, Reference<IQuorumChange> const& other);
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Exclude the given set of servers from use as state servers. Returns as soon as the change is durable, without
|
|
|
|
// necessarily waiting for the servers to be evacuated. A NetworkAddress with a port of 0 means all servers on the
|
|
|
|
// given IP.
|
|
|
|
ACTOR Future<Void> excludeServers(Database cx, vector<AddressExclusion> servers, bool failed = false);
|
2020-07-07 02:02:48 +08:00
|
|
|
void excludeServers(Transaction& tr, vector<AddressExclusion>& servers, bool failed = false);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-05-19 14:48:04 +08:00
|
|
|
// Exclude the servers matching the given set of localities from use as state servers. Returns as soon as the change
|
|
|
|
// is durable, without necessarily waiting for the servers to be evacuated.
|
2021-06-05 06:23:04 +08:00
|
|
|
ACTOR Future<Void> excludeLocalities(Database cx, std::unordered_set<std::string>* localities, bool failed = false);
|
|
|
|
void excludeLocalities(Transaction& tr, std::unordered_set<std::string>* localities, bool failed = false);
|
2021-05-19 14:48:04 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Remove the given servers from the exclusion list. A NetworkAddress with a port of 0 means all servers on the given
|
|
|
|
// IP. A NetworkAddress() means all servers (don't exclude anything)
|
2019-10-24 02:05:48 +08:00
|
|
|
ACTOR Future<Void> includeServers(Database cx, vector<AddressExclusion> servers, bool failed = false);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-05-19 14:48:04 +08:00
|
|
|
// Remove the given localities from the exclusion list.
|
2021-06-05 06:23:04 +08:00
|
|
|
ACTOR Future<Void> includeLocalities(Database cx,
|
|
|
|
vector<std::string>* localities,
|
|
|
|
bool failed = false,
|
|
|
|
bool includeAll = false);
|
2021-05-19 14:48:04 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Set the process class of processes with the given address. A NetworkAddress with a port of 0 means all servers on
|
|
|
|
// the given IP.
|
|
|
|
ACTOR Future<Void> setClass(Database cx, AddressExclusion server, ProcessClass processClass);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// Get the current list of excluded servers
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<vector<AddressExclusion>> getExcludedServers(Database cx);
|
|
|
|
ACTOR Future<vector<AddressExclusion>> getExcludedServers(Transaction* tr);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-05-19 14:48:04 +08:00
|
|
|
// Get the current list of excluded localities
|
|
|
|
ACTOR Future<vector<std::string>> getExcludedLocalities(Database cx);
|
|
|
|
ACTOR Future<vector<std::string>> getExcludedLocalities(Transaction* tr);
|
|
|
|
|
|
|
|
std::set<AddressExclusion> getAddressesByLocality(std::vector<ProcessData>& workers, std::string locality);
|
|
|
|
|
2019-07-17 09:10:26 +08:00
|
|
|
// Check for the given, previously excluded servers to be evacuated (no longer used for state). If waitForExclusion is
|
|
|
|
// true, this actor returns once it is safe to shut down all such machines without impacting fault tolerance, until and
|
|
|
|
// unless any of them are explicitly included with includeServers()
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<std::set<NetworkAddress>> checkForExcludingServers(Database cx,
|
|
|
|
vector<AddressExclusion> servers,
|
2019-07-17 09:10:26 +08:00
|
|
|
bool waitForAllExcluded);
|
2020-07-29 04:40:14 +08:00
|
|
|
ACTOR Future<bool> checkForExcludingServersTxActor(ReadYourWritesTransaction* tr,
|
|
|
|
std::set<AddressExclusion>* exclusions,
|
|
|
|
std::set<NetworkAddress>* inProgressExclusion);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// Gets a list of all workers in the cluster (excluding testers)
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<vector<ProcessData>> getWorkers(Database cx);
|
|
|
|
ACTOR Future<vector<ProcessData>> getWorkers(Transaction* tr);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> timeKeeperSetDisable(Database cx);
|
2017-09-29 04:13:24 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> lockDatabase(Transaction* tr, UID id);
|
|
|
|
ACTOR Future<Void> lockDatabase(Reference<ReadYourWritesTransaction> tr, UID id);
|
|
|
|
ACTOR Future<Void> lockDatabase(Database cx, UID id);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> unlockDatabase(Transaction* tr, UID id);
|
|
|
|
ACTOR Future<Void> unlockDatabase(Reference<ReadYourWritesTransaction> tr, UID id);
|
|
|
|
ACTOR Future<Void> unlockDatabase(Database cx, UID id);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> checkDatabaseLock(Transaction* tr, UID id);
|
|
|
|
ACTOR Future<Void> checkDatabaseLock(Reference<ReadYourWritesTransaction> tr, UID id);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-04-16 11:01:01 +08:00
|
|
|
ACTOR Future<Void> advanceVersion(Database cx, Version v);
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<int> setDDMode(Database cx, int mode);
|
2017-07-29 09:12:04 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> forceRecovery(Reference<ClusterConnectionFile> clusterFile, Standalone<StringRef> dcId);
|
2018-07-01 21:39:04 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> printHealthyZone(Database cx);
|
2019-07-12 05:53:00 +08:00
|
|
|
ACTOR Future<Void> setDDIgnoreRebalanceSwitch(Database cx, bool ignoreRebalance);
|
2019-07-25 06:32:52 +08:00
|
|
|
ACTOR Future<bool> clearHealthyZone(Database cx, bool printWarning = false, bool clearSSFailureZoneString = false);
|
|
|
|
ACTOR Future<bool> setHealthyZone(Database cx, StringRef zoneId, double seconds, bool printWarning = false);
|
2019-04-02 08:55:13 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> waitForPrimaryDC(Database cx, StringRef dcId);
|
2018-09-18 09:32:39 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
// Gets the cluster connection string
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<std::vector<NetworkAddress>> getCoordinators(Database cx);
|
|
|
|
|
|
|
|
void schemaCoverage(std::string const& spath, bool covered = true);
|
|
|
|
bool schemaMatch(json_spirit::mValue const& schema,
|
|
|
|
json_spirit::mValue const& result,
|
|
|
|
std::string& errorStr,
|
|
|
|
Severity sev = SevError,
|
|
|
|
bool checkCoverage = false,
|
|
|
|
std::string path = std::string(),
|
|
|
|
std::string schema_path = std::string());
|
2018-08-17 08:34:59 +08:00
|
|
|
|
2019-02-28 07:40:33 +08:00
|
|
|
// execute payload in 'snapCmd' on all the coordinators, TLogs and
|
|
|
|
// storage nodes
|
2019-09-14 02:50:36 +08:00
|
|
|
ACTOR Future<Void> mgmtSnapCreate(Database cx, Standalone<StringRef> snapCmd, UID snapUID);
|
2019-02-28 07:40:33 +08:00
|
|
|
|
2020-01-25 03:00:50 +08:00
|
|
|
Future<Void> addCachedRange(const Database& cx, KeyRangeRef range);
|
|
|
|
Future<Void> removeCachedRange(const Database& cx, KeyRangeRef range);
|
2020-01-08 03:42:57 +08:00
|
|
|
|
2019-02-18 09:38:13 +08:00
|
|
|
#include "flow/unactorcompiler.h"
|
2018-07-01 21:39:04 +08:00
|
|
|
#endif
|