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" 52 class ClientStressTest_TestUniqueClientIds_Test;
53 class LinkedListTester;
54 class PartitionSchema;
58 class KuduLoggingCallback;
61 class KuduStatusCallback;
63 class KuduTableAlterer;
64 class KuduTableCreator;
66 class KuduTabletServer;
68 class KuduWriteOperation;
73 class GetTableSchemaRpc;
77 class RemoteTabletServer;
93 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
101 void KUDU_EXPORT UninstallLoggingCallback();
118 void KUDU_EXPORT SetVerboseLogLevel(
int level);
129 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
142 Status KUDU_EXPORT DisableSaslInitialization();
146 std::string KUDU_EXPORT GetShortVersionString();
150 std::string KUDU_EXPORT GetAllVersionInfo();
212 Status Build(sp::shared_ptr<KuduClient>* client);
215 class KUDU_NO_EXPORT Data;
249 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
267 Status IsCreateTableInProgress(
const std::string& table_name,
268 bool *create_in_progress);
275 Status DeleteTable(
const std::string& table_name);
293 Status IsAlterTableInProgress(
const std::string& table_name,
294 bool *alter_in_progress);
302 Status GetTableSchema(
const std::string& table_name,
311 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
320 Status ListTables(std::vector<std::string>* tables,
321 const std::string& filter =
"");
330 Status TableExists(
const std::string& table_name,
bool* exists);
345 Status OpenTable(
const std::string& table_name,
346 sp::shared_ptr<KuduTable>* table);
353 sp::shared_ptr<KuduSession> NewSession();
369 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
386 bool IsMultiMaster()
const;
389 const MonoDelta& default_admin_operation_timeout()
const;
392 const MonoDelta& default_rpc_timeout()
const;
437 uint64_t GetLatestObservedTimestamp()
const;
453 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
456 class KUDU_NO_EXPORT Data;
458 friend class internal::Batcher;
459 friend class internal::GetTableSchemaRpc;
460 friend class internal::LookupRpc;
461 friend class internal::MetaCache;
462 friend class internal::RemoteTablet;
463 friend class internal::RemoteTabletServer;
464 friend class internal::WriteRpc;
465 friend class ClientTest;
475 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
476 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
477 FRIEND_TEST(ClientTest, TestMasterDown);
478 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
479 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
480 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
481 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
482 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
483 FRIEND_TEST(ClientTest, TestScanTimeout);
484 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
485 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
502 const std::string& uuid()
const;
506 const std::string& hostname()
const;
510 uint16_t port()
const;
513 class KUDU_NO_EXPORT Data;
524 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
536 bool is_leader()
const;
545 class KUDU_NO_EXPORT Data;
552 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
562 const std::string& id()
const;
569 const std::vector<const KuduReplica*>& replicas()
const;
575 class KUDU_NO_EXPORT Data;
582 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
631 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
632 int32_t num_buckets);
649 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
650 int32_t num_buckets, int32_t seed);
664 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
720 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
721 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
770 class KUDU_NO_EXPORT Data;
802 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
807 const std::string& name()
const;
816 const std::string& id()
const;
822 int num_replicas()
const;
895 std::vector<KuduValue*>* values);
902 const PartitionSchema& partition_schema()
const;
905 class KUDU_NO_EXPORT Data;
909 KuduTable(
const sp::shared_ptr<KuduClient>& client,
910 const std::string& name,
911 const std::string&
id,
914 const PartitionSchema& partition_schema);
919 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1075 class KUDU_NO_EXPORT Data;
1079 const std::string& name);
1084 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1097 const Status& status()
const;
1121 bool was_possibly_successful()
const;
1124 class KUDU_NO_EXPORT Data;
1126 friend class internal::Batcher;
1127 friend class internal::ErrorCollector;
1135 DISALLOW_COPY_AND_ASSIGN(KuduError);
1197 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1326 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1351 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1375 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1401 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1408 void SetTimeoutMillis(
int millis);
1453 Status Flush() WARN_UNUSED_RESULT;
1499 Status Close() WARN_UNUSED_RESULT;
1509 bool HasPendingOperations() const;
1532 int CountBufferedOperations() const
1533 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1534 "in a future release");
1560 Status SetErrorBufferSpace(
size_t size_bytes);
1571 int CountPendingErrors() const;
1583 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1589 class KUDU_NO_EXPORT Data;
1592 friend class internal::Batcher;
1593 friend class ClientTest;
1594 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1595 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1597 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1666 enum { kScanTimeoutMillis = 30000 };
1685 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1697 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1705 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1707 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1737 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1756 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1757 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1767 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1777 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1785 Status SetCacheBlocks(
bool cache_blocks);
1825 bool HasMoreRows()
const;
1838 Status NextBatch(std::vector<KuduRowResult>* rows)
1839 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
1870 Status SetBatchSizeBytes(uint32_t batch_size);
1895 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
1909 Status SetFaultTolerant() WARN_UNUSED_RESULT;
1916 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
1930 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
1937 Status SetTimeoutMillis(
int millis);
1947 std::string ToString()
const;
1950 class KUDU_NO_EXPORT Data;
1953 FRIEND_TEST(ClientTest, TestScanCloseProxy);
1954 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
1955 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
1956 FRIEND_TEST(ClientTest, TestScanTimeout);
1957 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
1958 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
1963 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2013 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2027 const std::string& serialized_token,
2031 class KUDU_NO_EXPORT Data;
2040 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2066 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2070 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2090 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2098 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2114 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2117 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2121 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2124 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2134 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2137 class KUDU_NO_EXPORT Data;
A single row update to be sent to the cluster.
Definition: write_op.h:184
A representation of a table's schema.
Definition: schema.h:417
A representation of an operation's outcome.
Definition: status.h:116
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:1263
Definition: callbacks.h:28
Definition: client.h:1282
A single row insert to be sent to the cluster.
Definition: write_op.h:132
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:230
static const uint64_t kNoTimestamp
Definition: client.h:396
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:375
A single row upsert to be sent to the cluster.
Definition: write_op.h:157
Builds scan tokens for a table.
Definition: client.h:2046
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:39
Alters an existing table based on the provided steps.
Definition: client.h:933
OrderMode
Definition: client.h:1648
Definition: client.h:1654
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:668
This class represents an error which occurred in a write operation.
Definition: client.h:1092
A handle for a connection to a cluster.
Definition: client.h:249
An inclusive bound.
Definition: client.h:669
In-memory representation of a remote tablet server.
Definition: client.h:496
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:802
This class is a representation of a single scan.
Definition: client.h:1610
ReadMode
The read modes for scanners.
Definition: client.h:1613
Definition: client.h:1235
Definition: client.h:1621
A "factory" for KuduClient objects.
Definition: client.h:156
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:56
Select the LEADER replica.
Definition: client.h:376
RangePartitionBound
Range partition bound type.
Definition: client.h:667
In-memory representation of a remote tablet.
Definition: client.h:556
In-memory representation of a remote tablet's replica.
Definition: client.h:528
FlushMode
Modes of flush operations.
Definition: client.h:1202
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:1986
Definition: client.h:1207
A single row delete to be sent to the cluster.
Definition: write_op.h:211
A generic catalog of simple metrics.
Definition: resource_metrics.h:30
A helper class to create a new table with the desired options.
Definition: client.h:586
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:55
Representation of a Kudu client session.
Definition: client.h:1197
A batch of zero or more rows returned by a scan operation.
Definition: scan_batch.h:75
A representation of a time interval.
Definition: monotime.h:43