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;
    58 class KuduLoggingCallback;
    61 class KuduStatusCallback;
    63 class KuduTableAlterer;
    64 class KuduTableCreator;
    66 class KuduTabletServer;
    68 class KuduWriteOperation;
    73 class GetTableSchemaRpc;
    77 class RemoteTabletServer;
    93 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
   101 void KUDU_EXPORT UninstallLoggingCallback();
   118 void KUDU_EXPORT SetVerboseLogLevel(
int level);
   129 Status KUDU_EXPORT SetInternalSignalNumber(
int signum);
   142 Status KUDU_EXPORT DisableSaslInitialization();
   167 Status KUDU_EXPORT DisableOpenSSLInitialization();
   171 std::string KUDU_EXPORT GetShortVersionString();
   175 std::string KUDU_EXPORT GetAllVersionInfo();
   246   Status Build(sp::shared_ptr<KuduClient>* client);
   249   class KUDU_NO_EXPORT Data;
   283 class KUDU_EXPORT 
KuduClient : 
public sp::enable_shared_from_this<KuduClient> {
   301   Status IsCreateTableInProgress(
const std::string& table_name,
   302                                  bool *create_in_progress);
   309   Status DeleteTable(
const std::string& table_name);
   327   Status IsAlterTableInProgress(
const std::string& table_name,
   328                                 bool *alter_in_progress);
   336   Status GetTableSchema(
const std::string& table_name,
   345   Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
   354   Status ListTables(std::vector<std::string>* tables,
   355                     const std::string& filter = 
"");
   364   Status TableExists(
const std::string& table_name, 
bool* exists);
   379   Status OpenTable(
const std::string& table_name,
   380                    sp::shared_ptr<KuduTable>* table);
   387   sp::shared_ptr<KuduSession> NewSession();
   403   Status KUDU_NO_EXPORT GetTablet(
const std::string& tablet_id,
   420   bool IsMultiMaster() 
const;
   423   const MonoDelta& default_admin_operation_timeout() 
const;
   426   const MonoDelta& default_rpc_timeout() 
const;
   471   uint64_t GetLatestObservedTimestamp() 
const;
   487   void SetLatestObservedTimestamp(uint64_t ht_timestamp);
   500   Status ExportAuthenticationCredentials(std::string* authn_creds) 
const;
   503   class KUDU_NO_EXPORT Data;
   505   friend class internal::Batcher;
   506   friend class internal::GetTableSchemaRpc;
   507   friend class internal::LookupRpc;
   508   friend class internal::MetaCache;
   509   friend class internal::RemoteTablet;
   510   friend class internal::RemoteTabletServer;
   511   friend class internal::WriteRpc;
   512   friend class ClientTest;
   522   FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
   523   FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
   524   FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
   525   FRIEND_TEST(ClientTest, TestMasterDown);
   526   FRIEND_TEST(ClientTest, TestMasterLookupPermits);
   527   FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
   528   FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
   529   FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
   530   FRIEND_TEST(ClientTest, TestScanFaultTolerance);
   531   FRIEND_TEST(ClientTest, TestScanTimeout);
   532   FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
   533   FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
   550   const std::string& uuid() 
const;
   554   const std::string& hostname() 
const;
   558   uint16_t port() 
const;
   561   class KUDU_NO_EXPORT Data;
   572   DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
   584   bool is_leader() 
const;
   593   class KUDU_NO_EXPORT Data;
   600   DISALLOW_COPY_AND_ASSIGN(KuduReplica);
   610   const std::string& id() 
const;
   617   const std::vector<const KuduReplica*>& replicas() 
const;
   623   class KUDU_NO_EXPORT Data;
   630   DISALLOW_COPY_AND_ASSIGN(KuduTablet);
   679   KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
   680                                         int32_t num_buckets);
   697   KuduTableCreator& add_hash_partitions(
const std::vector<std::string>& columns,
   698                                         int32_t num_buckets, int32_t seed);
   712   KuduTableCreator& set_range_partition_columns(
const std::vector<std::string>& columns);
   768   KuduTableCreator& split_rows(
const std::vector<const KuduPartialRow*>& split_rows)
   769       ATTRIBUTE_DEPRECATED(
"use add_range_partition_split() instead");
   818   class KUDU_NO_EXPORT Data;
   850 class KUDU_EXPORT 
KuduTable : 
public sp::enable_shared_from_this<KuduTable> {
   855   const std::string& name() 
const;
   864   const std::string& id() 
const;
   870   int num_replicas() 
const;
   943                                     std::vector<KuduValue*>* values);
   974   const PartitionSchema& partition_schema() 
const;
   977   class KUDU_NO_EXPORT Data;
   981   KuduTable(
const sp::shared_ptr<KuduClient>& client,
   982             const std::string& name,
   983             const std::string& 
id,
   986             const PartitionSchema& partition_schema);
   991   DISALLOW_COPY_AND_ASSIGN(KuduTable);
  1147   class KUDU_NO_EXPORT Data;
  1151                    const std::string& name);
  1156   DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
  1169   const Status& status() 
const;
  1193   bool was_possibly_successful() 
const;
  1196   class KUDU_NO_EXPORT Data;
  1198   friend class internal::Batcher;
  1199   friend class internal::ErrorCollector;
  1207   DISALLOW_COPY_AND_ASSIGN(KuduError);
  1269 class KUDU_EXPORT 
KuduSession : 
public sp::enable_shared_from_this<KuduSession> {
  1398   Status SetMutationBufferSpace(
size_t size_bytes) WARN_UNUSED_RESULT;
  1423   Status SetMutationBufferFlushWatermark(
double watermark_pct)
  1447   Status SetMutationBufferFlushInterval(
unsigned int millis) WARN_UNUSED_RESULT;
  1473   Status SetMutationBufferMaxNum(
unsigned int max_num) WARN_UNUSED_RESULT;
  1480   void SetTimeoutMillis(
int millis);
  1525   Status Flush() WARN_UNUSED_RESULT;
  1571   Status Close() WARN_UNUSED_RESULT;
  1581   bool HasPendingOperations() const;
  1604   int CountBufferedOperations() const
  1605       ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
  1606                            "in a future release");
  1632   Status SetErrorBufferSpace(
size_t size_bytes);
  1643   int CountPendingErrors() const;
  1655   void GetPendingErrors(std::vector<
KuduError*>* errors, 
bool* overflowed);
  1661   class KUDU_NO_EXPORT Data;
  1664   friend class internal::Batcher;
  1665   friend class ClientTest;
  1666   FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
  1667   FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
  1669   explicit 
KuduSession(const sp::shared_ptr<KuduClient>& client);
  1738   enum { kScanTimeoutMillis = 30000 };
  1757   Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
  1769   Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
  1777   Status SetProjectedColumns(
const std::vector<std::string>& col_names)
  1779       ATTRIBUTE_DEPRECATED(
"use SetProjectedColumnNames() instead");
  1809       ATTRIBUTE_DEPRECATED(
"use AddLowerBound() instead");
  1828   Status AddExclusiveUpperBoundRaw(
const Slice& key)
  1829       ATTRIBUTE_DEPRECATED(
"use AddExclusiveUpperBound() instead");
  1839   Status AddLowerBoundPartitionKeyRaw(
const Slice& partition_key);
  1849   Status AddExclusiveUpperBoundPartitionKeyRaw(
const Slice& partition_key);
  1857   Status SetCacheBlocks(
bool cache_blocks);
  1897   bool HasMoreRows() 
const;
  1910   Status NextBatch(std::vector<KuduRowResult>* rows)
  1911       ATTRIBUTE_DEPRECATED(
"use NextBatch(KuduScanBatch*) instead");
  1942   Status SetBatchSizeBytes(uint32_t batch_size);
  1967       ATTRIBUTE_DEPRECATED(
"use SetFaultTolerant() instead");
  1981   Status SetFaultTolerant() WARN_UNUSED_RESULT;
  1988   Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
  2002   Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
  2009   Status SetTimeoutMillis(
int millis);
  2019   std::string ToString() 
const;
  2022   class KUDU_NO_EXPORT Data;
  2025   FRIEND_TEST(ClientTest, TestScanCloseProxy);
  2026   FRIEND_TEST(ClientTest, TestScanFaultTolerance);
  2027   FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
  2028   FRIEND_TEST(ClientTest, TestScanTimeout);
  2029   FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
  2030   FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
  2035   DISALLOW_COPY_AND_ASSIGN(KuduScanner);
  2085   Status Serialize(std::string* buf) 
const WARN_UNUSED_RESULT;
  2099                                        const std::string& serialized_token,
  2103   class KUDU_NO_EXPORT Data;
  2112   DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
  2138   Status SetProjectedColumnNames(
const std::vector<std::string>& col_names)
  2142   Status SetProjectedColumnIndexes(
const std::vector<int>& col_indexes)
  2162   Status SetCacheBlocks(
bool cache_blocks) WARN_UNUSED_RESULT;
  2170   Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
  2186   Status SetFaultTolerant() WARN_UNUSED_RESULT;
  2189   Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
  2193   Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
  2196   Status SetTimeoutMillis(
int millis) WARN_UNUSED_RESULT;
  2206   Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
  2209   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:417
 
A representation of an operation's outcome. 
Definition: status.h:130
 
A constant cell value with a specific type. 
Definition: value.h:33
 
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates. 
Definition: client.h:1335
 
Definition: callbacks.h:28
 
Definition: client.h:1354
 
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:230
 
static const uint64_t kNoTimestamp
Definition: client.h:430
 
ReplicaSelection
Policy with which to choose amongst multiple replicas. 
Definition: client.h:409
 
A single row upsert to be sent to the cluster. 
Definition: write_op.h:157
 
Builds scan tokens for a table. 
Definition: client.h:2118
 
ComparisonOp
Supported comparison operators. 
Definition: scan_predicate.h:39
 
Alters an existing table based on the provided steps. 
Definition: client.h:1005
 
OrderMode
Definition: client.h:1720
 
Definition: client.h:1726
 
Smart pointer typedefs for externally-faced code. 
 
A representation of comparison predicate for Kudu queries. 
Definition: scan_predicate.h:36
 
An exclusive bound. 
Definition: client.h:716
 
This class represents an error which occurred in a write operation. 
Definition: client.h:1164
 
A handle for a connection to a cluster. 
Definition: client.h:283
 
An inclusive bound. 
Definition: client.h:717
 
In-memory representation of a remote tablet server. 
Definition: client.h:544
 
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:850
 
This class is a representation of a single scan. 
Definition: client.h:1682
 
ReadMode
The read modes for scanners. 
Definition: client.h:1685
 
Definition: client.h:1307
 
Definition: client.h:1693
 
A "factory" for KuduClient objects. 
Definition: client.h:181
 
A single-row write operation to be sent to a Kudu table. 
Definition: write_op.h:56
 
Select the LEADER replica. 
Definition: client.h:410
 
RangePartitionBound
Range partition bound type. 
Definition: client.h:715
 
In-memory representation of a remote tablet. 
Definition: client.h:604
 
In-memory representation of a remote tablet's replica. 
Definition: client.h:576
 
FlushMode
Modes of flush operations. 
Definition: client.h:1274
 
A scan descriptor limited to a single physical contiguous location. 
Definition: client.h:2058
 
Definition: client.h:1279
 
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:634
 
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:1269
 
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