34 #include "Request/Parameters/Compact.h"
38 #include "Request/Parameters/DropTable.h"
51 #include "Request/Parameters/SetState.h"
59 #include "Response/Parameters/Status.h"
76 : m_comm(comm), m_default_timeout_ms(timeout_ms) {
87 const String &row, int32_t flags) {
93 params.
encode(cbuf->get_data_ptr_address());
95 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
99 String(
"RangeServer compact() failure : ")
104 const String &row, int32_t flags,
109 params.
encode(cbuf->get_data_ptr_address());
110 send_message(addr, cbuf, handler, m_default_timeout_ms);
114 const String &row, int32_t flags,
119 params.
encode(cbuf->get_data_ptr_address());
120 send_message(addr, cbuf, handler, timer.
remaining());
127 const RangeState &range_state,
bool needs_compaction) {
128 do_load_range(addr, table, range_spec, range_state, needs_compaction,
129 m_default_timeout_ms);
135 const RangeState &range_state,
bool needs_compaction,
137 do_load_range(addr, table, range_spec, range_state, needs_compaction,
144 const RangeState &range_state,
bool needs_compaction,
145 int32_t timeout_ms) {
152 params.
encode(cbuf->get_data_ptr_address());
154 send_message(addr, cbuf, &sync_handler, timeout_ms);
158 String(
"RangeServer load_range() failure : ")
164 const vector<QualifiedRangeSpec*> &ranges,
165 map<QualifiedRangeSpec, int> &response_map) {
170 for (
auto spec : ranges)
177 params.
encode(cbuf->get_data_ptr_address());
179 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
183 String(
"RangeServer acknowledge_load() failure : ")
188 const uint8_t *ptr =
event->payload + 4;
189 size_t remain =
event->payload_len - 4;
191 params.
decode(&ptr, &remain);
193 for (
auto & entry : params.
error_map()) {
194 auto iter = response_map.find(entry.first);
196 iter->second = entry.second;
212 params.encode(cbuf->get_data_ptr_address());
213 send_message(addr, cbuf, handler, m_default_timeout_ms);
226 params.encode(cbuf->get_data_ptr_address());
227 send_message(addr, cbuf, handler, m_default_timeout_ms);
241 params.encode(cbuf->get_data_ptr_address());
242 send_message(addr, cbuf, handler, timer.
remaining());
249 do_create_scanner(addr, table, range, scan_spec,
250 scan_block, m_default_timeout_ms);
258 do_create_scanner(addr, table, range, scan_spec,
266 int32_t timeout_ms) {
275 params.encode(cbuf->get_data_ptr_address());
277 send_message(addr, cbuf, &sync_handler, timeout_ms);
281 String(
"RangeServer create_scanner() failure : ")
294 header.
gid = scanner_id;
297 params.
encode(cbuf->get_data_ptr_address());
298 send_message(addr, cbuf, handler, m_default_timeout_ms);
305 header.
gid = scanner_id;
308 params.
encode(cbuf->get_data_ptr_address());
309 send_message(addr, cbuf, handler, timer.
remaining());
315 do_destroy_scanner(addr, scanner_id, m_default_timeout_ms);
321 do_destroy_scanner(addr, scanner_id, timer.
remaining());
326 int32_t timeout_ms) {
330 header.
gid = scanner_id;
333 params.
encode(cbuf->get_data_ptr_address());
334 send_message(addr, cbuf, &sync_handler, timeout_ms);
339 String(
"RangeServer destroy_scanner() failure : ")
348 header.
gid = scanner_id;
351 params.
encode(cbuf->get_data_ptr_address());
352 send_message(addr, cbuf, handler, m_default_timeout_ms);
360 header.
gid = scanner_id;
363 params.
encode(cbuf->get_data_ptr_address());
364 send_message(addr, cbuf, handler, timer.
remaining());
371 do_fetch_scanblock(addr, scanner_id, scan_block, m_default_timeout_ms);
377 do_fetch_scanblock(addr, scanner_id, scan_block, timer.
remaining());
382 ScanBlock &scan_block, int32_t timeout_ms) {
386 header.
gid = scanner_id;
389 params.
encode(cbuf->get_data_ptr_address());
390 send_message(addr, cbuf, &sync_handler, timeout_ms);
395 String(
"RangeServer fetch_scanblock() failure : ")
409 params.
encode(cbuf->get_data_ptr_address());
410 send_message(addr, cbuf, handler, m_default_timeout_ms);
418 params.
encode(cbuf->get_data_ptr_address());
419 send_message(addr, cbuf, handler, timer.
remaining());
424 do_drop_table(addr, table, m_default_timeout_ms);
428 int32_t timeout_ms) {
433 params.
encode(cbuf->get_data_ptr_address());
434 send_message(addr, cbuf, &sync_handler, timeout_ms);
439 String(
"RangeServer drop_table() failure : ")
450 params.encode(cbuf->get_data_ptr_address());
451 send_message(addr, cbuf, handler, m_default_timeout_ms);
463 params.encode(cbuf->get_data_ptr_address());
464 send_message(addr, cbuf, handler, timer.
remaining());
475 params.encode(cbuf->get_data_ptr_address());
476 send_message(addr, cbuf, handler, m_default_timeout_ms);
487 params.encode(cbuf->get_data_ptr_address());
488 send_message(addr, cbuf, handler, timer.
remaining());
492 do_status(addr, status, m_default_timeout_ms);
496 do_status(addr, status, timer.
remaining());
504 send_message(addr, cbuf, &sync_handler, timeout_ms);
509 String(
"RangeServer status() failure : ")
513 size_t remaining =
event->payload_len - 4;
514 const uint8_t *ptr =
event->payload + 4;
516 params.
decode(&ptr, &remaining);
526 send_message(addr, cbuf, handler, timer.
remaining());
535 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
540 String(
"RangeServer wait_for_maintenance() failure : ")
549 send_message(addr, cbuf, 0, m_default_timeout_ms);
558 params.
encode(cbuf->get_data_ptr_address());
559 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
564 String(
"RangeServer dump() failure : ")
571 const String &pseudo_table_name,
577 params.
encode(cbuf->get_data_ptr_address());
578 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
583 String(
"RangeServer dump_pseudo_table() failure : ")
588 vector<SystemVariable::Spec>&specs,
590 do_get_statistics(addr, specs, generation, stats, m_default_timeout_ms);
594 vector<SystemVariable::Spec>&specs,
597 do_get_statistics(addr, specs, generation, stats, timer.
remaining());
601 vector<SystemVariable::Spec> &specs,
603 int32_t timeout_ms) {
609 params.
encode(cbuf->get_data_ptr_address());
610 send_message(addr, cbuf, &sync_handler, timeout_ms);
615 String(
"RangeServer get_statistics() failure : ")
619 size_t remaining =
event->payload_len - 4;
620 const uint8_t *ptr =
event->payload + 4;
622 params.
decode(&ptr, &remaining);
623 stats = params.
stats();
628 vector<SystemVariable::Spec>&specs,
634 params.
encode(cbuf->get_data_ptr_address());
635 send_message(addr, cbuf, handler, m_default_timeout_ms);
639 vector<SystemVariable::Spec>&specs,
646 params.
encode(cbuf->get_data_ptr_address());
647 send_message(addr, cbuf, handler, timer.
remaining());
655 params.
encode(cbuf->get_data_ptr_address());
656 send_message(addr, cbuf, handler, m_default_timeout_ms);
665 params.
encode(cbuf->get_data_ptr_address());
666 send_message(addr, cbuf, handler, timer.
remaining());
672 do_relinquish_range(addr, table, range, m_default_timeout_ms);
678 do_relinquish_range(addr, table, range, timer.
remaining());
684 int32_t timeout_ms) {
689 params.
encode(cbuf->get_data_ptr_address());
692 send_message(addr, cbuf, &sync_handler, timeout_ms);
696 String(
"RangeServer relinquish_range() failure : ")
705 params.
encode(cbuf->get_data_ptr_address());
706 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
711 String(
"RangeServer heapcheck() failure : ")
716 const String &recover_location,
int plan_generation, int32_t type,
718 int32_t replay_timeout) {
723 plan_generation, type, fragments,
724 plan, replay_timeout);
726 params.
encode(cbuf->get_data_ptr_address());
727 send_message(addr, cbuf, &sync_handler, replay_timeout);
732 String(
"RangeServer replay_fragments() failure : ")
738 int32_t plan_generation,
739 const vector<int32_t> &fragments,
740 const vector<QualifiedRangeSpec> &range_specs,
741 const vector<RangeState> &range_states) {
746 range_specs, range_states);
748 params.
encode(cbuf->get_data_ptr_address());
749 send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
754 String(
"RangeServer phantom_load() failure : ")
767 params.
encode(cbuf->get_data_ptr_address());
768 send_message(addr, cbuf, handler, m_default_timeout_ms);
773 int32_t plan_generation,
774 const vector<QualifiedRangeSpec> &ranges,
775 int32_t timeout_ms) {
780 plan_generation, ranges);
782 params.
encode(cbuf->get_data_ptr_address());
783 send_message(addr, cbuf, &sync_handler, timeout_ms);
788 String(
"RangeServer phantom_prepare_ranges() failure : ")
794 const String &location, int32_t plan_generation,
795 const vector<QualifiedRangeSpec> &ranges,
796 int32_t timeout_ms) {
801 plan_generation, ranges);
803 params.
encode(cbuf->get_data_ptr_address());
804 send_message(addr, cbuf, &sync_handler, timeout_ms);
809 String(
"RangeServer phantom_commit_ranges() failure : ")
814 vector<SystemVariable::Spec> &specs, int64_t generation,
820 params.
encode(cbuf->get_data_ptr_address());
821 send_message(addr, cbuf, handler, timer.
remaining());
832 params.
encode(cbuf->get_data_ptr_address());
833 send_message(addr, cbuf, handler, m_default_timeout_ms);
843 params.
encode(cbuf->get_data_ptr_address());
844 send_message(addr, cbuf, handler, m_default_timeout_ms);
852 if ((error = m_comm->send_request(addr, timeout_ms, cbuf, handler))
854 HT_WARNF(
"Comm::send_request to %s failed - %s",
858 HT_THROWF(error,
"Comm::send_request to %s failed",
A memory buffer of static size.
Response parameters for open requests.
void status(const CommAddress &addr, Status &status)
Issues a "status" request.
Request parameters for table maintenance disable function.
Client(Comm *comm, int32_t timeout_ms=0)
Declarations for LoadRange request parameters.
void create_scanner(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, const ScanSpec &scan_spec, DispatchHandler *handler)
Issues a "create scanner" request asynchronously.
void phantom_prepare_ranges(const CommAddress &addr, int64_t op_id, const String &location, int32_t plan_generation, const vector< QualifiedRangeSpec > &ranges, int32_t timeout)
Issues a "phantom_prepare_ranges" synchronous request.
#define HT_WARNF(msg,...)
const Hypertable::Status & status() const
Gets status information.
Request parameters for compact function.
void drop_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, DispatchHandler *handler)
Issues an asynchronous "drop range" request asynchronously.
Declarations for PhantomUpdate request parameters.
Request parameters for set state function.
Request parameters for dump pseudo table function.
Holds Nagios-style program status information.
static int32_t response_code(const Event *event)
Returns the response code from an event event generated in response to a request message.
Declarations for DropRange request parameters.
Declarations for PhantomPrepareRanges request parameters.
std::string String
A String is simply a typedef to std::string.
static String string_format_message(const Event *event)
Returns error message decoded standard error MESSAGE generated in response to a request message...
Declarations for AcknowledgeLoad response parameters.
void heapcheck(const CommAddress &addr, String &outfile)
Issues a "heapcheck" request.
void commit_log_sync(const CommAddress &addr, uint64_t cluster_id, const TableIdentifier &table, DispatchHandler *handler)
Issues a "commit_log_sync" request asynchronously.
Abstract base class for application dispatch handlers registered with AsyncComm.
void update(const CommAddress &addr, uint64_t cluster_id, const TableIdentifier &table, int32_t count, StaticBuffer &buffer, int32_t flags, DispatchHandler *handler)
Issues an "update" request asynchronously.
virtual size_t encoded_length() const
Returns serialized object length.
void table_maintenance_enable(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues an asynchronous RangeServer::table_maintenance_enable().
void dump_pseudo_table(const CommAddress &addr, const TableIdentifier &table, const String &pseudo_table_name, const String &outfile)
void acknowledge_load(const CommAddress &addr, const vector< QualifiedRangeSpec * > &ranges, std::map< QualifiedRangeSpec, int > &response_map)
Issues a synchronous "acknowledge load" request for multiple ranges.
void do_create_scanner(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, const ScanSpec &scan_spec, ScanBlock &scan_block, int32_t timeout_ms)
Declarations for RelinquishRange request parameters.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Request should be profiled.
Response parameters for acknowledge load function.
const map< QualifiedRangeSpec, int32_t > & error_map()
Gets range error map.
uint32_t remaining()
Returns the remaining time till expiry.
Declarations for RangeServerClient.
bool wait_for_reply(EventPtr &event)
This method is used by a client to synchronize.
void table_maintenance_disable(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues an asynchronous RangeServer::table_maintenance_disable() request.
const StatsRangeServer & stats()
Gets range server statistics.
Request parameters for commit log sync function.
Declarations for Update request parameters.
#define HT_EXPECT(_e_, _code_)
void dump(const CommAddress &addr, String &outfile, bool nokeys)
Declarations for ReplayFragments request parameters.
Declarations for TableMaintenanceDisable request parameters.
Scan predicate and control specification.
Request parameters for fetch scanblock function.
Request parameters for update schema function.
void replay_fragments(const CommAddress &addr, int64_t op_id, const String &recover_location, int32_t plan_generation, int32_t type, const vector< int32_t > &fragments, const Lib::RangeServerRecovery::ReceiverPlan &plan, int32_t replay_timeout)
Issues a synchronous "replay_fragments" request.
Request parameters for update function.
Declarations for Dump request parameters.
Request parameters for phantom commit ranges function.
Request parameters for destroy scanner function.
virtual void encode(uint8_t **bufp) const
Writes serialized representation of object to a buffer.
void fetch_scanblock(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "fetch scanblock" request asynchronously.
Declarations for DumpPseudoTable request parameters.
const char * get_text(int error)
Returns a descriptive error message.
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Request parameters for create scanner function.
std::shared_ptr< CommBuf > CommBufPtr
Smart pointer to CommBuf.
Declarations for TableMaintenanceEnable request parameters.
void shutdown(const CommAddress &addr)
Issues a "shutdown" request.
Request parameters for dump function.
Declarations for CommitLogSync request parameters.
Declarations for PhantomLoad request parameters.
Request parameters for phantom prepare ranges function.
Compatibility Macros for C/C++.
void phantom_commit_ranges(const CommAddress &addr, int64_t op_id, const String &location, int32_t plan_generation, const vector< QualifiedRangeSpec > &ranges, int32_t timeout)
Issues a "phantom_commit_ranges" synchronous request.
void do_drop_table(const CommAddress &addr, const TableIdentifier &table, int32_t timeout_ms)
void destroy_scanner(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "destroy scanner" request asynchronously.
Functions to serialize/deserialize primitives to/from a memory buffer.
String to_str() const
Returns string representation of address.
Request parameters for relinquish range function.
void phantom_update(const CommAddress &addr, const String &location, int32_t plan_generation, const QualifiedRangeSpec &range, int32_t fragment, StaticBuffer &updates, DispatchHandler *handler)
Issues a "phantom_update" asynchronous request.
void do_get_statistics(const CommAddress &addr, std::vector< SystemVariable::Spec > &specs, int64_t generation, StatsRangeServer &stats, int32_t timeout_ms)
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Declarations for GetStatistics request parameters.
void relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range)
Issues a "relinquish range" request synchronously.
Encapsulates a block of scan results.
void get_statistics(const CommAddress &addr, std::vector< SystemVariable::Spec > &specs, int64_t generation, StatsRangeServer &stats)
Issues an synchronous "get_statistics" request.
DispatchHandler class used to synchronize with response messages.
Declarations for CreateScanner request parameters.
Entry point to AsyncComm service.
Request parameters for drop range function.
void compact(const CommAddress &addr, const TableIdentifier &table, const String &row, int32_t flags)
Issues a "compact" request synchronously.
Declarations for UpdateSchema request parameters.
void set_state(const CommAddress &addr, std::vector< SystemVariable::Spec > &specs, int64_t generation, DispatchHandler *handler, Timer &timer)
Issues an asynchronous "set_state" request with timer.
Declarations for Protocol.
Declarations for AcknowledgeLoad request parameters.
Request parameters for get statistics function.
void phantom_load(const CommAddress &addr, const String &location, int32_t plan_generation, const vector< int32_t > &fragments, const vector< QualifiedRangeSpec > &range_specs, const vector< RangeState > &range_states)
Issues a "phantom_load" synchronous request.
#define HT_THROWF(_code_, _fmt_,...)
Request parameters for phantom load function.
void drop_table(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues a "drop table" request asynchronously.
Request parameters for load range function.
A timer class to keep timeout states across AsyncComm related calls.
Declarations for ScanBlock.
void do_relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, int32_t timeout_ms)
Message buffer for holding data to be transmitted over a network.
Declarations for DestroyScanner request parameters.
void do_status(const CommAddress &addr, Status &status, int32_t timeout_ms)
Qualified (with table identifier) range specification.
void update_schema(const CommAddress &addr, const TableIdentifier &table, const String &schema, DispatchHandler *handler)
Issues a "update schema" request asynchronously.
Request parameters for phantom update function.
Declarations for GetStatistics response parameters.
Request parameters for heapcheck function.
void do_destroy_scanner(const CommAddress &addr, int32_t scanner_id, int32_t timeout_ms)
void load_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range_spec, const RangeState &range_state, bool needs_compaction)
Issues a synchronous "load range" request.
Declarations for PhantomCommitRanges request parameters.
Declarations for CreateScanner response parameters.
void send_message(const CommAddress &addr, CommBufPtr &cbp, DispatchHandler *handler, int32_t timeout_ms)
Request parameters for drop table function.
Request parameters for replay fragments function.
String extensions and helpers: sets, maps, append operators etc.
void do_fetch_scanblock(const CommAddress &addr, int32_t scanner_id, ScanBlock &scan_block, int32_t timeout_ms)
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Declarations for FetchScanblock request parameters.
int32_t m_default_timeout_ms
int load(EventPtr &event)
Loads scanblock data returned from RangeServer.
Request parameters for table maintenance enable function.
Request parameters for acknowledge load function.
Address abstraction to hold either proxy name or IPv4:port address.
Response parameters for get statistics function.
Declarations for Heapcheck request parameters.
Declarations for DispatchHandlerSynchronizer.
void do_load_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range_spec, const RangeState &range_state, bool needs_compaction, int32_t timeout_ms)
void wait_for_maintenance(const CommAddress &addr)
Issues a "wait_for_maintenance" request.
RangeServer recovery receiver plan.