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;
105 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
113 void KUDU_EXPORT UninstallLoggingCallback();
130 void KUDU_EXPORT SetVerboseLogLevel(
int level);
141 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
154 Status KUDU_EXPORT DisableSaslInitialization();
179 Status KUDU_EXPORT DisableOpenSSLInitialization();
183 std::string KUDU_EXPORT GetShortVersionString();
187 std::string KUDU_EXPORT GetAllVersionInfo();
258 Status Build(sp::shared_ptr<KuduClient>* client);
261 class KUDU_NO_EXPORT Data;
295 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
313 Status IsCreateTableInProgress(
const std::string& table_name,
314 bool *create_in_progress);
321 Status DeleteTable(
const std::string& table_name);
339 Status IsAlterTableInProgress(
const std::string& table_name,
340 bool *alter_in_progress);
348 Status GetTableSchema(
const std::string& table_name,
357 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
366 Status ListTables(std::vector<std::string>* tables,
367 const std::string& filter =
"");
376 Status TableExists(
const std::string& table_name,
bool* exists);
394 Status OpenTable(
const std::string& table_name,
395 sp::shared_ptr<KuduTable>* table);
402 sp::shared_ptr<KuduSession> NewSession();
418 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
435 bool IsMultiMaster()
const;
438 const MonoDelta& default_admin_operation_timeout()
const;
441 const MonoDelta& default_rpc_timeout()
const;
486 uint64_t GetLatestObservedTimestamp()
const;
502 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
515 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
518 class KUDU_NO_EXPORT Data;
520 friend class internal::Batcher;
521 friend class internal::GetTableSchemaRpc;
522 friend class internal::LookupRpc;
523 friend class internal::MetaCache;
524 friend class internal::RemoteTablet;
525 friend class internal::RemoteTabletServer;
526 friend class internal::WriteRpc;
527 friend class ClientTest;
537 friend class ::kudu::SecurityUnknownTskTest;
538 friend class tools::LeaderMasterProxy;
540 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
541 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
542 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
543 FRIEND_TEST(ClientTest, TestMasterDown);
544 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
545 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
546 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
547 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
548 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
549 FRIEND_TEST(ClientTest, TestScanTimeout);
550 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
551 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
568 const std::string& uuid()
const;
572 const std::string& hostname()
const;
576 uint16_t port()
const;
579 class KUDU_NO_EXPORT Data;
590 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
602 bool is_leader()
const;
611 class KUDU_NO_EXPORT Data;
618 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
628 const std::string& id()
const;
635 const std::vector<const KuduReplica*>& replicas()
const;
641 class KUDU_NO_EXPORT Data;
648 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
697 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
698 int32_t num_buckets);
715 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
716 int32_t num_buckets, int32_t seed);
730 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
768 RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
769 RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
786 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
787 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
836 class KUDU_NO_EXPORT Data;
868 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
873 const std::string& name()
const;
882 const std::string& id()
const;
888 int num_replicas()
const;
961 std::vector<KuduValue*>* values);
992 const PartitionSchema& partition_schema()
const;
995 class KUDU_NO_EXPORT Data;
1000 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1001 const std::string& name,
1002 const std::string&
id,
1005 const PartitionSchema& partition_schema);
1010 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1166 class KUDU_NO_EXPORT Data;
1170 const std::string& name);
1175 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1188 const Status& status()
const;
1212 bool was_possibly_successful()
const;
1215 class KUDU_NO_EXPORT Data;
1217 friend class internal::Batcher;
1218 friend class internal::ErrorCollector;
1226 DISALLOW_COPY_AND_ASSIGN(KuduError);
1288 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1351 Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1397 Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1417 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1442 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1466 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1492 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1499 void SetTimeoutMillis(
int millis);
1544 Status Flush() WARN_UNUSED_RESULT;
1590 Status Close() WARN_UNUSED_RESULT;
1600 bool HasPendingOperations() const;
1623 int CountBufferedOperations() const
1624 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1625 "in a future release");
1651 Status SetErrorBufferSpace(
size_t size_bytes);
1662 int CountPendingErrors() const;
1674 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1680 class KUDU_NO_EXPORT Data;
1683 friend class internal::Batcher;
1684 friend class ClientTest;
1685 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1686 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1688 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1757 enum { kScanTimeoutMillis = 30000 };
1764 explicit KuduScanner(KuduTable* table);
1776 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1788 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1796 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1798 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1808 Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1828 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1847 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1848 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1858 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1868 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1876 Status SetCacheBlocks(
bool cache_blocks);
1916 bool HasMoreRows()
const;
1929 Status NextBatch(std::vector<KuduRowResult>* rows)
1930 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
1940 Status NextBatch(KuduScanBatch* batch);
1950 Status GetCurrentServer(KuduTabletServer** server);
1953 const ResourceMetrics& GetResourceMetrics()
const;
1961 Status SetBatchSizeBytes(uint32_t batch_size);
1978 Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
1985 Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT
1986 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2000 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2007 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2021 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2028 Status SetTimeoutMillis(
int millis);
2031 KuduSchema GetProjectionSchema() const;
2040 static const uint64_t NO_FLAGS = 0;
2048 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2072 Status SetRowFormatFlags(uint64_t flags);
2080 std::
string ToString() const;
2083 class KUDU_NO_EXPORT Data;
2086 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2087 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2088 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2089 FRIEND_TEST(ClientTest, TestScanTimeout);
2090 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2091 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2096 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2119 class KUDU_EXPORT KuduScanToken {
2134 Status IntoKuduScanner(KuduScanner** scanner)
const WARN_UNUSED_RESULT;
2146 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2159 static Status DeserializeIntoScanner(KuduClient* client,
2160 const std::string& serialized_token,
2161 KuduScanner** scanner) WARN_UNUSED_RESULT;
2164 class KUDU_NO_EXPORT Data;
2173 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2199 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2203 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2223 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2231 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2247 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2250 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2254 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2257 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2267 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2270 class KUDU_NO_EXPORT Data;
2309 class KUDU_NO_EXPORT Data;
2334 int NumPartitions()
const;
2349 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:431
A representation of an operation's outcome.
Definition: status.h:135
A constant cell value with a specific type.
Definition: value.h:34
Builder for Partitioner instances.
Definition: client.h:2279
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1354
Definition: client.h:1373
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:240
static const uint64_t kNoTimestamp
Definition: client.h:445
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:424
A single row upsert to be sent to the cluster.
Definition: write_op.h:166
Builds scan tokens for a table.
Definition: client.h:2179
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1024
OrderMode
Definition: client.h:1739
Definition: client.h:1745
Smart pointer typedefs for externally-faced code.
Definition: client.h:2327
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:734
This class represents an error which occurred in a write operation.
Definition: client.h:1183
A handle for a connection to a cluster.
Definition: client.h:295
An inclusive bound.
Definition: client.h:735
In-memory representation of a remote tablet server.
Definition: client.h:562
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:868
This class is a representation of a single scan.
Definition: client.h:1701
ReadMode
The read modes for scanners.
Definition: client.h:1704
Definition: client.h:1326
Definition: client.h:1712
A "factory" for KuduClient objects.
Definition: client.h:193
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:425
RangePartitionBound
Range partition bound type.
Definition: client.h:733
In-memory representation of a remote tablet.
Definition: client.h:622
In-memory representation of a remote tablet's replica.
Definition: client.h:594
FlushMode
Modes of flush operations.
Definition: client.h:1293
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2119
Definition: client.h:1298
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:652
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:63
Representation of a Kudu client session.
Definition: client.h:1288
A representation of a time interval.
Definition: monotime.h:46