0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Client.h
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 #ifndef Hypertable_Lib_RangeServer_Client_h
29 #define Hypertable_Lib_RangeServer_Client_h
30 
31 #include <Common/InetAddr.h>
32 #include <Common/StaticBuffer.h>
33 #include <Common/Status.h>
34 
35 #include <AsyncComm/Comm.h>
36 #include <AsyncComm/CommBuf.h>
38 
48 
49 #include <map>
50 #include <memory>
51 
52 namespace Hypertable {
53 namespace Lib {
54 namespace RangeServer {
55 
58 
63  class Client {
64  public:
65 
66  Client(Comm *comm, int32_t timeout_ms=0);
67  ~Client();
68 
72  void set_default_timeout(int32_t timeout_ms) {
73  m_default_timeout_ms = timeout_ms;
74  }
75  int32_t default_timeout() const { return m_default_timeout_ms; }
76 
84  void compact(const CommAddress &addr, const TableIdentifier &table,
85  const String &row, int32_t flags);
86 
95  void compact(const CommAddress &addr, const TableIdentifier &table,
96  const String &row, int32_t flags, DispatchHandler *handler);
97 
107  void compact(const CommAddress &addr, const TableIdentifier &table,
108  const String &row, int32_t flags,
109  DispatchHandler *handler, Timer &timer);
110 
118  void load_range(const CommAddress &addr, const TableIdentifier &table,
119  const RangeSpec &range_spec, const RangeState &range_state,
120  bool needs_compaction);
121 
130  void load_range(const CommAddress &addr, const TableIdentifier &table,
131  const RangeSpec &range_spec, const RangeState &range_state,
132  bool needs_compaction, Timer &timer);
133 
139  void acknowledge_load(const CommAddress &addr,
140  const vector<QualifiedRangeSpec *> &ranges,
141  std::map<QualifiedRangeSpec, int> &response_map);
142 
155  void update(const CommAddress &addr, uint64_t cluster_id,
156  const TableIdentifier &table, int32_t count,
157  StaticBuffer &buffer, int32_t flags,
158  DispatchHandler *handler);
159 
167  void create_scanner(const CommAddress &addr, const TableIdentifier &table,
168  const RangeSpec &range, const ScanSpec &scan_spec,
169  DispatchHandler *handler);
170 
179  void create_scanner(const CommAddress &addr, const TableIdentifier &table,
180  const RangeSpec &range, const ScanSpec &scan_spec,
181  DispatchHandler *handler, Timer &timer);
182 
190  void create_scanner(const CommAddress &addr, const TableIdentifier &table,
191  const RangeSpec &range, const ScanSpec &scan_spec,
192  ScanBlock &scan_block);
193 
202  void create_scanner(const CommAddress &addr, const TableIdentifier &table,
203  const RangeSpec &range, const ScanSpec &scan_spec,
204  ScanBlock &scan_block, Timer &timer);
205 
211  void destroy_scanner(const CommAddress &addr, int32_t scanner_id,
212  DispatchHandler *handler);
213 
220  void destroy_scanner(const CommAddress &addr, int32_t scanner_id,
221  DispatchHandler *handler, Timer &timer);
222 
227  void destroy_scanner(const CommAddress &addr, int32_t scanner_id);
228 
234  void destroy_scanner(const CommAddress &addr, int32_t scanner_id, Timer &timer);
235 
241  void fetch_scanblock(const CommAddress &addr, int32_t scanner_id,
242  DispatchHandler *handler);
243 
250  void fetch_scanblock(const CommAddress &addr, int32_t scanner_id,
251  DispatchHandler *handler, Timer &timer);
252 
258  void fetch_scanblock(const CommAddress &addr, int32_t scanner_id,
259  ScanBlock &scan_block);
260 
267  void fetch_scanblock(const CommAddress &addr, int32_t scanner_id,
268  ScanBlock &scan_block, Timer &timer);
269 
275  void drop_table(const CommAddress &addr, const TableIdentifier &table,
276  DispatchHandler *handler);
277 
284  void drop_table(const CommAddress &addr, const TableIdentifier &table,
285  DispatchHandler *handler, Timer &timer);
286 
291  void drop_table(const CommAddress &addr, const TableIdentifier &table);
292 
298  void drop_table(const CommAddress &addr,
299  const TableIdentifier &table,
300  Timer &timer);
301 
308  void update_schema(const CommAddress &addr,
309  const TableIdentifier &table, const String &schema,
310  DispatchHandler *handler);
311 
319  void update_schema(const CommAddress &addr,
320  const TableIdentifier &table, const String &schema,
321  DispatchHandler *handler, Timer &timer);
322 
329  void commit_log_sync(const CommAddress &addr, uint64_t cluster_id,
330  const TableIdentifier &table,
331  DispatchHandler *handler);
332 
340  void commit_log_sync(const CommAddress &addr, uint64_t cluster_id,
341  const TableIdentifier &table,
342  DispatchHandler *handler, Timer &timer);
343 
349  void status(const CommAddress &addr, Status &status);
350 
357  void status(const CommAddress &addr, Status &status, Timer &timer);
358 
363  void status(const CommAddress &addr, DispatchHandler *handler,
364  Timer &timer);
365 
370  void wait_for_maintenance(const CommAddress &addr);
371 
376  void shutdown(const CommAddress &addr);
377 
378  void dump(const CommAddress &addr, String &outfile, bool nokeys);
379 
382  void dump_pseudo_table(const CommAddress &addr, const TableIdentifier &table,
383  const String &pseudo_table_name, const String &outfile);
384 
391  void get_statistics(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
392  int64_t generation, StatsRangeServer &stats);
393 
401  void get_statistics(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
402  int64_t generation, StatsRangeServer &stats, Timer &timer);
403 
410  void get_statistics(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
411  int64_t generation, DispatchHandler *handler);
412 
413 
421  void get_statistics(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
422  int64_t generation, DispatchHandler *handler, Timer &timer);
423 
430  void drop_range(const CommAddress &addr, const TableIdentifier &table,
431  const RangeSpec &range, DispatchHandler *handler);
432 
440  void drop_range(const CommAddress &addr, const TableIdentifier &table,
441  const RangeSpec &range, DispatchHandler *handler,
442  Timer &timer);
443 
449  void relinquish_range(const CommAddress &addr, const TableIdentifier &table,
450  const RangeSpec &range);
451 
458  void relinquish_range(const CommAddress &addr, const TableIdentifier &table,
459  const RangeSpec &range, Timer &timer);
460 
466  void heapcheck(const CommAddress &addr, String &outfile);
467 
478  void replay_fragments(const CommAddress &addr, int64_t op_id,
479  const String &recover_location, int32_t plan_generation,
480  int32_t type, const vector<int32_t> &fragments,
482  int32_t replay_timeout);
483 
492  void phantom_load(const CommAddress &addr, const String &location,
493  int32_t plan_generation,
494  const vector<int32_t> &fragments,
495  const vector<QualifiedRangeSpec> &range_specs,
496  const vector<RangeState> &range_states);
497 
507  void phantom_update(const CommAddress &addr, const String &location,
508  int32_t plan_generation, const QualifiedRangeSpec &range,
509  int32_t fragment, StaticBuffer &updates,
510  DispatchHandler *handler);
511 
520  void phantom_prepare_ranges(const CommAddress &addr, int64_t op_id,
521  const String &location, int32_t plan_generation,
522  const vector<QualifiedRangeSpec> &ranges,
523  int32_t timeout);
524 
533  void phantom_commit_ranges(const CommAddress &addr, int64_t op_id,
534  const String &location, int32_t plan_generation,
535  const vector<QualifiedRangeSpec> &ranges,
536  int32_t timeout);
537 
545  void set_state(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
546  int64_t generation, DispatchHandler *handler, Timer &timer);
547 
552  void table_maintenance_enable(const CommAddress &addr,
553  const TableIdentifier &table,
554  DispatchHandler *handler);
555 
560  void table_maintenance_disable(const CommAddress &addr,
561  const TableIdentifier &table,
562  DispatchHandler *handler);
563 
564  private:
565  void do_load_range(const CommAddress &addr, const TableIdentifier &table,
566  const RangeSpec &range_spec, const RangeState &range_state,
567  bool needs_compaction, int32_t timeout_ms);
568  void do_create_scanner(const CommAddress &addr,
569  const TableIdentifier &table, const RangeSpec &range,
570  const ScanSpec &scan_spec, ScanBlock &scan_block,
571  int32_t timeout_ms);
572  void do_destroy_scanner(const CommAddress &addr, int32_t scanner_id,
573  int32_t timeout_ms);
574  void do_fetch_scanblock(const CommAddress &addr, int32_t scanner_id,
575  ScanBlock &scan_block, int32_t timeout_ms);
576  void do_drop_table(const CommAddress &addr,
577  const TableIdentifier &table,
578  int32_t timeout_ms);
579  void do_status(const CommAddress &addr, Status &status, int32_t timeout_ms);
580  void do_get_statistics(const CommAddress &addr, std::vector<SystemVariable::Spec> &specs,
581  int64_t generation, StatsRangeServer &stats,
582  int32_t timeout_ms);
583  void do_relinquish_range(const CommAddress &addr, const TableIdentifier &table,
584  const RangeSpec &range, int32_t timeout_ms);
585 
586  void send_message(const CommAddress &addr, CommBufPtr &cbp,
587  DispatchHandler *handler, int32_t timeout_ms);
588 
591  };
592 
594  typedef std::shared_ptr<Client> ClientPtr;
595 
597 
598 }}}
599 
600 #endif // Hypertable_Lib_RangeServer_Client_h
A memory buffer of static size.
Definition: StaticBuffer.h:45
void status(const CommAddress &addr, Status &status)
Issues a "status" request.
Definition: Client.cc:491
Client(Comm *comm, int32_t timeout_ms=0)
Definition: Client.cc:75
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
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
Range specification.
Definition: RangeSpec.h:40
Holds Nagios-style program status information.
Definition: Status.h:42
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
Declarations for Status.
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
Declarations for SystemVariable.
void table_maintenance_enable(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues an asynchronous RangeServer::table_maintenance_enable().
Definition: Client.cc:825
Declarations for TableIdentifier and TableIdentifierManaged.
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
void table_maintenance_disable(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues an asynchronous RangeServer::table_maintenance_disable() request.
Definition: Client.cc:836
void dump(const CommAddress &addr, String &outfile, bool nokeys)
Definition: Client.cc:552
Scan predicate and control specification.
Definition: ScanSpec.h:56
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
Declarations for DispatchHandler.
Declarations for QualifiedRangeSpec and QualifiedRangeSpecManaged.
Declarations for RangeState.
void fetch_scanblock(const CommAddress &addr, int32_t scanner_id, DispatchHandler *handler)
Issues a "fetch scanblock" request asynchronously.
Definition: Client.cc:344
std::shared_ptr< Client > ClientPtr
Smart pointer to Client.
Definition: Client.h:594
std::shared_ptr< CommBuf > CommBufPtr
Smart pointer to CommBuf.
Definition: CommBuf.h:305
void shutdown(const CommAddress &addr)
Issues a "shutdown" request.
Definition: Client.cc:545
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
A memory buffer of static size.
void set_default_timeout(int32_t timeout_ms)
Sets the default client connection timeout.
Definition: Client.h:72
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
void relinquish_range(const CommAddress &addr, const TableIdentifier &table, const RangeSpec &range)
Issues a "relinquish range" request synchronously.
Definition: Client.cc:669
Declarations for RangeSpec and RangeSpecManaged.
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
Entry point to AsyncComm service.
Definition: Comm.h:61
void compact(const CommAddress &addr, const TableIdentifier &table, const String &row, int32_t flags)
Issues a "compact" request synchronously.
Definition: Client.cc:86
Declarations for CommBuf.
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 Comm.
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
Client interface to RangeServer.
Definition: Client.h:63
void drop_table(const CommAddress &addr, const TableIdentifier &table, DispatchHandler *handler)
Issues a "drop table" request asynchronously.
Definition: Client.cc:404
Internet address wrapper classes and utility functions.
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
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
int32_t default_timeout() const
Definition: Client.h:75
Range state.
Definition: RangeState.h:48
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
void send_message(const CommAddress &addr, CommBufPtr &cbp, DispatchHandler *handler, int32_t timeout_ms)
Definition: Client.cc:848
void do_fetch_scanblock(const CommAddress &addr, int32_t scanner_id, ScanBlock &scan_block, int32_t timeout_ms)
Definition: Client.cc:381
Address abstraction to hold either proxy name or IPv4:port address.
Definition: CommAddress.h:52
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