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"
37 #include "kudu/client/shared_ptr.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;
73 class KuduTabletServer;
75 class KuduWriteOperation;
79 class GetTableSchemaRpc;
83 class RemoteTabletServer;
99 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
107 void KUDU_EXPORT UninstallLoggingCallback();
124 void KUDU_EXPORT SetVerboseLogLevel(
int level);
135 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
139 std::string KUDU_EXPORT GetShortVersionString();
143 std::string KUDU_EXPORT GetAllVersionInfo();
205 Status Build(sp::shared_ptr<KuduClient>* client);
208 class KUDU_NO_EXPORT Data;
242 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
260 Status IsCreateTableInProgress(
const std::string& table_name,
261 bool *create_in_progress);
268 Status DeleteTable(
const std::string& table_name);
286 Status IsAlterTableInProgress(
const std::string& table_name,
287 bool *alter_in_progress);
295 Status GetTableSchema(
const std::string& table_name,
304 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
313 Status ListTables(std::vector<std::string>* tables,
314 const std::string& filter =
"");
323 Status TableExists(
const std::string& table_name,
bool* exists);
338 Status OpenTable(
const std::string& table_name,
339 sp::shared_ptr<KuduTable>* table);
346 sp::shared_ptr<KuduSession> NewSession();
360 bool IsMultiMaster()
const;
363 const MonoDelta& default_admin_operation_timeout()
const;
366 const MonoDelta& default_rpc_timeout()
const;
379 uint64_t GetLatestObservedTimestamp()
const;
392 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
395 class KUDU_NO_EXPORT Data;
397 friend class internal::Batcher;
398 friend class internal::GetTableSchemaRpc;
399 friend class internal::LookupRpc;
400 friend class internal::MetaCache;
401 friend class internal::RemoteTablet;
402 friend class internal::RemoteTabletServer;
403 friend class internal::WriteRpc;
404 friend class ClientTest;
412 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
413 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
414 FRIEND_TEST(ClientTest, TestMasterDown);
415 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
416 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
417 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
418 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
419 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
420 FRIEND_TEST(ClientTest, TestScanTimeout);
421 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
422 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
478 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
479 int32_t num_buckets);
496 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
497 int32_t num_buckets, int32_t seed);
511 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
549 RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
550 RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
567 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows);
616 class KUDU_NO_EXPORT Data;
648 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
653 const std::string& name()
const;
662 const std::string& id()
const;
719 const PartitionSchema& partition_schema()
const;
722 class KUDU_NO_EXPORT Data;
726 KuduTable(
const sp::shared_ptr<KuduClient>& client,
727 const std::string& name,
728 const std::string& table_id,
730 const PartitionSchema& partition_schema);
735 DISALLOW_COPY_AND_ASSIGN(KuduTable);
891 class KUDU_NO_EXPORT Data;
895 const std::string& name);
900 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
913 const Status& status()
const;
937 bool was_possibly_successful()
const;
940 class KUDU_NO_EXPORT Data;
942 friend class internal::Batcher;
950 DISALLOW_COPY_AND_ASSIGN(KuduError);
1012 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1058 Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1104 Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1122 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1128 void SetTimeoutMillis(
int millis);
1182 Status Flush() WARN_UNUSED_RESULT;
1225 Status Close() WARN_UNUSED_RESULT;
1237 bool HasPendingOperations() const;
1252 int CountBufferedOperations() const;
1262 int CountPendingErrors() const;
1276 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1282 class KUDU_NO_EXPORT Data;
1285 friend class internal::Batcher;
1286 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1354 enum { kScanTimeoutMillis = 30000 };
1361 explicit KuduScanner(KuduTable* table);
1373 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1385 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1393 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1404 Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1442 Status AddExclusiveUpperBoundRaw(
const Slice& key);
1452 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1462 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1470 Status SetCacheBlocks(
bool cache_blocks);
1510 bool HasMoreRows()
const;
1523 Status NextBatch(std::vector<KuduRowResult>* rows);
1533 Status NextBatch(KuduScanBatch* batch);
1543 Status GetCurrentServer(KuduTabletServer** server);
1546 const ResourceMetrics& GetResourceMetrics()
const;
1554 Status SetBatchSizeBytes(uint32_t batch_size);
1571 Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
1578 Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT;
1592 Status SetFaultTolerant() WARN_UNUSED_RESULT;
1599 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
1607 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
1614 Status SetTimeoutMillis(
int millis);
1617 KuduSchema GetProjectionSchema() const;
1620 std::
string ToString() const;
1623 class KUDU_NO_EXPORT Data;
1625 friend class KuduScanToken;
1626 FRIEND_TEST(ClientTest, TestScanCloseProxy);
1627 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
1628 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
1629 FRIEND_TEST(ClientTest, TestScanTimeout);
1634 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
1657 class KUDU_EXPORT KuduScanToken {
1672 Status IntoKuduScanner(KuduScanner** scanner)
const WARN_UNUSED_RESULT;
1682 const std::vector<KuduTabletServer*>& TabletServers()
const;
1691 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
1704 static Status DeserializeIntoScanner(KuduClient* client,
1705 const std::string& serialized_token,
1706 KuduScanner** scanner) WARN_UNUSED_RESULT;
1709 class KUDU_NO_EXPORT Data;
1713 explicit KuduScanToken(Data* data);
1718 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
1744 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1748 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1768 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
1776 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
1792 Status SetFaultTolerant() WARN_UNUSED_RESULT;
1795 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
1799 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
1802 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
1812 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
1815 std::string ToString()
const;
1818 class KUDU_NO_EXPORT Data;
1833 const std::string& uuid()
const;
1837 const std::string& hostname()
const;
1840 class KUDU_NO_EXPORT Data;
1842 friend class KuduClient;
1843 friend class KuduScanner;
1851 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
A single row update to be sent to the cluster.
Definition: write_op.h:175
A representation of a table's schema.
Definition: schema.h:409
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:1061
Definition: client.h:1080
A single row insert to be sent to the cluster.
Definition: write_op.h:123
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:222
static const uint64_t kNoTimestamp
Definition: client.h:370
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:349
A single row upsert to be sent to the cluster.
Definition: write_op.h:148
Builds scan tokens for a table.
Definition: client.h:1724
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:39
Alters an existing table based on the provided steps.
Definition: client.h:749
OrderMode
Definition: client.h:1336
Definition: client.h:1342
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:36
An exclusive bound.
Definition: client.h:515
This class represents an error which occurred in a write operation.
Definition: client.h:908
A handle for a connection to a cluster.
Definition: client.h:242
An inclusive bound.
Definition: client.h:516
In-memory representation of a remote tablet server.
Definition: client.h:1827
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:648
This class is a representation of a single scan.
Definition: client.h:1299
ReadMode
The read modes for scanners.
Definition: client.h:1302
Definition: client.h:1042
Definition: client.h:1310
A "factory" for KuduClient objects.
Definition: client.h:149
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:55
Select the LEADER replica.
Definition: client.h:350
RangePartitionBound
Range partition bound type.
Definition: client.h:514
FlushMode
Modes of flush operations.
Definition: client.h:1017
Definition: client.h:1022
A single row delete to be sent to the cluster.
Definition: write_op.h:202
A helper class to create a new table with the desired options.
Definition: client.h:433
Representation of a Kudu client session.
Definition: client.h:1012
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