1
2
3
4
5
6
7
8
9
10
11
12 package org.apache.hadoop.hbase.client;
13
14 import org.apache.hadoop.conf.Configuration;
15 import org.apache.hadoop.hbase.HConstants;
16 import org.apache.hadoop.hbase.classification.InterfaceAudience;
17
18 import com.google.common.annotations.VisibleForTesting;
19
20
21
22
23
24
25
26
27
28 @InterfaceAudience.Private
29 public class ConnectionConfiguration {
30
31 public static final String WRITE_BUFFER_SIZE_KEY = "hbase.client.write.buffer";
32 public static final long WRITE_BUFFER_SIZE_DEFAULT = 2097152;
33 public static final String MAX_KEYVALUE_SIZE_KEY = "hbase.client.keyvalue.maxsize";
34 public static final int MAX_KEYVALUE_SIZE_DEFAULT = -1;
35
36 private final long writeBufferSize;
37 private final int metaOperationTimeout;
38 private final int operationTimeout;
39 private final int scannerCaching;
40 private final long scannerMaxResultSize;
41 private final int primaryCallTimeoutMicroSecond;
42 private final int replicaCallTimeoutMicroSecondScan;
43 private final int retries;
44 private final int maxKeyValueSize;
45
46
47
48
49
50 ConnectionConfiguration(Configuration conf) {
51 this.writeBufferSize = conf.getLong(WRITE_BUFFER_SIZE_KEY, WRITE_BUFFER_SIZE_DEFAULT);
52
53 this.metaOperationTimeout = conf.getInt(
54 HConstants.HBASE_CLIENT_META_OPERATION_TIMEOUT,
55 HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
56
57 this.operationTimeout = conf.getInt(
58 HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
59
60 this.scannerCaching = conf.getInt(
61 HConstants.HBASE_CLIENT_SCANNER_CACHING, HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING);
62
63 this.scannerMaxResultSize =
64 conf.getLong(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
65 HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE);
66
67 this.primaryCallTimeoutMicroSecond =
68 conf.getInt("hbase.client.primaryCallTimeout.get", 10000);
69
70 this.replicaCallTimeoutMicroSecondScan =
71 conf.getInt("hbase.client.replicaCallTimeout.scan", 1000000);
72
73 this.retries = conf.getInt(
74 HConstants.HBASE_CLIENT_RETRIES_NUMBER, HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
75
76 this.maxKeyValueSize = conf.getInt(MAX_KEYVALUE_SIZE_KEY, MAX_KEYVALUE_SIZE_DEFAULT);
77 }
78
79
80
81
82
83
84 @VisibleForTesting
85 protected ConnectionConfiguration() {
86 this.writeBufferSize = WRITE_BUFFER_SIZE_DEFAULT;
87 this.metaOperationTimeout = HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT;
88 this.operationTimeout = HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT;
89 this.scannerCaching = HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING;
90 this.scannerMaxResultSize = HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE;
91 this.primaryCallTimeoutMicroSecond = 10000;
92 this.replicaCallTimeoutMicroSecondScan = 1000000;
93 this.retries = HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER;
94 this.maxKeyValueSize = MAX_KEYVALUE_SIZE_DEFAULT;
95 }
96
97 public long getWriteBufferSize() {
98 return writeBufferSize;
99 }
100
101 public int getMetaOperationTimeout() {
102 return metaOperationTimeout;
103 }
104
105 public int getOperationTimeout() {
106 return operationTimeout;
107 }
108
109 public int getScannerCaching() {
110 return scannerCaching;
111 }
112
113 public int getPrimaryCallTimeoutMicroSecond() {
114 return primaryCallTimeoutMicroSecond;
115 }
116
117 public int getReplicaCallTimeoutMicroSecondScan() {
118 return replicaCallTimeoutMicroSecondScan;
119 }
120
121 public int getRetriesNumber() {
122 return retries;
123 }
124
125 public int getMaxKeyValueSize() {
126 return maxKeyValueSize;
127 }
128
129 public long getScannerMaxResultSize() {
130 return scannerMaxResultSize;
131 }
132 }