0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Client.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
28 #include <Common/Compat.h>
29 
30 #include "Client.h"
31 #include "Protocol.h"
34 #include "Request/Parameters/Compact.h"
38 #include "Request/Parameters/DropTable.h"
51 #include "Request/Parameters/SetState.h"
59 #include "Response/Parameters/Status.h"
60 
62 
64 #include <AsyncComm/Protocol.h>
65 
66 #include <Common/Config.h>
67 #include <Common/Error.h>
68 #include <Common/StringExt.h>
69 #include <Common/Serialization.h>
70 
71 using namespace Hypertable;
72 using namespace Hypertable::Config;
73 using namespace std;
74 
75 Lib::RangeServer::Client::Client(Comm *comm, int32_t timeout_ms)
76  : m_comm(comm), m_default_timeout_ms(timeout_ms) {
77  if (timeout_ms == 0)
78  m_default_timeout_ms = get_i32("Hypertable.Request.Timeout");
79 }
80 
81 
83 }
84 
85 
87  const String &row, int32_t flags) {
88  DispatchHandlerSynchronizer sync_handler;
89  EventPtr event;
91  Request::Parameters::Compact params(table, row, flags);
92  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
93  params.encode(cbuf->get_data_ptr_address());
94 
95  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
96 
97  if (!sync_handler.wait_for_reply(event))
99  String("RangeServer compact() failure : ")
101 }
102 
104  const String &row, int32_t flags,
105  DispatchHandler *handler) {
107  Request::Parameters::Compact params(table, row, flags);
108  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
109  params.encode(cbuf->get_data_ptr_address());
110  send_message(addr, cbuf, handler, m_default_timeout_ms);
111 }
112 
114  const String &row, int32_t flags,
115  DispatchHandler *handler, Timer &timer) {
117  Request::Parameters::Compact params(table, row, flags);
118  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
119  params.encode(cbuf->get_data_ptr_address());
120  send_message(addr, cbuf, handler, timer.remaining());
121 }
122 
123 
124 void
126  const TableIdentifier &table, const RangeSpec &range_spec,
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);
130 }
131 
132 void
134  const TableIdentifier &table, const RangeSpec &range_spec,
135  const RangeState &range_state, bool needs_compaction,
136  Timer &timer) {
137  do_load_range(addr, table, range_spec, range_state, needs_compaction,
138  timer.remaining());
139 }
140 
141 void
143  const TableIdentifier &table, const RangeSpec &range_spec,
144  const RangeState &range_state, bool needs_compaction,
145  int32_t timeout_ms) {
146  DispatchHandlerSynchronizer sync_handler;
147  EventPtr event;
150  Request::Parameters::LoadRange params(table, range_spec, range_state, needs_compaction);
151  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
152  params.encode(cbuf->get_data_ptr_address());
153 
154  send_message(addr, cbuf, &sync_handler, timeout_ms);
155 
156  if (!sync_handler.wait_for_reply(event))
158  String("RangeServer load_range() failure : ")
160 }
161 
162 void
164  const vector<QualifiedRangeSpec*> &ranges,
165  map<QualifiedRangeSpec, int> &response_map) {
166  DispatchHandlerSynchronizer sync_handler;
167  EventPtr event;
168 
169  // Initialize response map
170  for (auto spec : ranges)
171  response_map[*spec] = Error::NO_RESPONSE;
172 
176  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
177  params.encode(cbuf->get_data_ptr_address());
178 
179  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
180 
181  if (!sync_handler.wait_for_reply(event))
183  String("RangeServer acknowledge_load() failure : ")
185 
186  // Decode response
187  {
188  const uint8_t *ptr = event->payload + 4;
189  size_t remain = event->payload_len - 4;
191  params.decode(&ptr, &remain);
192  // Copy error codes into response map
193  for (auto & entry : params.error_map()) {
194  auto iter = response_map.find(entry.first);
195  HT_ASSERT(iter != response_map.end());
196  iter->second = entry.second;
197  }
198 
199  }
200 }
201 
202 void Lib::RangeServer::Client::update(const CommAddress &addr, uint64_t cluster_id,
203  const TableIdentifier &table, int32_t count,
204  StaticBuffer &buffer, int32_t flags,
205  DispatchHandler *handler) {
206 
208  if (table.is_system())
210  Request::Parameters::Update params(cluster_id, table, count, flags);
211  CommBufPtr cbuf(new CommBuf(header, params.encoded_length(), buffer));
212  params.encode(cbuf->get_data_ptr_address());
213  send_message(addr, cbuf, handler, m_default_timeout_ms);
214 }
215 
216 void
218  const TableIdentifier &table, const RangeSpec &range,
219  const ScanSpec &scan_spec, DispatchHandler *handler) {
222  if (table.is_system())
224  Request::Parameters::CreateScanner params(table, range, scan_spec);
225  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
226  params.encode(cbuf->get_data_ptr_address());
227  send_message(addr, cbuf, handler, m_default_timeout_ms);
228 }
229 
230 void
232  const TableIdentifier &table, const RangeSpec &range,
233  const ScanSpec &scan_spec, DispatchHandler *handler,
234  Timer &timer) {
237  if (table.is_system())
239  Request::Parameters::CreateScanner params(table, range, scan_spec);
240  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
241  params.encode(cbuf->get_data_ptr_address());
242  send_message(addr, cbuf, handler, timer.remaining());
243 }
244 
245 void
247  const TableIdentifier &table, const RangeSpec &range,
248  const ScanSpec &scan_spec, ScanBlock &scan_block) {
249  do_create_scanner(addr, table, range, scan_spec,
250  scan_block, m_default_timeout_ms);
251 }
252 
253 void
255  const TableIdentifier &table, const RangeSpec &range,
256  const ScanSpec &scan_spec, ScanBlock &scan_block,
257  Timer &timer) {
258  do_create_scanner(addr, table, range, scan_spec,
259  scan_block, timer.remaining());
260 }
261 
262 void
264  const TableIdentifier &table, const RangeSpec &range,
265  const ScanSpec &scan_spec, ScanBlock &scan_block,
266  int32_t timeout_ms) {
267  DispatchHandlerSynchronizer sync_handler;
268  EventPtr event;
271  if (table.is_system())
273  Request::Parameters::CreateScanner params(table, range, scan_spec);
274  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
275  params.encode(cbuf->get_data_ptr_address());
276 
277  send_message(addr, cbuf, &sync_handler, timeout_ms);
278 
279  if (!sync_handler.wait_for_reply(event))
281  String("RangeServer create_scanner() failure : ")
283  else {
284  HT_ASSERT(scan_block.load(event) == Error::OK);
285  }
286 }
287 
288 
289 void
291  DispatchHandler *handler) {
292 
294  header.gid = scanner_id;
295  Request::Parameters::DestroyScanner params(scanner_id);
296  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
297  params.encode(cbuf->get_data_ptr_address());
298  send_message(addr, cbuf, handler, m_default_timeout_ms);
299 }
300 
301 void
303  DispatchHandler *handler, Timer &timer) {
305  header.gid = scanner_id;
306  Request::Parameters::DestroyScanner params(scanner_id);
307  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
308  params.encode(cbuf->get_data_ptr_address());
309  send_message(addr, cbuf, handler, timer.remaining());
310 }
311 
312 
313 void
314 Lib::RangeServer::Client::destroy_scanner(const CommAddress &addr, int32_t scanner_id) {
315  do_destroy_scanner(addr, scanner_id, m_default_timeout_ms);
316 }
317 
318 void
320  Timer &timer) {
321  do_destroy_scanner(addr, scanner_id, timer.remaining());
322 }
323 
324 void
326  int32_t timeout_ms) {
327 
328  DispatchHandlerSynchronizer sync_handler;
330  header.gid = scanner_id;
331  Request::Parameters::DestroyScanner params(scanner_id);
332  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
333  params.encode(cbuf->get_data_ptr_address());
334  send_message(addr, cbuf, &sync_handler, timeout_ms);
335 
336  EventPtr event;
337  if (!sync_handler.wait_for_reply(event))
339  String("RangeServer destroy_scanner() failure : ")
341 }
342 
343 void
345  DispatchHandler *handler) {
348  header.gid = scanner_id;
349  Request::Parameters::FetchScanblock params(scanner_id);
350  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
351  params.encode(cbuf->get_data_ptr_address());
352  send_message(addr, cbuf, handler, m_default_timeout_ms);
353 }
354 
355 void
357  DispatchHandler *handler, Timer &timer) {
360  header.gid = scanner_id;
361  Request::Parameters::FetchScanblock params(scanner_id);
362  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
363  params.encode(cbuf->get_data_ptr_address());
364  send_message(addr, cbuf, handler, timer.remaining());
365 }
366 
367 
368 void
370  ScanBlock &scan_block) {
371  do_fetch_scanblock(addr, scanner_id, scan_block, m_default_timeout_ms);
372 }
373 
374 void
376  ScanBlock &scan_block, Timer &timer) {
377  do_fetch_scanblock(addr, scanner_id, scan_block, timer.remaining());
378 }
379 
380 void
382  ScanBlock &scan_block, int32_t timeout_ms) {
383  DispatchHandlerSynchronizer sync_handler;
386  header.gid = scanner_id;
387  Request::Parameters::FetchScanblock params(scanner_id);
388  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
389  params.encode(cbuf->get_data_ptr_address());
390  send_message(addr, cbuf, &sync_handler, timeout_ms);
391 
392  EventPtr event;
393  if (!sync_handler.wait_for_reply(event))
395  String("RangeServer fetch_scanblock() failure : ")
397  else {
398  HT_EXPECT(scan_block.load(event) == Error::OK,
400  }
401 }
402 
403 
405  DispatchHandler *handler) {
407  Request::Parameters::DropTable params(table);
408  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
409  params.encode(cbuf->get_data_ptr_address());
410  send_message(addr, cbuf, handler, m_default_timeout_ms);
411 }
412 
414  DispatchHandler *handler, Timer &timer) {
416  Request::Parameters::DropTable params(table);
417  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
418  params.encode(cbuf->get_data_ptr_address());
419  send_message(addr, cbuf, handler, timer.remaining());
420 }
421 
422 
424  do_drop_table(addr, table, m_default_timeout_ms);
425 }
426 
428  int32_t timeout_ms) {
429  DispatchHandlerSynchronizer sync_handler;
431  Request::Parameters::DropTable params(table);
432  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
433  params.encode(cbuf->get_data_ptr_address());
434  send_message(addr, cbuf, &sync_handler, timeout_ms);
435 
436  EventPtr event;
437  if (!sync_handler.wait_for_reply(event))
439  String("RangeServer drop_table() failure : ")
441 }
442 
444  const String &schema, DispatchHandler *handler) {
446  if (table.is_system())
448  Request::Parameters::UpdateSchema params(table, schema);
449  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
450  params.encode(cbuf->get_data_ptr_address());
451  send_message(addr, cbuf, handler, m_default_timeout_ms);
452 }
453 
454 void
456  const TableIdentifier &table, const String &schema,
457  DispatchHandler *handler, Timer &timer) {
459  if (table.is_system())
461  Request::Parameters::UpdateSchema params(table, schema);
462  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
463  params.encode(cbuf->get_data_ptr_address());
464  send_message(addr, cbuf, handler, timer.remaining());
465 }
466 
467 void Lib::RangeServer::Client::commit_log_sync(const CommAddress &addr, uint64_t cluster_id,
468  const TableIdentifier &table,
469  DispatchHandler *handler) {
471  if (table.is_system())
473  Request::Parameters::CommitLogSync params(cluster_id, table);
474  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
475  params.encode(cbuf->get_data_ptr_address());
476  send_message(addr, cbuf, handler, m_default_timeout_ms);
477 }
478 
479 void Lib::RangeServer::Client::commit_log_sync(const CommAddress &addr, uint64_t cluster_id,
480  const TableIdentifier &table,
481  DispatchHandler *handler, Timer &timer) {
483  if (table.is_system())
485  Request::Parameters::CommitLogSync params(cluster_id, table);
486  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
487  params.encode(cbuf->get_data_ptr_address());
488  send_message(addr, cbuf, handler, timer.remaining());
489 }
490 
492  do_status(addr, status, m_default_timeout_ms);
493 }
494 
496  do_status(addr, status, timer.remaining());
497 }
498 
499 void Lib::RangeServer::Client::do_status(const CommAddress &addr, Status &status, int32_t timeout_ms) {
500  DispatchHandlerSynchronizer sync_handler;
503  CommBufPtr cbuf(new CommBuf(header));
504  send_message(addr, cbuf, &sync_handler, timeout_ms);
505 
506  EventPtr event;
507  if (!sync_handler.wait_for_reply(event))
509  String("RangeServer status() failure : ")
511 
512  {
513  size_t remaining = event->payload_len - 4;
514  const uint8_t *ptr = event->payload + 4;
516  params.decode(&ptr, &remaining);
517  status = params.status();
518  }
519 }
520 
522  DispatchHandler *handler, Timer &timer) {
525  CommBufPtr cbuf(new CommBuf(header));
526  send_message(addr, cbuf, handler, timer.remaining());
527 }
528 
529 
531  DispatchHandlerSynchronizer sync_handler;
534  CommBufPtr cbuf(new CommBuf(header));
535  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
536 
537  EventPtr event;
538  if (!sync_handler.wait_for_reply(event))
540  String("RangeServer wait_for_maintenance() failure : ")
542 }
543 
544 
548  CommBufPtr cbuf(new CommBuf(header));
549  send_message(addr, cbuf, 0, m_default_timeout_ms);
550 }
551 
552 void Lib::RangeServer::Client::dump(const CommAddress &addr, String &outfile, bool nokeys) {
553  DispatchHandlerSynchronizer sync_handler;
556  Request::Parameters::Dump params(outfile, nokeys);
557  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
558  params.encode(cbuf->get_data_ptr_address());
559  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
560 
561  EventPtr event;
562  if (!sync_handler.wait_for_reply(event))
564  String("RangeServer dump() failure : ")
566 
567 }
568 
569 void
571  const String &pseudo_table_name,
572  const String &outfile) {
573  DispatchHandlerSynchronizer sync_handler;
575  Request::Parameters::DumpPseudoTable params(table, pseudo_table_name, outfile);
576  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
577  params.encode(cbuf->get_data_ptr_address());
578  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
579 
580  EventPtr event;
581  if (!sync_handler.wait_for_reply(event))
583  String("RangeServer dump_pseudo_table() failure : ")
585 }
586 
588  vector<SystemVariable::Spec>&specs,
589  int64_t generation, StatsRangeServer &stats) {
590  do_get_statistics(addr, specs, generation, stats, m_default_timeout_ms);
591 }
592 
594  vector<SystemVariable::Spec>&specs,
595  int64_t generation, StatsRangeServer &stats,
596  Timer &timer) {
597  do_get_statistics(addr, specs, generation, stats, timer.remaining());
598 }
599 
601  vector<SystemVariable::Spec> &specs,
602  int64_t generation, StatsRangeServer &stats,
603  int32_t timeout_ms) {
604  DispatchHandlerSynchronizer sync_handler;
607  Request::Parameters::GetStatistics params(specs, generation);
608  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
609  params.encode(cbuf->get_data_ptr_address());
610  send_message(addr, cbuf, &sync_handler, timeout_ms);
611 
612  EventPtr event;
613  if (!sync_handler.wait_for_reply(event))
615  String("RangeServer get_statistics() failure : ")
617 
618  {
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();
624  }
625 }
626 
628  vector<SystemVariable::Spec>&specs,
629  int64_t generation, DispatchHandler *handler) {
632  Request::Parameters::GetStatistics params(specs, generation);
633  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
634  params.encode(cbuf->get_data_ptr_address());
635  send_message(addr, cbuf, handler, m_default_timeout_ms);
636 }
637 
639  vector<SystemVariable::Spec>&specs,
640  int64_t generation, DispatchHandler *handler,
641  Timer &timer) {
644  Request::Parameters::GetStatistics params(specs, generation);
645  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
646  params.encode(cbuf->get_data_ptr_address());
647  send_message(addr, cbuf, handler, timer.remaining());
648 }
649 
651  const RangeSpec &range, DispatchHandler *handler) {
653  Request::Parameters::DropRange params(table, range);
654  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
655  params.encode(cbuf->get_data_ptr_address());
656  send_message(addr, cbuf, handler, m_default_timeout_ms);
657 }
658 
660  const RangeSpec &range, DispatchHandler *handler,
661  Timer &timer) {
663  Request::Parameters::DropRange params(table, range);
664  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
665  params.encode(cbuf->get_data_ptr_address());
666  send_message(addr, cbuf, handler, timer.remaining());
667 }
668 
670  const TableIdentifier &table,
671  const RangeSpec &range) {
672  do_relinquish_range(addr, table, range, m_default_timeout_ms);
673 }
674 
676  const TableIdentifier &table,
677  const RangeSpec &range, Timer &timer) {
678  do_relinquish_range(addr, table, range, timer.remaining());
679 }
680 
682  const TableIdentifier &table,
683  const RangeSpec &range,
684  int32_t timeout_ms) {
685  DispatchHandlerSynchronizer sync_handler;
687  Request::Parameters::RelinquishRange params(table, range);
688  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
689  params.encode(cbuf->get_data_ptr_address());
690 
691  EventPtr event;
692  send_message(addr, cbuf, &sync_handler, timeout_ms);
693 
694  if (!sync_handler.wait_for_reply(event))
696  String("RangeServer relinquish_range() failure : ")
698 }
699 
701  DispatchHandlerSynchronizer sync_handler;
703  Request::Parameters::Heapcheck params(outfile);
704  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
705  params.encode(cbuf->get_data_ptr_address());
706  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
707 
708  EventPtr event;
709  if (!sync_handler.wait_for_reply(event))
711  String("RangeServer heapcheck() failure : ")
713 }
714 
716  const String &recover_location, int plan_generation, int32_t type,
717  const vector<int32_t> &fragments, const Lib::RangeServerRecovery::ReceiverPlan &plan,
718  int32_t replay_timeout) {
719  DispatchHandlerSynchronizer sync_handler;
722  Request::Parameters::ReplayFragments params(op_id, recover_location,
723  plan_generation, type, fragments,
724  plan, replay_timeout);
725  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
726  params.encode(cbuf->get_data_ptr_address());
727  send_message(addr, cbuf, &sync_handler, replay_timeout);
728 
729  EventPtr event;
730  if (!sync_handler.wait_for_reply(event))
732  String("RangeServer replay_fragments() failure : ")
734 
735 }
736 
738  int32_t plan_generation,
739  const vector<int32_t> &fragments,
740  const vector<QualifiedRangeSpec> &range_specs,
741  const vector<RangeState> &range_states) {
742  DispatchHandlerSynchronizer sync_handler;
745  Request::Parameters::PhantomLoad params(location, plan_generation, fragments,
746  range_specs, range_states);
747  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
748  params.encode(cbuf->get_data_ptr_address());
749  send_message(addr, cbuf, &sync_handler, m_default_timeout_ms);
750 
751  EventPtr event;
752  if (!sync_handler.wait_for_reply(event))
754  String("RangeServer phantom_load() failure : ")
756 }
757 
759  int32_t plan_generation, const QualifiedRangeSpec &range,
760  int32_t fragment, StaticBuffer &buffer,
761  DispatchHandler *handler) {
764  Request::Parameters::PhantomUpdate params(location, plan_generation,
765  range, fragment);
766  CommBufPtr cbuf(new CommBuf(header, params.encoded_length(), buffer));
767  params.encode(cbuf->get_data_ptr_address());
768  send_message(addr, cbuf, handler, m_default_timeout_ms);
769 }
770 
772  const String &location,
773  int32_t plan_generation,
774  const vector<QualifiedRangeSpec> &ranges,
775  int32_t timeout_ms) {
776  DispatchHandlerSynchronizer sync_handler;
779  Request::Parameters::PhantomPrepareRanges params(op_id, location,
780  plan_generation, ranges);
781  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
782  params.encode(cbuf->get_data_ptr_address());
783  send_message(addr, cbuf, &sync_handler, timeout_ms);
784 
785  EventPtr event;
786  if (!sync_handler.wait_for_reply(event))
788  String("RangeServer phantom_prepare_ranges() failure : ")
790 
791 }
792 
794  const String &location, int32_t plan_generation,
795  const vector<QualifiedRangeSpec> &ranges,
796  int32_t timeout_ms) {
797  DispatchHandlerSynchronizer sync_handler;
800  Request::Parameters::PhantomCommitRanges params(op_id, location,
801  plan_generation, ranges);
802  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
803  params.encode(cbuf->get_data_ptr_address());
804  send_message(addr, cbuf, &sync_handler, timeout_ms);
805 
806  EventPtr event;
807  if (!sync_handler.wait_for_reply(event))
809  String("RangeServer phantom_commit_ranges() failure : ")
811 }
812 
814  vector<SystemVariable::Spec> &specs, int64_t generation,
815  DispatchHandler *handler, Timer &timer) {
818  Request::Parameters::SetState params(specs, generation);
819  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
820  params.encode(cbuf->get_data_ptr_address());
821  send_message(addr, cbuf, handler, timer.remaining());
822 }
823 
824 
826  const TableIdentifier &table,
827  DispatchHandler *handler) {
831  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
832  params.encode(cbuf->get_data_ptr_address());
833  send_message(addr, cbuf, handler, m_default_timeout_ms);
834 }
835 
837  const TableIdentifier &table,
838  DispatchHandler *handler) {
842  CommBufPtr cbuf(new CommBuf(header, params.encoded_length()));
843  params.encode(cbuf->get_data_ptr_address());
844  send_message(addr, cbuf, handler, m_default_timeout_ms);
845 }
846 
847 
849  DispatchHandler *handler, int32_t timeout_ms) {
850  int error;
851 
852  if ((error = m_comm->send_request(addr, timeout_ms, cbuf, handler))
853  != Error::OK) {
854  HT_WARNF("Comm::send_request to %s failed - %s",
855  addr.to_str().c_str(), Error::get_text(error));
856  // COMM_BROKEN_CONNECTION implies handler will get a callback
857  if (error != Error::COMM_BROKEN_CONNECTION)
858  HT_THROWF(error, "Comm::send_request to %s failed",
859  addr.to_str().c_str());
860  }
861 }
A memory buffer of static size.
Definition: StaticBuffer.h:45
Response parameters for open requests.
Definition: Status.h:49
void status(const CommAddress &addr, Status &status)
Issues a "status" request.
Definition: Client.cc:491
Request parameters for table maintenance disable function.
Client(Comm *comm, int32_t timeout_ms=0)
Definition: Client.cc:75
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.
Definition: Client.cc:217
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.
Definition: Client.cc:771
#define HT_WARNF(msg,...)
Definition: Logger.h:290
const Hypertable::Status & status() const
Gets status information.
Definition: Status.h:64
Request parameters for compact function.
Definition: Compact.h:48
void drop_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, DispatchHandler *handler)
Issues an asynchronous "drop range" request asynchronously.
Definition: Client.cc:650
Declarations for PhantomUpdate request parameters.
Request parameters for set state function.
Definition: SetState.h:49
Range specification.
Definition: RangeSpec.h:40
Request parameters for dump pseudo table function.
Holds Nagios-style program status information.
Definition: Status.h:42
static int32_t response_code(const Event *event)
Returns the response code from an event event generated in response to a request message.
Definition: Protocol.cc:39
Declarations for DropRange request parameters.
Declarations for PhantomPrepareRanges request parameters.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
static String string_format_message(const Event *event)
Returns error message decoded standard error MESSAGE generated in response to a request message...
Definition: Protocol.cc:51
Declarations for AcknowledgeLoad response parameters.
uint16_t flags
Flags.
Definition: CommHeader.h:139
void heapcheck(const CommAddress &addr, String &outfile)
Issues a "heapcheck" request.
Definition: Client.cc:700
void commit_log_sync(const CommAddress &addr, uint64_t cluster_id, const TableIdentifier &table, DispatchHandler *handler)
Issues a "commit_log_sync" request asynchronously.
Definition: Client.cc:467
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.
Definition: Client.cc:202
virtual size_t encoded_length() const
Returns serialized object length.
Definition: Serializable.cc:37
void table_maintenance_enable(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues an asynchronous RangeServer::table_maintenance_enable().
Definition: Client.cc:825
void dump_pseudo_table(const CommAddress &addr, const TableIdentifier &table, const String &pseudo_table_name, const String &outfile)
Definition: Client.cc:570
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.
Definition: Client.cc:163
void do_create_scanner(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, const ScanSpec &scan_spec, ScanBlock &scan_block, int32_t timeout_ms)
Definition: Client.cc:263
Declarations for RelinquishRange request parameters.
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
Request should be profiled.
Definition: CommHeader.h:54
STL namespace.
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.
Definition: Timer.h:101
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.
Definition: Client.cc:836
const StatsRangeServer & stats()
Gets range server statistics.
Definition: GetStatistics.h:65
Request parameters for commit log sync function.
Definition: CommitLogSync.h:48
Declarations for Update request parameters.
#define HT_EXPECT(_e_, _code_)
Definition: Logger.h:388
#define HT_ASSERT(_e_)
Definition: Logger.h:396
void dump(const CommAddress &addr, String &outfile, bool nokeys)
Definition: Client.cc:552
Declarations for ReplayFragments request parameters.
Declarations for TableMaintenanceDisable request parameters.
uint32_t gid
Group ID (see ApplicationQueue)
Definition: CommHeader.h:142
Scan predicate and control specification.
Definition: ScanSpec.h:56
Request parameters for fetch scanblock function.
Request parameters for update schema function.
Definition: UpdateSchema.h:48
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.
Definition: Client.cc:715
Request parameters for update function.
Definition: Update.h:50
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.
Definition: Serializable.cc:64
void fetch_scanblock(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "fetch scanblock" request asynchronously.
Definition: Client.cc:344
Declarations for DumpPseudoTable request parameters.
const char * get_text(int error)
Returns a descriptive error message.
Definition: Error.cc:330
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Definition: Utility.cc:408
Request parameters for create scanner function.
Definition: CreateScanner.h:50
std::shared_ptr< CommBuf > CommBufPtr
Smart pointer to CommBuf.
Definition: CommBuf.h:305
Declarations for TableMaintenanceEnable request parameters.
void shutdown(const CommAddress &addr)
Issues a "shutdown" request.
Definition: Client.cc:545
Request parameters for dump function.
Definition: Dump.h:48
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.
Definition: Client.cc:793
void do_drop_table(const CommAddress &addr, const TableIdentifier &table, int32_t timeout_ms)
Definition: Client.cc:427
void destroy_scanner(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "destroy scanner" request asynchronously.
Definition: Client.cc:290
Functions to serialize/deserialize primitives to/from a memory buffer.
String to_str() const
Returns string representation of address.
Definition: CommAddress.cc:34
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.
Definition: Client.cc:758
void do_get_statistics(const CommAddress &addr, std::vector< SystemVariable::Spec > &specs, int64_t generation, StatsRangeServer &stats, int32_t timeout_ms)
Definition: Client.cc:600
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.
Definition: Serializable.cc:70
Declarations for GetStatistics request parameters.
void relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range)
Issues a "relinquish range" request synchronously.
Definition: Client.cc:669
Hypertable definitions
Encapsulates a block of scan results.
Definition: ScanBlock.h:50
void get_statistics(const CommAddress &addr, std::vector< SystemVariable::Spec > &specs, int64_t generation, StatsRangeServer &stats)
Issues an synchronous "get_statistics" request.
Definition: Client.cc:587
DispatchHandler class used to synchronize with response messages.
Declarations for CreateScanner request parameters.
Entry point to AsyncComm service.
Definition: Comm.h:61
Request parameters for drop range function.
Definition: DropRange.h:50
Header for messages transmitted via AsyncComm.
Definition: CommHeader.h:40
void compact(const CommAddress &addr, const TableIdentifier &table, const String &row, int32_t flags)
Issues a "compact" request synchronously.
Definition: Client.cc:86
size_t encoded_length() const
Returns encoded length of header.
Definition: CommHeader.h:95
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.
Definition: Client.cc:813
Declarations for Protocol.
Declarations for AcknowledgeLoad request parameters.
Request parameters for get statistics function.
Definition: GetStatistics.h:49
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.
Definition: Client.cc:737
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
Request parameters for phantom load function.
Definition: PhantomLoad.h:50
void drop_table(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues a "drop table" request asynchronously.
Definition: Client.cc:404
Request parameters for load range function.
Definition: LoadRange.h:50
A timer class to keep timeout states across AsyncComm related calls.
Definition: Timer.h:44
Declarations for ScanBlock.
void do_relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range, int32_t timeout_ms)
Definition: Client.cc:681
Message buffer for holding data to be transmitted over a network.
Definition: CommBuf.h:79
Declarations for DestroyScanner request parameters.
void do_status(const CommAddress &addr, Status &status, int32_t timeout_ms)
Definition: Client.cc:499
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.
Definition: Client.cc:443
Request parameters for phantom update function.
Definition: PhantomUpdate.h:49
Declarations for GetStatistics response parameters.
Request parameters for heapcheck function.
Definition: Heapcheck.h:48
Range state.
Definition: RangeState.h:48
Configuration settings.
void do_destroy_scanner(const CommAddress &addr, int32_t scanner_id, int32_t timeout_ms)
Definition: Client.cc:325
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.
Definition: Client.cc:125
Declarations for PhantomCommitRanges request parameters.
Declarations for CreateScanner response parameters.
void send_message(const CommAddress &addr, CommBufPtr &cbp, DispatchHandler *handler, int32_t timeout_ms)
Definition: Client.cc:848
Request parameters for drop table function.
Definition: DropTable.h:48
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)
Definition: Client.cc:381
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
Declarations for FetchScanblock request parameters.
int load(EventPtr &event)
Loads scanblock data returned from RangeServer.
Definition: ScanBlock.cc:46
Request parameters for table maintenance enable function.
Request parameters for acknowledge load function.
Address abstraction to hold either proxy name or IPv4:port address.
Definition: CommAddress.h:52
Response parameters for get statistics function.
Definition: GetStatistics.h:50
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)
Definition: Client.cc:142
void wait_for_maintenance(const CommAddress &addr)
Issues a "wait_for_maintenance" request.
Definition: Client.cc:530
RangeServer recovery receiver plan.
Definition: ReceiverPlan.h:48