25#include "DatabaseManager.h"
30using namespace fbcpp::impl;
37 fbUnique(
getClient().getUtil()->getXpbBuilder(&statusWrapper, fb::IXpbBuilder::SPB_START,
nullptr, 0));
38 builder->insertTag(&statusWrapper, isc_action_svc_properties);
39 builder->insertString(&statusWrapper, isc_spb_dbname, options.
getDatabase().c_str());
43 std::uint8_t modeVal = 0;
48 modeVal = isc_spb_prp_rm_none;
51 modeVal = isc_spb_prp_rm_readonly;
54 modeVal = isc_spb_prp_rm_readwrite;
61 builder->insertBytes(&statusWrapper, isc_spb_prp_replica_mode, &modeVal, 1u);
66 std::uint8_t stateVal = 0;
68 switch (*shutdownMode)
71 stateVal = isc_spb_prp_sm_normal;
74 stateVal = isc_spb_prp_sm_multi;
77 stateVal = isc_spb_prp_sm_single;
80 stateVal = isc_spb_prp_sm_full;
87 builder->insertBytes(&statusWrapper, isc_spb_prp_shutdown_mode, &stateVal, 1u);
94 switch (*shutdownType)
97 builder->insertInt(&statusWrapper, isc_spb_prp_deny_new_transactions, timeout);
100 builder->insertInt(&statusWrapper, isc_spb_prp_deny_new_attachments, timeout);
103 builder->insertInt(&statusWrapper, isc_spb_prp_force_shutdown, timeout);
111 if (
const auto online = options.
getOnline())
115 std::uint8_t stateVal = isc_spb_prp_sm_normal;
116 builder->insertBytes(&statusWrapper, isc_spb_prp_online_mode, &stateVal, 1u);
120 const auto buffer = builder->getBuffer(&statusWrapper);
121 const auto length = builder->getBufferLength(&statusWrapper);
123 startAction(std::vector<std::uint8_t>(buffer, buffer + length));
130 StatusWrapper statusWrapper{
getClient()};
132 fbUnique(
getClient().getUtil()->getXpbBuilder(&statusWrapper, fb::IXpbBuilder::SPB_START,
nullptr, 0));
134 builder->insertTag(&statusWrapper, isc_action_svc_repair);
135 builder->insertString(&statusWrapper, isc_spb_dbname, options.
getDatabase().c_str());
139 optionsVal |= isc_spb_rpr_sweep_db;
141 optionsVal |= isc_spb_rpr_validate_db;
143 optionsVal |= isc_spb_rpr_mend_db;
145 optionsVal |= isc_spb_rpr_ignore_checksum;
147 optionsVal |= isc_spb_rpr_kill_shadows;
149 optionsVal |= isc_spb_rpr_full;
151 optionsVal |= isc_spb_rpr_check_db;
153 optionsVal |= isc_spb_rpr_icu;
155 optionsVal |= isc_spb_rpr_upgrade_db;
158 builder->insertInt(&statusWrapper, isc_spb_options, optionsVal);
161 builder->insertInt(&statusWrapper, isc_spb_rpr_par_workers,
static_cast<int>(*parallelWorkers));
163 const auto buffer = builder->getBuffer(&statusWrapper);
164 const auto length = builder->getBufferLength(&statusWrapper);
166 startAction(std::vector<std::uint8_t>(buffer, buffer + length));
void setProperties(const DatabasePropertiesOptions &options)
Configures database properties using the provided options.
void repair(const DatabaseRepairOptions &options)
Runs a repair operation using the provided options.
Represents options used to configure database properties through the service manager.
const std::string & getDatabase() const
Returns the database path to be configured.
const std::optional< bool > & getOnline() const
Returns whether the database should be brought online.
const std::optional< ReplicaMode > & getReplicaMode() const
Returns the replica mode.
const std::optional< ShutdownMode > & getShutdownMode() const
Returns the shutdown mode.
const std::optional< ShutdownType > & getShutdownType() const
Returns the shutdown type.
const std::optional< int > & getShutdownTimeout() const
Returns the shutdown timeout in seconds.
Represents options used to run a database maintenance operation through the service manager.
bool getIgnoreChecksum() const
Returns whether checksum verification is configured to be ignored.
const std::optional< std::uint32_t > & getParallelWorkers() const
Returns the requested number of parallel workers.
bool getUpgradeDb() const
Returns whether database upgrade is configured to be run.
const ServiceManager::VerboseOutput & getVerboseOutput() const
Returns the verbose output callback.
bool getValidate() const
Returns whether database validation is configured to be run.
bool getCheckDb() const
Returns whether checking only metadata/structure is configured to be run.
bool getKillShadows() const
Returns whether killing database shadows is configured to be run.
bool getSweep() const
Returns whether database sweep is configured to be run.
const std::string & getDatabase() const
Returns the database path to be maintained.
bool getIcu() const
Returns whether recreating ICU indexes is configured to be run.
bool getMend() const
Returns whether database mending is configured to be run.
bool getFull() const
Returns whether full validation is configured to be run.
Client & getClient() noexcept
Returns the Client object reference used to create this ServiceManager object.
@ DENY_TRANSACTIONS
Deny new transactions: waits for existing transactions to finish.
@ FORCED
Forced shutdown: disconnects all users immediately after the timeout.
@ DENY_ATTACHMENTS
Deny new attachments: waits for existing connections to finish.
@ SINGLE
Single-user shutdown.
@ NORMAL
Normal online state.
@ FULL
Full exclusive shutdown.
@ MULTI
Multi-user shutdown.
FbUniquePtr< T > fbUnique(T *obj) noexcept
Creates a unique pointer for a Firebird disposable object.
@ READ_ONLY
Read-only replica.
@ READ_WRITE
Read-write replica.
@ NONE
The database is not a replica (operates as primary).