25 #ifndef KUDU_CLIENT_CLIENT_H 26 #define KUDU_CLIENT_CLIENT_H 38 #include "kudu/client/row_result.h" 39 #include "kudu/client/scan_predicate.h" 40 #include "kudu/client/schema.h" 42 #ifdef KUDU_HEADERS_NO_STUBS 43 #include <gtest/gtest_prod.h> 45 #include "kudu/gutil/macros.h" 46 #include "kudu/gutil/port.h" 48 #include "kudu/client/stubs.h" 50 #include "kudu/util/kudu_export.h" 51 #include "kudu/util/slice.h" 57 class ClientStressTest_TestUniqueClientIds_Test;
61 class PartitionSchema;
62 class SecurityUnknownTskTest;
70 class LeaderMasterProxy;
71 class RemoteKsckCluster;
76 class KuduColumnarScanBatch;
79 class KuduInsertIgnore;
80 class KuduLoggingCallback;
81 class KuduPartitioner;
84 class KuduStatusCallback;
85 class KuduTableAlterer;
86 class KuduTableCreator;
87 class KuduTableStatistics;
89 class KuduTabletServer;
93 class KuduWriteOperation;
94 class ResourceMetrics;
99 class GetTableSchemaRpc;
103 class RemoteTabletServer;
104 class ReplicaController;
105 class RetrieveAuthzTokenRpc;
106 class ScanBatchDataInterface;
108 template <
class ReqClass,
class RespClass>
132 void KUDU_EXPORT UninstallLoggingCallback();
149 void KUDU_EXPORT SetVerboseLogLevel(
int level);
160 Status KUDU_EXPORT SetInternalSignalNumber(
int signum) WARN_UNUSED_RESULT;
173 Status KUDU_EXPORT DisableSaslInitialization() WARN_UNUSED_RESULT;
198 Status KUDU_EXPORT DisableOpenSSLInitialization() WARN_UNUSED_RESULT;
202 std::
string KUDU_EXPORT GetShortVersionString();
206 std::
string KUDU_EXPORT GetAllVersionInfo();
215 ~KuduClientBuilder();
220 KuduClientBuilder& clear_master_server_addrs();
227 KuduClientBuilder& master_server_addrs(
const std::vector<std::string>& addrs);
236 KuduClientBuilder& add_master_server_addr(
const std::string& addr);
247 KuduClientBuilder& default_admin_operation_timeout(
const MonoDelta& timeout);
256 KuduClientBuilder& default_rpc_timeout(
const MonoDelta& timeout);
265 KuduClientBuilder& import_authentication_credentials(std::string authn_creds);
276 KuduClientBuilder& num_reactors(
int num_reactors);
288 Status Build(sp::shared_ptr<KuduClient>* client);
291 class KUDU_NO_EXPORT Data;
293 friend class internal::ReplicaController;
298 DISALLOW_COPY_AND_ASSIGN(KuduClientBuilder);
327 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
345 Status IsCreateTableInProgress(
const std::string& table_name,
346 bool* create_in_progress);
353 Status DeleteTable(
const std::string& table_name);
367 Status DeleteTableInCatalogs(
const std::string& table_name,
368 bool modify_external_catalogs) KUDU_NO_EXPORT;
387 Status IsAlterTableInProgress(
const std::string& table_name,
388 bool* alter_in_progress);
396 Status GetTableSchema(
const std::string& table_name,
405 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
414 Status ListTables(std::vector<std::string>* tables,
415 const std::string& filter =
"");
424 Status TableExists(
const std::string& table_name,
bool* exists);
442 Status OpenTable(
const std::string& table_name,
443 sp::shared_ptr<KuduTable>* table);
450 sp::shared_ptr<KuduSession> NewSession();
466 Status GetTablet(
const std::string& tablet_id,
476 Status GetTableStatistics(
const std::string& table_name,
486 std::string GetMasterAddresses()
const KUDU_NO_EXPORT;
505 bool IsMultiMaster()
const;
508 const MonoDelta& default_admin_operation_timeout()
const;
511 const MonoDelta& default_rpc_timeout()
const;
527 uint64_t GetLatestObservedTimestamp()
const;
543 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
556 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
565 std::string GetHiveMetastoreUris() const KUDU_NO_EXPORT;
572 bool GetHiveMetastoreSaslEnabled() const KUDU_NO_EXPORT;
583 std::
string GetHiveMetastoreUuid() const KUDU_NO_EXPORT;
591 std::
string location() const KUDU_NO_EXPORT;
595 class KUDU_NO_EXPORT Data;
597 template <class ReqClass, class RespClass>
598 friend class internal::AsyncLeaderMasterRpc;
600 friend class ClientTest;
601 friend class ConnectToClusterBaseTest;
611 friend class internal::Batcher;
612 friend class internal::GetTableSchemaRpc;
613 friend class internal::LookupRpc;
614 friend class internal::MetaCache;
615 friend class internal::RemoteTablet;
616 friend class internal::RemoteTabletServer;
617 friend class internal::RetrieveAuthzTokenRpc;
618 friend class internal::WriteRpc;
619 friend class
kudu::AuthzTokenTest;
620 friend class
kudu::SecurityUnknownTskTest;
621 friend class tools::LeaderMasterProxy;
622 friend class tools::RemoteKsckCluster;
624 FRIEND_TEST(
kudu::ClientStressTest, TestUniqueClientIds);
625 FRIEND_TEST(ClientTest, TestCacheAuthzTokens);
626 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
627 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
628 FRIEND_TEST(ClientTest, TestMasterDown);
629 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
630 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
631 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
632 FRIEND_TEST(ClientTest, TestRetrieveAuthzTokenInParallel);
633 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
634 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
635 FRIEND_TEST(ClientTest, TestScanTimeout);
636 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
637 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
654 const std::string& uuid()
const;
658 const std::string& hostname()
const;
662 uint16_t port()
const;
670 const std::string& location()
const KUDU_NO_EXPORT;
674 class KUDU_NO_EXPORT Data;
676 friend class KuduClient;
677 friend class KuduScanner;
678 friend class KuduScanTokenBuilder;
685 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
697 bool is_leader()
const;
705 friend class internal::ReplicaController;
707 class KUDU_NO_EXPORT Data;
714 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
724 const std::string& id()
const;
731 const std::vector<const KuduReplica*>& replicas()
const;
737 class KUDU_NO_EXPORT Data;
744 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
793 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
794 int32_t num_buckets);
811 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
812 int32_t num_buckets, int32_t seed);
826 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
882 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
883 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
916 KuduTableCreator& extra_configs(
const std::map<std::string, std::string>& extra_configs);
954 class KUDU_NO_EXPORT Data;
976 int64_t on_disk_size()
const;
982 int64_t live_row_count()
const;
987 std::string ToString()
const;
990 class KUDU_NO_EXPORT Data;
1020 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
1025 const std::string& name()
const;
1034 const std::string& id()
const;
1040 int num_replicas()
const;
1121 std::vector<KuduBloomFilter*>* bloom_filters);
1158 const Slice& allocator,
1159 const std::vector<Slice>& bloom_filters);
1186 std::vector<KuduValue*>* values);
1217 const PartitionSchema& partition_schema()
const;
1220 const std::map<std::string, std::string>& extra_configs()
const;
1233 Status ListPartitions(std::vector<Partition>* partitions) KUDU_NO_EXPORT;
1238 class KUDU_NO_EXPORT Data;
1243 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1244 const std::string& name,
1245 const std::string&
id,
1248 const PartitionSchema& partition_schema,
1249 const std::map<std::string, std::string>& extra_configs);
1254 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1383 const std::string& dimension_label,
1429 KuduTableAlterer* AlterExtraConfig(
const std::map<std::string, std::string>& extra_configs);
1465 KuduTableAlterer* modify_external_catalogs(
bool modify_external_catalogs) KUDU_NO_EXPORT;
1476 class KUDU_NO_EXPORT Data;
1481 const std::string& name);
1486 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1499 const Status& status()
const;
1523 bool was_possibly_successful()
const;
1526 class KUDU_NO_EXPORT Data;
1528 friend class internal::Batcher;
1529 friend class internal::ErrorCollector;
1537 DISALLOW_COPY_AND_ASSIGN(KuduError);
1599 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1728 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1753 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1777 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1803 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1810 void SetTimeoutMillis(
int millis);
1855 Status Flush() WARN_UNUSED_RESULT;
1901 Status Close() WARN_UNUSED_RESULT;
1911 bool HasPendingOperations() const;
1934 int CountBufferedOperations() const
1935 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1936 "in a future release");
1962 Status SetErrorBufferSpace(
size_t size_bytes);
1973 int CountPendingErrors() const;
1985 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1991 class KUDU_NO_EXPORT Data;
1994 friend class internal::Batcher;
1995 friend class ClientTest;
1996 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1997 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1999 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
2080 enum { kScanTimeoutMillis = 30000 };
2099 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2111 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2119 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
2121 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
2151 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
2170 Status AddExclusiveUpperBoundRaw(
const Slice& key)
2171 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
2181 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
2191 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
2199 Status SetCacheBlocks(
bool cache_blocks);
2242 bool HasMoreRows()
const;
2255 Status NextBatch(std::vector<KuduRowResult>* rows)
2256 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
2303 Status SetBatchSizeBytes(uint32_t batch_size);
2328 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2342 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2349 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2360 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2378 Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2379 WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2388 Status SetTimeoutMillis(
int millis);
2400 static const uint64_t NO_FLAGS = 0;
2408 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2417 static const uint64_t COLUMNAR_LAYOUT = 1 << 1;
2446 Status SetRowFormatFlags(uint64_t flags);
2454 Status SetLimit(int64_t limit) WARN_UNUSED_RESULT;
2461 std::string ToString()
const;
2464 class KUDU_NO_EXPORT Data;
2466 Status NextBatch(internal::ScanBatchDataInterface* batch);
2469 FRIEND_TEST(ClientTest, TestBlockScannerHijackingAttempts);
2470 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2471 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2472 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2473 FRIEND_TEST(ClientTest, TestScanTimeout);
2474 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2475 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2476 FRIEND_TEST(ScanTokenTest, TestScanTokens);
2481 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2531 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2545 const std::string& serialized_token,
2549 class KUDU_NO_EXPORT Data;
2558 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2584 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2588 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2608 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2616 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2632 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2635 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2639 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2644 Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2645 WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2649 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2659 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2662 class KUDU_NO_EXPORT Data;
2707 class KUDU_NO_EXPORT Data;
2732 int NumPartitions()
const;
2747 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:224
A representation of a table's schema.
Definition: schema.h:594
A single row insert ignore to be sent to the cluster, duplicate row errors are ignored.
Definition: write_op.h:171
A representation of an operation's outcome.
Definition: status.h:165
A constant cell value with a specific type.
Definition: value.h:35
Builder for Partitioner instances.
Definition: client.h:2671
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1665
Definition: callbacks.h:28
Definition: client.h:1684
A batch of columnar data returned from a scanner.
Definition: columnar_scan_batch.h:51
A single row insert to be sent to the cluster.
Definition: write_op.h:144
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:338
static const uint64_t kNoTimestamp
Definition: client.h:515
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:491
A single row upsert to be sent to the cluster.
Definition: write_op.h:197
Builds scan tokens for a table.
Definition: client.h:2564
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:46
Alters an existing table based on the provided steps.
Definition: client.h:1268
OrderMode
Definition: client.h:2062
Definition: client.h:2068
Smart pointer typedefs for externally-faced code.
Definition: client.h:2725
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:43
An exclusive bound.
Definition: client.h:830
This class represents an error which occurred in a write operation.
Definition: client.h:1494
A handle for a connection to a cluster.
Definition: client.h:327
An inclusive bound.
Definition: client.h:831
In-memory representation of a remote tablet server.
Definition: client.h:648
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:51
A representation of a table on a particular cluster.
Definition: client.h:1020
This class is a representation of a single scan.
Definition: client.h:2012
ReadMode
The read modes for scanners.
Definition: client.h:2015
Definition: client.h:1637
Definition: client.h:2023
A "factory" for KuduClient objects.
Definition: client.h:212
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:66
Select the LEADER replica.
Definition: client.h:492
RangePartitionBound
Range partition bound type.
Definition: client.h:829
In-memory statistics of table.
Definition: client.h:967
In-memory representation of a remote tablet.
Definition: client.h:718
In-memory representation of a remote tablet's replica.
Definition: client.h:689
Definition: client.h:2044
FlushMode
Modes of flush operations.
Definition: client.h:1604
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2504
Definition: client.h:1609
A single row delete to be sent to the cluster.
Definition: write_op.h:251
A generic catalog of simple metrics.
Definition: resource_metrics.h:39
A helper class to create a new table with the desired options.
Definition: client.h:748
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:72
Representation of a Kudu client session.
Definition: client.h:1599
A batch of zero or more rows returned by a scan operation.
Definition: scan_batch.h:84
A representation of a time interval.
Definition: monotime.h:57