25 #ifndef KUDU_CLIENT_CLIENT_H
26 #define KUDU_CLIENT_CLIENT_H
32 #include "kudu/client/resource_metrics.h"
33 #include "kudu/client/row_result.h"
34 #include "kudu/client/scan_batch.h"
35 #include "kudu/client/scan_predicate.h"
36 #include "kudu/client/schema.h"
38 #ifdef KUDU_HEADERS_NO_STUBS
39 #include <gtest/gtest_prod.h>
40 #include "kudu/gutil/macros.h"
41 #include "kudu/gutil/port.h"
43 #include "kudu/client/stubs.h"
45 #include "kudu/client/write_op.h"
46 #include "kudu/util/kudu_export.h"
47 #include "kudu/util/monotime.h"
50 #if _GLIBCXX_USE_CXX11_ABI
52 "Kudu will not function properly if built with gcc 5's new ABI. " \
53 "Please modify your application to set -D_GLIBCXX_USE_CXX11_ABI=0. " \
54 "For more information about the new ABI, see " \
55 "https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html."
60 class ClientStressTest_TestUniqueClientIds_Test;
61 class LinkedListTester;
62 class PartitionSchema;
66 class KuduLoggingCallback;
69 class KuduStatusCallback;
71 class KuduTableAlterer;
72 class KuduTableCreator;
74 class KuduTabletServer;
76 class KuduWriteOperation;
80 class GetTableSchemaRpc;
84 class RemoteTabletServer;
100 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
108 void KUDU_EXPORT UninstallLoggingCallback();
125 void KUDU_EXPORT SetVerboseLogLevel(
int level);
136 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
140 std::string KUDU_EXPORT GetShortVersionString();
144 std::string KUDU_EXPORT GetAllVersionInfo();
206 Status Build(sp::shared_ptr<KuduClient>* client);
209 class KUDU_NO_EXPORT Data;
243 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
261 Status IsCreateTableInProgress(
const std::string& table_name,
262 bool *create_in_progress);
269 Status DeleteTable(
const std::string& table_name);
287 Status IsAlterTableInProgress(
const std::string& table_name,
288 bool *alter_in_progress);
296 Status GetTableSchema(
const std::string& table_name,
305 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
314 Status ListTables(std::vector<std::string>* tables,
315 const std::string& filter =
"");
324 Status TableExists(
const std::string& table_name,
bool* exists);
339 Status OpenTable(
const std::string& table_name,
340 sp::shared_ptr<KuduTable>* table);
347 sp::shared_ptr<KuduSession> NewSession();
363 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
380 bool IsMultiMaster()
const;
383 const MonoDelta& default_admin_operation_timeout()
const;
386 const MonoDelta& default_rpc_timeout()
const;
399 uint64_t GetLatestObservedTimestamp()
const;
412 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
415 class KUDU_NO_EXPORT Data;
417 friend class internal::Batcher;
418 friend class internal::GetTableSchemaRpc;
419 friend class internal::LookupRpc;
420 friend class internal::MetaCache;
421 friend class internal::RemoteTablet;
422 friend class internal::RemoteTabletServer;
423 friend class internal::WriteRpc;
424 friend class ClientTest;
433 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
434 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
435 FRIEND_TEST(ClientTest, TestMasterDown);
436 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
437 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
438 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
439 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
440 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
441 FRIEND_TEST(ClientTest, TestScanTimeout);
442 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
443 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
460 const std::string& uuid()
const;
464 const std::string& hostname()
const;
468 uint16_t port()
const;
471 class KUDU_NO_EXPORT Data;
482 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
494 bool is_leader()
const;
503 class KUDU_NO_EXPORT Data;
510 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
520 const std::string& id()
const;
527 const std::vector<const KuduReplica*>& replicas()
const;
533 class KUDU_NO_EXPORT Data;
540 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
589 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
590 int32_t num_buckets);
607 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
608 int32_t num_buckets, int32_t seed);
622 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
660 RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
661 RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
678 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows);
727 class KUDU_NO_EXPORT Data;
759 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
764 const std::string& name()
const;
773 const std::string& id()
const;
779 int num_replicas()
const;
833 const PartitionSchema& partition_schema()
const;
836 class KUDU_NO_EXPORT Data;
840 KuduTable(
const sp::shared_ptr<KuduClient>& client,
841 const std::string& name,
842 const std::string&
id,
845 const PartitionSchema& partition_schema);
850 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1006 class KUDU_NO_EXPORT Data;
1010 const std::string& name);
1015 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1028 const Status& status()
const;
1052 bool was_possibly_successful()
const;
1055 class KUDU_NO_EXPORT Data;
1057 friend class internal::Batcher;
1065 DISALLOW_COPY_AND_ASSIGN(KuduError);
1127 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1173 Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1219 Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1239 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1264 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1288 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1314 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1321 void SetTimeoutMillis(
int millis);
1366 Status Flush() WARN_UNUSED_RESULT;
1412 Status Close() WARN_UNUSED_RESULT;
1422 bool HasPendingOperations() const;
1435 int CountBufferedOperations() const;
1443 int CountPendingErrors() const;
1455 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1461 class KUDU_NO_EXPORT Data;
1464 friend class internal::Batcher;
1465 friend class ClientTest;
1466 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1468 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1536 enum { kScanTimeoutMillis = 30000 };
1543 explicit KuduScanner(KuduTable* table);
1555 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1567 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1575 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1586 Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1624 Status AddExclusiveUpperBoundRaw(
const Slice& key);
1634 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1644 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1652 Status SetCacheBlocks(
bool cache_blocks);
1692 bool HasMoreRows()
const;
1705 Status NextBatch(std::vector<KuduRowResult>* rows);
1715 Status NextBatch(KuduScanBatch* batch);
1725 Status GetCurrentServer(KuduTabletServer** server);
1728 const ResourceMetrics& GetResourceMetrics()
const;
1736 Status SetBatchSizeBytes(uint32_t batch_size);
1753 Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
1760 Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT;
1774 Status SetFaultTolerant() WARN_UNUSED_RESULT;
1781 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
1789 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
1796 Status SetTimeoutMillis(
int millis);
1799 KuduSchema GetProjectionSchema() const;
1802 std::
string ToString() const;
1805 class KUDU_NO_EXPORT Data;
1807 friend class KuduScanToken;
1808 FRIEND_TEST(ClientTest, TestScanCloseProxy);
1809 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
1810 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
1811 FRIEND_TEST(ClientTest, TestScanTimeout);
1816 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
1839 class KUDU_EXPORT KuduScanToken {
1854 Status IntoKuduScanner(KuduScanner** scanner)
const WARN_UNUSED_RESULT;
1866 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
1879 static Status DeserializeIntoScanner(KuduClient* client,
1880 const std::string& serialized_token,
1881 KuduScanner** scanner) WARN_UNUSED_RESULT;
1884 class KUDU_NO_EXPORT Data;
1893 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
1919 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1923 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1943 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
1951 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
1967 Status SetFaultTolerant() WARN_UNUSED_RESULT;
1970 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
1974 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
1977 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
1987 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
1990 std::string ToString()
const;
1993 class KUDU_NO_EXPORT Data;
A single row update to be sent to the cluster.
Definition: write_op.h:178
A representation of a table's schema.
Definition: schema.h:411
A representation of an operation's outcome.
Definition: status.h:106
A constant cell value with a specific type.
Definition: value.h:33
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1176
Definition: client.h:1195
A single row insert to be sent to the cluster.
Definition: write_op.h:126
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:224
static const uint64_t kNoTimestamp
Definition: client.h:390
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:369
A single row upsert to be sent to the cluster.
Definition: write_op.h:151
Builds scan tokens for a table.
Definition: client.h:1899
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:39
Alters an existing table based on the provided steps.
Definition: client.h:864
OrderMode
Definition: client.h:1518
Definition: client.h:1524
Smart pointer typedefs for externally-faced code.
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:36
An exclusive bound.
Definition: client.h:626
This class represents an error which occurred in a write operation.
Definition: client.h:1023
A handle for a connection to a cluster.
Definition: client.h:243
An inclusive bound.
Definition: client.h:627
In-memory representation of a remote tablet server.
Definition: client.h:454
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:43
A representation of a table on a particular cluster.
Definition: client.h:759
This class is a representation of a single scan.
Definition: client.h:1481
ReadMode
The read modes for scanners.
Definition: client.h:1484
Definition: client.h:1157
Definition: client.h:1492
A "factory" for KuduClient objects.
Definition: client.h:150
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:55
Select the LEADER replica.
Definition: client.h:370
RangePartitionBound
Range partition bound type.
Definition: client.h:625
In-memory representation of a remote tablet.
Definition: client.h:514
In-memory representation of a remote tablet's replica.
Definition: client.h:486
FlushMode
Modes of flush operations.
Definition: client.h:1132
Definition: client.h:1137
A single row delete to be sent to the cluster.
Definition: write_op.h:205
A helper class to create a new table with the desired options.
Definition: client.h:544
Representation of a Kudu client session.
Definition: client.h:1127
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:53
A representation of a time interval.
Definition: monotime.h:43