43 #include <boost/algorithm/string.hpp>
60 const uint8_t *ptr =
event->payload;
61 size_t remaining =
event->payload_len;
97 HT_INFOF(
"Entering SetState-%lld() state=%s",
106 std::vector<NotificationMessage> notifications;
107 if (
m_context->system_state->get_notifications(notifications)) {
108 for (
auto &msg : notifications)
109 m_context->notification_hook(msg.subject, msg.body);
119 std::vector<MetaLog::EntityPtr> entities;
120 entities.push_back(shared_from_this());
121 entities.push_back(
m_context->system_state);
122 m_context->mml_writer->record_state(entities);
129 std::vector<RangeServerConnectionPtr> servers;
130 m_context->rsc_manager->get_servers(servers);
131 if (servers.empty()) {
135 for (
auto &rsc : servers)
136 locations.insert(rsc->location());
138 dispatch_handler.DispatchHandlerOperation::start(locations);
142 std::set<DispatchHandlerOperation::Result> results;
144 for (
auto &result : results) {
146 HT_WARNF(
"Problem setting state variables at %s - %s",
155 HT_FATALF(
"Unrecognized state %d", state);
180 length += spec.encoded_length();
196 for (
size_t i=0; i<count; i++) {
198 spec.
decode(bufp, remainp);
210 for (int32_t i=0; i<count; i++) {
218 return "OperationSetState";
std::set< String > StringSet
STL Set managing Strings.
#define HT_WARNF(msg,...)
The FailureInducer simulates errors.
ContextPtr m_context
Pointer to Master context.
std::string String
A String is simply a typedef to std::string.
virtual size_t encoded_length() const
Returns serialized object length.
int32_t code
Variable code.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
std::string specs_to_string(const std::vector< Spec > &specs)
Returns a textual representation of variable specifications.
const std::vector< SystemVariable::Spec > & specs()
Gets system variable specifications.
const char * get_text(int32_t state)
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
size_t encoded_length_state() const override
Returns length of encoded state.
uint64_t decode_i64(const uint8_t **bufp, size_t *remainp)
Decode a 64-bit integer in little-endian order.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
void set_state(int32_t state)
bool decode_bool(const uint8_t **bufp, size_t *remainp)
Decodes a boolean value from the given buffer.
const char * get_text(int error)
Returns a descriptive error message.
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Decodes operation state.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
OperationSetState(ContextPtr &context)
Constructor.
std::vector< SystemVariable::Spec > m_specs
Current system state variables.
void encode_i64(uint8_t **bufp, uint64_t val)
Encode a 64-bit integer in little-endian order.
Functions to serialize/deserialize primitives to/from a memory buffer.
const String label() override
Returns textual string describing operation plus state.
Holds a variable code and boolean value.
Declarations for DispatchHandlerOperationSetState.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
bool wait_for_completion()
Waits for requests to complete.
const String name() override
Returns operation name (OperationSetState)
#define HT_FATALF(msg,...)
long long int Lld
Shortcut for printf formats.
uint64_t m_generation
Generation number of system state variables (m_specs)a.
void get_results(std::set< Result > &results)
Returns the Result set.
Declarations for general-purpose utility functions.
#define HT_INFOF(msg,...)
Declarations for OperationSetState.
void execute() override
Executes "set state" operation.
Abstract base class for master operations.
Lib::Master::Request::Parameters::SetState m_params
Request parmaeters.
DependencySet m_exclusivities
Set of exclusivities.
void display_state(std::ostream &os) override
Displays textual representation of object state.
bool value
Variable value.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
void encode_state(uint8_t **bufp) const override
Encodes operation state.
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
Error codes, Exception handling, error logging.
void initialize()
Pre-request initialization.
const char * code_to_string(int var_code)
Converts variable code to variable string.
Executes user-defined functions when leaving the current scope.
DispatchHandler class for gathering responses to a set of RangeServer::set_state() requests...