Repository: hbase Updated Branches: refs/heads/HBASE-14850 517090a09 -> 3d861a17a
HBASE-15602 Clean up using directives in cc files. Signed-off-by: Enis Soztutar <e...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3d861a17 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3d861a17 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3d861a17 Branch: refs/heads/HBASE-14850 Commit: 3d861a17af443df01d7091d1daa70446f259b9b6 Parents: 517090a Author: Scott Hunt <sch...@adobe.com> Authored: Tue May 30 16:26:04 2017 -0700 Committer: Enis Soztutar <e...@apache.org> Committed: Tue May 30 16:26:04 2017 -0700 ---------------------------------------------------------------------- .../connection/client-dispatcher.cc | 20 +++--- .../connection/client-handler.cc | 21 +++--- .../connection/connection-factory.cc | 7 +- .../connection/connection-factory.h | 6 +- hbase-native-client/connection/connection-id.h | 17 +++-- .../connection/connection-pool.cc | 22 +++--- .../connection/connection-pool.h | 9 +-- hbase-native-client/connection/pipeline.cc | 15 ++--- hbase-native-client/connection/request.cc | 3 +- hbase-native-client/connection/rpc-client.cc | 3 +- hbase-native-client/connection/rpc-client.h | 27 +++----- hbase-native-client/connection/rpc-connection.h | 3 +- hbase-native-client/connection/sasl-handler.cc | 4 +- .../core/async-batch-rpc-retrying-caller.cc | 14 ---- .../core/async-batch-rpc-retrying-caller.h | 40 +++++------ .../core/async-rpc-retrying-caller-factory.h | 24 +++---- .../core/async-rpc-retrying-caller.cc | 12 ++-- .../core/async-rpc-retrying-caller.h | 23 +++---- .../core/async-rpc-retrying-test.cc | 3 +- hbase-native-client/core/client.cc | 2 + hbase-native-client/core/client.h | 5 +- .../core/connection-configuration.h | 50 +++++++------- hbase-native-client/core/filter.h | 12 ++-- hbase-native-client/core/get.h | 1 - hbase-native-client/core/hbase-rpc-controller.h | 11 +-- hbase-native-client/core/location-cache.cc | 71 +++++++++----------- hbase-native-client/core/meta-utils.cc | 9 ++- hbase-native-client/core/multi-response.cc | 2 + hbase-native-client/core/multi-response.h | 6 +- hbase-native-client/core/raw-async-table.cc | 25 ++++--- hbase-native-client/core/raw-async-table.h | 26 +++---- hbase-native-client/core/region-request.h | 2 +- hbase-native-client/core/region-result.cc | 1 - hbase-native-client/core/region-result.h | 11 ++- hbase-native-client/core/request-converter.cc | 2 +- hbase-native-client/core/request-converter.h | 12 ++-- hbase-native-client/core/response-converter.h | 2 - hbase-native-client/core/server-request.h | 3 - hbase-native-client/core/table.h | 9 ++- hbase-native-client/exceptions/exception.h | 3 +- hbase-native-client/serde/rpc.cc | 20 +++--- hbase-native-client/serde/zk.cc | 11 ++- hbase-native-client/utils/time-util.h | 38 ++++++----- hbase-native-client/utils/user-util.cc | 8 +-- 44 files changed, 269 insertions(+), 346 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/client-dispatcher.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/client-dispatcher.cc b/hbase-native-client/connection/client-dispatcher.cc index 27201d2..35a1f7d 100644 --- a/hbase-native-client/connection/client-dispatcher.cc +++ b/hbase-native-client/connection/client-dispatcher.cc @@ -21,14 +21,13 @@ #include <utility> -using namespace folly; -using namespace hbase; -using namespace wangle; -using folly::exception_wrapper; +using std::unique_ptr; + +namespace hbase { ClientDispatcher::ClientDispatcher() : requests_(5000), current_call_id_(9) {} -void ClientDispatcher::read(Context *ctx, std::unique_ptr<Response> in) { +void ClientDispatcher::read(Context *ctx, unique_ptr<Response> in) { auto call_id = in->call_id(); auto search = requests_.find(call_id); @@ -44,10 +43,10 @@ void ClientDispatcher::read(Context *ctx, std::unique_ptr<Response> in) { } } -Future<std::unique_ptr<Response>> ClientDispatcher::operator()(std::unique_ptr<Request> arg) { +folly::Future<unique_ptr<Response>> ClientDispatcher::operator()(unique_ptr<Request> arg) { auto call_id = current_call_id_++; arg->set_call_id(call_id); - requests_.insert(call_id, Promise<std::unique_ptr<Response>>{}); + requests_.insert(call_id, folly::Promise<unique_ptr<Response>>{}); auto &p = requests_.find(call_id)->second; auto f = p.getFuture(); p.setInterruptHandler([call_id, this](const folly::exception_wrapper &e) { @@ -59,6 +58,9 @@ Future<std::unique_ptr<Response>> ClientDispatcher::operator()(std::unique_ptr<R return f; } -Future<Unit> ClientDispatcher::close() { return ClientDispatcherBase::close(); } +folly::Future<folly::Unit> ClientDispatcher::close() { return ClientDispatcherBase::close(); } -Future<Unit> ClientDispatcher::close(Context *ctx) { return ClientDispatcherBase::close(ctx); } +folly::Future<folly::Unit> ClientDispatcher::close(Context *ctx) { + return ClientDispatcherBase::close(ctx); +} +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/client-handler.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/client-handler.cc b/hbase-native-client/connection/client-handler.cc index e60382d..ac16197 100644 --- a/hbase-native-client/connection/client-handler.cc +++ b/hbase-native-client/connection/client-handler.cc @@ -30,28 +30,24 @@ #include "if/Client.pb.h" #include "if/RPC.pb.h" -using namespace hbase; -using namespace folly; -using namespace wangle; -using hbase::pb::ResponseHeader; -using hbase::pb::GetResponse; using google::protobuf::Message; +namespace hbase { + ClientHandler::ClientHandler(std::string user_name, std::shared_ptr<Codec> codec, const std::string &server) : user_name_(user_name), serde_(codec), server_(server), once_flag_(std::make_unique<std::once_flag>()), - resp_msgs_( - make_unique<folly::AtomicHashMap<uint32_t, std::shared_ptr<google::protobuf::Message>>>( - 5000)) {} + resp_msgs_(std::make_unique<folly::AtomicHashMap<uint32_t, std::shared_ptr<Message>>>(5000)) { +} -void ClientHandler::read(Context *ctx, std::unique_ptr<IOBuf> buf) { +void ClientHandler::read(Context *ctx, std::unique_ptr<folly::IOBuf> buf) { if (LIKELY(buf != nullptr)) { buf->coalesce(); auto received = std::make_unique<Response>(); - ResponseHeader header; + pb::ResponseHeader header; int used_bytes = serde_.ParseDelimited(buf.get(), &header); VLOG(3) << "Read RPC ResponseHeader size=" << used_bytes << " call_id=" << header.call_id() @@ -118,13 +114,13 @@ void ClientHandler::read(Context *ctx, std::unique_ptr<IOBuf> buf) { VLOG(3) << "Exception RPC ResponseHeader, call_id=" << header.call_id() << " exception.what=" << remote_exception->what() << ", do_not_retry=" << remote_exception->do_not_retry(); - received->set_exception(::folly::exception_wrapper{*remote_exception}); + received->set_exception(folly::exception_wrapper{*remote_exception}); } ctx->fireRead(std::move(received)); } } -Future<Unit> ClientHandler::write(Context *ctx, std::unique_ptr<Request> r) { +folly::Future<folly::Unit> ClientHandler::write(Context *ctx, std::unique_ptr<Request> r) { // We need to send the header once. // So use call_once to make sure that only one thread wins this. std::call_once((*once_flag_), [ctx, this]() { @@ -142,3 +138,4 @@ Future<Unit> ClientHandler::write(Context *ctx, std::unique_ptr<Request> r) { // Send the data down the pipeline. return ctx->fireWrite(serde_.Request(r->call_id(), r->method(), r->req_msg().get())); } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/connection-factory.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/connection-factory.cc b/hbase-native-client/connection/connection-factory.cc index 9b06c84..d1bfbce 100644 --- a/hbase-native-client/connection/connection-factory.cc +++ b/hbase-native-client/connection/connection-factory.cc @@ -28,11 +28,11 @@ #include "connection/pipeline.h" #include "connection/service.h" -using namespace folly; -using namespace hbase; using std::chrono::milliseconds; using std::chrono::nanoseconds; +namespace hbase { + ConnectionFactory::ConnectionFactory(std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool, std::shared_ptr<Codec> codec, std::shared_ptr<Configuration> conf, @@ -60,10 +60,11 @@ std::shared_ptr<HBaseService> ConnectionFactory::Connect( // much nicer. // TODO see about using shared promise for this. auto pipeline = client - ->connect(SocketAddress(hostname, port, true), + ->connect(folly::SocketAddress(hostname, port, true), std::chrono::duration_cast<milliseconds>(connect_timeout_)) .get(); auto dispatcher = std::make_shared<ClientDispatcher>(); dispatcher->setPipeline(pipeline); return dispatcher; } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/connection-factory.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/connection-factory.h b/hbase-native-client/connection/connection-factory.h index e1d7f6c..c96087d 100644 --- a/hbase-native-client/connection/connection-factory.h +++ b/hbase-native-client/connection/connection-factory.h @@ -30,8 +30,6 @@ #include "connection/service.h" #include "security/user.h" -using std::chrono::nanoseconds; - namespace hbase { /** @@ -46,7 +44,7 @@ class ConnectionFactory { */ ConnectionFactory(std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool, std::shared_ptr<Codec> codec, std::shared_ptr<Configuration> conf, - nanoseconds connect_timeout = nanoseconds(0)); + std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); /** Default Destructor */ virtual ~ConnectionFactory() = default; @@ -66,7 +64,7 @@ class ConnectionFactory { const std::string &hostname, uint16_t port); private: - nanoseconds connect_timeout_; + std::chrono::nanoseconds connect_timeout_; std::shared_ptr<Configuration> conf_; std::shared_ptr<wangle::IOThreadPoolExecutor> io_pool_; std::shared_ptr<RpcPipelineFactory> pipeline_factory_; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/connection-id.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/connection-id.h b/hbase-native-client/connection/connection-id.h index 78b9780..7381103 100644 --- a/hbase-native-client/connection/connection-id.h +++ b/hbase-native-client/connection/connection-id.h @@ -25,31 +25,29 @@ #include <memory> #include <utility> -using hbase::pb::ServerName; -using hbase::security::User; - namespace hbase { + class ConnectionId { public: ConnectionId(const std::string &host, uint16_t port) - : ConnectionId(host, port, User::defaultUser(), "") {} + : ConnectionId(host, port, security::User::defaultUser(), "") {} - ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<User> user) + ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<security::User> user) : ConnectionId(host, port, user, "") {} - ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<User> user, + ConnectionId(const std::string &host, uint16_t port, std::shared_ptr<security::User> user, const std::string &service_name) : user_(user), service_name_(service_name), host_(host), port_(port) {} virtual ~ConnectionId() = default; - std::shared_ptr<User> user() const { return user_; } + std::shared_ptr<security::User> user() const { return user_; } std::string service_name() const { return service_name_; } std::string host() { return host_; } uint16_t port() { return port_; } private: - std::shared_ptr<User> user_; + std::shared_ptr<security::User> user_; std::string service_name_; std::string host_; uint16_t port_; @@ -65,7 +63,8 @@ struct ConnectionIdEquals { } private: - bool userEquals(const std::shared_ptr<User> &lhs, const std::shared_ptr<User> &rhs) const { + bool userEquals(const std::shared_ptr<security::User> &lhs, + const std::shared_ptr<security::User> &rhs) const { return lhs == nullptr ? rhs == nullptr : (rhs == nullptr ? false : lhs->user_name() == rhs->user_name()); } http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/connection-pool.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/connection-pool.cc b/hbase-native-client/connection/connection-pool.cc index d3ac3c2..e98759d 100644 --- a/hbase-native-client/connection/connection-pool.cc +++ b/hbase-native-client/connection/connection-pool.cc @@ -21,19 +21,14 @@ #include <folly/Conv.h> #include <folly/Logging.h> -#include <folly/SocketAddress.h> #include <wangle/service/Service.h> #include <memory> #include <utility> -using std::mutex; -using std::unique_ptr; -using std::shared_ptr; -using hbase::ConnectionPool; -using hbase::HBaseService; -using folly::SharedMutexWritePriority; -using folly::SocketAddress; +using std::chrono::nanoseconds; + +namespace hbase { ConnectionPool::ConnectionPool(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor, std::shared_ptr<Codec> codec, std::shared_ptr<Configuration> conf, @@ -62,7 +57,7 @@ std::shared_ptr<RpcConnection> ConnectionPool::GetConnection( std::shared_ptr<RpcConnection> ConnectionPool::GetCachedConnection( std::shared_ptr<ConnectionId> remote_id) { - SharedMutexWritePriority::ReadHolder holder(map_mutex_); + folly::SharedMutexWritePriority::ReadHolder holder(map_mutex_); auto found = connections_.find(remote_id); if (found == connections_.end()) { return nullptr; @@ -74,7 +69,7 @@ std::shared_ptr<RpcConnection> ConnectionPool::GetNewConnection( std::shared_ptr<ConnectionId> remote_id) { // Grab the upgrade lock. While we are double checking other readers can // continue on - SharedMutexWritePriority::UpgradeHolder u_holder{map_mutex_}; + folly::SharedMutexWritePriority::UpgradeHolder u_holder{map_mutex_}; // Now check if someone else created the connection before we got the lock // This is safe since we hold the upgrade lock. @@ -84,7 +79,7 @@ std::shared_ptr<RpcConnection> ConnectionPool::GetNewConnection( return found->second; } else { // Yeah it looks a lot like there's no connection - SharedMutexWritePriority::WriteHolder w_holder{std::move(u_holder)}; + folly::SharedMutexWritePriority::WriteHolder w_holder{std::move(u_holder)}; // Make double sure there are not stale connections hanging around. connections_.erase(remote_id); @@ -102,7 +97,7 @@ std::shared_ptr<RpcConnection> ConnectionPool::GetNewConnection( } void ConnectionPool::Close(std::shared_ptr<ConnectionId> remote_id) { - SharedMutexWritePriority::WriteHolder holder{map_mutex_}; + folly::SharedMutexWritePriority::WriteHolder holder{map_mutex_}; DLOG(INFO) << "Closing RPC Connection to host:" << remote_id->host() << ", port:" << folly::to<std::string>(remote_id->port()); @@ -116,7 +111,7 @@ void ConnectionPool::Close(std::shared_ptr<ConnectionId> remote_id) { } void ConnectionPool::Close() { - SharedMutexWritePriority::WriteHolder holder{map_mutex_}; + folly::SharedMutexWritePriority::WriteHolder holder{map_mutex_}; for (auto &item : connections_) { auto &con = item.second; con->Close(); @@ -124,3 +119,4 @@ void ConnectionPool::Close() { connections_.clear(); clients_.clear(); } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/connection-pool.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/connection-pool.h b/hbase-native-client/connection/connection-pool.h index 0582d9b..c7c4246 100644 --- a/hbase-native-client/connection/connection-pool.h +++ b/hbase-native-client/connection/connection-pool.h @@ -31,13 +31,6 @@ #include "connection/service.h" #include "if/HBase.pb.h" -using hbase::ConnectionId; -using hbase::ConnectionIdEquals; -using hbase::ConnectionIdHash; -using hbase::RpcConnection; - -using std::chrono::nanoseconds; - namespace hbase { /** @@ -51,7 +44,7 @@ class ConnectionPool { /** Create connection pool wit default connection factory */ ConnectionPool(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor, std::shared_ptr<Codec> codec, std::shared_ptr<Configuration> conf, - nanoseconds connect_timeout = nanoseconds(0)); + std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); /** * Constructor that allows specifiying the connetion factory. http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/pipeline.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/pipeline.cc b/hbase-native-client/connection/pipeline.cc index d27c849..2844752 100644 --- a/hbase-native-client/connection/pipeline.cc +++ b/hbase-native-client/connection/pipeline.cc @@ -27,26 +27,25 @@ #include "connection/client-handler.h" #include "connection/sasl-handler.h" -using namespace folly; -using namespace hbase; -using namespace wangle; +namespace hbase { RpcPipelineFactory::RpcPipelineFactory(std::shared_ptr<Codec> codec, std::shared_ptr<Configuration> conf) : user_util_(), codec_(codec), conf_(conf) {} SerializePipeline::Ptr RpcPipelineFactory::newPipeline( - std::shared_ptr<AsyncTransportWrapper> sock) { - SocketAddress addr; // for logging + std::shared_ptr<folly::AsyncTransportWrapper> sock) { + folly::SocketAddress addr; // for logging sock->getPeerAddress(&addr); auto pipeline = SerializePipeline::create(); - pipeline->addBack(AsyncSocketHandler{sock}); - pipeline->addBack(EventBaseHandler{}); + pipeline->addBack(wangle::AsyncSocketHandler{sock}); + pipeline->addBack(wangle::EventBaseHandler{}); auto secure = security::User::IsSecurityEnabled(*conf_); pipeline->addBack(SaslHandler{user_util_.user_name(secure), conf_}); - pipeline->addBack(LengthFieldBasedFrameDecoder{}); + pipeline->addBack(wangle::LengthFieldBasedFrameDecoder{}); pipeline->addBack(ClientHandler{user_util_.user_name(secure), codec_, addr.describe()}); pipeline->finalize(); return pipeline; } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/request.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/request.cc b/hbase-native-client/connection/request.cc index 80883cc..8983726 100644 --- a/hbase-native-client/connection/request.cc +++ b/hbase-native-client/connection/request.cc @@ -21,7 +21,7 @@ #include "if/Client.pb.h" -using namespace hbase; +namespace hbase { Request::Request(std::shared_ptr<google::protobuf::Message> req, std::shared_ptr<google::protobuf::Message> resp, std::string method) @@ -43,3 +43,4 @@ std::unique_ptr<Request> Request::multi() { return std::make_unique<Request>(std::make_shared<hbase::pb::MultiRequest>(), std::make_shared<hbase::pb::MultiResponse>(), "Multi"); } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/rpc-client.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/rpc-client.cc b/hbase-native-client/connection/rpc-client.cc index 57df66d..fbbe3e7 100644 --- a/hbase-native-client/connection/rpc-client.cc +++ b/hbase-native-client/connection/rpc-client.cc @@ -25,7 +25,8 @@ #include <memory> #include <string> -using hbase::RpcClient; +using hbase::security::User; +using std::chrono::nanoseconds; namespace hbase { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/rpc-client.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/rpc-client.h b/hbase-native-client/connection/rpc-client.h index fbb773a..8b0abe7 100644 --- a/hbase-native-client/connection/rpc-client.h +++ b/hbase-native-client/connection/rpc-client.h @@ -29,43 +29,32 @@ #include <chrono> #include <utility> -using hbase::security::User; -using hbase::pb::ServerName; -using hbase::Request; -using hbase::Response; -using hbase::ConnectionId; -using hbase::ConnectionPool; -using hbase::RpcConnection; -using hbase::security::User; - -using google::protobuf::Message; -using std::chrono::nanoseconds; - namespace hbase { class RpcClient { public: RpcClient(std::shared_ptr<wangle::IOThreadPoolExecutor> io_executor, std::shared_ptr<Codec> codec, - std::shared_ptr<Configuration> conf, nanoseconds connect_timeout = nanoseconds(0)); + std::shared_ptr<Configuration> conf, + std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); virtual ~RpcClient() { Close(); } virtual std::unique_ptr<Response> SyncCall(const std::string &host, uint16_t port, std::unique_ptr<Request> req, - std::shared_ptr<User> ticket); + std::shared_ptr<security::User> ticket); virtual std::unique_ptr<Response> SyncCall(const std::string &host, uint16_t port, std::unique_ptr<Request> req, - std::shared_ptr<User> ticket, + std::shared_ptr<security::User> ticket, const std::string &service_name); - virtual folly::Future<std::unique_ptr<Response>> AsyncCall(const std::string &host, uint16_t port, - std::unique_ptr<Request> req, - std::shared_ptr<User> ticket); + virtual folly::Future<std::unique_ptr<Response>> AsyncCall( + const std::string &host, uint16_t port, std::unique_ptr<Request> req, + std::shared_ptr<security::User> ticket); virtual folly::Future<std::unique_ptr<Response>> AsyncCall(const std::string &host, uint16_t port, std::unique_ptr<Request> req, - std::shared_ptr<User> ticket, + std::shared_ptr<security::User> ticket, const std::string &service_name); virtual void Close(); http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/rpc-connection.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/rpc-connection.h b/hbase-native-client/connection/rpc-connection.h index c37b1e0..d9966a1 100644 --- a/hbase-native-client/connection/rpc-connection.h +++ b/hbase-native-client/connection/rpc-connection.h @@ -26,9 +26,8 @@ #include <memory> #include <utility> -using hbase::HBaseService; - namespace hbase { + class RpcConnection { public: RpcConnection(std::shared_ptr<ConnectionId> connection_id, http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/connection/sasl-handler.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/connection/sasl-handler.cc b/hbase-native-client/connection/sasl-handler.cc index 02cddce..ea09595 100644 --- a/hbase-native-client/connection/sasl-handler.cc +++ b/hbase-native-client/connection/sasl-handler.cc @@ -134,7 +134,7 @@ folly::Future<folly::Unit> SaslHandler::WriteSaslOutput(Context *ctx, const char return ctx->fireWrite(std::move(iob)); } -void SaslHandler::FinishAuth(Context *ctx, folly::IOBufQueue* bufQueue) { +void SaslHandler::FinishAuth(Context *ctx, folly::IOBufQueue *bufQueue) { std::unique_ptr<folly::IOBuf> iob; if (!bufQueue->empty()) { iob = bufQueue->pop_front(); @@ -183,7 +183,7 @@ folly::Future<folly::Unit> SaslHandler::SaslInit(Context *ctx) { return fut; } -void SaslHandler::ContinueSaslNegotiation(Context *ctx, folly::IOBufQueue* bufQueue) { +void SaslHandler::ContinueSaslNegotiation(Context *ctx, folly::IOBufQueue *bufQueue) { const char *out; unsigned int outlen; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-batch-rpc-retrying-caller.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-batch-rpc-retrying-caller.cc b/hbase-native-client/core/async-batch-rpc-retrying-caller.cc index f3be637..05290f5 100644 --- a/hbase-native-client/core/async-batch-rpc-retrying-caller.cc +++ b/hbase-native-client/core/async-batch-rpc-retrying-caller.cc @@ -24,25 +24,11 @@ using folly::Future; using folly::Promise; using folly::Try; - -using folly::Future; -using folly::Promise; -using folly::Try; -using hbase::Action; -using hbase::LocationCache; -using hbase::MultiResponse; -using hbase::RegionLocation; -using hbase::RegionRequest; -using hbase::RequestConverter; -using hbase::Result; -using hbase::RpcClient; -using hbase::ServerRequest; using hbase::pb::ServerName; using hbase::pb::TableName; using hbase::security::User; using std::chrono::nanoseconds; using std::chrono::milliseconds; -using wangle::CPUThreadPoolExecutor; namespace hbase { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-batch-rpc-retrying-caller.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-batch-rpc-retrying-caller.h b/hbase-native-client/core/async-batch-rpc-retrying-caller.h index 6803a0e..29a0e6a 100644 --- a/hbase-native-client/core/async-batch-rpc-retrying-caller.h +++ b/hbase-native-client/core/async-batch-rpc-retrying-caller.h @@ -65,8 +65,8 @@ namespace hbase { /* Equals function for ServerName */ struct ServerNameEquals { - bool operator()(const std::shared_ptr<ServerName> &lhs, - const std::shared_ptr<ServerName> &rhs) const { + bool operator()(const std::shared_ptr<pb::ServerName> &lhs, + const std::shared_ptr<pb::ServerName> &rhs) const { return (lhs->start_code() == rhs->start_code() && lhs->host_name() == rhs->host_name() && lhs->port() == rhs->port()); } @@ -74,7 +74,7 @@ struct ServerNameEquals { struct ServerNameHash { /** hash */ - std::size_t operator()(const std::shared_ptr<ServerName> &sn) const { + std::size_t operator()(const std::shared_ptr<pb::ServerName> &sn) const { std::size_t h = 0; boost::hash_combine(h, sn->start_code()); boost::hash_combine(h, sn->host_name()); @@ -86,16 +86,18 @@ struct ServerNameHash { class AsyncBatchRpcRetryingCaller { public: using ActionsByServer = - std::unordered_map<std::shared_ptr<ServerName>, std::shared_ptr<ServerRequest>, + std::unordered_map<std::shared_ptr<pb::ServerName>, std::shared_ptr<ServerRequest>, ServerNameHash, ServerNameEquals>; using ActionsByRegion = ServerRequest::ActionsByRegion; AsyncBatchRpcRetryingCaller(std::shared_ptr<AsyncConnection> conn, std::shared_ptr<folly::HHWheelTimer> retry_timer, std::shared_ptr<pb::TableName> table_name, - const std::vector<hbase::Get> &actions, nanoseconds pause_ns, - int32_t max_attempts, nanoseconds operation_timeout_ns, - nanoseconds rpc_timeout_ns, int32_t start_log_errors_count); + const std::vector<hbase::Get> &actions, + std::chrono::nanoseconds pause_ns, int32_t max_attempts, + std::chrono::nanoseconds operation_timeout_ns, + std::chrono::nanoseconds rpc_timeout_ns, + int32_t start_log_errors_count); ~AsyncBatchRpcRetryingCaller(); @@ -106,33 +108,33 @@ class AsyncBatchRpcRetryingCaller { void LogException(int32_t tries, std::shared_ptr<RegionRequest> region_request, std::shared_ptr<std::exception> &error, - std::shared_ptr<ServerName> server_name); + std::shared_ptr<pb::ServerName> server_name); void LogException(int32_t tries, std::vector<std::shared_ptr<RegionRequest>> ®ion_requests, std::shared_ptr<std::exception> &error, - std::shared_ptr<ServerName> server_name); + std::shared_ptr<pb::ServerName> server_name); - const std::string GetExtraContextForError(std::shared_ptr<ServerName> server_name); + const std::string GetExtraContextForError(std::shared_ptr<pb::ServerName> server_name); void AddError(const std::shared_ptr<Action> &action, std::shared_ptr<std::exception> error, - std::shared_ptr<ServerName> server_name); + std::shared_ptr<pb::ServerName> server_name); void AddError(const std::vector<std::shared_ptr<Action>> &actions, - std::shared_ptr<std::exception> error, std::shared_ptr<ServerName> server_name); + std::shared_ptr<std::exception> error, std::shared_ptr<pb::ServerName> server_name); void FailOne(const std::shared_ptr<Action> &action, int32_t tries, std::shared_ptr<std::exception> error, int64_t current_time, const std::string extras); void FailAll(const std::vector<std::shared_ptr<Action>> &actions, int32_t tries, - std::shared_ptr<std::exception> error, std::shared_ptr<ServerName> server_name); + std::shared_ptr<std::exception> error, std::shared_ptr<pb::ServerName> server_name); void FailAll(const std::vector<std::shared_ptr<Action>> &actions, int32_t tries); void AddAction2Error(uint64_t action_index, const ThrowableWithExtraContext &twec); void OnError(const ActionsByRegion &actions_by_region, int32_t tries, - std::shared_ptr<std::exception> exc, std::shared_ptr<ServerName> server_name); + std::shared_ptr<std::exception> exc, std::shared_ptr<pb::ServerName> server_name); void TryResubmit(std::vector<std::shared_ptr<Action>> actions, int32_t tries); @@ -147,12 +149,12 @@ class AsyncBatchRpcRetryingCaller { void Send(ActionsByServer &actions_by_server, int32_t tries); void OnComplete(const ActionsByRegion &actions_by_region, int32_t tries, - const std::shared_ptr<ServerName> server_name, + const std::shared_ptr<pb::ServerName> server_name, const std::unique_ptr<MultiResponse> multi_results); void OnComplete(const std::shared_ptr<Action> &action, const std::shared_ptr<RegionRequest> ®ion_request, int32_t tries, - const std::shared_ptr<ServerName> &server_name, + const std::shared_ptr<pb::ServerName> &server_name, const std::shared_ptr<RegionResult> ®ion_result, std::vector<std::shared_ptr<Action>> &failed_actions); @@ -161,10 +163,10 @@ class AsyncBatchRpcRetryingCaller { std::shared_ptr<hbase::AsyncConnection> conn_; std::shared_ptr<pb::TableName> table_name_; std::vector<std::shared_ptr<Action>> actions_; - nanoseconds pause_ns_; + std::chrono::nanoseconds pause_ns_; int32_t max_attempts_ = 0; - nanoseconds operation_timeout_ns_; - nanoseconds rpc_timeout_ns_; + std::chrono::nanoseconds operation_timeout_ns_; + std::chrono::nanoseconds rpc_timeout_ns_; int32_t start_log_errors_count_ = 0; int64_t start_ns_ = TimeUtil::GetNowNanos(); http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-rpc-retrying-caller-factory.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-rpc-retrying-caller-factory.h b/hbase-native-client/core/async-rpc-retrying-caller-factory.h index f1ffdac..3c11f52 100644 --- a/hbase-native-client/core/async-rpc-retrying-caller-factory.h +++ b/hbase-native-client/core/async-rpc-retrying-caller-factory.h @@ -62,17 +62,17 @@ class SingleRequestCallerBuilder return shared_this(); } - SharedThisPtr rpc_timeout(nanoseconds rpc_timeout_nanos) { + SharedThisPtr rpc_timeout(std::chrono::nanoseconds rpc_timeout_nanos) { rpc_timeout_nanos_ = rpc_timeout_nanos; return shared_this(); } - SharedThisPtr operation_timeout(nanoseconds operation_timeout_nanos) { + SharedThisPtr operation_timeout(std::chrono::nanoseconds operation_timeout_nanos) { operation_timeout_nanos_ = operation_timeout_nanos; return shared_this(); } - SharedThisPtr pause(nanoseconds pause) { + SharedThisPtr pause(std::chrono::nanoseconds pause) { pause_ = pause; return shared_this(); } @@ -119,9 +119,9 @@ class SingleRequestCallerBuilder std::shared_ptr<AsyncConnection> conn_; std::shared_ptr<folly::HHWheelTimer> retry_timer_; std::shared_ptr<pb::TableName> table_name_; - nanoseconds rpc_timeout_nanos_; - nanoseconds operation_timeout_nanos_; - nanoseconds pause_; + std::chrono::nanoseconds rpc_timeout_nanos_; + std::chrono::nanoseconds operation_timeout_nanos_; + std::chrono::nanoseconds pause_; uint32_t max_retries_; uint32_t start_log_errors_count_; std::string row_; @@ -149,17 +149,17 @@ class BatchCallerBuilder : public std::enable_shared_from_this<BatchCallerBuilde return shared_this(); } - SharedThisPtr operation_timeout(nanoseconds operation_timeout_nanos) { + SharedThisPtr operation_timeout(std::chrono::nanoseconds operation_timeout_nanos) { operation_timeout_nanos_ = operation_timeout_nanos; return shared_this(); } - SharedThisPtr rpc_timeout(nanoseconds rpc_timeout_nanos) { + SharedThisPtr rpc_timeout(std::chrono::nanoseconds rpc_timeout_nanos) { rpc_timeout_nanos_ = rpc_timeout_nanos; return shared_this(); } - SharedThisPtr pause(nanoseconds pause_ns) { + SharedThisPtr pause(std::chrono::nanoseconds pause_ns) { pause_ns_ = pause_ns; return shared_this(); } @@ -192,10 +192,10 @@ class BatchCallerBuilder : public std::enable_shared_from_this<BatchCallerBuilde std::shared_ptr<folly::HHWheelTimer> retry_timer_; std::shared_ptr<hbase::pb::TableName> table_name_ = nullptr; std::shared_ptr<std::vector<hbase::Get>> actions_ = nullptr; - nanoseconds pause_ns_; + std::chrono::nanoseconds pause_ns_; int32_t max_attempts_ = 0; - nanoseconds operation_timeout_nanos_; - nanoseconds rpc_timeout_nanos_; + std::chrono::nanoseconds operation_timeout_nanos_; + std::chrono::nanoseconds rpc_timeout_nanos_; int32_t start_log_errors_count_ = 0; }; class AsyncRpcRetryingCallerFactory { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-rpc-retrying-caller.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-rpc-retrying-caller.cc b/hbase-native-client/core/async-rpc-retrying-caller.cc index f8b237b..a2c5f0e 100644 --- a/hbase-native-client/core/async-rpc-retrying-caller.cc +++ b/hbase-native-client/core/async-rpc-retrying-caller.cc @@ -44,9 +44,9 @@ template <typename RESP> AsyncSingleRequestRpcRetryingCaller<RESP>::AsyncSingleRequestRpcRetryingCaller( std::shared_ptr<AsyncConnection> conn, std::shared_ptr<folly::HHWheelTimer> retry_timer, std::shared_ptr<hbase::pb::TableName> table_name, const std::string& row, - RegionLocateType locate_type, Callable<RESP> callable, nanoseconds pause, uint32_t max_retries, - nanoseconds operation_timeout_nanos, nanoseconds rpc_timeout_nanos, - uint32_t start_log_errors_count) + RegionLocateType locate_type, Callable<RESP> callable, std::chrono::nanoseconds pause, + uint32_t max_retries, std::chrono::nanoseconds operation_timeout_nanos, + std::chrono::nanoseconds rpc_timeout_nanos, uint32_t start_log_errors_count) : conn_(conn), retry_timer_(retry_timer), table_name_(table_name), @@ -144,7 +144,7 @@ void AsyncSingleRequestRpcRetryingCaller<RESP>::OnError( conn_->retry_executor()->add([&]() { retry_timer_->scheduleTimeoutFn( [this]() { conn_->cpu_executor()->add([&]() { LocateThenCall(); }); }, - milliseconds(TimeUtil::ToMillis(delay_ns))); + std::chrono::milliseconds(TimeUtil::ToMillis(delay_ns))); }); } @@ -212,8 +212,8 @@ void AsyncSingleRequestRpcRetryingCaller<RESP>::ResetController( std::shared_ptr<HBaseRpcController> controller, const int64_t& timeout_ns) { controller->Reset(); if (timeout_ns >= 0) { - controller->set_call_timeout( - milliseconds(std::min(static_cast<int64_t>(INT_MAX), TimeUtil::ToMillis(timeout_ns)))); + controller->set_call_timeout(std::chrono::milliseconds( + std::min(static_cast<int64_t>(INT_MAX), TimeUtil::ToMillis(timeout_ns)))); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-rpc-retrying-caller.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-rpc-retrying-caller.h b/hbase-native-client/core/async-rpc-retrying-caller.h index c86ad0b5..fa3c288 100644 --- a/hbase-native-client/core/async-rpc-retrying-caller.h +++ b/hbase-native-client/core/async-rpc-retrying-caller.h @@ -37,9 +37,6 @@ #include "exceptions/exception.h" #include "if/HBase.pb.h" -using std::chrono::nanoseconds; -using std::chrono::milliseconds; - namespace hbase { template <typename T> @@ -70,14 +67,12 @@ using Callable = template <typename RESP> class AsyncSingleRequestRpcRetryingCaller { public: - AsyncSingleRequestRpcRetryingCaller(std::shared_ptr<AsyncConnection> conn, - std::shared_ptr<folly::HHWheelTimer> retry_timer, - std::shared_ptr<hbase::pb::TableName> table_name, - const std::string& row, RegionLocateType locate_type, - Callable<RESP> callable, nanoseconds pause, - uint32_t max_retries, nanoseconds operation_timeout_nanos, - nanoseconds rpc_timeout_nanos, - uint32_t start_log_errors_count); + AsyncSingleRequestRpcRetryingCaller( + std::shared_ptr<AsyncConnection> conn, std::shared_ptr<folly::HHWheelTimer> retry_timer, + std::shared_ptr<hbase::pb::TableName> table_name, const std::string& row, + RegionLocateType locate_type, Callable<RESP> callable, std::chrono::nanoseconds pause, + uint32_t max_retries, std::chrono::nanoseconds operation_timeout_nanos, + std::chrono::nanoseconds rpc_timeout_nanos, uint32_t start_log_errors_count); virtual ~AsyncSingleRequestRpcRetryingCaller(); @@ -107,10 +102,10 @@ class AsyncSingleRequestRpcRetryingCaller { std::string row_; RegionLocateType locate_type_; Callable<RESP> callable_; - nanoseconds pause_; + std::chrono::nanoseconds pause_; uint32_t max_retries_; - nanoseconds operation_timeout_nanos_; - nanoseconds rpc_timeout_nanos_; + std::chrono::nanoseconds operation_timeout_nanos_; + std::chrono::nanoseconds rpc_timeout_nanos_; uint32_t start_log_errors_count_; std::shared_ptr<folly::Promise<RESP>> promise_; std::shared_ptr<HBaseRpcController> controller_; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/async-rpc-retrying-test.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/async-rpc-retrying-test.cc b/hbase-native-client/core/async-rpc-retrying-test.cc index 11750eb..0f83914 100644 --- a/hbase-native-client/core/async-rpc-retrying-test.cc +++ b/hbase-native-client/core/async-rpc-retrying-test.cc @@ -66,6 +66,7 @@ using hbase::RespConverter; using hbase::Put; using hbase::TimeUtil; using hbase::Client; +using hbase::security::User; using ::testing::Return; using ::testing::_; @@ -350,7 +351,7 @@ void runTest(std::shared_ptr<AsyncRegionLocatorBase> region_locator, std::string /* call with retry to get result */ auto async_caller = - builder->table(std::make_shared<TableName>(tn)) + builder->table(std::make_shared<hbase::pb::TableName>(tn)) ->row(row) ->rpc_timeout(conn->connection_conf()->read_rpc_timeout()) ->operation_timeout(conn->connection_conf()->operation_timeout()) http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/client.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/client.cc b/hbase-native-client/core/client.cc index 0053e19..e23aeae 100644 --- a/hbase-native-client/core/client.cc +++ b/hbase-native-client/core/client.cc @@ -25,6 +25,8 @@ #include <memory> #include <utility> +using hbase::pb::TableName; + namespace hbase { Client::Client() { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/client.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/client.h b/hbase-native-client/core/client.h index 2719470..5563a15 100644 --- a/hbase-native-client/core/client.h +++ b/hbase-native-client/core/client.h @@ -29,9 +29,8 @@ #include "core/table.h" #include "serde/table-name.h" -using hbase::pb::TableName; - namespace hbase { + class Table; /** * Client. @@ -54,7 +53,7 @@ class Client { * @brief Retrieve a Table implementation for accessing a table. * @param - table_name */ - std::unique_ptr<::hbase::Table> Table(const TableName& table_name); + std::unique_ptr<::hbase::Table> Table(const pb::TableName& table_name); /** * @brief Close the Client connection. http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/connection-configuration.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/connection-configuration.h b/hbase-native-client/core/connection-configuration.h index c6d1d60..adc8d5b 100644 --- a/hbase-native-client/core/connection-configuration.h +++ b/hbase-native-client/core/connection-configuration.h @@ -25,9 +25,6 @@ #include "core/configuration.h" -using std::chrono::nanoseconds; -using std::chrono::milliseconds; - namespace hbase { /** @@ -57,9 +54,10 @@ class ConnectionConfiguration { } // Used by tests - ConnectionConfiguration(nanoseconds connect_timeout, nanoseconds operation_timeout, - nanoseconds rpc_timeout, nanoseconds pause, uint32_t max_retries, - uint32_t start_log_errors_count) + ConnectionConfiguration(std::chrono::nanoseconds connect_timeout, + std::chrono::nanoseconds operation_timeout, + std::chrono::nanoseconds rpc_timeout, std::chrono::nanoseconds pause, + uint32_t max_retries, uint32_t start_log_errors_count) : connect_timeout_(connect_timeout), operation_timeout_(operation_timeout), meta_operation_timeout_(operation_timeout), @@ -70,25 +68,25 @@ class ConnectionConfiguration { max_retries_(max_retries), start_log_errors_count_(start_log_errors_count) {} - nanoseconds connect_timeout() const { return connect_timeout_; } + std::chrono::nanoseconds connect_timeout() const { return connect_timeout_; } - nanoseconds meta_operation_timeout() const { return meta_operation_timeout_; } + std::chrono::nanoseconds meta_operation_timeout() const { return meta_operation_timeout_; } // timeout for a whole operation such as get, put or delete. Notice that scan will not be effected // by this value, see scanTimeoutNs. - nanoseconds operation_timeout() const { return operation_timeout_; } + std::chrono::nanoseconds operation_timeout() const { return operation_timeout_; } // timeout for each rpc request. Can be overridden by a more specific config, such as // readRpcTimeout or writeRpcTimeout. - nanoseconds rpc_timeout() const { return rpc_timeout_; } + std::chrono::nanoseconds rpc_timeout() const { return rpc_timeout_; } // timeout for each read rpc request - nanoseconds read_rpc_timeout() const { return read_rpc_timeout_; } + std::chrono::nanoseconds read_rpc_timeout() const { return read_rpc_timeout_; } // timeout for each write rpc request - nanoseconds write_rpc_timeout() const { return write_rpc_timeout_; } + std::chrono::nanoseconds write_rpc_timeout() const { return write_rpc_timeout_; } - nanoseconds pause() const { return pause_; } + std::chrono::nanoseconds pause() const { return pause_; } uint32_t max_retries() const { return max_retries_; } @@ -97,7 +95,7 @@ class ConnectionConfiguration { // The scan timeout is used as operation timeout for every // operations in a scan, such as openScanner or next. - nanoseconds scan_timeout() const { return scan_timeout_; } + std::chrono::nanoseconds scan_timeout() const { return scan_timeout_; } uint32_t scanner_caching() const { return scanner_caching_; } @@ -184,25 +182,25 @@ class ConnectionConfiguration { */ static constexpr const uint64_t kDefaultClientScannerMaxResultsSize = 2 * 1024 * 1024; - nanoseconds connect_timeout_; - nanoseconds meta_operation_timeout_; - nanoseconds operation_timeout_; - nanoseconds rpc_timeout_; - nanoseconds read_rpc_timeout_; - nanoseconds write_rpc_timeout_; - nanoseconds pause_; + std::chrono::nanoseconds connect_timeout_; + std::chrono::nanoseconds meta_operation_timeout_; + std::chrono::nanoseconds operation_timeout_; + std::chrono::nanoseconds rpc_timeout_; + std::chrono::nanoseconds read_rpc_timeout_; + std::chrono::nanoseconds write_rpc_timeout_; + std::chrono::nanoseconds pause_; uint32_t max_retries_; uint32_t start_log_errors_count_; - nanoseconds scan_timeout_; + std::chrono::nanoseconds scan_timeout_; uint32_t scanner_caching_; uint64_t scanner_max_result_size_; - static nanoseconds ToNanos(const uint64_t& millis) { - return std::chrono::duration_cast<nanoseconds>(milliseconds(millis)); + static std::chrono::nanoseconds ToNanos(const uint64_t& millis) { + return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(millis)); } - static uint64_t ToMillis(const nanoseconds& nanos) { - return std::chrono::duration_cast<milliseconds>(nanos).count(); + static uint64_t ToMillis(const std::chrono::nanoseconds& nanos) { + return std::chrono::duration_cast<std::chrono::milliseconds>(nanos).count(); } }; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/filter.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/filter.h b/hbase-native-client/core/filter.h index 10accaa..1e870f9 100644 --- a/hbase-native-client/core/filter.h +++ b/hbase-native-client/core/filter.h @@ -29,8 +29,6 @@ #include "if/Filter.pb.h" #include "if/HBase.pb.h" -using google::protobuf::Message; - namespace hbase { /** @@ -59,13 +57,13 @@ namespace hbase { */ class Filter { public: - Filter(std::string java_class_name, std::unique_ptr<Message> data) + Filter(std::string java_class_name, std::unique_ptr<google::protobuf::Message> data) : java_class_name_(java_class_name), data_(std::move(data)) {} virtual ~Filter() {} const std::string java_class_name() const { return java_class_name_; } - const Message& data() const { return *data_; } + const google::protobuf::Message& data() const { return *data_; } /** * Serialize the filter data to the given buffer. Does protobuf encoding by default. * Can be overriden if Filter does not use protobuf. @@ -85,7 +83,7 @@ class Filter { } private: - std::unique_ptr<Message> data_; + std::unique_ptr<google::protobuf::Message> data_; std::string java_class_name_; }; @@ -94,7 +92,7 @@ class Filter { */ class Comparator { public: - Comparator(std::string java_class_name, std::unique_ptr<Message> data) + Comparator(std::string java_class_name, std::unique_ptr<google::protobuf::Message> data) : java_class_name_(java_class_name), data_(std::move(data)) {} virtual ~Comparator() {} @@ -119,7 +117,7 @@ class Comparator { } private: - std::unique_ptr<Message> data_; + std::unique_ptr<google::protobuf::Message> data_; std::string java_class_name_; }; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/get.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/get.h b/hbase-native-client/core/get.h index 098635d..c4cddfb 100644 --- a/hbase-native-client/core/get.h +++ b/hbase-native-client/core/get.h @@ -29,7 +29,6 @@ #include "core/time-range.h" #include "if/Client.pb.h" -using hbase::Row; namespace hbase { class Get : public Row, public Query { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/hbase-rpc-controller.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/hbase-rpc-controller.h b/hbase-native-client/core/hbase-rpc-controller.h index 661c810..9bb89b9 100644 --- a/hbase-native-client/core/hbase-rpc-controller.h +++ b/hbase-native-client/core/hbase-rpc-controller.h @@ -22,19 +22,14 @@ #include <chrono> #include <string> -using google::protobuf::RpcController; -using google::protobuf::Closure; - -using std::chrono::milliseconds; - namespace hbase { -class HBaseRpcController : public RpcController { +class HBaseRpcController : public google::protobuf::RpcController { public: HBaseRpcController() {} virtual ~HBaseRpcController() = default; - void set_call_timeout(const milliseconds& call_timeout) { + void set_call_timeout(const std::chrono::milliseconds& call_timeout) { // TODO: } @@ -50,7 +45,7 @@ class HBaseRpcController : public RpcController { bool IsCanceled() const override { return false; } - void NotifyOnCancel(Closure* callback) override {} + void NotifyOnCancel(google::protobuf::Closure* callback) override {} }; } /* namespace hbase */ http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/location-cache.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/location-cache.cc b/hbase-native-client/core/location-cache.cc index e0afcfb..d368314 100644 --- a/hbase-native-client/core/location-cache.cc +++ b/hbase-native-client/core/location-cache.cc @@ -35,22 +35,11 @@ #include <utility> -using namespace std; -using namespace folly; -using hbase::RpcConnection; - -using wangle::ServiceFilter; -using hbase::Request; -using hbase::Response; -using hbase::LocationCache; -using hbase::RegionLocation; -using hbase::HBaseService; -using hbase::ConnectionPool; -using hbase::pb::ScanResponse; -using hbase::pb::TableName; -using hbase::pb::ServerName; using hbase::pb::MetaRegionServer; -using hbase::pb::RegionInfo; +using hbase::pb::ServerName; +using hbase::pb::TableName; + +namespace hbase { LocationCache::LocationCache(std::shared_ptr<hbase::Configuration> conf, std::shared_ptr<wangle::CPUThreadPoolExecutor> cpu_executor, @@ -74,8 +63,8 @@ LocationCache::~LocationCache() { LOG(INFO) << "Closed connection to ZooKeeper."; } -Future<ServerName> LocationCache::LocateMeta() { - lock_guard<mutex> g(meta_lock_); +folly::Future<ServerName> LocationCache::LocateMeta() { + std::lock_guard<std::mutex> g(meta_lock_); if (meta_promise_ == nullptr) { this->RefreshMetaLocation(); } @@ -84,19 +73,19 @@ Future<ServerName> LocationCache::LocateMeta() { void LocationCache::InvalidateMeta() { if (meta_promise_ != nullptr) { - lock_guard<mutex> g(meta_lock_); + std::lock_guard<std::mutex> g(meta_lock_); meta_promise_ = nullptr; } } /// MUST hold the meta_lock_ void LocationCache::RefreshMetaLocation() { - meta_promise_ = make_unique<SharedPromise<ServerName>>(); + meta_promise_ = std::make_unique<folly::SharedPromise<ServerName>>(); cpu_executor_->add([&] { meta_promise_->setWith([&] { return this->ReadMetaLocation(); }); }); } ServerName LocationCache::ReadMetaLocation() { - auto buf = IOBuf::create(4096); + auto buf = folly::IOBuf::create(4096); ZkDeserializer derser; // This needs to be int rather than size_t as that's what ZK expects. @@ -107,7 +96,7 @@ ServerName LocationCache::ReadMetaLocation() { reinterpret_cast<char *>(buf->writableData()), &len, nullptr); if (zk_result != ZOK || len < 9) { LOG(ERROR) << "Error getting meta location."; - throw runtime_error("Error getting meta location. Quorum: " + zk_quorum_); + throw std::runtime_error("Error getting meta location. Quorum: " + zk_quorum_); } buf->append(len); @@ -118,8 +107,8 @@ ServerName LocationCache::ReadMetaLocation() { return mrs.server(); } -Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta(const TableName &tn, - const string &row) { +folly::Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta( + const TableName &tn, const std::string &row) { return this->LocateMeta() .via(cpu_executor_.get()) .then([this](ServerName sn) { @@ -150,17 +139,16 @@ Future<std::shared_ptr<RegionLocation>> LocationCache::LocateFromMeta(const Tabl // assertion errors return rl; }) - .then([tn, this](shared_ptr<RegionLocation> rl) { + .then([tn, this](std::shared_ptr<RegionLocation> rl) { // now add fetched location to the cache. this->CacheLocation(tn, rl); return rl; }); } -Future<shared_ptr<RegionLocation>> LocationCache::LocateRegion(const hbase::pb::TableName &tn, - const std::string &row, - const RegionLocateType locate_type, - const int64_t locate_ns) { +folly::Future<std::shared_ptr<RegionLocation>> LocationCache::LocateRegion( + const TableName &tn, const std::string &row, const RegionLocateType locate_type, + const int64_t locate_ns) { // TODO: implement region locate type and timeout auto cached_loc = this->GetCachedLocation(tn, row); if (cached_loc != nullptr) { @@ -171,8 +159,8 @@ Future<shared_ptr<RegionLocation>> LocationCache::LocateRegion(const hbase::pb:: } // must hold shared lock on locations_lock_ -shared_ptr<RegionLocation> LocationCache::GetCachedLocation(const hbase::pb::TableName &tn, - const std::string &row) { +std::shared_ptr<RegionLocation> LocationCache::GetCachedLocation(const hbase::pb::TableName &tn, + const std::string &row) { auto t_locs = this->GetTableLocations(tn); std::shared_lock<folly::SharedMutexWritePriority> lock(locations_lock_); @@ -213,7 +201,7 @@ shared_ptr<RegionLocation> LocationCache::GetCachedLocation(const hbase::pb::Tab // must hold unique lock on locations_lock_ void LocationCache::CacheLocation(const hbase::pb::TableName &tn, - const shared_ptr<RegionLocation> loc) { + const std::shared_ptr<RegionLocation> loc) { auto t_locs = this->GetTableLocations(tn); std::unique_lock<folly::SharedMutexWritePriority> lock(locations_lock_); @@ -228,7 +216,7 @@ bool LocationCache::IsLocationCached(const hbase::pb::TableName &tn, const std:: // shared lock needed for cases when this table has been requested before; // in the rare case it hasn't, unique lock will be grabbed to add it to cache -shared_ptr<hbase::PerTableLocationMap> LocationCache::GetTableLocations( +std::shared_ptr<hbase::PerTableLocationMap> LocationCache::GetTableLocations( const hbase::pb::TableName &tn) { auto found_locs = this->GetCachedTableLocations(tn); if (found_locs == nullptr) { @@ -237,9 +225,9 @@ shared_ptr<hbase::PerTableLocationMap> LocationCache::GetTableLocations( return found_locs; } -shared_ptr<hbase::PerTableLocationMap> LocationCache::GetCachedTableLocations( +std::shared_ptr<hbase::PerTableLocationMap> LocationCache::GetCachedTableLocations( const hbase::pb::TableName &tn) { - SharedMutexWritePriority::ReadHolder r_holder{locations_lock_}; + folly::SharedMutexWritePriority::ReadHolder r_holder{locations_lock_}; auto table_locs = cached_locations_.find(tn); if (table_locs != cached_locations_.end()) { @@ -249,38 +237,38 @@ shared_ptr<hbase::PerTableLocationMap> LocationCache::GetCachedTableLocations( } } -shared_ptr<hbase::PerTableLocationMap> LocationCache::GetNewTableLocations( +std::shared_ptr<hbase::PerTableLocationMap> LocationCache::GetNewTableLocations( const hbase::pb::TableName &tn) { // double-check locking under upgradable lock - SharedMutexWritePriority::UpgradeHolder u_holder{locations_lock_}; + folly::SharedMutexWritePriority::UpgradeHolder u_holder{locations_lock_}; auto table_locs = cached_locations_.find(tn); if (table_locs != cached_locations_.end()) { return table_locs->second; } - SharedMutexWritePriority::WriteHolder w_holder{std::move(u_holder)}; + folly::SharedMutexWritePriority::WriteHolder w_holder{std::move(u_holder)}; - auto t_locs_p = make_shared<map<std::string, shared_ptr<RegionLocation>>>(); + auto t_locs_p = std::make_shared<std::map<std::string, std::shared_ptr<RegionLocation>>>(); cached_locations_.insert(std::make_pair(tn, t_locs_p)); return t_locs_p; } // must hold unique lock on locations_lock_ void LocationCache::ClearCache() { - unique_lock<SharedMutexWritePriority> lock(locations_lock_); + std::unique_lock<folly::SharedMutexWritePriority> lock(locations_lock_); cached_locations_.clear(); } // must hold unique lock on locations_lock_ void LocationCache::ClearCachedLocations(const hbase::pb::TableName &tn) { - unique_lock<SharedMutexWritePriority> lock(locations_lock_); + std::unique_lock<folly::SharedMutexWritePriority> lock(locations_lock_); cached_locations_.erase(tn); } // must hold unique lock on locations_lock_ void LocationCache::ClearCachedLocation(const hbase::pb::TableName &tn, const std::string &row) { auto table_locs = this->GetTableLocations(tn); - unique_lock<folly::SharedMutexWritePriority> lock(locations_lock_); + std::unique_lock<folly::SharedMutexWritePriority> lock(locations_lock_); table_locs->erase(row); } @@ -289,3 +277,4 @@ void LocationCache::UpdateCachedLocation(const RegionLocation &loc, // TODO: just clears the location for now. We can inspect RegionMovedExceptions, etc later. ClearCachedLocation(loc.region_info().table_name(), loc.region_info().start_key()); } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/meta-utils.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/meta-utils.cc b/hbase-native-client/core/meta-utils.cc index 119520f..0577bfc 100644 --- a/hbase-native-client/core/meta-utils.cc +++ b/hbase-native-client/core/meta-utils.cc @@ -31,14 +31,12 @@ #include "serde/table-name.h" using hbase::pb::TableName; -using hbase::MetaUtil; -using hbase::Request; -using hbase::Response; -using hbase::RegionLocation; using hbase::pb::RegionInfo; +using hbase::pb::RegionSpecifier_RegionSpecifierType; using hbase::pb::ScanRequest; using hbase::pb::ServerName; -using hbase::pb::RegionSpecifier_RegionSpecifierType; + +namespace hbase { static const std::string META_REGION = "1588230740"; static const std::string CATALOG_FAMILY = "info"; @@ -113,3 +111,4 @@ std::shared_ptr<RegionLocation> MetaUtil::CreateLocation(const Response &resp) { auto server_name = folly::to<ServerName>(*server_str); return std::make_shared<RegionLocation>(row, std::move(region_info), server_name, nullptr); } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/multi-response.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/multi-response.cc b/hbase-native-client/core/multi-response.cc index 562f3b6..f620c98 100644 --- a/hbase-native-client/core/multi-response.cc +++ b/hbase-native-client/core/multi-response.cc @@ -20,6 +20,8 @@ #include "core/multi-response.h" #include "core/region-result.h" +using hbase::pb::RegionLoadStats; + namespace hbase { MultiResponse::MultiResponse() {} http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/multi-response.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/multi-response.h b/hbase-native-client/core/multi-response.h index cebd2b7..96883fd 100644 --- a/hbase-native-client/core/multi-response.h +++ b/hbase-native-client/core/multi-response.h @@ -28,10 +28,6 @@ #include "core/result.h" #include "if/Client.pb.h" -using hbase::RegionResult; -using hbase::Result; -using hbase::pb::RegionLoadStats; - namespace hbase { class MultiResponse { @@ -62,7 +58,7 @@ class MultiResponse { const std::map<std::string, std::shared_ptr<std::exception>>& RegionExceptions() const; - void AddStatistic(const std::string& region_name, std::shared_ptr<RegionLoadStats> stat); + void AddStatistic(const std::string& region_name, std::shared_ptr<pb::RegionLoadStats> stat); const std::map<std::string, std::shared_ptr<RegionResult>>& RegionResults() const; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/raw-async-table.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/raw-async-table.cc b/hbase-native-client/core/raw-async-table.cc index 9e0d4a3..1a66a04 100644 --- a/hbase-native-client/core/raw-async-table.cc +++ b/hbase-native-client/core/raw-async-table.cc @@ -22,11 +22,13 @@ #include "core/request-converter.h" #include "core/response-converter.h" +using hbase::security::User; + namespace hbase { template <typename RESP> std::shared_ptr<SingleRequestCallerBuilder<RESP>> RawAsyncTable::CreateCallerBuilder( - std::string row, nanoseconds rpc_timeout) { + std::string row, std::chrono::nanoseconds rpc_timeout) { return connection_->caller_factory() ->Single<RESP>() ->table(table_name_) @@ -54,7 +56,7 @@ folly::Future<RESP> RawAsyncTable::Call( [resp_converter](const std::unique_ptr<PRESP>& presp) { return resp_converter(*presp); }); } -Future<std::shared_ptr<Result>> RawAsyncTable::Get(const hbase::Get& get) { +folly::Future<std::shared_ptr<Result>> RawAsyncTable::Get(const hbase::Get& get) { auto caller = CreateCallerBuilder<std::shared_ptr<Result>>(get.row(), connection_conf_->read_rpc_timeout()) ->action([=, &get](std::shared_ptr<hbase::HBaseRpcController> controller, @@ -76,27 +78,28 @@ Future<std::shared_ptr<Result>> RawAsyncTable::Get(const hbase::Get& get) { return caller->Call().then([caller](const auto r) { return r; }); } -Future<Unit> RawAsyncTable::Put(const hbase::Put& put) { +folly::Future<folly::Unit> RawAsyncTable::Put(const hbase::Put& put) { auto caller = - CreateCallerBuilder<Unit>(put.row(), connection_conf_->write_rpc_timeout()) - ->action([=, &put](std::shared_ptr<hbase::HBaseRpcController> controller, - std::shared_ptr<hbase::RegionLocation> loc, - std::shared_ptr<hbase::RpcClient> rpc_client) -> folly::Future<Unit> { - return Call<hbase::Put, hbase::Request, hbase::Response, Unit>( + CreateCallerBuilder<folly::Unit>(put.row(), connection_conf_->write_rpc_timeout()) + ->action([=, &put]( + std::shared_ptr<hbase::HBaseRpcController> controller, + std::shared_ptr<hbase::RegionLocation> loc, + std::shared_ptr<hbase::RpcClient> rpc_client) -> folly::Future<folly::Unit> { + return Call<hbase::Put, hbase::Request, hbase::Response, folly::Unit>( rpc_client, controller, loc, put, &hbase::RequestConverter::ToMutateRequest, - [](const Response& r) -> Unit { return folly::unit; }); + [](const Response& r) -> folly::Unit { return folly::unit; }); }) ->Build(); return caller->Call().then([caller](const auto r) { return r; }); } -Future<std::vector<Try<std::shared_ptr<Result>>>> RawAsyncTable::Get( +folly::Future<std::vector<folly::Try<std::shared_ptr<Result>>>> RawAsyncTable::Get( const std::vector<hbase::Get>& gets) { return this->Batch(gets); } -Future<std::vector<Try<std::shared_ptr<Result>>>> RawAsyncTable::Batch( +folly::Future<std::vector<folly::Try<std::shared_ptr<Result>>>> RawAsyncTable::Batch( const std::vector<hbase::Get>& gets) { auto caller = connection_->caller_factory() ->Batch() http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/raw-async-table.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/raw-async-table.h b/hbase-native-client/core/raw-async-table.h index e26d46e..9d9ed91 100644 --- a/hbase-native-client/core/raw-async-table.h +++ b/hbase-native-client/core/raw-async-table.h @@ -33,13 +33,6 @@ #include "core/put.h" #include "core/result.h" -using folly::Future; -using folly::Try; -using folly::Unit; -using hbase::pb::TableName; -using std::chrono::nanoseconds; -using std::chrono::milliseconds; - namespace hbase { /** @@ -48,26 +41,29 @@ namespace hbase { */ class RawAsyncTable { public: - RawAsyncTable(std::shared_ptr<TableName> table_name, std::shared_ptr<AsyncConnection> connection) + RawAsyncTable(std::shared_ptr<pb::TableName> table_name, + std::shared_ptr<AsyncConnection> connection) : connection_(connection), connection_conf_(connection->connection_conf()), table_name_(table_name), rpc_client_(connection->rpc_client()) {} virtual ~RawAsyncTable() = default; - Future<std::shared_ptr<Result>> Get(const hbase::Get& get); + folly::Future<std::shared_ptr<Result>> Get(const hbase::Get& get); - Future<Unit> Put(const hbase::Put& put); + folly::Future<folly::Unit> Put(const hbase::Put& put); void Close() {} - Future<std::vector<Try<std::shared_ptr<Result>>>> Get(const std::vector<hbase::Get>& gets); - Future<std::vector<Try<std::shared_ptr<Result>>>> Batch(const std::vector<hbase::Get>& gets); + folly::Future<std::vector<folly::Try<std::shared_ptr<Result>>>> Get( + const std::vector<hbase::Get>& gets); + folly::Future<std::vector<folly::Try<std::shared_ptr<Result>>>> Batch( + const std::vector<hbase::Get>& gets); private: /* Data */ std::shared_ptr<AsyncConnection> connection_; std::shared_ptr<ConnectionConfiguration> connection_conf_; - std::shared_ptr<TableName> table_name_; + std::shared_ptr<pb::TableName> table_name_; std::shared_ptr<RpcClient> rpc_client_; /* Methods */ @@ -79,7 +75,7 @@ class RawAsyncTable { const RespConverter<RESP, PRESP> resp_converter); template <typename RESP> - std::shared_ptr<SingleRequestCallerBuilder<RESP>> CreateCallerBuilder(std::string row, - nanoseconds rpc_timeout); + std::shared_ptr<SingleRequestCallerBuilder<RESP>> CreateCallerBuilder( + std::string row, std::chrono::nanoseconds rpc_timeout); }; } // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/region-request.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/region-request.h b/hbase-native-client/core/region-request.h index 7ce7c96..aded3a9 100644 --- a/hbase-native-client/core/region-request.h +++ b/hbase-native-client/core/region-request.h @@ -18,13 +18,13 @@ */ #pragma once + #include <memory> #include <queue> #include <vector> #include "core/action.h" #include "core/region-location.h" -using hbase::Action; namespace hbase { class RegionRequest { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/region-result.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/region-result.cc b/hbase-native-client/core/region-result.cc index d9ab942..05ab274 100644 --- a/hbase-native-client/core/region-result.cc +++ b/hbase-native-client/core/region-result.cc @@ -21,7 +21,6 @@ #include <glog/logging.h> #include <stdexcept> -using hbase::Result; using hbase::pb::RegionLoadStats; namespace hbase { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/region-result.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/region-result.h b/hbase-native-client/core/region-result.h index 9b7ca03..cfd9e5a 100644 --- a/hbase-native-client/core/region-result.h +++ b/hbase-native-client/core/region-result.h @@ -26,30 +26,29 @@ #include "core/result.h" #include "if/Client.pb.h" -using hbase::Result; -using hbase::pb::RegionLoadStats; - namespace hbase { + using ResultOrExceptionTuple = std::tuple<std::shared_ptr<hbase::Result>, std::shared_ptr<std::exception>>; + class RegionResult { public: RegionResult(); void AddResultOrException(int32_t index, std::shared_ptr<hbase::Result> result, std::shared_ptr<std::exception> exc); - void set_stat(std::shared_ptr<RegionLoadStats> stat); + void set_stat(std::shared_ptr<pb::RegionLoadStats> stat); int ResultOrExceptionSize() const; std::shared_ptr<ResultOrExceptionTuple> ResultOrException(int32_t index) const; - const std::shared_ptr<RegionLoadStats>& stat() const; + const std::shared_ptr<pb::RegionLoadStats>& stat() const; ~RegionResult(); private: std::map<int, ResultOrExceptionTuple> result_or_excption_; - std::shared_ptr<RegionLoadStats> stat_; + std::shared_ptr<pb::RegionLoadStats> stat_; }; } /* namespace hbase */ http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/request-converter.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/request-converter.cc b/hbase-native-client/core/request-converter.cc index c90e1ab..eb293f5 100644 --- a/hbase-native-client/core/request-converter.cc +++ b/hbase-native-client/core/request-converter.cc @@ -24,8 +24,8 @@ #include <utility> #include "if/Client.pb.h" -using hbase::Request; using hbase::pb::GetRequest; +using hbase::pb::MutationProto; using hbase::pb::RegionAction; using hbase::pb::RegionSpecifier; using hbase::pb::RegionSpecifier_RegionSpecifierType; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/request-converter.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/request-converter.h b/hbase-native-client/core/request-converter.h index 6861604..b604d18 100644 --- a/hbase-native-client/core/request-converter.h +++ b/hbase-native-client/core/request-converter.h @@ -34,11 +34,6 @@ #include "if/Client.pb.h" #include "if/HBase.pb.h" -using hbase::pb::MutationProto; -using hbase::pb::RegionAction; -using hbase::pb::RegionSpecifier; -using hbase::pb::ServerName; -using hbase::ServerRequest; using MutationType = hbase::pb::MutationProto_MutationType; using DeleteType = hbase::pb::MutationProto_DeleteType; @@ -73,8 +68,9 @@ class RequestConverter { static std::unique_ptr<Request> ToMutateRequest(const Put &put, const std::string ®ion_name); - static std::unique_ptr<MutationProto> ToMutation(const MutationType type, - const Mutation &mutation, const int64_t nonce); + static std::unique_ptr<pb::MutationProto> ToMutation(const MutationType type, + const Mutation &mutation, + const int64_t nonce); private: // Constructor not required. We have all static methods to create PB requests. @@ -86,7 +82,7 @@ class RequestConverter { * @param region_specifier - RegionSpecifier to be filled and passed in PB * Request. */ - static void SetRegion(const std::string ®ion_name, RegionSpecifier *region_specifier); + static void SetRegion(const std::string ®ion_name, pb::RegionSpecifier *region_specifier); static std::unique_ptr<hbase::pb::Get> ToGet(const Get &get); static DeleteType ToDeleteType(const CellType type); static bool IsDelete(const CellType type); http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/response-converter.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/response-converter.h b/hbase-native-client/core/response-converter.h index a5095fd..443527d 100644 --- a/hbase-native-client/core/response-converter.h +++ b/hbase-native-client/core/response-converter.h @@ -28,8 +28,6 @@ #include "if/Client.pb.h" #include "serde/cell-scanner.h" -using hbase::Request; -using hbase::Response; namespace hbase { /** http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/server-request.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/server-request.h b/hbase-native-client/core/server-request.h index 827b2e7..7f31c2b 100644 --- a/hbase-native-client/core/server-request.h +++ b/hbase-native-client/core/server-request.h @@ -27,9 +27,6 @@ #include "core/region-location.h" #include "core/region-request.h" -using hbase::Action; -using hbase::RegionRequest; - namespace hbase { class ServerRequest { http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/core/table.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/core/table.h b/hbase-native-client/core/table.h index 142baae..0ee8312 100644 --- a/hbase-native-client/core/table.h +++ b/hbase-native-client/core/table.h @@ -35,9 +35,8 @@ #include "core/result.h" #include "serde/table-name.h" -using hbase::pb::TableName; - namespace hbase { + class Client; class Table { @@ -45,7 +44,7 @@ class Table { /** * Constructors */ - Table(const TableName &table_name, std::shared_ptr<AsyncConnection> async_connection); + Table(const pb::TableName &table_name, std::shared_ptr<AsyncConnection> async_connection); ~Table(); /** @@ -75,12 +74,12 @@ class Table { std::shared_ptr<RegionLocation> GetRegionLocation(const std::string &row); private: - std::shared_ptr<TableName> table_name_; + std::shared_ptr<pb::TableName> table_name_; std::shared_ptr<AsyncConnection> async_connection_; std::shared_ptr<hbase::Configuration> conf_; std::unique_ptr<RawAsyncTable> async_table_; private: - milliseconds operation_timeout() const; + std::chrono::milliseconds operation_timeout() const; }; } /* namespace hbase */ http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/exceptions/exception.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/exceptions/exception.h b/hbase-native-client/exceptions/exception.h index 2943d57..f25fbea 100644 --- a/hbase-native-client/exceptions/exception.h +++ b/hbase-native-client/exceptions/exception.h @@ -80,7 +80,8 @@ public: std::shared_ptr<std::vector<ThrowableWithExtraContext>> exceptions) : IOException( GetMessage(num_retries, exceptions), - exceptions->empty() ? folly::exception_wrapper{} : (*exceptions)[exceptions->size() - 1].cause()){ + exceptions->empty() ? folly::exception_wrapper{} + : (*exceptions)[exceptions->size() - 1].cause()){ } virtual ~RetriesExhaustedException() = default; http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/serde/rpc.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/serde/rpc.cc b/hbase-native-client/serde/rpc.cc index 968cd5b..957a317 100644 --- a/hbase-native-client/serde/rpc.cc +++ b/hbase-native-client/serde/rpc.cc @@ -32,19 +32,16 @@ #include "if/RPC.pb.h" #include "utils/version.h" -using namespace hbase; - using folly::IOBuf; using folly::io::RWPrivateCursor; using google::protobuf::Message; -using google::protobuf::Message; using google::protobuf::io::ArrayInputStream; using google::protobuf::io::ArrayOutputStream; using google::protobuf::io::CodedInputStream; using google::protobuf::io::CodedOutputStream; using google::protobuf::io::ZeroCopyOutputStream; -using std::string; -using std::unique_ptr; + +namespace hbase { static const std::string PREAMBLE = "HBas"; static const std::string INTERFACE = "ClientService"; @@ -104,7 +101,7 @@ std::unique_ptr<IOBuf> RpcSerde::Preamble(bool secure) { return magic; } -unique_ptr<IOBuf> RpcSerde::Header(const string &user) { +std::unique_ptr<IOBuf> RpcSerde::Header(const std::string &user) { pb::ConnectionHeader h; // TODO(eclark): Make this not a total lie. @@ -150,8 +147,8 @@ std::unique_ptr<pb::VersionInfo> RpcSerde::CreateVersionInfo() { return version_info; } -unique_ptr<IOBuf> RpcSerde::Request(const uint32_t call_id, const string &method, - const Message *msg) { +std::unique_ptr<IOBuf> RpcSerde::Request(const uint32_t call_id, const std::string &method, + const Message *msg) { pb::RequestHeader rq; rq.set_method_name(method); rq.set_call_id(call_id); @@ -173,7 +170,7 @@ std::unique_ptr<CellScanner> RpcSerde::CreateCellScanner(std::unique_ptr<folly:: return codec_->CreateDecoder(std::move(buf), offset, length); } -unique_ptr<IOBuf> RpcSerde::PrependLength(unique_ptr<IOBuf> msg) { +std::unique_ptr<IOBuf> RpcSerde::PrependLength(std::unique_ptr<IOBuf> msg) { // Java ints are 4 long. So create a buffer that large auto len_buf = IOBuf::create(4); // Then make those bytes visible. @@ -191,7 +188,7 @@ unique_ptr<IOBuf> RpcSerde::PrependLength(unique_ptr<IOBuf> msg) { return len_buf; } -unique_ptr<IOBuf> RpcSerde::SerializeDelimited(const Message &msg) { +std::unique_ptr<IOBuf> RpcSerde::SerializeDelimited(const Message &msg) { // Get the buffer size needed for just the message. int msg_size = msg.ByteSize(); int buf_size = CodedOutputStream::VarintSize32(msg_size) + msg_size; @@ -218,7 +215,8 @@ unique_ptr<IOBuf> RpcSerde::SerializeDelimited(const Message &msg) { return buf; } // TODO(eclark): Make this 1 copy. -unique_ptr<IOBuf> RpcSerde::SerializeMessage(const Message &msg) { +std::unique_ptr<IOBuf> RpcSerde::SerializeMessage(const Message &msg) { auto buf = IOBuf::copyBuffer(msg.SerializeAsString()); return buf; } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/serde/zk.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/serde/zk.cc b/hbase-native-client/serde/zk.cc index bf68400..a71eb87 100644 --- a/hbase-native-client/serde/zk.cc +++ b/hbase-native-client/serde/zk.cc @@ -25,15 +25,13 @@ #include <string> -using hbase::ZkDeserializer; using std::runtime_error; -using folly::IOBuf; -using folly::io::Cursor; -using google::protobuf::Message; + +namespace hbase { static const std::string MAGIC_STRING = "PBUF"; -bool ZkDeserializer::Parse(IOBuf *buf, Message *out) { +bool ZkDeserializer::Parse(folly::IOBuf *buf, google::protobuf::Message *out) { // The format is like this // 1 byte of magic number. 255 // 4 bytes of id length. @@ -41,7 +39,7 @@ bool ZkDeserializer::Parse(IOBuf *buf, Message *out) { // 4 bytes of a magic string PBUF // Then the protobuf serialized without a varint header. - Cursor c{buf}; + folly::io::Cursor c{buf}; // There should be a magic number for recoverable zk uint8_t magic_num = c.read<uint8_t>(); @@ -76,3 +74,4 @@ bool ZkDeserializer::Parse(IOBuf *buf, Message *out) { return true; } +} // namespace hbase http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/utils/time-util.h ---------------------------------------------------------------------- diff --git a/hbase-native-client/utils/time-util.h b/hbase-native-client/utils/time-util.h index 183260b..165e9f1 100644 --- a/hbase-native-client/utils/time-util.h +++ b/hbase-native-client/utils/time-util.h @@ -21,49 +21,51 @@ #include <chrono> #include <string> -using std::chrono::nanoseconds; -using std::chrono::milliseconds; -using std::chrono::seconds; namespace hbase { + class TimeUtil { public: static inline int64_t ToMillis(const int64_t& nanos) { - return std::chrono::duration_cast<milliseconds>(nanoseconds(nanos)).count(); + return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::nanoseconds(nanos)) + .count(); } - static inline milliseconds ToMillis(const nanoseconds& nanos) { - return std::chrono::duration_cast<milliseconds>(nanoseconds(nanos)); + static inline std::chrono::milliseconds ToMillis(const std::chrono::nanoseconds& nanos) { + return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::nanoseconds(nanos)); } - static inline nanoseconds ToNanos(const milliseconds& millis) { - return std::chrono::duration_cast<nanoseconds>(millis); + static inline std::chrono::nanoseconds ToNanos(const std::chrono::milliseconds& millis) { + return std::chrono::duration_cast<std::chrono::nanoseconds>(millis); } - static inline nanoseconds MillisToNanos(const int64_t& millis) { - return std::chrono::duration_cast<nanoseconds>(milliseconds(millis)); + static inline std::chrono::nanoseconds MillisToNanos(const int64_t& millis) { + return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::milliseconds(millis)); } - static inline nanoseconds SecondsToNanos(const int64_t& secs) { - return std::chrono::duration_cast<nanoseconds>(seconds(secs)); + static inline std::chrono::nanoseconds SecondsToNanos(const int64_t& secs) { + return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::seconds(secs)); } - static inline std::string ToMillisStr(const nanoseconds& nanos) { - return std::to_string(std::chrono::duration_cast<milliseconds>(nanos).count()); + static inline std::string ToMillisStr(const std::chrono::nanoseconds& nanos) { + return std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>(nanos).count()); } static inline int64_t GetNowNanos() { auto duration = std::chrono::high_resolution_clock::now().time_since_epoch(); - return std::chrono::duration_cast<nanoseconds>(duration).count(); + return std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count(); } static inline int64_t ElapsedMillis(const int64_t& start_ns) { - return std::chrono::duration_cast<milliseconds>(nanoseconds(GetNowNanos() - start_ns)).count(); + return std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::nanoseconds(GetNowNanos() - start_ns)) + .count(); } static inline std::string ElapsedMillisStr(const int64_t& start_ns) { - return std::to_string( - std::chrono::duration_cast<milliseconds>(nanoseconds(GetNowNanos() - start_ns)).count()); + return std::to_string(std::chrono::duration_cast<std::chrono::milliseconds>( + std::chrono::nanoseconds(GetNowNanos() - start_ns)) + .count()); } }; } /* namespace hbase */ http://git-wip-us.apache.org/repos/asf/hbase/blob/3d861a17/hbase-native-client/utils/user-util.cc ---------------------------------------------------------------------- diff --git a/hbase-native-client/utils/user-util.cc b/hbase-native-client/utils/user-util.cc index 71f0012..092d54c 100644 --- a/hbase-native-client/utils/user-util.cc +++ b/hbase-native-client/utils/user-util.cc @@ -25,12 +25,11 @@ #include <sys/types.h> #include <unistd.h> -using namespace hbase; -using namespace std; +namespace hbase { UserUtil::UserUtil() : once_flag_{} {} -string UserUtil::user_name(bool secure) { +std::string UserUtil::user_name(bool secure) { std::call_once(once_flag_, [this, secure]() { compute_user_name(secure); }); return user_name_; } @@ -44,7 +43,7 @@ void UserUtil::compute_user_name(bool secure) { // make sure that we got something. if (passwd && passwd->pw_name) { - user_name_ = string{passwd->pw_name}; + user_name_ = std::string{passwd->pw_name}; } if (!secure) return; krb5_context ctx; @@ -75,3 +74,4 @@ void UserUtil::compute_user_name(bool secure) { krb5_free_principal(ctx, princ); krb5_free_context(ctx); } +} // namespace hbase