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;
90 class ReplicaController;
106 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
114 void KUDU_EXPORT UninstallLoggingCallback();
131 void KUDU_EXPORT SetVerboseLogLevel(
int level);
142 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
155 Status KUDU_EXPORT DisableSaslInitialization();
180 Status KUDU_EXPORT DisableOpenSSLInitialization();
184 std::string KUDU_EXPORT GetShortVersionString();
188 std::string KUDU_EXPORT GetAllVersionInfo();
259 Status Build(sp::shared_ptr<KuduClient>* client);
262 class KUDU_NO_EXPORT Data;
264 friend class internal::ReplicaController;
298 class KUDU_EXPORT
KuduClient :
public sp::enable_shared_from_this<KuduClient> {
316 Status IsCreateTableInProgress(
const std::string& table_name,
317 bool* create_in_progress);
324 Status DeleteTable(
const std::string& table_name);
342 Status IsAlterTableInProgress(
const std::string& table_name,
343 bool* alter_in_progress);
351 Status GetTableSchema(
const std::string& table_name,
360 Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
369 Status ListTables(std::vector<std::string>* tables,
370 const std::string& filter =
"");
379 Status TableExists(
const std::string& table_name,
bool* exists);
397 Status OpenTable(
const std::string& table_name,
398 sp::shared_ptr<KuduTable>* table);
405 sp::shared_ptr<KuduSession> NewSession();
421 Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
438 bool IsMultiMaster()
const;
441 const MonoDelta& default_admin_operation_timeout()
const;
444 const MonoDelta& default_rpc_timeout()
const;
489 uint64_t GetLatestObservedTimestamp()
const;
505 void SetLatestObservedTimestamp(uint64_t ht_timestamp);
518 Status ExportAuthenticationCredentials(std::string* authn_creds)
const;
521 class KUDU_NO_EXPORT Data;
523 friend class internal::Batcher;
524 friend class internal::GetTableSchemaRpc;
525 friend class internal::LookupRpc;
526 friend class internal::MetaCache;
527 friend class internal::RemoteTablet;
528 friend class internal::RemoteTabletServer;
529 friend class internal::WriteRpc;
530 friend class ClientTest;
540 friend class ::kudu::SecurityUnknownTskTest;
541 friend class tools::LeaderMasterProxy;
543 FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
544 FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
545 FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
546 FRIEND_TEST(ClientTest, TestMasterDown);
547 FRIEND_TEST(ClientTest, TestMasterLookupPermits);
548 FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
549 FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
550 FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
551 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
552 FRIEND_TEST(ClientTest, TestScanTimeout);
553 FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
554 FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
571 const std::string& uuid()
const;
575 const std::string& hostname()
const;
579 uint16_t port()
const;
582 class KUDU_NO_EXPORT Data;
593 DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
605 bool is_leader()
const;
613 friend class internal::ReplicaController;
615 class KUDU_NO_EXPORT Data;
622 DISALLOW_COPY_AND_ASSIGN(KuduReplica);
632 const std::string& id()
const;
639 const std::vector<const KuduReplica*>& replicas()
const;
645 class KUDU_NO_EXPORT Data;
652 DISALLOW_COPY_AND_ASSIGN(KuduTablet);
701 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
702 int32_t num_buckets);
719 KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
720 int32_t num_buckets, int32_t seed);
734 KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
790 KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
791 ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
840 class KUDU_NO_EXPORT Data;
872 class KUDU_EXPORT
KuduTable :
public sp::enable_shared_from_this<KuduTable> {
877 const std::string& name()
const;
886 const std::string& id()
const;
892 int num_replicas()
const;
965 std::vector<KuduValue*>* values);
996 const PartitionSchema& partition_schema()
const;
999 class KUDU_NO_EXPORT Data;
1004 KuduTable(
const sp::shared_ptr<KuduClient>& client,
1005 const std::string& name,
1006 const std::string&
id,
1009 const PartitionSchema& partition_schema);
1014 DISALLOW_COPY_AND_ASSIGN(KuduTable);
1170 class KUDU_NO_EXPORT Data;
1174 const std::string& name);
1179 DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1192 const Status& status()
const;
1216 bool was_possibly_successful()
const;
1219 class KUDU_NO_EXPORT Data;
1221 friend class internal::Batcher;
1222 friend class internal::ErrorCollector;
1230 DISALLOW_COPY_AND_ASSIGN(KuduError);
1292 class KUDU_EXPORT
KuduSession :
public sp::enable_shared_from_this<KuduSession> {
1421 Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
1446 Status SetMutationBufferFlushWatermark(
double watermark_pct)
1470 Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
1496 Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
1503 void SetTimeoutMillis(
int millis);
1548 Status Flush() WARN_UNUSED_RESULT;
1594 Status Close() WARN_UNUSED_RESULT;
1604 bool HasPendingOperations() const;
1627 int CountBufferedOperations() const
1628 ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1629 "in a future release");
1655 Status SetErrorBufferSpace(
size_t size_bytes);
1666 int CountPendingErrors() const;
1678 void GetPendingErrors(std::vector<
KuduError*>* errors,
bool* overflowed);
1684 class KUDU_NO_EXPORT Data;
1687 friend class internal::Batcher;
1688 friend class ClientTest;
1689 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1690 FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1692 explicit
KuduSession(const sp::shared_ptr<KuduClient>& client);
1761 enum { kScanTimeoutMillis = 30000 };
1780 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
1792 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
1800 Status SetProjectedColumns(
const std::vector<std::string>& col_names)
1802 ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
1832 ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
1851 Status AddExclusiveUpperBoundRaw(
const Slice& key)
1852 ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
1862 Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
1872 Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
1880 Status SetCacheBlocks(
bool cache_blocks);
1920 bool HasMoreRows()
const;
1933 Status NextBatch(std::vector<KuduRowResult>* rows)
1934 ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
1965 Status SetBatchSizeBytes(uint32_t batch_size);
1990 ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
2004 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2011 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2025 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2032 Status SetTimeoutMillis(
int millis);
2044 static const uint64_t NO_FLAGS = 0;
2052 static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2076 Status SetRowFormatFlags(uint64_t flags);
2084 std::string ToString()
const;
2087 class KUDU_NO_EXPORT Data;
2090 FRIEND_TEST(ClientTest, TestScanCloseProxy);
2091 FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2092 FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2093 FRIEND_TEST(ClientTest, TestScanTimeout);
2094 FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2095 FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2096 FRIEND_TEST(ScanTokenTest, TestScanTokens);
2101 DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2151 Status Serialize(std::string* buf)
const WARN_UNUSED_RESULT;
2165 const std::string& serialized_token,
2169 class KUDU_NO_EXPORT Data;
2178 DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2204 Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
2208 Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
2228 Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
2236 Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2252 Status SetFaultTolerant() WARN_UNUSED_RESULT;
2255 Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2259 Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2262 Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
2272 Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2275 class KUDU_NO_EXPORT Data;
2314 class KUDU_NO_EXPORT Data;
2339 int NumPartitions()
const;
2354 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:145
A constant cell value with a specific type.
Definition: value.h:34
Builder for Partitioner instances.
Definition: client.h:2284
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1358
Definition: callbacks.h:28
Definition: client.h:1377
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:448
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:427
A single row upsert to be sent to the cluster.
Definition: write_op.h:166
Builds scan tokens for a table.
Definition: client.h:2184
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1028
OrderMode
Definition: client.h:1743
Definition: client.h:1749
Smart pointer typedefs for externally-faced code.
Definition: client.h:2332
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:738
This class represents an error which occurred in a write operation.
Definition: client.h:1187
A handle for a connection to a cluster.
Definition: client.h:298
An inclusive bound.
Definition: client.h:739
In-memory representation of a remote tablet server.
Definition: client.h:565
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:872
This class is a representation of a single scan.
Definition: client.h:1705
ReadMode
The read modes for scanners.
Definition: client.h:1708
Definition: client.h:1330
Definition: client.h:1716
A "factory" for KuduClient objects.
Definition: client.h:194
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:428
RangePartitionBound
Range partition bound type.
Definition: client.h:737
In-memory representation of a remote tablet.
Definition: client.h:626
In-memory representation of a remote tablet's replica.
Definition: client.h:597
FlushMode
Modes of flush operations.
Definition: client.h:1297
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2124
Definition: client.h:1302
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:656
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:1292
A batch of zero or more rows returned by a scan operation.
Definition: scan_batch.h:82
A representation of a time interval.
Definition: monotime.h:46