55 m_plan = make_shared<BalancePlan>();
67 const uint8_t *ptr =
event->payload;
68 size_t remaining =
event->payload_len;
88 HT_INFOF(
"Entering Balance-%lld algorithm= %s state=%s",
97 std::vector<RangeServerConnectionPtr> balanced;
98 std::vector<MetaLog::EntityPtr> entities;
99 int generation =
m_context->get_balance_plan_authority()->get_generation();
105 entities.push_back(shared_from_this());
106 for (
auto & rsc : balanced) {
108 entities.push_back(rsc);
111 if (!
m_context->get_balance_plan_authority()->register_balance_plan(
m_plan, generation, entities))
129 if (!
m_plan->moves.empty()) {
130 uint32_t wait_millis =
m_plan->duration_millis /
m_plan->moves.size();
132 for (
auto &move :
m_plan->moves) {
136 this_thread::sleep_for(chrono::milliseconds(wait_millis));
139 move->complete =
true;
140 move->error = e.
code();
142 m_context->get_balance_plan_authority(bpa_entity);
143 static_pointer_cast<
BalancePlanAuthority>(bpa_entity)->balance_move_complete(move->table, move->range);
146 std::stringstream sout;
147 for (
auto &move :
m_plan->moves) {
158 HT_FATALF(
"Unrecognized state %d", state);
162 m_plan->algorithm.c_str());
170 return "OperationBalance";
175 return format(
"Balance %s (%u moves)",
m_plan->algorithm.c_str(),
176 (unsigned)
m_plan->moves.size());
195 const uint8_t **bufp,
198 m_plan = make_shared<BalancePlan>();
199 m_plan->decode(bufp, remainp);
203 const uint8_t **bufp,
205 m_plan = make_shared<BalancePlan>();
const String label() override
Human readable label for operation.
Retrieves system information (hardware, installation directory, etc)
void display_state(std::ostream &os) override
Write human readable operation state to output stream.
The FailureInducer simulates errors.
ContextPtr m_context
Pointer to Master context.
int64_t md5_hash(const char *input)
Returns a 64-bit hash checksum of a null terminated input buffer.
std::string String
A String is simply a typedef to std::string.
std::shared_ptr< Entity > EntityPtr
Smart pointer to Entity.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
virtual size_t encoded_length() const
Returns serialized object length.
Declarations for OperationProcessor.
const String name() override
Name of operation used for exclusivity.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
void encode_state(uint8_t **bufp) const override
Encode operation state.
BalancePlanPtr m_plan
Balance plan.
const char * get_text(int32_t state)
const char * RECOVER_SERVER
int64_t m_hash_code
Hash code uniqely identifying operation.
std::shared_ptr< Context > ContextPtr
Smart pointer to Context.
void execute() override
Executes (carries out) the operation.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
void set_state(int32_t state)
void set_proxy(const String &str)
Sets address type to CommAddress::PROXY and proxy name to p.
Compatibility Macros for C/C++.
void decode_state(uint8_t version, const uint8_t **bufp, size_t *remainp) override
Decode operation state.
Functions to serialize/deserialize primitives to/from a memory buffer.
size_t encoded_length_state() const override
Encoded length of operation state.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
void relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range)
Issues a "relinquish range" request synchronously.
OperationBalance(ContextPtr &context)
BalancePlan & plan()
Gets balance plan.
Lib::Master::Request::Parameters::Balance m_params
Request parmaeters.
#define HT_FATALF(msg,...)
long long int Lld
Shortcut for printf formats.
Declarations for general-purpose utility functions.
void legacy_decode(const uint8_t **bufp, size_t *remainp, BalancePlan *plan)
Central authority for balance plans.
void decode_state_old(uint8_t version, const uint8_t **bufp, size_t *remainp) override
DependencySet m_dependencies
Set of dependencies.
#define HT_INFOF(msg,...)
Client interface to RangeServer.
Abstract base class for master operations.
uint8_t encoding_version_state() const override
Returns version of encoding format of state.
This is a generic exception class for Hypertable.
void initialize_dependencies()
void complete_ok(std::vector< MetaLog::EntityPtr > &additional)
Declarations for BalancePlanAuthority.
Declarations for ResponseCallback.
String extensions and helpers: sets, maps, append operators etc.
Error codes, Exception handling, error logging.
void complete_error(int error, const String &msg, std::vector< MetaLog::EntityPtr > &additional)
Completes operation with error.
Address abstraction to hold either proxy name or IPv4:port address.
int code() const
Returns the error code.
Executes user-defined functions when leaving the current scope.