25 #ifndef KUDU_CLIENT_CLIENT_H
26 #define KUDU_CLIENT_CLIENT_H
34 #include "kudu/client/row_result.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/util/kudu_export.h"
46 #include "kudu/util/slice.h"
51 class ClientStressTest_TestUniqueClientIds_Test;
54 class PartitionSchema;
55 class SecurityUnknownTskTest;
58 class LeaderMasterProxy;
66 class KuduLoggingCallback;
67 class KuduPartitioner;
70 class KuduStatusCallback;
72 class KuduTableAlterer;
73 class KuduTableCreator;
75 class KuduTabletServer;
79 class KuduWriteOperation;
80 class ResourceMetrics;
85 class GetTableSchemaRpc;
89 class RemoteTabletServer;
90 class ReplicaController;
106 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
114 void KUDU_EXPORT UninstallLoggingCallback();
131 void KUDU_EXPORT SetVerboseLogLevel(
int level);
142 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
155 Status KUDU_EXPORT DisableSaslInitialization();
180 Status KUDU_EXPORT DisableOpenSSLInitialization();
184 std::string KUDU_EXPORT GetShortVersionString();
188 std::string KUDU_EXPORT GetAllVersionInfo();
259 Status Build(sp::shared_ptr<KuduClient>* client);
262 class KUDU_NO_EXPORT Data;
264 friend class internal::ReplicaController;
298 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
316 Status IsCreateTableInProgress(
const std::string& table_name,
317 bool* create_in_progress);
324 Status DeleteTable(
const std::string& table_name);
342 Status IsAlterTableInProgress(
const std::string& table_name,
343 bool* alter_in_progress);
351 Status GetTableSchema(
const std::string& table_name,
360 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
369 Status ListTables(std::vector<std::string>* tables,
370 const std::string& filter =
"");
379 Status TableExists(
const std::string& table_name,
bool* exists);
397 Status OpenTable(
const std::string& table_name,
398 sp::shared_ptr<KuduTable>* table);
405 sp::shared_ptr<KuduSession> NewSession();
421 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
438 bool IsMultiMaster()
const;
441 const MonoDelta& default_admin_operation_timeout()
const;
444 const MonoDelta& default_rpc_timeout()
const;
489 uint64_t GetLatestObservedTimestamp()
const;
505 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
518 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
521 class KUDU_NO_EXPORT Data;
523 friend class internal::Batcher;
524 friend class internal::GetTableSchemaRpc;
525 friend class internal::LookupRpc;
526 friend class internal::MetaCache;
527 friend class internal::RemoteTablet;
528 friend class internal::RemoteTabletServer;
529 friend class internal::WriteRpc;
530 friend class ConnectToClusterBaseTest;
531 friend class ClientTest;
541 friend class ::kudu::SecurityUnknownTskTest;
542 friend class tools::LeaderMasterProxy;
544 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
545 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
546 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
547 FRIEND_TEST(ClientTest, TestMasterDown);
548 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
549 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
550 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
551 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
552 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
553 FRIEND_TEST(ClientTest, TestScanTimeout);
554 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
555 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
572 const std::string& uuid()
const;
576 const std::string& hostname()
const;
580 uint16_t port()
const;
583 class KUDU_NO_EXPORT Data;
594 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
606 bool is_leader()
const;
614 friend class internal::ReplicaController;
616 class KUDU_NO_EXPORT Data;
623 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
633 const std::string& id()
const;
640 const std::vector<const KuduReplica*>& replicas()
const;
646 class KUDU_NO_EXPORT Data;
653 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
702 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
703 int32_t num_buckets);
720 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
721 int32_t num_buckets, int32_t seed);
735 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
773 RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
774 RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
791 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
792 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
841 class KUDU_NO_EXPORT Data;
873 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
878 const std::string& name()
const;
887 const std::string& id()
const;
893 int num_replicas()
const;
966 std::vector<KuduValue*>* values);
997 const PartitionSchema& partition_schema()
const;
1000 class KUDU_NO_EXPORT Data;
1005 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1006 const std::string& name,
1007 const std::string&
id,
1010 const PartitionSchema& partition_schema);
1015 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1171 class KUDU_NO_EXPORT Data;
1175 const std::string& name);
1180 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1193 const Status& status()
const;
1217 bool was_possibly_successful()
const;
1220 class KUDU_NO_EXPORT Data;
1222 friend class internal::Batcher;
1223 friend class internal::ErrorCollector;
1231 DISALLOW_COPY_AND_ASSIGN(KuduError);
1293 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1356 Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1402 Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1422 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1447 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1471 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1497 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1504 void SetTimeoutMillis(
int millis);
1549 Status Flush() WARN_UNUSED_RESULT;
1595 Status Close() WARN_UNUSED_RESULT;
1605 bool HasPendingOperations() const;
1628 int CountBufferedOperations() const
1629 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1630 "in a future release");
1656 Status SetErrorBufferSpace(
size_t size_bytes);
1667 int CountPendingErrors() const;
1679 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1685 class KUDU_NO_EXPORT Data;
1688 friend class internal::Batcher;
1689 friend class ClientTest;
1690 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1691 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1693 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1774 enum { kScanTimeoutMillis = 30000 };
1781 explicit KuduScanner(KuduTable* table);
1793 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1805 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1813 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1815 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1825 Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1845 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1864 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1865 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1875 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1885 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1893 Status SetCacheBlocks(
bool cache_blocks);
1933 bool HasMoreRows()
const;
1946 Status NextBatch(std::vector<KuduRowResult>* rows)
1947 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
1957 Status NextBatch(KuduScanBatch* batch);
1967 Status GetCurrentServer(KuduTabletServer** server);
1970 const ResourceMetrics& GetResourceMetrics()
const;
1978 Status SetBatchSizeBytes(uint32_t batch_size);
1995 Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
2002 Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT
2003 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2017 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2024 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2038 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2045 Status SetTimeoutMillis(
int millis);
2048 KuduSchema GetProjectionSchema() const;
2057 static const uint64_t NO_FLAGS = 0;
2065 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2089 Status SetRowFormatFlags(uint64_t flags);
2097 std::
string ToString() const;
2100 class KUDU_NO_EXPORT Data;
2103 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2104 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2105 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2106 FRIEND_TEST(ClientTest, TestScanTimeout);
2107 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2108 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2109 FRIEND_TEST(ScanTokenTest, TestScanTokens);
2114 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2137 class KUDU_EXPORT KuduScanToken {
2152 Status IntoKuduScanner(KuduScanner** scanner)
const WARN_UNUSED_RESULT;
2164 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2177 static Status DeserializeIntoScanner(KuduClient* client,
2178 const std::string& serialized_token,
2179 KuduScanner** scanner) WARN_UNUSED_RESULT;
2182 class KUDU_NO_EXPORT Data;
2191 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2217 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2221 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2241 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2249 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2265 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2268 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2272 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2275 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2285 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2288 class KUDU_NO_EXPORT Data;
2327 class KUDU_NO_EXPORT Data;
2352 int NumPartitions()
const;
2367 class KUDU_NO_EXPORT Data;
A single row update to be sent to the cluster.
Definition: write_op.h:193
A representation of a table's schema.
Definition: schema.h:497
A representation of an operation's outcome.
Definition: status.h:145
A constant cell value with a specific type.
Definition: value.h:35
Builder for Partitioner instances.
Definition: client.h:2297
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1359
Definition: client.h:1378
A single row insert to be sent to the cluster.
Definition: write_op.h:141
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:272
static const uint64_t kNoTimestamp
Definition: client.h:448
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:427
A single row upsert to be sent to the cluster.
Definition: write_op.h:166
Builds scan tokens for a table.
Definition: client.h:2197
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1029
OrderMode
Definition: client.h:1756
Definition: client.h:1762
Smart pointer typedefs for externally-faced code.
Definition: client.h:2345
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:739
This class represents an error which occurred in a write operation.
Definition: client.h:1188
A handle for a connection to a cluster.
Definition: client.h:298
An inclusive bound.
Definition: client.h:740
In-memory representation of a remote tablet server.
Definition: client.h:566
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:47
A representation of a table on a particular cluster.
Definition: client.h:873
This class is a representation of a single scan.
Definition: client.h:1706
ReadMode
The read modes for scanners.
Definition: client.h:1709
Definition: client.h:1331
Definition: client.h:1717
A "factory" for KuduClient objects.
Definition: client.h:194
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:428
RangePartitionBound
Range partition bound type.
Definition: client.h:738
In-memory representation of a remote tablet.
Definition: client.h:627
In-memory representation of a remote tablet's replica.
Definition: client.h:598
Definition: client.h:1738
FlushMode
Modes of flush operations.
Definition: client.h:1298
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2137
Definition: client.h:1303
A single row delete to be sent to the cluster.
Definition: write_op.h:220
A helper class to create a new table with the desired options.
Definition: client.h:657
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:64
Representation of a Kudu client session.
Definition: client.h:1293
A representation of a time interval.
Definition: monotime.h:44