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> 41 #include "kudu/gutil/macros.h" 42 #include "kudu/gutil/port.h" 44 #include "kudu/client/stubs.h" 46 #include "kudu/util/kudu_export.h" 47 #include "kudu/util/slice.h" 52 class ClientStressTest_TestUniqueClientIds_Test;
56 class PartitionSchema;
57 class SecurityUnknownTskTest;
65 class LeaderMasterProxy;
72 class KuduLoggingCallback;
73 class KuduPartitioner;
76 class KuduStatusCallback;
77 class KuduTableAlterer;
78 class KuduTableCreator;
80 class KuduTabletServer;
84 class KuduWriteOperation;
85 class ResourceMetrics;
88 template <
class ReqClass,
class RespClass>
92 class GetTableSchemaRpc;
96 class RemoteTabletServer;
97 class ReplicaController;
121 void KUDU_EXPORT UninstallLoggingCallback();
138 void KUDU_EXPORT SetVerboseLogLevel(
int level);
149 Status KUDU_EXPORT SetInternalSignalNumber(
int signum) WARN_UNUSED_RESULT;
162 Status KUDU_EXPORT DisableSaslInitialization() WARN_UNUSED_RESULT;
187 Status KUDU_EXPORT DisableOpenSSLInitialization() WARN_UNUSED_RESULT;
191 std::
string KUDU_EXPORT GetShortVersionString();
195 std::
string KUDU_EXPORT GetAllVersionInfo();
204 ~KuduClientBuilder();
209 KuduClientBuilder& clear_master_server_addrs();
216 KuduClientBuilder& master_server_addrs(
const std::vector<std::string>& addrs);
225 KuduClientBuilder& add_master_server_addr(
const std::string& addr);
236 KuduClientBuilder& default_admin_operation_timeout(
const MonoDelta& timeout);
245 KuduClientBuilder& default_rpc_timeout(
const MonoDelta& timeout);
254 KuduClientBuilder& import_authentication_credentials(std::string authn_creds);
265 KuduClientBuilder& num_reactors(
int num_reactors);
277 Status Build(sp::shared_ptr<KuduClient>* client);
280 class KUDU_NO_EXPORT Data;
282 friend class internal::ReplicaController;
287 DISALLOW_COPY_AND_ASSIGN(KuduClientBuilder);
316 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
334 Status IsCreateTableInProgress(
const std::string& table_name,
335 bool* create_in_progress);
342 Status DeleteTable(
const std::string& table_name);
356 Status DeleteTableInCatalogs(
const std::string& table_name,
357 bool modify_external_catalogs) KUDU_NO_EXPORT;
376 Status IsAlterTableInProgress(
const std::string& table_name,
377 bool* alter_in_progress);
385 Status GetTableSchema(
const std::string& table_name,
394 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
403 Status ListTables(std::vector<std::string>* tables,
404 const std::string& filter =
"");
413 Status TableExists(
const std::string& table_name,
bool* exists);
431 Status OpenTable(
const std::string& table_name,
432 sp::shared_ptr<KuduTable>* table);
439 sp::shared_ptr<KuduSession> NewSession();
455 Status GetTablet(
const std::string& tablet_id,
465 std::string GetMasterAddresses()
const KUDU_NO_EXPORT;
484 bool IsMultiMaster()
const;
487 const MonoDelta& default_admin_operation_timeout()
const;
490 const MonoDelta& default_rpc_timeout()
const;
535 uint64_t GetLatestObservedTimestamp()
const;
551 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
564 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
573 std::string GetHiveMetastoreUris() const KUDU_NO_EXPORT;
580 bool GetHiveMetastoreSaslEnabled() const KUDU_NO_EXPORT;
591 std::
string GetHiveMetastoreUuid() const KUDU_NO_EXPORT;
599 std::
string location() const KUDU_NO_EXPORT;
603 class KUDU_NO_EXPORT Data;
605 template <class ReqClass, class RespClass>
606 friend class internal::AsyncLeaderMasterRpc;
608 friend class ClientTest;
609 friend class ConnectToClusterBaseTest;
619 friend class internal::Batcher;
620 friend class internal::GetTableSchemaRpc;
621 friend class internal::LookupRpc;
622 friend class internal::MetaCache;
623 friend class internal::RemoteTablet;
624 friend class internal::RemoteTabletServer;
625 friend class internal::WriteRpc;
626 friend class
kudu::SecurityUnknownTskTest;
627 friend class tools::LeaderMasterProxy;
629 FRIEND_TEST(
kudu::ClientStressTest, TestUniqueClientIds);
630 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
631 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
632 FRIEND_TEST(ClientTest, TestMasterDown);
633 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
634 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
635 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
636 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
637 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
638 FRIEND_TEST(ClientTest, TestScanTimeout);
639 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
640 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
657 const std::string& uuid()
const;
661 const std::string& hostname()
const;
665 uint16_t port()
const;
673 const std::string& location()
const KUDU_NO_EXPORT;
677 class KUDU_NO_EXPORT Data;
679 friend class KuduClient;
680 friend class KuduScanner;
681 friend class KuduScanTokenBuilder;
688 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
700 bool is_leader()
const;
708 friend class internal::ReplicaController;
710 class KUDU_NO_EXPORT Data;
717 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
727 const std::string& id()
const;
734 const std::vector<const KuduReplica*>& replicas()
const;
740 class KUDU_NO_EXPORT Data;
747 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
796 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
797 int32_t num_buckets);
814 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
815 int32_t num_buckets, int32_t seed);
829 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
885 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
886 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
935 class KUDU_NO_EXPORT Data;
967 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
972 const std::string& name()
const;
981 const std::string& id()
const;
987 int num_replicas()
const;
1060 std::vector<KuduValue*>* values);
1091 const PartitionSchema& partition_schema()
const;
1104 Status ListPartitions(std::vector<Partition>* partitions) KUDU_NO_EXPORT;
1109 class KUDU_NO_EXPORT Data;
1114 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1115 const std::string& name,
1116 const std::string&
id,
1119 const PartitionSchema& partition_schema);
1124 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1283 KuduTableAlterer* modify_external_catalogs(
bool modify_external_catalogs) KUDU_NO_EXPORT;
1294 class KUDU_NO_EXPORT Data;
1299 const std::string& name);
1304 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1317 const Status& status()
const;
1341 bool was_possibly_successful()
const;
1344 class KUDU_NO_EXPORT Data;
1346 friend class internal::Batcher;
1347 friend class internal::ErrorCollector;
1355 DISALLOW_COPY_AND_ASSIGN(KuduError);
1417 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1546 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1571 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1595 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1621 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1628 void SetTimeoutMillis(
int millis);
1673 Status Flush() WARN_UNUSED_RESULT;
1719 Status Close() WARN_UNUSED_RESULT;
1729 bool HasPendingOperations() const;
1752 int CountBufferedOperations() const
1753 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1754 "in a future release");
1780 Status SetErrorBufferSpace(
size_t size_bytes);
1791 int CountPendingErrors() const;
1803 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1809 class KUDU_NO_EXPORT Data;
1812 friend class internal::Batcher;
1813 friend class ClientTest;
1814 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1815 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1817 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1898 enum { kScanTimeoutMillis = 30000 };
1917 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1929 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1937 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1939 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1969 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1988 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1989 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1999 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
2009 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
2017 Status SetCacheBlocks(
bool cache_blocks);
2060 bool HasMoreRows()
const;
2073 Status NextBatch(std::vector<KuduRowResult>* rows)
2074 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
2105 Status SetBatchSizeBytes(uint32_t batch_size);
2130 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2144 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2151 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2165 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2172 Status SetTimeoutMillis(
int millis);
2184 static const uint64_t NO_FLAGS = 0;
2192 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2221 Status SetRowFormatFlags(uint64_t flags);
2229 Status SetLimit(int64_t limit) WARN_UNUSED_RESULT;
2236 std::string ToString()
const;
2239 class KUDU_NO_EXPORT Data;
2242 FRIEND_TEST(ClientTest, TestBlockScannerHijackingAttempts);
2243 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2244 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2245 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2246 FRIEND_TEST(ClientTest, TestScanTimeout);
2247 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2248 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2249 FRIEND_TEST(ScanTokenTest, TestScanTokens);
2254 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2304 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2318 const std::string& serialized_token,
2322 class KUDU_NO_EXPORT Data;
2331 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2357 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2361 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2381 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2389 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2405 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2408 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2412 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2415 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2425 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2428 class KUDU_NO_EXPORT Data;
2473 class KUDU_NO_EXPORT Data;
2498 int NumPartitions()
const;
2513 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:193
A representation of a table's schema.
Definition: schema.h:512
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:2437
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1483
Definition: callbacks.h:28
Definition: client.h:1502
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:283
static const uint64_t kNoTimestamp
Definition: client.h:494
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:470
A single row upsert to be sent to the cluster.
Definition: write_op.h:166
Builds scan tokens for a table.
Definition: client.h:2337
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1138
OrderMode
Definition: client.h:1880
Definition: client.h:1886
Smart pointer typedefs for externally-faced code.
Definition: client.h:2491
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:833
This class represents an error which occurred in a write operation.
Definition: client.h:1312
A handle for a connection to a cluster.
Definition: client.h:316
An inclusive bound.
Definition: client.h:834
In-memory representation of a remote tablet server.
Definition: client.h:651
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:967
This class is a representation of a single scan.
Definition: client.h:1830
ReadMode
The read modes for scanners.
Definition: client.h:1833
Definition: client.h:1455
Definition: client.h:1841
A "factory" for KuduClient objects.
Definition: client.h:201
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:471
RangePartitionBound
Range partition bound type.
Definition: client.h:832
In-memory representation of a remote tablet.
Definition: client.h:721
In-memory representation of a remote tablet's replica.
Definition: client.h:692
Definition: client.h:1862
FlushMode
Modes of flush operations.
Definition: client.h:1422
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2277
Definition: client.h:1427
A single row delete to be sent to the cluster.
Definition: write_op.h:220
A generic catalog of simple metrics.
Definition: resource_metrics.h:33
A helper class to create a new table with the desired options.
Definition: client.h:751
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:1417
A batch of zero or more rows returned by a scan operation.
Definition: scan_batch.h:83
A representation of a time interval.
Definition: monotime.h:44