/* * fdbcli.actor.h * * This source file is part of the FoundationDB open source project * * Copyright 2013-2022 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 // 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 #include "fdbcli/FlowLineNoise.h" #include "fdbclient/CoordinationInterface.h" #include "fdbclient/IClientApi.h" #include "fdbclient/StatusClient.h" #include "flow/Arena.h" #include "flow/actorcompiler.h" // This must be the last #include. namespace fdb_cli { 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; } CommandFactory(const char* name) { hiddenCommands().insert(name); } static std::map& commands() { static std::map helpMap; return helpMap; } static std::set& hiddenCommands() { static std::set commands; return commands; } }; // Special keys used by fdbcli commands // advanceversion extern const KeyRef advanceVersionSpecialKey; // consistencycheck extern const KeyRef consistencyCheckSpecialKey; // coordinators extern const KeyRef clusterDescriptionSpecialKey; extern const KeyRef coordinatorsAutoSpecialKey; extern const KeyRef coordinatorsProcessSpecialKey; // datadistribution extern const KeyRef ddModeSpecialKey; extern const KeyRef ddIgnoreRebalanceSpecialKey; // exclude/include extern const KeyRangeRef excludedServersSpecialKeyRange; extern const KeyRangeRef failedServersSpecialKeyRange; extern const KeyRangeRef excludedLocalitySpecialKeyRange; extern const KeyRangeRef failedLocalitySpecialKeyRange; extern const KeyRef excludedForceOptionSpecialKey; extern const KeyRef failedForceOptionSpecialKey; extern const KeyRef excludedLocalityForceOptionSpecialKey; extern const KeyRef failedLocalityForceOptionSpecialKey; extern const KeyRangeRef exclusionInProgressSpecialKeyRange; // lock/unlock extern const KeyRef lockSpecialKey; // maintenance extern const KeyRangeRef maintenanceSpecialKeyRange; extern const KeyRef ignoreSSFailureSpecialKey; // setclass extern const KeyRangeRef processClassSourceSpecialKeyRange; extern const KeyRangeRef processClassTypeSpecialKeyRange; // Other special keys inline const KeyRef errorMsgSpecialKey = LiteralStringRef("\xff\xff/error_message"); // help functions (Copied from fdbcli.actor.cpp) // decode worker interfaces ACTOR Future addInterface(std::map>* address_interface, Reference connectLock, KeyValue kv); // get all workers' info ACTOR Future getWorkers(Reference db, std::vector* workers); // compare StringRef with the given c string bool tokencmp(StringRef token, const char* command); // print the usage of the specified command void printUsage(StringRef command); // Pre: tr failed with special_keys_api_failure error // Read the error message special key and return the message ACTOR Future getSpecialKeysFailureErrorMessage(Reference tr); // Using \xff\xff/worker_interfaces/ special key, get all worker interfaces ACTOR Future getWorkerInterfaces(Reference tr, std::map>* address_interface); // Deserialize \xff\xff/worker_interfaces/
:= k-v pair and verify by a RPC call ACTOR Future verifyAndAddInterface(std::map>* address_interface, Reference connectLock, KeyValue kv); // print cluster status info void printStatus(StatusObjectReader statusObj, StatusClient::StatusLevel level, bool displayDatabaseAvailable = true, bool hideErrorMessages = false); // All fdbcli commands (alphabetically) // All below actors return true if the command is executed successfully // advanceversion command ACTOR Future advanceVersionCommandActor(Reference db, std::vector tokens); // cache_range command ACTOR Future cacheRangeCommandActor(Reference db, std::vector tokens); // configure command ACTOR Future configureCommandActor(Reference db, Database localDb, std::vector tokens, LineNoise* linenoise, Future warn); // consistency command ACTOR Future consistencyCheckCommandActor(Reference tr, std::vector tokens, bool intrans); // coordinators command ACTOR Future coordinatorsCommandActor(Reference db, std::vector tokens); // createtenant command ACTOR Future createTenantCommandActor(Reference db, std::vector tokens); // datadistribution command ACTOR Future dataDistributionCommandActor(Reference db, std::vector tokens); // deletetenant command ACTOR Future deleteTenantCommandActor(Reference db, std::vector tokens); // exclude command ACTOR Future excludeCommandActor(Reference db, std::vector tokens, Future warn); // expensive_data_check command ACTOR Future expensiveDataCheckCommandActor( Reference db, Reference tr, std::vector tokens, std::map>* address_interface); // fileconfigure command ACTOR Future fileConfigureCommandActor(Reference db, std::string filePath, bool isNewDatabase, bool force); // force_recovery_with_data_loss command ACTOR Future forceRecoveryWithDataLossCommandActor(Reference db, std::vector tokens); // gettenant command ACTOR Future getTenantCommandActor(Reference db, std::vector tokens); // include command ACTOR Future includeCommandActor(Reference db, std::vector tokens); // kill command ACTOR Future killCommandActor(Reference db, Reference tr, std::vector tokens, std::map>* address_interface); // listtenants command ACTOR Future listTenantsCommandActor(Reference db, std::vector tokens); // lock/unlock command ACTOR Future lockCommandActor(Reference db, std::vector tokens); ACTOR Future unlockDatabaseActor(Reference db, UID uid); // changefeed command ACTOR Future changeFeedCommandActor(Database localDb, Optional tenantEntry, std::vector tokens, Future warn); // blobrange command ACTOR Future blobRangeCommandActor(Database localDb, Optional tenantEntry, std::vector tokens); // maintenance command ACTOR Future setHealthyZone(Reference db, StringRef zoneId, double seconds, bool printWarning = false); ACTOR Future clearHealthyZone(Reference db, bool printWarning = false, bool clearSSFailureZoneString = false); ACTOR Future maintenanceCommandActor(Reference db, std::vector tokens); // profile command ACTOR Future profileCommandActor(Reference tr, std::vector tokens, bool intrans); // setclass command ACTOR Future setClassCommandActor(Reference db, std::vector tokens); // snapshot command ACTOR Future snapshotCommandActor(Reference db, std::vector tokens); // status command ACTOR Future statusCommandActor(Reference db, Database localDb, std::vector tokens, bool isExecMode = false); // suspend command ACTOR Future suspendCommandActor(Reference db, Reference tr, std::vector tokens, std::map>* address_interface); // throttle command ACTOR Future throttleCommandActor(Reference db, std::vector tokens); // triggerteaminfolog command ACTOR Future triggerddteaminfologCommandActor(Reference db); // tssq command ACTOR Future tssqCommandActor(Reference db, std::vector tokens); // versionepoch command ACTOR Future versionEpochCommandActor(Reference db, Database cx, std::vector tokens); // targetversion command ACTOR Future targetVersionCommandActor(Reference db, std::vector tokens); } // namespace fdb_cli #include "flow/unactorcompiler.h" #endif