2021-03-25 00:33:20 +08:00
|
|
|
/*
|
|
|
|
* fdbcli.actor.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-05-12 05:31:08 +08:00
|
|
|
// When actually compiled (NO_INTELLISENSE), include the generated
|
|
|
|
// version of this file. In intellisense use the source version.
|
|
|
|
#if defined(NO_INTELLISENSE) && !defined(FDBCLI_FDBCLI_ACTOR_G_H)
|
|
|
|
#define FDBCLI_FDBCLI_ACTOR_G_H
|
|
|
|
#include "fdbcli/fdbcli.actor.g.h"
|
|
|
|
#elif !defined(FDBCLI_FDBCLI_ACTOR_H)
|
|
|
|
#define FDBCLI_FDBCLI_ACTOR_H
|
|
|
|
|
2021-09-21 05:41:20 +08:00
|
|
|
#include "fdbcli/FlowLineNoise.h"
|
|
|
|
|
2021-07-10 03:32:28 +08:00
|
|
|
#include "fdbclient/CoordinationInterface.h"
|
2021-03-25 00:33:20 +08:00
|
|
|
#include "fdbclient/IClientApi.h"
|
2021-07-13 14:04:23 +08:00
|
|
|
#include "fdbclient/StatusClient.h"
|
2021-03-25 00:33:20 +08:00
|
|
|
#include "flow/Arena.h"
|
|
|
|
|
2021-05-12 05:31:08 +08:00
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
|
|
|
|
2021-03-30 03:51:32 +08:00
|
|
|
namespace fdb_cli {
|
2021-03-25 00:33:20 +08:00
|
|
|
|
|
|
|
struct CommandHelp {
|
|
|
|
std::string usage;
|
|
|
|
std::string short_desc;
|
|
|
|
std::string long_desc;
|
|
|
|
CommandHelp() {}
|
|
|
|
CommandHelp(const char* u, const char* s, const char* l) : usage(u), short_desc(s), long_desc(l) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandFactory {
|
|
|
|
CommandFactory(const char* name, CommandHelp help) { commands()[name] = help; }
|
2021-04-14 04:27:40 +08:00
|
|
|
CommandFactory(const char* name) { hiddenCommands().insert(name); }
|
|
|
|
static std::map<std::string, CommandHelp>& commands() {
|
2021-03-25 00:33:20 +08:00
|
|
|
static std::map<std::string, CommandHelp> helpMap;
|
|
|
|
return helpMap;
|
|
|
|
}
|
2021-04-14 04:27:40 +08:00
|
|
|
static std::set<std::string>& hiddenCommands() {
|
|
|
|
static std::set<std::string> commands;
|
|
|
|
return commands;
|
|
|
|
}
|
2021-03-25 00:33:20 +08:00
|
|
|
};
|
|
|
|
|
2021-04-14 04:27:40 +08:00
|
|
|
// Special keys used by fdbcli commands
|
2021-05-18 15:22:17 +08:00
|
|
|
// advanceversion
|
|
|
|
extern const KeyRef advanceVersionSpecialKey;
|
2021-04-14 04:27:40 +08:00
|
|
|
// consistencycheck
|
2021-05-08 07:03:27 +08:00
|
|
|
extern const KeyRef consistencyCheckSpecialKey;
|
2021-07-18 04:24:38 +08:00
|
|
|
// coordinators
|
|
|
|
extern const KeyRef clusterDescriptionSpecialKey;
|
|
|
|
extern const KeyRef coordinatorsAutoSpecialKey;
|
|
|
|
extern const KeyRef coordinatorsProcessSpecialKey;
|
2021-06-24 03:49:19 +08:00
|
|
|
// datadistribution
|
|
|
|
extern const KeyRef ddModeSpecialKey;
|
|
|
|
extern const KeyRef ddIgnoreRebalanceSpecialKey;
|
2021-07-18 04:24:38 +08:00
|
|
|
// exclude/include
|
|
|
|
extern const KeyRangeRef excludedServersSpecialKeyRange;
|
|
|
|
extern const KeyRangeRef failedServersSpecialKeyRange;
|
|
|
|
extern const KeyRangeRef excludedLocalitySpecialKeyRange;
|
|
|
|
extern const KeyRangeRef failedLocalitySpecialKeyRange;
|
2021-07-18 17:27:25 +08:00
|
|
|
extern const KeyRef excludedForceOptionSpecialKey;
|
|
|
|
extern const KeyRef failedForceOptionSpecialKey;
|
|
|
|
extern const KeyRef excludedLocalityForceOptionSpecialKey;
|
|
|
|
extern const KeyRef failedLocalityForceOptionSpecialKey;
|
|
|
|
extern const KeyRangeRef exclusionInProgressSpecialKeyRange;
|
2021-07-14 01:21:55 +08:00
|
|
|
// lock/unlock
|
|
|
|
extern const KeyRef lockSpecialKey;
|
2021-05-21 02:37:03 +08:00
|
|
|
// maintenance
|
|
|
|
extern const KeyRangeRef maintenanceSpecialKeyRange;
|
|
|
|
extern const KeyRef ignoreSSFailureSpecialKey;
|
2021-07-09 06:00:05 +08:00
|
|
|
// setclass
|
|
|
|
extern const KeyRangeRef processClassSourceSpecialKeyRange;
|
|
|
|
extern const KeyRangeRef processClassTypeSpecialKeyRange;
|
2021-07-09 06:29:04 +08:00
|
|
|
// Other special keys
|
|
|
|
inline const KeyRef errorMsgSpecialKey = LiteralStringRef("\xff\xff/error_message");
|
2021-03-30 03:51:32 +08:00
|
|
|
// help functions (Copied from fdbcli.actor.cpp)
|
2021-07-10 03:32:28 +08:00
|
|
|
// decode worker interfaces
|
|
|
|
ACTOR Future<Void> addInterface(std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface,
|
|
|
|
Reference<FlowLock> connectLock,
|
|
|
|
KeyValue kv);
|
2021-07-18 17:27:25 +08:00
|
|
|
// get all workers' info
|
|
|
|
ACTOR Future<bool> getWorkers(Reference<IDatabase> db, std::vector<ProcessData>* workers);
|
2021-03-30 03:51:32 +08:00
|
|
|
|
|
|
|
// compare StringRef with the given c string
|
2021-03-25 00:33:20 +08:00
|
|
|
bool tokencmp(StringRef token, const char* command);
|
2021-03-30 03:51:32 +08:00
|
|
|
// print the usage of the specified command
|
2021-03-25 00:33:20 +08:00
|
|
|
void printUsage(StringRef command);
|
2021-08-25 05:18:43 +08:00
|
|
|
// Pre: tr failed with special_keys_api_failure error
|
|
|
|
// Read the error message special key and return the message
|
|
|
|
ACTOR Future<std::string> getSpecialKeysFailureErrorMessage(Reference<ITransaction> tr);
|
2021-08-26 02:54:08 +08:00
|
|
|
// Using \xff\xff/worker_interfaces/ special key, get all worker interfaces
|
|
|
|
ACTOR Future<Void> getWorkerInterfaces(Reference<ITransaction> tr,
|
|
|
|
std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface);
|
|
|
|
// Deserialize \xff\xff/worker_interfaces/<address>:=<ClientInterface> k-v pair and verify by a RPC call
|
|
|
|
ACTOR Future<Void> verifyAndAddInterface(std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface,
|
|
|
|
Reference<FlowLock> connectLock,
|
|
|
|
KeyValue kv);
|
2021-07-13 14:04:23 +08:00
|
|
|
// print cluster status info
|
|
|
|
void printStatus(StatusObjectReader statusObj,
|
|
|
|
StatusClient::StatusLevel level,
|
|
|
|
bool displayDatabaseAvailable = true,
|
|
|
|
bool hideErrorMessages = false);
|
2021-03-25 00:33:20 +08:00
|
|
|
|
2021-03-30 03:51:32 +08:00
|
|
|
// All fdbcli commands (alphabetically)
|
2021-09-21 06:40:53 +08:00
|
|
|
// All below actors return true if the command is executed successfully
|
2021-05-18 15:22:17 +08:00
|
|
|
// advanceversion command
|
|
|
|
ACTOR Future<bool> advanceVersionCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-09 03:28:46 +08:00
|
|
|
// cache_range command
|
|
|
|
ACTOR Future<bool> cacheRangeCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-09-21 05:41:20 +08:00
|
|
|
// configure command
|
|
|
|
ACTOR Future<bool> configureCommandActor(Reference<IDatabase> db,
|
|
|
|
Database localDb,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
LineNoise* linenoise,
|
|
|
|
Future<Void> warn);
|
2021-03-25 00:33:20 +08:00
|
|
|
// consistency command
|
2021-07-13 04:08:35 +08:00
|
|
|
ACTOR Future<bool> consistencyCheckCommandActor(Reference<ITransaction> tr,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
bool intrans);
|
2021-07-18 04:24:38 +08:00
|
|
|
// coordinators command
|
|
|
|
ACTOR Future<bool> coordinatorsCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-06-24 03:49:19 +08:00
|
|
|
// datadistribution command
|
|
|
|
ACTOR Future<bool> dataDistributionCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-18 04:24:38 +08:00
|
|
|
// exclude command
|
2021-07-18 17:27:25 +08:00
|
|
|
ACTOR Future<bool> excludeCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens, Future<Void> warn);
|
2021-07-10 04:50:55 +08:00
|
|
|
// expensive_data_check command
|
|
|
|
ACTOR Future<bool> expensiveDataCheckCommandActor(
|
|
|
|
Reference<IDatabase> db,
|
|
|
|
Reference<ITransaction> tr,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface);
|
2021-09-21 06:40:53 +08:00
|
|
|
// fileconfigure command
|
|
|
|
ACTOR Future<bool> fileConfigureCommandActor(Reference<IDatabase> db,
|
|
|
|
std::string filePath,
|
|
|
|
bool isNewDatabase,
|
|
|
|
bool force);
|
2021-05-21 03:47:00 +08:00
|
|
|
// force_recovery_with_data_loss command
|
|
|
|
ACTOR Future<bool> forceRecoveryWithDataLossCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-18 04:24:38 +08:00
|
|
|
// include command
|
|
|
|
ACTOR Future<bool> includeCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-10 03:32:28 +08:00
|
|
|
// kill command
|
|
|
|
ACTOR Future<bool> killCommandActor(Reference<IDatabase> db,
|
|
|
|
Reference<ITransaction> tr,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface);
|
2021-07-14 01:21:55 +08:00
|
|
|
// lock/unlock command
|
|
|
|
ACTOR Future<bool> lockCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-09-10 06:59:43 +08:00
|
|
|
ACTOR Future<bool> unlockDatabaseActor(Reference<IDatabase> db, UID uid);
|
2021-10-20 04:56:52 +08:00
|
|
|
// changefeed command
|
|
|
|
ACTOR Future<bool> changeFeedCommandActor(Database localDb, std::vector<StringRef> tokens, Future<Void> warn);
|
2021-10-22 07:24:39 +08:00
|
|
|
// blobrange command
|
|
|
|
ACTOR Future<bool> blobRangeCommandActor(Database localDb, std::vector<StringRef> tokens);
|
2021-05-21 02:37:03 +08:00
|
|
|
// maintenance command
|
2021-06-24 03:49:19 +08:00
|
|
|
ACTOR Future<bool> setHealthyZone(Reference<IDatabase> db, StringRef zoneId, double seconds, bool printWarning = false);
|
|
|
|
ACTOR Future<bool> clearHealthyZone(Reference<IDatabase> db,
|
|
|
|
bool printWarning = false,
|
|
|
|
bool clearSSFailureZoneString = false);
|
2021-05-21 02:37:03 +08:00
|
|
|
ACTOR Future<bool> maintenanceCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-13 04:08:35 +08:00
|
|
|
// profile command
|
|
|
|
ACTOR Future<bool> profileCommandActor(Reference<ITransaction> tr, std::vector<StringRef> tokens, bool intrans);
|
2021-07-09 06:00:05 +08:00
|
|
|
// setclass command
|
|
|
|
ACTOR Future<bool> setClassCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-05-21 05:01:50 +08:00
|
|
|
// snapshot command
|
|
|
|
ACTOR Future<bool> snapshotCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-07-13 14:04:23 +08:00
|
|
|
// status command
|
2021-09-09 01:05:13 +08:00
|
|
|
ACTOR Future<bool> statusCommandActor(Reference<IDatabase> db,
|
|
|
|
Database localDb,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
bool isExecMode = false);
|
2021-07-10 04:50:55 +08:00
|
|
|
// suspend command
|
|
|
|
ACTOR Future<bool> suspendCommandActor(Reference<IDatabase> db,
|
|
|
|
Reference<ITransaction> tr,
|
|
|
|
std::vector<StringRef> tokens,
|
|
|
|
std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface);
|
2021-07-28 01:58:11 +08:00
|
|
|
// throttle command
|
|
|
|
ACTOR Future<bool> throttleCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-08-28 04:05:59 +08:00
|
|
|
// triggerteaminfolog command
|
2021-09-21 06:54:08 +08:00
|
|
|
ACTOR Future<bool> triggerddteaminfologCommandActor(Reference<IDatabase> db);
|
2021-08-28 04:05:59 +08:00
|
|
|
// tssq command
|
|
|
|
ACTOR Future<bool> tssqCommandActor(Reference<IDatabase> db, std::vector<StringRef> tokens);
|
2021-03-25 00:33:20 +08:00
|
|
|
|
2021-03-30 03:51:32 +08:00
|
|
|
} // namespace fdb_cli
|
2021-03-25 00:33:20 +08:00
|
|
|
|
2021-05-12 05:31:08 +08:00
|
|
|
#include "flow/unactorcompiler.h"
|
2021-04-14 04:27:40 +08:00
|
|
|
#endif
|