25 #ifndef KUDU_CLIENT_CLIENT_H
26 #define KUDU_CLIENT_CLIENT_H
35 #include "kudu/client/row_result.h"
36 #include "kudu/client/scan_predicate.h"
37 #include "kudu/client/schema.h"
39 #ifdef KUDU_HEADERS_NO_STUBS
40 #include <gtest/gtest_prod.h>
42 #include "kudu/gutil/macros.h"
43 #include "kudu/gutil/port.h"
45 #include "kudu/client/stubs.h"
47 #include "kudu/util/kudu_export.h"
48 #include "kudu/util/slice.h"
54 class ClientStressTest_TestUniqueClientIds_Test;
58 class PartitionSchema;
59 class SecurityUnknownTskTest;
67 class LeaderMasterProxy;
74 class KuduLoggingCallback;
75 class KuduPartitioner;
78 class KuduStatusCallback;
79 class KuduTableAlterer;
80 class KuduTableCreator;
82 class KuduTabletServer;
86 class KuduWriteOperation;
87 class ResourceMetrics;
90 template <
class ReqClass,
class RespClass>
94 class GetTableSchemaRpc;
98 class RemoteTabletServer;
99 class ReplicaController;
100 class RetrieveAuthzTokenRpc;
124 void KUDU_EXPORT UninstallLoggingCallback();
141 void KUDU_EXPORT SetVerboseLogLevel(
int level);
152 Status KUDU_EXPORT SetInternalSignalNumber(
int signum) WARN_UNUSED_RESULT;
165 Status KUDU_EXPORT DisableSaslInitialization() WARN_UNUSED_RESULT;
190 Status KUDU_EXPORT DisableOpenSSLInitialization() WARN_UNUSED_RESULT;
194 std::
string KUDU_EXPORT GetShortVersionString();
198 std::
string KUDU_EXPORT GetAllVersionInfo();
207 ~KuduClientBuilder();
212 KuduClientBuilder& clear_master_server_addrs();
219 KuduClientBuilder& master_server_addrs(
const std::vector<std::string>& addrs);
228 KuduClientBuilder& add_master_server_addr(
const std::string& addr);
239 KuduClientBuilder& default_admin_operation_timeout(
const MonoDelta& timeout);
248 KuduClientBuilder& default_rpc_timeout(
const MonoDelta& timeout);
257 KuduClientBuilder& import_authentication_credentials(std::string authn_creds);
268 KuduClientBuilder& num_reactors(
int num_reactors);
280 Status Build(sp::shared_ptr<KuduClient>* client);
283 class KUDU_NO_EXPORT Data;
285 friend class internal::ReplicaController;
290 DISALLOW_COPY_AND_ASSIGN(KuduClientBuilder);
319 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
337 Status IsCreateTableInProgress(
const std::string& table_name,
338 bool* create_in_progress);
345 Status DeleteTable(
const std::string& table_name);
359 Status DeleteTableInCatalogs(
const std::string& table_name,
360 bool modify_external_catalogs) KUDU_NO_EXPORT;
379 Status IsAlterTableInProgress(
const std::string& table_name,
380 bool* alter_in_progress);
388 Status GetTableSchema(
const std::string& table_name,
397 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
406 Status ListTables(std::vector<std::string>* tables,
407 const std::string& filter =
"");
416 Status TableExists(
const std::string& table_name,
bool* exists);
434 Status OpenTable(
const std::string& table_name,
435 sp::shared_ptr<KuduTable>* table);
442 sp::shared_ptr<KuduSession> NewSession();
458 Status GetTablet(
const std::string& tablet_id,
468 std::string GetMasterAddresses()
const KUDU_NO_EXPORT;
487 bool IsMultiMaster()
const;
490 const MonoDelta& default_admin_operation_timeout()
const;
493 const MonoDelta& default_rpc_timeout()
const;
509 uint64_t GetLatestObservedTimestamp()
const;
525 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
538 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
547 std::string GetHiveMetastoreUris() const KUDU_NO_EXPORT;
554 bool GetHiveMetastoreSaslEnabled() const KUDU_NO_EXPORT;
565 std::
string GetHiveMetastoreUuid() const KUDU_NO_EXPORT;
573 std::
string location() const KUDU_NO_EXPORT;
577 class KUDU_NO_EXPORT Data;
579 template <class ReqClass, class RespClass>
580 friend class internal::AsyncLeaderMasterRpc;
582 friend class ClientTest;
583 friend class ConnectToClusterBaseTest;
593 friend class internal::Batcher;
594 friend class internal::GetTableSchemaRpc;
595 friend class internal::LookupRpc;
596 friend class internal::MetaCache;
597 friend class internal::RemoteTablet;
598 friend class internal::RemoteTabletServer;
599 friend class internal::RetrieveAuthzTokenRpc;
600 friend class internal::WriteRpc;
601 friend class kudu::AuthzTokenTest;
602 friend class kudu::SecurityUnknownTskTest;
603 friend class tools::LeaderMasterProxy;
605 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
606 FRIEND_TEST(ClientTest, TestCacheAuthzTokens);
607 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
608 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
609 FRIEND_TEST(ClientTest, TestMasterDown);
610 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
611 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
612 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
613 FRIEND_TEST(ClientTest, TestRetrieveAuthzTokenInParallel);
614 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
615 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
616 FRIEND_TEST(ClientTest, TestScanTimeout);
617 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
618 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
635 const std::string& uuid()
const;
639 const std::string& hostname()
const;
643 uint16_t port()
const;
651 const std::string& location()
const KUDU_NO_EXPORT;
655 class KUDU_NO_EXPORT Data;
657 friend class KuduClient;
658 friend class KuduScanner;
659 friend class KuduScanTokenBuilder;
666 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
678 bool is_leader()
const;
686 friend class internal::ReplicaController;
688 class KUDU_NO_EXPORT Data;
695 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
705 const std::string& id()
const;
712 const std::vector<const KuduReplica*>& replicas()
const;
718 class KUDU_NO_EXPORT Data;
725 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
774 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
775 int32_t num_buckets);
792 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
793 int32_t num_buckets, int32_t seed);
807 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
845 RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
846 RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
863 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
864 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
884 KuduTableCreator& extra_configs(
const std::map<std::string, std::string>& extra_configs);
922 class KUDU_NO_EXPORT Data;
954 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
959 const std::string& name()
const;
968 const std::string& id()
const;
974 int num_replicas()
const;
1047 std::vector<KuduValue*>* values);
1078 const PartitionSchema& partition_schema()
const;
1081 const std::map<std::string, std::string>& extra_configs()
const;
1094 Status ListPartitions(std::vector<Partition>* partitions) KUDU_NO_EXPORT;
1099 class KUDU_NO_EXPORT Data;
1104 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1105 const std::string& name,
1106 const std::string&
id,
1109 const PartitionSchema& partition_schema,
1110 const std::map<std::string, std::string>& extra_configs);
1115 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1249 KuduTableAlterer* AlterExtraConfig(
const std::map<std::string, std::string>& extra_configs);
1285 KuduTableAlterer* modify_external_catalogs(
bool modify_external_catalogs) KUDU_NO_EXPORT;
1296 class KUDU_NO_EXPORT Data;
1301 const std::string& name);
1306 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1319 const Status& status()
const;
1343 bool was_possibly_successful()
const;
1346 class KUDU_NO_EXPORT Data;
1348 friend class internal::Batcher;
1349 friend class internal::ErrorCollector;
1357 DISALLOW_COPY_AND_ASSIGN(KuduError);
1419 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1482 Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1528 Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1548 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1573 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1597 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1623 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1630 void SetTimeoutMillis(
int millis);
1675 Status Flush() WARN_UNUSED_RESULT;
1721 Status Close() WARN_UNUSED_RESULT;
1731 bool HasPendingOperations() const;
1754 int CountBufferedOperations() const
1755 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1756 "in a future release");
1782 Status SetErrorBufferSpace(
size_t size_bytes);
1793 int CountPendingErrors() const;
1805 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1811 class KUDU_NO_EXPORT Data;
1814 friend class internal::Batcher;
1815 friend class ClientTest;
1816 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1817 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1819 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1900 enum { kScanTimeoutMillis = 30000 };
1907 explicit KuduScanner(KuduTable* table);
1919 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1931 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1939 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1941 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1951 Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1971 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1990 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1991 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
2001 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
2011 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
2019 Status SetCacheBlocks(
bool cache_blocks);
2062 bool HasMoreRows()
const;
2075 Status NextBatch(std::vector<KuduRowResult>* rows)
2076 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
2086 Status NextBatch(KuduScanBatch* batch);
2096 Status GetCurrentServer(KuduTabletServer** server);
2099 const ResourceMetrics& GetResourceMetrics()
const;
2107 Status SetBatchSizeBytes(uint32_t batch_size);
2124 Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
2131 Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT
2132 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2146 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2153 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2164 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2182 Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2183 WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2192 Status SetTimeoutMillis(
int millis);
2195 KuduSchema GetProjectionSchema() const;
2204 static const uint64_t NO_FLAGS = 0;
2212 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2241 Status SetRowFormatFlags(uint64_t flags);
2249 Status SetLimit(int64_t limit) WARN_UNUSED_RESULT;
2256 std::
string ToString() const;
2259 class KUDU_NO_EXPORT Data;
2262 FRIEND_TEST(ClientTest, TestBlockScannerHijackingAttempts);
2263 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2264 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2265 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2266 FRIEND_TEST(ClientTest, TestScanTimeout);
2267 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2268 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2269 FRIEND_TEST(ScanTokenTest, TestScanTokens);
2274 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2297 class KUDU_EXPORT KuduScanToken {
2312 Status IntoKuduScanner(KuduScanner** scanner)
const WARN_UNUSED_RESULT;
2324 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2337 static Status DeserializeIntoScanner(KuduClient* client,
2338 const std::string& serialized_token,
2339 KuduScanner** scanner) WARN_UNUSED_RESULT;
2342 class KUDU_NO_EXPORT Data;
2351 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2377 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2381 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2401 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2409 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2425 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2428 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2432 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2435 Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2436 WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2439 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2449 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2452 class KUDU_NO_EXPORT Data;
2497 class KUDU_NO_EXPORT Data;
2522 int NumPartitions()
const;
2537 class KUDU_NO_EXPORT Data;
The interface for all logging callbacks.
Definition: callbacks.h:44
A single row update to be sent to the cluster.
Definition: write_op.h:194
A representation of a table's schema.
Definition: schema.h:531
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:2461
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1485
Definition: client.h:1504
A single row insert to be sent to the cluster.
Definition: write_op.h:142
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:295
static const uint64_t kNoTimestamp
Definition: client.h:497
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:473
A single row upsert to be sent to the cluster.
Definition: write_op.h:167
Builds scan tokens for a table.
Definition: client.h:2357
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1129
OrderMode
Definition: client.h:1882
Definition: client.h:1888
Smart pointer typedefs for externally-faced code.
Definition: client.h:2515
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:811
This class represents an error which occurred in a write operation.
Definition: client.h:1314
A handle for a connection to a cluster.
Definition: client.h:319
An inclusive bound.
Definition: client.h:812
In-memory representation of a remote tablet server.
Definition: client.h:629
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:50
A representation of a table on a particular cluster.
Definition: client.h:954
This class is a representation of a single scan.
Definition: client.h:1832
ReadMode
The read modes for scanners.
Definition: client.h:1835
Definition: client.h:1457
Definition: client.h:1843
A "factory" for KuduClient objects.
Definition: client.h:204
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:474
RangePartitionBound
Range partition bound type.
Definition: client.h:810
In-memory representation of a remote tablet.
Definition: client.h:699
In-memory representation of a remote tablet's replica.
Definition: client.h:670
Definition: client.h:1864
FlushMode
Modes of flush operations.
Definition: client.h:1424
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2297
Definition: client.h:1429
A single row delete to be sent to the cluster.
Definition: write_op.h:221
A helper class to create a new table with the desired options.
Definition: client.h:729
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:68
Representation of a Kudu client session.
Definition: client.h:1419
A representation of a time interval.
Definition: monotime.h:44