25 #ifndef KUDU_CLIENT_CLIENT_H 26 #define KUDU_CLIENT_CLIENT_H 32 #include "kudu/client/resource_metrics.h" 33 #include "kudu/client/row_result.h" 34 #include "kudu/client/scan_batch.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/client/write_op.h" 46 #include "kudu/util/kudu_export.h" 47 #include "kudu/util/monotime.h" 52 class ClientStressTest_TestUniqueClientIds_Test;
53 class LinkedListTester;
54 class PartitionSchema;
55 class SecurityUnknownTskTest;
58 class LeaderMasterProxy;
63 class KuduLoggingCallback;
64 class KuduPartitioner;
67 class KuduStatusCallback;
69 class KuduTableAlterer;
70 class KuduTableCreator;
72 class KuduTabletServer;
74 class KuduWriteOperation;
79 class GetTableSchemaRpc;
83 class RemoteTabletServer;
99 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
107 void KUDU_EXPORT UninstallLoggingCallback();
124 void KUDU_EXPORT SetVerboseLogLevel(
int level);
135 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
148 Status KUDU_EXPORT DisableSaslInitialization();
173 Status KUDU_EXPORT DisableOpenSSLInitialization();
177 std::string KUDU_EXPORT GetShortVersionString();
181 std::string KUDU_EXPORT GetAllVersionInfo();
252 Status Build(sp::shared_ptr<KuduClient>* client);
255 class KUDU_NO_EXPORT Data;
289 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
307 Status IsCreateTableInProgress(
const std::string& table_name,
308 bool *create_in_progress);
315 Status DeleteTable(
const std::string& table_name);
333 Status IsAlterTableInProgress(
const std::string& table_name,
334 bool *alter_in_progress);
342 Status GetTableSchema(
const std::string& table_name,
351 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
360 Status ListTables(std::vector<std::string>* tables,
361 const std::string& filter =
"");
370 Status TableExists(
const std::string& table_name,
bool* exists);
388 Status OpenTable(
const std::string& table_name,
389 sp::shared_ptr<KuduTable>* table);
396 sp::shared_ptr<KuduSession> NewSession();
412 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
429 bool IsMultiMaster()
const;
432 const MonoDelta& default_admin_operation_timeout()
const;
435 const MonoDelta& default_rpc_timeout()
const;
480 uint64_t GetLatestObservedTimestamp()
const;
496 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
509 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
512 class KUDU_NO_EXPORT Data;
514 friend class internal::Batcher;
515 friend class internal::GetTableSchemaRpc;
516 friend class internal::LookupRpc;
517 friend class internal::MetaCache;
518 friend class internal::RemoteTablet;
519 friend class internal::RemoteTabletServer;
520 friend class internal::WriteRpc;
521 friend class ClientTest;
531 friend class ::kudu::SecurityUnknownTskTest;
532 friend class tools::LeaderMasterProxy;
534 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
535 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
536 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
537 FRIEND_TEST(ClientTest, TestMasterDown);
538 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
539 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
540 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
541 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
542 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
543 FRIEND_TEST(ClientTest, TestScanTimeout);
544 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
545 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
562 const std::string& uuid()
const;
566 const std::string& hostname()
const;
570 uint16_t port()
const;
573 class KUDU_NO_EXPORT Data;
584 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
596 bool is_leader()
const;
605 class KUDU_NO_EXPORT Data;
612 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
622 const std::string& id()
const;
629 const std::vector<const KuduReplica*>& replicas()
const;
635 class KUDU_NO_EXPORT Data;
642 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
691 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
692 int32_t num_buckets);
709 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
710 int32_t num_buckets, int32_t seed);
724 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
780 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
781 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
830 class KUDU_NO_EXPORT Data;
862 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
867 const std::string& name()
const;
876 const std::string& id()
const;
882 int num_replicas()
const;
955 std::vector<KuduValue*>* values);
986 const PartitionSchema& partition_schema()
const;
989 class KUDU_NO_EXPORT Data;
994 KuduTable(
const sp::shared_ptr<KuduClient>& client,
995 const std::string& name,
996 const std::string&
id,
999 const PartitionSchema& partition_schema);
1004 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1160 class KUDU_NO_EXPORT Data;
1164 const std::string& name);
1169 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1182 const Status& status()
const;
1206 bool was_possibly_successful()
const;
1209 class KUDU_NO_EXPORT Data;
1211 friend class internal::Batcher;
1212 friend class internal::ErrorCollector;
1220 DISALLOW_COPY_AND_ASSIGN(KuduError);
1282 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1411 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1436 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1460 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1486 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1493 void SetTimeoutMillis(
int millis);
1538 Status Flush() WARN_UNUSED_RESULT;
1584 Status Close() WARN_UNUSED_RESULT;
1594 bool HasPendingOperations() const;
1617 int CountBufferedOperations() const
1618 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1619 "in a future release");
1645 Status SetErrorBufferSpace(
size_t size_bytes);
1656 int CountPendingErrors() const;
1668 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1674 class KUDU_NO_EXPORT Data;
1677 friend class internal::Batcher;
1678 friend class ClientTest;
1679 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1680 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1682 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1751 enum { kScanTimeoutMillis = 30000 };
1770 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1782 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1790 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1792 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1822 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1841 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1842 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1852 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1862 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1870 Status SetCacheBlocks(
bool cache_blocks);
1910 bool HasMoreRows()
const;
1923 Status NextBatch(std::vector<KuduRowResult>* rows)
1924 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
1955 Status SetBatchSizeBytes(uint32_t batch_size);
1980 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
1994 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2001 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2015 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2022 Status SetTimeoutMillis(
int millis);
2034 static const uint64_t NO_FLAGS = 0;
2042 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2066 Status SetRowFormatFlags(uint64_t flags);
2074 std::string ToString()
const;
2077 class KUDU_NO_EXPORT Data;
2080 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2081 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2082 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2083 FRIEND_TEST(ClientTest, TestScanTimeout);
2084 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2085 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2090 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2140 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2154 const std::string& serialized_token,
2158 class KUDU_NO_EXPORT Data;
2167 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2193 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2197 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2217 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2225 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2241 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2244 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2248 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2251 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2261 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2264 class KUDU_NO_EXPORT Data;
2303 class KUDU_NO_EXPORT Data;
2328 int NumPartitions()
const;
2343 class KUDU_NO_EXPORT Data;
A single row update to be sent to the cluster.
Definition: write_op.h:184
A representation of a table's schema.
Definition: schema.h:423
A representation of an operation's outcome.
Definition: status.h:130
A constant cell value with a specific type.
Definition: value.h:33
Builder for Partitioner instances.
Definition: client.h:2273
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1348
Definition: callbacks.h:28
Definition: client.h:1367
A single row insert to be sent to the cluster.
Definition: write_op.h:132
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:232
static const uint64_t kNoTimestamp
Definition: client.h:439
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:418
A single row upsert to be sent to the cluster.
Definition: write_op.h:157
Builds scan tokens for a table.
Definition: client.h:2173
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:39
Alters an existing table based on the provided steps.
Definition: client.h:1018
OrderMode
Definition: client.h:1733
Definition: client.h:1739
Smart pointer typedefs for externally-faced code.
Definition: client.h:2321
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:36
An exclusive bound.
Definition: client.h:728
This class represents an error which occurred in a write operation.
Definition: client.h:1177
A handle for a connection to a cluster.
Definition: client.h:289
An inclusive bound.
Definition: client.h:729
In-memory representation of a remote tablet server.
Definition: client.h:556
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:43
A representation of a table on a particular cluster.
Definition: client.h:862
This class is a representation of a single scan.
Definition: client.h:1695
ReadMode
The read modes for scanners.
Definition: client.h:1698
Definition: client.h:1320
Definition: client.h:1706
A "factory" for KuduClient objects.
Definition: client.h:187
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:56
Select the LEADER replica.
Definition: client.h:419
RangePartitionBound
Range partition bound type.
Definition: client.h:727
In-memory representation of a remote tablet.
Definition: client.h:616
In-memory representation of a remote tablet's replica.
Definition: client.h:588
FlushMode
Modes of flush operations.
Definition: client.h:1287
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2113
Definition: client.h:1292
A single row delete to be sent to the cluster.
Definition: write_op.h:211
A generic catalog of simple metrics.
Definition: resource_metrics.h:30
A helper class to create a new table with the desired options.
Definition: client.h:646
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:61
Representation of a Kudu client session.
Definition: client.h:1282
A batch of zero or more rows returned by a scan operation.
Definition: scan_batch.h:75
A representation of a time interval.
Definition: monotime.h:43