1/********************************************************************
2 * Copyright (c) 2013 - 2014, Pivotal Inc.
3 * All rights reserved.
4 *
5 * Author: Zhanwei Wang
6 ********************************************************************/
7/********************************************************************
8 * 2014 -
9 * open source under Apache License Version 2.0
10 ********************************************************************/
11/**
12 * Licensed to the Apache Software Foundation (ASF) under one
13 * or more contributor license agreements. See the NOTICE file
14 * distributed with this work for additional information
15 * regarding copyright ownership. The ASF licenses this file
16 * to you under the Apache License, Version 2.0 (the
17 * "License"); you may not use this file except in compliance
18 * with the License. You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28#ifndef _HDFS_LIBHDFS3_RPC_RPCCONFIG_H_
29#define _HDFS_LIBHDFS3_RPC_RPCCONFIG_H_
30
31#include "Hash.h"
32#include "SessionConfig.h"
33
34namespace Hdfs {
35namespace Internal {
36
37class RpcConfig {
38public:
39
40 RpcConfig(const SessionConfig & conf) {
41 connectTimeout = conf.getRpcConnectTimeout();
42 maxIdleTime = conf.getRpcMaxIdleTime();
43 maxRetryOnConnect = conf.getRpcMaxRetryOnConnect();
44 pingTimeout = conf.getRpcPingTimeout();
45 readTimeout = conf.getRpcReadTimeout();
46 writeTimeout = conf.getRpcWriteTimeout();
47 tcpNoDelay = conf.isRpcTcpNoDelay();
48 lingerTimeout = conf.getRpcSocketLingerTimeout();
49 rpcTimeout = conf.getRpcTimeout();
50 }
51
52 size_t hash_value() const;
53
54 int getConnectTimeout() const {
55 return connectTimeout;
56 }
57
58 void setConnectTimeout(int connectTimeout) {
59 this->connectTimeout = connectTimeout;
60 }
61
62 int getMaxIdleTime() const {
63 return maxIdleTime;
64 }
65
66 void setMaxIdleTime(int maxIdleTime) {
67 this->maxIdleTime = maxIdleTime;
68 }
69
70 int getMaxRetryOnConnect() const {
71 return maxRetryOnConnect;
72 }
73
74 void setMaxRetryOnConnect(int maxRetryOnConnect) {
75 this->maxRetryOnConnect = maxRetryOnConnect;
76 }
77
78 int getReadTimeout() const {
79 return readTimeout;
80 }
81
82 void setReadTimeout(int readTimeout) {
83 this->readTimeout = readTimeout;
84 }
85
86 bool isTcpNoDelay() const {
87 return tcpNoDelay;
88 }
89
90 void setTcpNoDelay(bool tcpNoDelay) {
91 this->tcpNoDelay = tcpNoDelay;
92 }
93
94 int getWriteTimeout() const {
95 return writeTimeout;
96 }
97
98 void setWriteTimeout(int writeTimeout) {
99 this->writeTimeout = writeTimeout;
100 }
101
102 int getPingTimeout() const {
103 return pingTimeout;
104 }
105
106 void setPingTimeout(int maxPingTimeout) {
107 this->pingTimeout = maxPingTimeout;
108 }
109
110 int getLingerTimeout() const {
111 return lingerTimeout;
112 }
113
114 void setLingerTimeout(int lingerTimeout) {
115 this->lingerTimeout = lingerTimeout;
116 }
117
118 int getRpcTimeout() const {
119 return rpcTimeout;
120 }
121
122 void setRpcTimeout(int rpcTimeout) {
123 this->rpcTimeout = rpcTimeout;
124 }
125
126 bool operator ==(const RpcConfig & other) const {
127 return this->maxIdleTime == other.maxIdleTime
128 && this->pingTimeout == other.pingTimeout
129 && this->connectTimeout == other.connectTimeout
130 && this->readTimeout == other.readTimeout
131 && this->writeTimeout == other.writeTimeout
132 && this->maxRetryOnConnect == other.maxRetryOnConnect
133 && this->tcpNoDelay == other.tcpNoDelay
134 && this->lingerTimeout == other.lingerTimeout
135 && this->rpcTimeout == other.rpcTimeout;
136 }
137
138private:
139 int maxIdleTime;
140 int pingTimeout;
141 int connectTimeout;
142 int readTimeout;
143 int writeTimeout;
144 int maxRetryOnConnect;
145 int lingerTimeout;
146 int rpcTimeout;
147 bool tcpNoDelay;
148};
149
150}
151}
152
153HDFS_HASH_DEFINE(::Hdfs::Internal::RpcConfig);
154
155#endif /* _HDFS_LIBHDFS3_RPC_RPCCONFIG_H_ */
156