1
2
3
4
5
6
7
8
9
10
11
12 package com.google.code.yanf4j.config;
13
14 import net.rubyeye.xmemcached.impl.ReconnectRequest;
15
16 import java.util.concurrent.DelayQueue;
17
18
19
20
21
22
23
24 public class Configuration {
25
26 public static final String XMEMCACHED_SELECTOR_POOL_SIZE = "xmemcached.selector.pool.size";
27
28
29
30
31 private int sessionReadBufferSize = 32 * 1024;
32
33
34
35
36 private int soTimeout = 0;
37
38
39
40
41 private int writeThreadCount = 0;
42
43
44
45
46 private boolean statisticsServer = false;
47
48
49
50
51 private boolean handleReadWriteConcurrently = true;
52
53
54
55
56 private int dispatchMessageThreadCount = 0;
57
58
59
60
61 private int readThreadCount = 1;
62
63 private int selectorPoolSize = System.getProperty(XMEMCACHED_SELECTOR_POOL_SIZE) == null ? 2 * Runtime.getRuntime().availableProcessors() : Integer.parseInt(System.getProperty(XMEMCACHED_SELECTOR_POOL_SIZE));
64
65
66
67
68 public static final int DEFAULT_INCREASE_BUFF_SIZE = 32 * 1024;
69
70
71
72
73 public final static int MAX_READ_BUFFER_SIZE = 128 * 1024;
74
75
76
77
78 private volatile long checkSessionTimeoutInterval = 1000L;
79
80 public final int getWriteThreadCount() {
81 return this.writeThreadCount;
82 }
83
84 public final int getDispatchMessageThreadCount() {
85 return this.dispatchMessageThreadCount;
86 }
87
88 public final void setDispatchMessageThreadCount(
89 int dispatchMessageThreadCount) {
90 this.dispatchMessageThreadCount = dispatchMessageThreadCount;
91 }
92
93 public final void setWriteThreadCount(int writeThreadCount) {
94 this.writeThreadCount = writeThreadCount;
95 }
96
97 private volatile long sessionIdleTimeout = 5000L;
98
99
100
101
102
103 public final long getSessionIdleTimeout() {
104 return this.sessionIdleTimeout;
105 }
106
107 public final void setSessionIdleTimeout(long sessionIdleTimeout) {
108 this.sessionIdleTimeout = sessionIdleTimeout;
109 }
110
111
112
113
114
115 public final int getSessionReadBufferSize() {
116 return this.sessionReadBufferSize;
117 }
118
119 public final boolean isHandleReadWriteConcurrently() {
120 return this.handleReadWriteConcurrently;
121 }
122
123 public final int getSoTimeout() {
124 return this.soTimeout;
125 }
126
127 protected long statisticsInterval = 5 * 60 * 1000L;
128
129 public final long getStatisticsInterval() {
130 return this.statisticsInterval;
131 }
132
133 public final void setStatisticsInterval(long statisticsInterval) {
134 this.statisticsInterval = statisticsInterval;
135 }
136
137 public final void setSoTimeout(int soTimeout) {
138 if (soTimeout < 0) {
139 throw new IllegalArgumentException("soTimeout<0");
140 }
141 this.soTimeout = soTimeout;
142 }
143
144 public final void setHandleReadWriteConcurrently(
145 boolean handleReadWriteConcurrently) {
146 this.handleReadWriteConcurrently = handleReadWriteConcurrently;
147 }
148
149 public final void setSessionReadBufferSize(int tcpHandlerReadBufferSize) {
150 if (tcpHandlerReadBufferSize <= 0) {
151 throw new IllegalArgumentException("tcpHandlerReadBufferSize<=0");
152 }
153 this.sessionReadBufferSize = tcpHandlerReadBufferSize;
154 }
155
156 public final boolean isStatisticsServer() {
157 return this.statisticsServer;
158 }
159
160 public final void setStatisticsServer(boolean statisticsServer) {
161 this.statisticsServer = statisticsServer;
162 }
163
164
165
166
167
168 public final int getReadThreadCount() {
169 return this.readThreadCount;
170 }
171
172 public final void setReadThreadCount(int readThreadCount) {
173 if (readThreadCount < 0) {
174 throw new IllegalArgumentException("readThreadCount<0");
175 }
176 this.readThreadCount = readThreadCount;
177 }
178
179 public void setCheckSessionTimeoutInterval(long checkSessionTimeoutInterval) {
180 this.checkSessionTimeoutInterval = checkSessionTimeoutInterval;
181 }
182
183 public long getCheckSessionTimeoutInterval() {
184 return this.checkSessionTimeoutInterval;
185 }
186
187 public void setSelectorPoolSize(int selectorPoolSize) {
188 this.selectorPoolSize = selectorPoolSize;
189 }
190
191 public int getSelectorPoolSize() {
192 return selectorPoolSize;
193 }
194 }