• R/O
  • SSH
  • HTTPS

okuyama: 提交


Commit MetaInfo

修訂1042 (tree)
時間2014-04-02 00:50:16
作者okuyamaoo

Log Message

(empty log message)

Change Summary

差異

--- trunk/TestSock.java (revision 1041)
+++ trunk/TestSock.java (revision 1042)
@@ -48,7 +48,7 @@
4848 StringBuilder strBuf =null;
4949 if (args.length > 4) {
5050 strBuf = new StringBuilder(120*10);
51- for (int i = 0; i < 3000; i++) {
51+ for (int i = 0; i < 50000; i++) {
5252 strBuf.append(rnd.nextInt(1999999999));
5353 }
5454 }
@@ -270,6 +270,7 @@
270270 } else {
271271 ret = okuyamaClient.getValue(args[3]);
272272 }
273+ long end = new Date().getTime();
273274 if (ret[0].equals("true")) {
274275 // データ有り
275276 System.out.println("Value=[" + ret[1] + "]");
@@ -278,7 +279,6 @@
278279 } else if (ret[0].equals("error")) {
279280 System.out.println(ret[1]);
280281 }
281- long end = new Date().getTime();
282282 System.out.println((end - start) + "milli second");
283283
284284 okuyamaClient.close();
@@ -1435,7 +1435,7 @@
14351435 // データ登録
14361436
14371437 //if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr_" + args[4] + "_" + new Integer(i).toString())) {
1438- if (!okuyamaClient.setValueAndCreateIndex("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr_swedcvfrtgbnhyujm_09876543" + args[4] + "_" + new Integer(i).toString())) {
1438+ if (!okuyamaClient.setValueAndCreateIndex("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "sav"+ i +"edatavaluestr_swedcvfrtgbnhyujm_09876543" + args[4] + "_" + new Integer(i).toString(), "aa", 6, 3)) {
14391439 //if (!okuyamaClient.setValue("datasavekey_" + args[4] + "_" + new Integer(i).toString(), "savedatavaluestr0987654321" + strBuf.toString() + "_" + args[4] + "_" + new Integer(i).toString())) {
14401440 System.out.println("OkuyamaClient - error");
14411441 } else {
@@ -1622,7 +1622,7 @@
16221622 keys = (String[])ret[1];
16231623 System.out.println("Result Count[" + keys.length + "]");
16241624 for (int idx = 0; idx < keys.length; idx++) {
1625- System.out.println(keys[idx]);
1625+// System.out.println(keys[idx]);
16261626 }
16271627 } else if (ret[0].equals("false")) {
16281628 System.out.println("データなし");
@@ -1661,7 +1661,7 @@
16611661 keys = (String[])ret[1];
16621662 System.out.println("Result Count[" + keys.length + "]");
16631663 for (int idx = 0; idx < keys.length; idx++) {
1664- System.out.println(keys[idx]);
1664+// System.out.println(keys[idx]);
16651665 }
16661666 } else if (ret[0].equals("false")) {
16671667 System.out.println("データなし");
--- trunk/src/okuyama/imdst/helper/ServerControllerHelper.java (revision 1041)
+++ trunk/src/okuyama/imdst/helper/ServerControllerHelper.java (revision 1042)
@@ -238,6 +238,55 @@
238238 pw.close();
239239 Thread.sleep(500);
240240 soc.close();
241+ } else if (command.equals("datanodelist")) {
242+ HashMap allNodeInfo = DataDispatcher.getAllDataNodeInfo();
243+
244+ List mainNodeList = (ArrayList)allNodeInfo.get("main");
245+ List subNodeList = (ArrayList)allNodeInfo.get("sub");
246+ List thirdNodeList = (ArrayList)allNodeInfo.get("third");
247+ List resulList = new ArrayList();
248+
249+ for (int i = 0; i < mainNodeList.size(); i++) {
250+ StringBuilder strBuf = new StringBuilder(30);
251+ strBuf.append("{");
252+ String mainNode = (String)mainNodeList.get(i);
253+ strBuf.append("DataNode=");
254+ strBuf.append(mainNode);
255+ strBuf.append(",Arrival=");
256+ boolean arRet = StatusUtil.isNodeArrival(mainNode);
257+ strBuf.append(arRet);
258+ strBuf.append("; ");
259+
260+ if (subNodeList != null && subNodeList.size() > i) {
261+ String subNode = (String)subNodeList.get(i);
262+ strBuf.append("SubNode=");
263+ strBuf.append(subNode);
264+ strBuf.append(",Arrival=");
265+ boolean subArRet = StatusUtil.isNodeArrival(subNode);
266+ strBuf.append(subArRet);
267+ strBuf.append("; ");
268+ }
269+
270+ if (thirdNodeList != null && thirdNodeList.size() > i) {
271+ String thNode = (String)thirdNodeList.get(i);
272+ strBuf.append("ThirdNode=");
273+ strBuf.append(thNode);
274+ strBuf.append(",Arrival=");
275+ boolean thArRet = StatusUtil.isNodeArrival(thNode);
276+ strBuf.append(thArRet);
277+ strBuf.append("; ");
278+ }
279+ strBuf.append("}");
280+ resulList.add(strBuf.toString());
281+ }
282+
283+ pw.println(command + " Success");
284+ pw.println(resulList.toString());
285+ pw.flush();
286+ br.close();
287+ pw.close();
288+ Thread.sleep(500);
289+ soc.close();
241290 } else if (command.equals("-help")) {
242291 pw.println(command + " Success");
243292 pw.println("");
@@ -252,6 +301,7 @@
252301 pw.println("fullgc");
253302 pw.println("netdebug");
254303 pw.println("jobstatus");
304+ pw.println("datanodelist");
255305 pw.println("");
256306
257307 pw.flush();
--- trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 1041)
+++ trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 1042)
@@ -3187,6 +3187,7 @@
31873187 boolean fullMatchFlg = ((Boolean)fullMatchList.get(0)).booleanValue();
31883188
31893189 for (int i = 0; i < singleWordList.length; i++) {
3190+
31903191 String[] ret = this.getTagKeys(singleWordList[i], true);
31913192 if (ret[0].equals("4") && ret[1].equals("true")) {
31923193 // 該当あり
--- trunk/src/okuyama/imdst/job/ServerManagedJob.java (revision 1041)
+++ trunk/src/okuyama/imdst/job/ServerManagedJob.java (revision 1042)
@@ -95,6 +95,7 @@
9595 gcExecuteTime = System.currentTimeMillis();
9696 //Thread.sleep(2000);
9797 } else {
98+
9899 // 限界値を超えている
99100 if (memoryLimitOverCount >= maxMemoryLimitOverCount) {
100101 System.out.println(new Date().toString() + " JVM Limit MemorySize Over");
@@ -102,7 +103,9 @@
102103 gcOff = true;
103104 }
104105 }
106+
105107 } else {
108+
106109 memoryLimitOverCount = 0;
107110 }
108111 // GC発行
--- trunk/src/okuyama/imdst/util/PartialConcurrentHashMap.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/PartialConcurrentHashMap.java (revision 1042)
@@ -48,8 +48,9 @@
4848
4949 byte[] valueBytes = (byte[])value;
5050 //System.out.println("Partial= " + valueBytes.length);
51- if (fullMemory == false && valueBytes.length > ImdstDefine.memoryStoreLimitSize) {
5251
52+ if (ImdstDefine.dataFullMemory == false && valueBytes.length > ImdstDefine.memoryStoreLimitSize) {
53+
5354 this.bigValueStoreMap.put(new String(((CoreMapKey)key).getDatas()), new String(BASE64EncoderStream.encode(valueBytes)));
5455 // 符号を登録
5556 super.put(key, PartialConcurrentHashMap.flg);
@@ -63,7 +64,7 @@
6364 public Object get(Object key) {
6465 // 規定サイズを超える場合でかつ、VirtualStoreのディレクトリが指定してある場合はFileBaseMapに格納
6566 Object ret = super.get(key);
66- if (ret == null || fullMemory == true || ((byte[])ret).length > 1) return ret;
67+ if (ret == null || ImdstDefine.dataFullMemory == true || ((byte[])ret).length > 1) return ret;
6768
6869 String valueStr = (String)this.bigValueStoreMap.get(new String(((CoreMapKey)key).getDatas()));
6970
@@ -76,7 +77,7 @@
7677 public Object remove(Object key) {
7778 // 規定サイズを超える場合でかつ、VirtualStoreのディレクトリが指定してある場合はFileBaseMapに格納
7879 Object ret = super.remove(key);
79- if (ret == null || fullMemory == true || ((byte[])ret).length > 1) return ret;
80+ if (ret == null || ImdstDefine.dataFullMemory == true || ((byte[])ret).length > 1) return ret;
8081
8182 String valueStr = (String)this.bigValueStoreMap.remove(new String(((CoreMapKey)key).getDatas()));
8283
--- trunk/src/okuyama/imdst/util/PartialSerializeMap.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/PartialSerializeMap.java (revision 1042)
@@ -50,7 +50,7 @@
5050
5151 byte[] valueBytes = (byte[])value;
5252 //System.out.println("Partial= " + valueBytes.length);
53- if (fullMemory == false && valueBytes.length > ImdstDefine.memoryStoreLimitSize) {
53+ if (ImdstDefine.dataFullMemory == false && valueBytes.length > ImdstDefine.memoryStoreLimitSize) {
5454
5555 this.bigValueStoreMap.put(new String(((CoreMapKey)key).getDatas()), new String(BASE64EncoderStream.encode(valueBytes)));
5656 // 符号を登録
@@ -65,7 +65,7 @@
6565 public Object get(Object key) {
6666 // 規定サイズを超える場合でかつ、VirtualStoreのディレクトリが指定してある場合はFileBaseMapに格納
6767 Object ret = super.get(key);
68- if (ret == null || fullMemory == true || ((byte[])ret).length > 1) return ret;
68+ if (ret == null || ImdstDefine.dataFullMemory == true || ((byte[])ret).length > 1) return ret;
6969
7070 String valueStr = (String)this.bigValueStoreMap.get(new String(((CoreMapKey)key).getDatas()));
7171
@@ -78,7 +78,7 @@
7878 public Object remove(Object key) {
7979 // 規定サイズを超える場合でかつ、VirtualStoreのディレクトリが指定してある場合はFileBaseMapに格納
8080 Object ret = super.remove(key);
81- if (ret == null || fullMemory == true || ((byte[])ret).length > 1) return ret;
81+ if (ret == null || ImdstDefine.dataFullMemory == true || ((byte[])ret).length > 1) return ret;
8282
8383 String valueStr = (String)this.bigValueStoreMap.remove(new String(((CoreMapKey)key).getDatas()));
8484
--- trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 1042)
@@ -197,7 +197,7 @@
197197
198198 private Object keyObjectExportSync = new Object();
199199
200- private int keyObjectStoreTiming = 25; // 25分に一度バックアップが作成される
200+ private int keyObjectStoreTiming = 1; // 25分に一度バックアップが作成される
201201
202202 private String diskCacheFile = null;
203203
@@ -937,6 +937,7 @@
937937
938938
939939 String data = null;
940+
940941 if (keyNode.indexOf("-1") == -1) {
941942
942943 data = keyNode;
@@ -4241,6 +4242,8 @@
42414242 // 対象データ判定
42424243 // タグの対象データ判定はタグ値に連結されているインデックス文字列や、左右のプレフィックス文字列をはずして判定する
42434244 sendFlg = DataDispatcher.isRangeData(checkKey.substring(0, lastIdx), rangs);
4245+ } else if (key.indexOf(ImdstDefine.imdstListStructCommonPrefixStr) == 0) {
4246+ sendFlg = false;
42444247 } else {
42454248 // 対象データ判定
42464249 sendFlg = DataDispatcher.isRangeData(key, rangs);
@@ -4354,6 +4357,7 @@
43544357 if (!dataLines[i].trim().equals("")) {
43554358
43564359 // TODO:ここで移行データから有効期限よりも後ろを削除してしまっている。
4360+
43574361 oneDatas = dataLines[i].split(KeyMapManager.workFileSeq);
43584362
43594363 // データの種類に合わせて処理分岐
@@ -4364,6 +4368,9 @@
43644368
43654369 // 通常データ
43664370 // 成功、失敗関係なく全て登録処理
4371+ if (oneDatas.length > 3) {
4372+ oneDatas[2] = oneDatas[2] + "," + oneDatas[3];
4373+ }
43674374 this.setKeyPairOnlyOnce(oneDatas[1], oneDatas[2], "0", true);
43684375 } else if (oneDatas[0].equals("2")) {
43694376
--- trunk/src/okuyama/imdst/util/StatusUtil.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/StatusUtil.java (revision 1042)
@@ -234,8 +234,10 @@
234234 */
235235 public static void setMemoryLimitMinSize(int limitSize) {
236236 synchronized(memoryLimitMinSize) {
237- if (memoryLimitMinSize.intValue() > limitSize)
238- memoryLimitMinSize = new Integer(limitSize);
237+ if (memoryLimitMinSize.intValue() > limitSize) {
238+
239+ memoryLimitMinSize = new Integer(limitSize);
240+ }
239241 }
240242 }
241243
--- trunk/src/okuyama/imdst/util/protocol/OkuyamaProtocolTaker.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/protocol/OkuyamaProtocolTaker.java (revision 1042)
@@ -32,7 +32,9 @@
3232
3333 private static String checkSetMethodCodeAdd = "6";
3434
35+ private static String checkSetMethodCodeSetVerChk = "16";
3536
37+
3638 /**
3739 * 初期化
3840 *
@@ -156,7 +158,6 @@
156158
157159 private String[] okuyamaMethodCnv(String executeMethodStr) {
158160 int methodLen = executeMethodStr.length();
159-
160161 String[] splitMethodSet = null;
161162 if (executeMethodStr.indexOf("2,") == 0) {
162163
@@ -170,9 +171,9 @@
170171 splitMethodSet = executeMethodStr.split(ImdstDefine.keyHelperClientParamSep);
171172 }
172173
173- if (splitMethodSet[0].equals(checkSetMethodCodeSet) || splitMethodSet[0].equals(checkSetMethodCodeAdd)) {
174+ if (splitMethodSet[0].equals(checkSetMethodCodeSet) || splitMethodSet[0].equals(checkSetMethodCodeAdd) || splitMethodSet[0].equals(checkSetMethodCodeSetVerChk)) {
174175
175- if (executeMethodStr.charAt(methodLen - 1) == ',') {
176+ if (executeMethodStr.charAt(methodLen - 1) == ',' && !splitMethodSet[0].equals(checkSetMethodCodeSetVerChk)) {
176177
177178 // 有効期限付き
178179 String[] retMethod = new String[5] ;
@@ -195,6 +196,30 @@
195196 append(splitMethodSet[5]);
196197 retMethod[4] = requestStrBuf.toString();
197198 return retMethod;
199+ } else if (executeMethodStr.charAt(methodLen - 1) == ',' && splitMethodSet[0].equals(checkSetMethodCodeSetVerChk)) {
200+
201+ // 有効期限付き
202+ String[] retMethod = new String[6] ;
203+
204+ StringBuilder requestStrBuf = new StringBuilder(methodLen + 20);
205+
206+ executeMethodStr = null;
207+
208+ retMethod[0] = splitMethodSet[0]; // 処理番号
209+ retMethod[1] = splitMethodSet[1]; // Key
210+ retMethod[2] = splitMethodSet[2]; // Tag
211+ retMethod[3] = splitMethodSet[3]; // TransactionCode
212+ retMethod[5] = splitMethodSet[5]; // VersionNo
213+
214+ requestStrBuf.append(splitMethodSet[4]);
215+ requestStrBuf.append(ImdstDefine.keyHelperClientParamSep);
216+ requestStrBuf.append("0");
217+ requestStrBuf.append(AbstractProtocolTaker.metaColumnSep).
218+ append(AbstractProtocolTaker.calcExpireTime(splitMethodSet[6])).
219+ append(AbstractProtocolTaker.metaColumnSep).
220+ append(splitMethodSet[6]);
221+ retMethod[4] = requestStrBuf.toString();
222+ return retMethod;
198223 } else {
199224 return splitMethodSet;
200225 }
--- trunk/src/okuyama/imdst/util/CoreValueMap.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/CoreValueMap.java (revision 1042)
@@ -53,6 +53,9 @@
5353
5454 // Value圧縮あり
5555 System.out.println(" PartialConcurrentHashMap Use");
56+ if (ImdstDefine.bigValueFileStoreUse == true && virtualStoreDirs != null) {
57+ ImdstDefine.dataFullMemory = false;
58+ }
5659 if (renewFlg) {
5760 mainMap = new PartialConcurrentHashMap(size, upper, multi, virtualStoreDirs);
5861 } else {
@@ -106,6 +109,10 @@
106109 long bucketSize = jvmMaxMemory * SerializeMap.bucketJvm1MBMemoryFactor;
107110
108111 System.out.println(" PartialSerializeMap Use");
112+ if (ImdstDefine.bigValueFileStoreUse == true && virtualStoreDirs != null) {
113+ ImdstDefine.dataFullMemory = false;
114+ }
115+
109116 MemoryModeCoreValueCnv.compressUnderLimitSize = 1024 * 1024 * 1024;
110117
111118 if (renewFlg) {
--- trunk/src/okuyama/imdst/util/ImdstDefine.java (revision 1041)
+++ trunk/src/okuyama/imdst/util/ImdstDefine.java (revision 1042)
@@ -11,7 +11,7 @@
1111 */
1212 public class ImdstDefine {
1313
14- public static final String okuyamaVersion = "VERSION okuyama-0.9.5";
14+ public static final String okuyamaVersion = "VERSION okuyama-0.9.6";
1515
1616 // -- MasterNodeをマルチクラスターのスレーブで起動する場合にtrueになる
1717 public volatile static boolean slaveClusterMasterNode = false;
@@ -65,6 +65,9 @@
6565 // Tag値の文字列の後方カッコ
6666 public static final String imdstMultiRequestByteDataSep = ":#:";
6767
68+ // List構造体の共通Prefix
69+ public static final String imdstListStructCommonPrefixStr = "{imdst_list";
70+
6871 // List構造体のFirst要素を表すPrefix
6972 public static final String imdstListStructStartStr = "{imdst_list#1234";
7073
@@ -389,6 +392,8 @@
389392 public volatile static boolean bigValueFileStoreUse = false;
390393 public volatile static int memoryStoreLimitSize = 1024 * 128;
391394
395+ public volatile static boolean dataFullMemory = true;
396+
392397 public static final int stringBufferSmallSize = 128;
393398
394399 public static final int stringBufferSmall_2Size = 160;
--- trunk/src/okuyama/imdst/client/OkuyamaClient.java (revision 1041)
+++ trunk/src/okuyama/imdst/client/OkuyamaClient.java (revision 1042)
@@ -371,14 +371,14 @@
371371 this.socket = new Socket();
372372 int timeOutCheckTime = 0;
373373
374- if (this.masterNodesList.size() < 4) {
375- timeOutCheckTime = 2000;
376- } else if (this.masterNodesList.size() < 6) {
377- timeOutCheckTime = 1200;
378- } else if (this.masterNodesList.size() < 8) {
374+ if (this.masterNodesList.size() < 2) {
379375 timeOutCheckTime = 1000;
376+ } else if (this.masterNodesList.size() < 3) {
377+ timeOutCheckTime = 700;
378+ } else if (this.masterNodesList.size() < 5) {
379+ timeOutCheckTime = 600;
380380 } else if (this.masterNodesList.size() < 13) {
381- timeOutCheckTime = 800;
381+ timeOutCheckTime = 500;
382382 } else {
383383 timeOutCheckTime = 500;
384384 }
@@ -2585,7 +2585,7 @@
25852585 * @throws OkuyamaClientException
25862586 */
25872587 public String[] setValueVersionCheck(String keyStr, String value, String versionNo) throws OkuyamaClientException {
2588- return this.setValueVersionCheck(keyStr, null, value, versionNo, null);
2588+ return this.setValueVersionCheck(keyStr, null, value, versionNo, null, null);
25892589 }
25902590
25912591
@@ -2605,7 +2605,7 @@
26052605 * @throws OkuyamaClientException
26062606 */
26072607 public String[] setValueVersionCheck(String keyStr, String[] tagStrs, String value, String versionNo) throws OkuyamaClientException {
2608- return this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, null);
2608+ return this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, null, null);
26092609 }
26102610
26112611 /**
@@ -2625,6 +2625,48 @@
26252625 * @throws OkuyamaClientException
26262626 */
26272627 public String[] setValueVersionCheck(String keyStr, String[] tagStrs, String value, String versionNo, String encode) throws OkuyamaClientException {
2628+ return this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, null, encode);
2629+ }
2630+
2631+ /**
2632+ * MasterNodeへバージョンチェック付き値登録要求をする.<br>
2633+ * Tag有り.<br>
2634+ * バージョン値を使用して更新前チェックを行う.<br>
2635+ * 失敗した場合は、falseが返る<br>
2636+ * 成功の場合は配列の長さは1である。失敗時は2である<br>
2637+ * memcachedのcasに相当.<br>
2638+ *
2639+ * @param keyStr Key値
2640+ * @param tagStrs Tag値
2641+ * @param value Value値
2642+ * @param versionNo getValueVersionCheckメソッドで取得したバージョンNo
2643+ * @param expireTime 有効期限(秒)
2644+ * @return String[] 要素1(データ有無):"true" or "false",要素2(失敗時はメッセージ):"メッセージ"
2645+ * @throws OkuyamaClientException
2646+ */
2647+ public String[] setValueVersionCheck(String keyStr, String[] tagStrs, String value, String versionNo, Integer expireTime) throws OkuyamaClientException {
2648+ return this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime, null);
2649+ }
2650+
2651+ /**
2652+ * MasterNodeへバージョンチェック付き値登録要求をする.<br>
2653+ * Tag有り.<br>
2654+ * バージョン値を使用して更新前チェックを行う.<br>
2655+ * 失敗した場合は、falseが返る<br>
2656+ * 成功の場合は配列の長さは1である。失敗時は2である<br>
2657+ * memcachedのcasに相当.<br>
2658+ *
2659+ * @param keyStr Key値
2660+ * @param tagStrs Tag値
2661+ * @param value Value値
2662+ * @param versionNo getValueVersionCheckメソッドで取得したバージョンNo
2663+ * @param expireTime 有効期限(秒)
2664+ * @param encode エンコード
2665+ * @return String[] 要素1(データ有無):"true" or "false",要素2(失敗時はメッセージ):"メッセージ"
2666+ * @throws OkuyamaClientException
2667+ */
2668+ public String[] setValueVersionCheck(String keyStr, String[] tagStrs, String value, String versionNo, Integer expireTime, String encode) throws OkuyamaClientException {
2669+
26282670 String[] ret = null;
26292671 String serverRetStr = null;
26302672 String[] serverRet = null;
@@ -2711,6 +2753,20 @@
27112753 // バージョン値連結
27122754 setValueServerReqBuf.append(versionNo);
27132755
2756+ // 有効期限あり
2757+ if (expireTime != null) {
2758+ if (0.880 > this.okuyamaVersionNo) {
2759+
2760+ throw new OkuyamaClientException("The version of the server is old [The expiration date can be used since version 0.8.8]");
2761+ } else {
2762+ // セパレータ連結
2763+ setValueServerReqBuf.append(OkuyamaClient.sepStr);
2764+ setValueServerReqBuf.append(expireTime);
2765+ // セパレータ連結 最後に区切りを入れて送信データ終わりを知らせる
2766+ setValueServerReqBuf.append(OkuyamaClient.sepStr);
2767+ }
2768+ }
2769+
27142770 // サーバ送信
27152771 pw.println(setValueServerReqBuf.toString());
27162772 pw.flush();
@@ -2746,7 +2802,7 @@
27462802 if (this.masterNodesList != null && masterNodesList.size() > 1) {
27472803 try {
27482804 this.autoConnect();
2749- ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo);
2805+ ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime, encode);
27502806 } catch (Exception e) {
27512807 throw new OkuyamaClientException(ce);
27522808 }
@@ -2757,7 +2813,7 @@
27572813 if (this.masterNodesList != null && masterNodesList.size() > 1) {
27582814 try {
27592815 this.autoConnect();
2760- ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo);
2816+ ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime, encode);
27612817 } catch (Exception e) {
27622818 throw new OkuyamaClientException(se);
27632819 }
@@ -2768,7 +2824,7 @@
27682824 if (this.masterNodesList != null && masterNodesList.size() > 1) {
27692825 try {
27702826 this.autoConnect();
2771- ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo);
2827+ ret = this.setValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime, encode);
27722828 } catch (Exception ee) {
27732829 throw new OkuyamaClientException(e);
27742830 }
@@ -2795,11 +2851,29 @@
27952851 * @throws OkuyamaClientException
27962852 */
27972853 public String[] setObjectValueVersionCheck(String keyStr, Object value, String versionNo) throws OkuyamaClientException {
2798- return setObjectValueVersionCheck(keyStr, null, value, versionNo);
2854+ return setObjectValueVersionCheck(keyStr, null, value, versionNo, null);
27992855 }
28002856
28012857
2858+ /**
2859+ * MasterNodeへバージョンチェック付きObject値登録要求をする.<br>
2860+ * バージョン値を使用して更新前チェックを行う.<br>
2861+ * 失敗した場合は、falseが返る<br>
2862+ * 成功の場合は配列の長さは1である。失敗時は2である<br>
2863+ * memcachedのcasに相当.<br>
2864+ *
2865+ * @param keyStr Key値
2866+ * @param value Value値
2867+ * @param versionNo getValueVersionCheckメソッドで取得したバージョンNo
2868+ * @param expireTime 有効期限(秒)
2869+ * @return String[] 要素1(データ有無):"true" or "false",要素2(失敗時はメッセージ):"メッセージ"
2870+ * @throws OkuyamaClientException
2871+ */
2872+ public String[] setObjectValueVersionCheck(String keyStr, Object value, String versionNo, Integer expireTime) throws OkuyamaClientException {
2873+ return setObjectValueVersionCheck(keyStr, null, value, versionNo, expireTime);
2874+ }
28022875
2876+
28032877 /**
28042878 * MasterNodeへバージョンチェック付きObject値登録要求をする.<br>
28052879 * Tag有り.<br>
@@ -2815,7 +2889,7 @@
28152889 * @return String[] 要素1(データ有無):"true" or "false",要素2(失敗時はメッセージ):"メッセージ"
28162890 * @throws OkuyamaClientException
28172891 */
2818- public String[] setObjectValueVersionCheck(String keyStr, String[] tagStrs, Object value, String versionNo) throws OkuyamaClientException {
2892+ public String[] setObjectValueVersionCheck(String keyStr, String[] tagStrs, Object value, String versionNo, Integer expireTime) throws OkuyamaClientException {
28192893 String[] ret = null;
28202894 String serverRetStr = null;
28212895 String[] serverRet = null;
@@ -2903,6 +2977,20 @@
29032977 // バージョン値連結
29042978 setValueServerReqBuf.append(versionNo);
29052979
2980+ // 有効期限あり
2981+ if (expireTime != null) {
2982+ if (0.880 > this.okuyamaVersionNo) {
2983+
2984+ throw new OkuyamaClientException("The version of the server is old [The expiration date can be used since version 0.8.8]");
2985+ } else {
2986+ // セパレータ連結
2987+ setValueServerReqBuf.append(OkuyamaClient.sepStr);
2988+ setValueServerReqBuf.append(expireTime);
2989+ // セパレータ連結 最後に区切りを入れて送信データ終わりを知らせる
2990+ setValueServerReqBuf.append(OkuyamaClient.sepStr);
2991+ }
2992+ }
2993+
29062994 // サーバ送信
29072995 pw.println(setValueServerReqBuf.toString());
29082996 pw.flush();
@@ -2938,7 +3026,7 @@
29383026 if (this.masterNodesList != null && masterNodesList.size() > 1) {
29393027 try {
29403028 this.autoConnect();
2941- ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo);
3029+ ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime);
29423030 } catch (Exception e) {
29433031 throw new OkuyamaClientException(ce);
29443032 }
@@ -2949,7 +3037,7 @@
29493037 if (this.masterNodesList != null && masterNodesList.size() > 1) {
29503038 try {
29513039 this.autoConnect();
2952- ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo);
3040+ ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime);
29533041 } catch (Exception e) {
29543042 throw new OkuyamaClientException(se);
29553043 }
@@ -2960,7 +3048,7 @@
29603048 if (this.masterNodesList != null && masterNodesList.size() > 1) {
29613049 try {
29623050 this.autoConnect();
2963- ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo);
3051+ ret = this.setObjectValueVersionCheck(keyStr, tagStrs, value, versionNo, expireTime);
29643052 } catch (Exception ee) {
29653053 throw new OkuyamaClientException(e);
29663054 }
--- trunk/src/okuyama/imdst/client/UtilClient.java (revision 1041)
+++ trunk/src/okuyama/imdst/client/UtilClient.java (revision 1042)
@@ -29,7 +29,7 @@
2929 System.out.println("Command3. MasterNodeConfigCheck args1=masterconfig args2=MainMasterNode-IPAdress args3=MainMasterNode-Port");
3030 System.out.println("Command4. DataNode is added args1=adddatanode args2=MasterNode-IPAdress:PortNo args3=DataNodeIPAddress:PortNo args4=Slave1-DataNodeIpAddress:PortNo args5=Slave2-DataNodeIpAddress:PortNo");
3131 System.out.println("Command5. DataNode save key list output args1=keylist args2=DataNode-IPAdress:PortNo");
32-
32+ System.out.println("Command6. Replace AllMasterNodeInfos args1=replacemasternode args2=MasterNode-IPAdress:PortNo args3=Replace AllMasterNodeInfos config");
3333 System.exit(1);
3434 }
3535
@@ -113,6 +113,15 @@
113113 }
114114
115115
116+ if (args[0].equals("replacemasternode")) {
117+ if (args.length < 3) {
118+ System.out.println("Argument Error! args[0]=Command, args[1]=MasterNodeIp:Port, args[2]=ReplaceMasterNodeInfos");
119+ System.exit(1);
120+ }
121+
122+ replaceMasterNode(args[1], args[2]);
123+ }
124+
116125 if (args[0].equals("keylist")) {
117126 if (args.length < 2) {
118127 System.out.println("Argument Error! args[0]=Command, args[1]=DataNodeIp:Port");
@@ -348,6 +357,43 @@
348357 }
349358
350359
360+
361+
362+ public static void replaceMasterNode(String masterNodeIpPort, String masternodeinfos) {
363+ OkuyamaClient client = null;
364+
365+ try {
366+ client = new OkuyamaClient();
367+ client.setConnectionInfos(masterNodeIpPort.split(","));
368+ client.autoConnect();
369+
370+
371+ String[] masterNodeRet = client.getValue(ImdstDefine.ConfigSaveNodePrefix + ImdstDefine.Prop_AllMasterNodeInfo);
372+
373+ if (masterNodeRet[0].equals("true")) {
374+ System.out.println("Repalce - befor =" + masterNodeRet[1]);
375+ String updateMasterNodeInfo = masternodeinfos;
376+ if(client.setValue(ImdstDefine.ConfigSaveNodePrefix + ImdstDefine.Prop_AllMasterNodeInfo, updateMasterNodeInfo)) {
377+ System.out.println("Repalce - after =" + updateMasterNodeInfo);
378+ System.out.println("MasterNode add success");
379+
380+ } else {
381+ System.out.println("MasterNode add error");
382+ }
383+ } else {
384+ System.out.println("MasterNode add error");
385+ }
386+
387+ } catch (Exception e) {
388+ e.printStackTrace();
389+ } finally {
390+ try {
391+ if (client != null) client.close();
392+ } catch (Exception e2) {
393+ }
394+ }
395+ }
396+
351397 /**
352398 * 全Keyの一覧を出力.<br>
353399 *
--- trunk/src/okuyama/imdst/process/ServerPreprocess.java (revision 1041)
+++ trunk/src/okuyama/imdst/process/ServerPreprocess.java (revision 1042)
@@ -47,6 +47,8 @@
4747 * -npmmns ImdstDefine.notPromotionMainMasterNodeStatus / MainMasterNodeに昇格しないMasterNodeを作成する場合にtrueとする / このオプションはMasterNodeの中でもデータ復旧を行うMasterNodeを限定したい場合に使う。例えばスプリットブレインなどの現象でMasterNode同士が通信出来なくなった際に、それぞれのMasterNodeが勝手に復旧をしないためなどである。
4848 * -rr ImdstDefine.recoverRequired / DataNodeがリカバリが必要な場合にtrueとして起動する
4949 * -smnca ImdstDefine.solitaryMasterNodeCheckAddress / MasterNodeの孤立チェック用の到達確認先のアドレス文字列。icmpでの確認のため、確認先のアドレスのみをカンマ区切りで設定する。全てのアドレスに届かない場合に自動的にMasterNodeがshutdownする
50+ * -ncopt ImdstDefine.nodeConnectionOpenPingTimeout / MainMasterNodeがDataNodeの生存監視を行う際にコネクションオープン時のタイムアウト閾値時間 数値にて指定(単位はミリ秒)
51+ * -ncpt ImdstDefine.nodeConnectionPingTimeout / MainMasterNodeがDataNodeの生存監視を行う際に接続後Pingの応答を待機する閾値時間 数値にて指定(単位はミリ秒)
5052 *
5153 * <br>
5254 * @author T.Okuyama
@@ -496,6 +498,29 @@
496498 settingStartParameterMap.put("-smnca", startOptions[i+1].trim());
497499 }
498500 }
501+
502+
503+ // -ncopt
504+/* if (startOptions[i].trim().equals("-ncopt")) {
505+ if (startOptions.length > (i+1)) {
506+ try {
507+ ImdstDefine.nodeConnectionOpenPingTimeout = Integer.parseInt(startOptions[i+1]);
508+ settingStartParameterMap.put("-ncopt", startOptions[i+1]);
509+ } catch(NumberFormatException nfe) {
510+ }
511+ }
512+ }
513+
514+ // -ncpt
515+ if (startOptions[i].trim().equals("-ncpt")) {
516+ if (startOptions.length > (i+1)) {
517+ try {
518+ ImdstDefine.nodeConnectionPingTimeout = Integer.parseInt(startOptions[i+1]);
519+ settingStartParameterMap.put("-ncpt", startOptions[i+1]);
520+ } catch(NumberFormatException nfe) {
521+ }
522+ }
523+ }*/
499524 }
500525 }
501526
--- trunk/okuyamaFuse/ReadMe-UTF.txt (revision 1041)
+++ trunk/okuyamaFuse/ReadMe-UTF.txt (revision 1042)
@@ -68,8 +68,8 @@
6868 -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC \
6969 fuse.okuyamafs.OkuyamaFuse \
7070 -f -o allow_other \
71- /var/tmp/okuyamafuse \
72- 192.168.1.1:8888,192.168.1.2:8888
71+ 192.168.1.1:8888,192.168.1.2:8888 \
72+ /var/tmp/okuyamafuse
7373
7474 ■アンマウント
7575 $fusermount -u /var/tmp/okufs
@@ -76,5 +76,7 @@
7676 $kill -9 実行プロセス
7777
7878
79+slave2:8888,slave3:8888
7980
8081
82+
--- trunk/okuyamaFuse/src/fuse/okuyamafs/DelayStoreDaemon.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/DelayStoreDaemon.java (revision 1042)
@@ -29,9 +29,9 @@
2929
3030 private OkuyamaClientFactory factory = null;
3131
32- private Map nowPutStringRequestKey = new HashMap(50000);
33- private Map nowPutByteRequestKey = new HashMap(50000);
34- private Map nowPutMapRequestKey = new HashMap(50000);
32+ private Map nowPutStringRequestKey = new HashMap(150000);
33+ private Map nowPutByteRequestKey = new HashMap(150000);
34+ private Map nowPutMapRequestKey = new HashMap(150000);
3535
3636
3737 public DelayStoreDaemon(String[] masterNodeInfos, int queueSize, ExpireCacheMap cacheMap, OkuyamaClientFactory factory) {
@@ -148,7 +148,6 @@
148148 }
149149
150150 this.client.sendByteValue(key, replaceBytes);
151- this.cacheMap.removeStoreTmpCache(key, requestSetTime);
152151 if (this.nowPutByteRequestKey.containsKey(key)) this.nowPutByteRequestKey.remove(key);
153152 }
154153 }
--- trunk/okuyamaFuse/src/fuse/okuyamafs/MemoryBufferedFsMap.java (nonexistent)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/MemoryBufferedFsMap.java (revision 1042)
@@ -0,0 +1,367 @@
1+// a
2+package fuse.okuyamafs;
3+import java.util.*;
4+import java.util.concurrent.ConcurrentHashMap;
5+import java.util.concurrent.*;
6+
7+import okuyama.imdst.client.*;
8+import okuyama.imdst.util.*;
9+
10+/**
11+ * OkuyamaFuse.<br>
12+ * okuyama上で全てのデータを管理するコアのMap.<br>
13+ * !!1つのブロックを大きく取って、送る際に圧縮して送ることで速度が出る。!!
14+ *
15+ * @author T.Okuyama
16+ * @license GPL(Lv3)
17+ */
18+public class MemoryBufferedFsMap extends OkuyamaFsMap implements IFsMap {
19+
20+ public int type = -1;
21+
22+
23+ private String[] masterNodeList = null;
24+
25+ private Object putSync = new Object();
26+ private Object delSync = new Object();
27+
28+ public static int delayStoreDaemonSize = 60;
29+ public static int allDelaySJobSize = 100000;
30+
31+ private ArrayBlockingQueue responseCheckDaemonQueue = null;
32+
33+ private ArrayBlockingQueue requestCheckDaemonQueue = null;
34+
35+ private Map testDataMap = new ConcurrentHashMap(50000);
36+
37+ static boolean getCache = true;
38+
39+ public OkuyamaClientFactory factory = null;
40+
41+ private String prefix = "fd1";
42+
43+ static {
44+ if (OkuyamaFilesystem.blockSize > (1024*24)) {
45+ // Fsが扱うデータがBlockサイズが24KBを超える場合はOnとなる
46+ OkuyamaFsMapUtil.setLargeDataMode(true);
47+ }
48+ }
49+
50+
51+ /**
52+ * コンストラクタ
53+ */
54+ public MemoryBufferedFsMap(int type, String[] masterNodeInfos) {
55+ super();
56+ this.type = type;
57+ this.masterNodeList = masterNodeInfos;
58+ }
59+
60+ private void initData() {
61+// String tagName = prefix "-" + type;
62+
63+ // Okuyamaに格納されている全データを取得する
64+
65+ }
66+
67+ public OkuyamaClient createClient() {
68+ OkuyamaClient client = null;
69+ try {
70+ client = new BufferedOkuyamaClient(factory.getClient(300*1000));
71+ } catch (Exception e) {
72+ e.printStackTrace();
73+ }
74+ return client;
75+ }
76+
77+
78+ public boolean putNewString(Object key, String value) {
79+ printDebug("1");
80+ //OkuyamaClient client = createClient();
81+ try {
82+
83+ //Object[] setRet = client.setNewValue(type + "\t" + (String)key, value);
84+ testDataMap.put(type + "\t" + (String)key, value);
85+/* if (!setRet[0].equals("true")) {
86+ return false;
87+ }*/
88+
89+ } catch (Exception e) {
90+ e.printStackTrace();
91+ }
92+ return true;
93+ }
94+
95+ public boolean putNewMap(Object key, Map value) {
96+ printDebug("2");
97+ try {
98+ testDataMap.put(type + "\t" + (String)key, value);
99+ } catch (Exception e) {
100+ e.printStackTrace();
101+ return false;
102+ } return true;
103+ }
104+
105+ public boolean putNewBytes(Object key, byte[] value) {
106+ printDebug("3");
107+ try {
108+
109+ synchronized(putSync) {
110+ Object a = testDataMap.get(type + "\t" + (String)key);
111+ if (a != null) return false;
112+ testDataMap.put(type + "\t" + (String)key, OkuyamaFsMapUtil.dataCompress(value));
113+ }
114+ } catch (Exception e) {
115+ e.printStackTrace();
116+ }
117+ return true;
118+ }
119+
120+
121+ public Object putBytes(Object key, byte[] value) {
122+ printDebug("4");
123+
124+ String keyStr = type + "\t" + (String)key;
125+ try {
126+ testDataMap.put(keyStr, OkuyamaFsMapUtil.dataCompress(value));
127+ } catch (Exception e) {}
128+ return null;
129+ }
130+
131+ public Object putMultiBytes(Object[] dataList) {
132+ printDebug("4.5");
133+
134+ try {
135+ List useDaemonList = new ArrayList();
136+ //long start = System.nanoTime();
137+ // 暫定実装
138+ for (int idx = 0; idx < dataList.length; idx++){
139+ Object[] putData = (Object[])dataList[idx];
140+ String keyStr = type + "\t" + (String)putData[0];
141+ byte[] data = (byte[])putData[1];
142+ testDataMap.put(keyStr, OkuyamaFsMapUtil.dataCompress(data));
143+ }
144+ } catch (Exception e) {
145+ e.printStackTrace();
146+ }
147+
148+ return null;
149+ }
150+
151+
152+ public Object putMap(Object key, Map value) {
153+ printDebug("5");
154+ try {
155+
156+ testDataMap.put(type + "\t" + (String)key, value);
157+ } catch (Exception e) {
158+ e.printStackTrace();
159+ }
160+ return null;
161+ }
162+
163+
164+ public Object putString(Object key, String value) {
165+ printDebug("5.5");
166+ try {
167+
168+ String keyStr = type + "\t" + (String)key;
169+ testDataMap.put(keyStr, value);
170+ } catch (Exception e) {
171+ e.printStackTrace();
172+ } return null;
173+ }
174+
175+
176+ public String getString(Object key) {
177+ printDebug("6");
178+ try {
179+ String keyStr = type + "\t" + (String)key;
180+ String cacheRetStr = (String)testDataMap.get(keyStr);
181+ return cacheRetStr ;
182+ } catch (Exception e) {
183+ e.printStackTrace();
184+ }
185+ return null;
186+ }
187+
188+ public Map getMap(Object key) {
189+ printDebug("7");
190+ try {
191+ Map ret = (Map)testDataMap.get(type + "\t" + (String)key);
192+ return ret;
193+ } catch (Exception e) {
194+ e.printStackTrace();
195+ }
196+ return null;
197+ }
198+
199+ public byte[] getBytes(Object key) {
200+ printDebug("8");
201+ String realKey = type + "\t" + (String)key;
202+
203+ try {
204+ byte[] data = null;
205+ if (data == null) {
206+ data = (byte[])testDataMap.get(realKey);
207+ if (data == null) return null;
208+ return OkuyamaFsMapUtil.dataDecompress(data);
209+ } else {
210+ return data;
211+ }
212+
213+ } catch (Exception e) {
214+ e.printStackTrace();
215+ }
216+ return null;
217+ }
218+
219+ public Map getMultiBytes(Object[] keyList) {
220+ printDebug("9");
221+ Map retMap = new HashMap();
222+ Map okuyamaDataMap = new HashMap();
223+
224+ try {
225+ List tmpKeyList = new ArrayList();
226+ List realTmpKeyList = new ArrayList();
227+ String[] keyStrList = null;
228+
229+ for (int idx = 0; idx < keyList.length; idx++) {
230+ String key = type + "\t" + (String)keyList[idx];
231+ byte[] data = (byte[])testDataMap.get(key);
232+
233+ if (data != null) {
234+ retMap.put((String)keyList[idx], OkuyamaFsMapUtil.dataDecompress(data));
235+ }
236+ }
237+
238+ } catch (Exception e) {
239+ e.printStackTrace();
240+ }
241+
242+ //long end = System.nanoTime();
243+ //printDebug("Key count=" + keyList.length + " Time=" + ((end - start) / 1000));
244+ return retMap;
245+ }
246+
247+ public Object remove(Object key) {
248+ printDebug("10");
249+ try {
250+ String cnvKey = type + "\t" + (String)key;
251+ testDataMap.remove(cnvKey);
252+ } catch (Exception e) {
253+ e.printStackTrace();
254+ }
255+ return null;
256+ }
257+
258+ public boolean removeMulti(Object[] keyList) {
259+ printDebug("11");
260+ boolean ret = true;
261+
262+ try {
263+
264+ //List clientList = new ArrayList(20);
265+ for (int idx = 0; idx < keyList.length; idx++) {
266+
267+ if (keyList[idx] != null) {
268+
269+ Object key = keyList[idx];
270+
271+ String removeKey = type + "\t" + (String)key;
272+ Object rmRet = testDataMap.remove(removeKey);
273+ if (rmRet == null) return false;
274+
275+/* String[] removeRet = client.removeValue(removeKey);
276+ if(!removeRet[0].equals("true")) {
277+ ret = false;
278+ }*/
279+ }
280+ }
281+
282+ } catch (Exception e) {
283+ e.printStackTrace();
284+ }
285+ return ret;
286+ }
287+/*
288+ public boolean removeMulti(Object[] keyList) {
289+
290+ boolean ret = true;
291+
292+ try {
293+
294+ //List clientList = new ArrayList(20);
295+ Object[] clientList = new Object[keyList.length];
296+ for (int idx = 0; idx < keyList.length; idx++) {
297+
298+ if (keyList[idx] != null) {
299+ OkuyamaClient client = createClient();
300+ Object key = keyList[idx];
301+
302+ String removeKey = type + "\t" + (String)key;
303+ dataCache.remove(removeKey);
304+ client.requestRemoveValue(removeKey);
305+
306+ Object[] checkSt = new Object[2];
307+ checkSt[0] = removeKey;
308+ checkSt[1] = client;
309+ clientList[idx] = checkSt;
310+ }
311+ }
312+
313+
314+ for (int idx = 0; idx < clientList.length; idx++) {
315+
316+ Object[] checkSt = (Object[])clientList[idx];
317+
318+ String removeKey = (String)checkSt[0];
319+ OkuyamaClient client = (OkuyamaClient)checkSt[1];
320+
321+ String[] removeRet = client.responseRemoveValue(removeKey);
322+ client.close();
323+
324+ if(!removeRet[0].equals("true")) {
325+ ret = false;
326+ }
327+ }
328+ clientList = null;
329+ } catch (Exception e) {
330+ e.printStackTrace();
331+ }
332+ return ret;
333+ }
334+*/
335+ public boolean removeExistObject(Object key) {
336+ printDebug("12");
337+ //OkuyamaClient client = createClient();
338+ try {
339+
340+ synchronized(delSync) {
341+ String cnvKey = type + "\t" + (String)key;
342+ /*Object[] ret = client.getValue(cnvKey);
343+ if (!ret[0].equals("true")) {
344+ return false;
345+ }*/
346+ Object rmRet = testDataMap.remove(cnvKey);
347+ if (rmRet == null) return false;
348+/*
349+ client.removeValue(cnvKey);*/
350+ }
351+ } catch (Exception e) {
352+ e.printStackTrace();
353+ }
354+ return true;
355+ }
356+
357+ public boolean containsKey(Object key) {
358+ printDebug("13");
359+ return testDataMap.containsKey(type + "\t" + (String)key);
360+ }
361+
362+ private void printDebug(String str) {
363+ //System.out.println(new Date() + " " + str);
364+ }
365+}
366+
367+
--- trunk/okuyamaFuse/src/fuse/okuyamafs/BufferedOkuyamaClient.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/BufferedOkuyamaClient.java (revision 1042)
@@ -46,7 +46,8 @@
4646 okuyamaRequestQueue = new ArrayBlockingQueue(500);
4747 } else {
4848 okuyamaRequestQueue = new ArrayBlockingQueue(4000);
49- parallel = 16;
49+// parallel = 16;
50+ parallel = 30;
5051 }
5152 }
5253
@@ -65,10 +66,12 @@
6566
6667
6768 public String[] setNewValue(String key, String value) throws OkuyamaClientException {
69+ System.out.println("setNewValue");
6870 return this.client.setNewValue(key, value);
6971 }
7072
7173 public String[] setNewObjectValue(String key, Object value) throws OkuyamaClientException {
74+ System.out.println("setNewObjectValue");
7275 return this.client.setNewObjectValue(key, value);
7376 }
7477
@@ -79,7 +82,7 @@
7982 *
8083 */
8184 public static void initClientMaster(OkuyamaClientFactory factory, boolean bufferedFlg, boolean stripingDataBlock) throws Exception {
82-
85+ System.out.println("initClientMaster");
8386 BufferedOkuyamaClient.stripingDataBlock = stripingDataBlock;
8487 BufferedOkuyamaClient.factory = factory;
8588 if (bufferedFlg == false) {
@@ -103,6 +106,8 @@
103106
104107
105108 public void close() throws OkuyamaClientException {
109+ System.out.println("close");
110+
106111 this.client.close();
107112 if (stripingDataBlock == true) {
108113 try {
@@ -116,7 +121,10 @@
116121
117122
118123 public boolean setValue(String key, String value) throws OkuyamaClientException {
119- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.setValue(key, value);
124+ if (!BufferedOkuyamaClient.bufferedFlg) {
125+ System.out.println("setValue-1");
126+ return this.client.setValue(key, value);
127+ }
120128
121129 try {
122130
@@ -144,7 +152,10 @@
144152 }
145153
146154 public String[] getValue(String key) throws OkuyamaClientException {
147- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.getValue(key);
155+ if (!BufferedOkuyamaClient.bufferedFlg) {
156+ System.out.println("getValue-1");
157+ return this.client.getValue(key);
158+ }
148159
149160 String[] ret = null;
150161
@@ -156,6 +167,8 @@
156167
157168 if (value == null) {
158169 realClientRet = this.client.getValue(key);
170+ System.out.println("this.client.getValue("+key+")");
171+
159172 if (realClientRet != null && realClientRet[0].equals("true")) {
160173 value = realClientRet[1];
161174 }
@@ -186,7 +199,10 @@
186199
187200
188201 public Object[] getObjectValue(String key) throws OkuyamaClientException {
189- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.getObjectValue(key);
202+ if (!BufferedOkuyamaClient.bufferedFlg) {
203+ System.out.println("getObjectValue-1");
204+ return this.client.getObjectValue(key);
205+ }
190206 Object[] ret = null;
191207
192208 try {
@@ -197,6 +213,7 @@
197213
198214 if (value == null) {
199215 realClientRet = this.client.getObjectValue(key);
216+ System.out.println("this.client.getObjectValue("+key+")");
200217 if (realClientRet != null && realClientRet[0].equals("true")) {
201218 value = realClientRet[1];
202219 }
@@ -227,7 +244,10 @@
227244
228245
229246 public boolean setObjectValue(String key, Object value) throws OkuyamaClientException {
230- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.setObjectValue(key, value);
247+ if (!BufferedOkuyamaClient.bufferedFlg) {
248+ System.out.println("setObjectValue-1");
249+ return this.client.setObjectValue(key, value);
250+ }
231251 try {
232252 while (true) {
233253
@@ -252,8 +272,12 @@
252272 }
253273
254274 public boolean sendByteValue(String key, byte[] value) throws OkuyamaClientException {
255- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.sendByteValue(key, value);
275+ if (!BufferedOkuyamaClient.bufferedFlg) {
276+ System.out.println("sendByteValue-1");
256277
278+ return this.client.sendByteValue(key, value);
279+ }
280+
257281 try {
258282 while (true) {
259283 synchronized(sendSyncObject[((key.hashCode() << 1) >>> 1) % syncParallel]) {
@@ -282,7 +306,10 @@
282306
283307
284308 public String[] removeValue(String key) throws OkuyamaClientException {
285- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.removeValue(key);
309+ if (!BufferedOkuyamaClient.bufferedFlg) {
310+ System.out.println("removeValue-1");
311+ return this.client.removeValue(key);
312+ }
286313 String[] ret = null;
287314 try {
288315 while (true) {
@@ -300,6 +327,7 @@
300327 Object removeRet = putBufferedDataMap.remove(key);
301328 if (removeRet == null) {
302329 String[] realClientRmRet = this.client.getValue(key);
330+ System.out.println("removeValue-this.client.getValue("+key+")");
303331 if (realClientRmRet[0].equals("false")) {
304332 ret = new String[1];
305333 ret[0] = "false";
@@ -319,7 +347,10 @@
319347
320348
321349 public boolean requestRemoveValue(String key) throws OkuyamaClientException {
322- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.requestRemoveValue(key);
350+ if (!BufferedOkuyamaClient.bufferedFlg) {
351+ System.out.println("requestRemoveValue-1");
352+ return this.client.requestRemoveValue(key);
353+ }
323354 try {
324355 while (true) {
325356 synchronized(sendSyncObject[((key.hashCode() << 1) >>> 1) % syncParallel]) {
@@ -342,7 +373,10 @@
342373 }
343374
344375 public String[] responseRemoveValue(String key) throws OkuyamaClientException {
345- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.responseRemoveValue(key);
376+ if (!BufferedOkuyamaClient.bufferedFlg) {
377+ System.out.println("responseRemoveValue-1");
378+ return this.client.responseRemoveValue(key);
379+ }
346380 String[] ret = null;
347381
348382 try {
@@ -364,7 +398,10 @@
364398
365399
366400 public Object[] readByteValue(String key) throws OkuyamaClientException {
367- if (!BufferedOkuyamaClient.bufferedFlg) return this.client.readByteValue(key);
401+ if (!BufferedOkuyamaClient.bufferedFlg) {
402+ System.out.println("readByteValue-1");
403+ return this.client.readByteValue(key);
404+ }
368405 Object[] ret = null;
369406
370407 try {
@@ -376,7 +413,7 @@
376413 // Stripingの場合で処理がことなる
377414 if (BufferedOkuyamaClient.stripingDataBlock == false) {
378415 Object[] realClientRet = this.client.readByteValue(key);
379-
416+ System.out.println("readByteValue(" + key+");");
380417 if (realClientRet != null && realClientRet[0].equals("true")) {
381418
382419 value = (byte[])realClientRet[1];
--- trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFilesystem.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFilesystem.java (revision 1042)
@@ -24,7 +24,7 @@
2424
2525 public volatile static int blockSizeAssist = 50;
2626
27- public volatile static int blockSize = 1024*16;//5200; // Blockサイズ
27+ public volatile static int blockSize = 1024*16+5;//5200; // Blockサイズ
2828 //public volatile static int blockSize = 5632; // Blockサイズ
2929
3030
@@ -654,7 +654,7 @@
654654 }
655655
656656 public int write(String path, Object fh, boolean isWritepage, ByteBuffer buf, long offset) throws FuseException {
657- //log.info("write path:" + path + " offset:" + offset + " isWritepage:" + isWritepage + " buf.limit:" + buf.limit());
657+ log.info("write path:" + path + " offset:" + offset + " isWritepage:" + isWritepage + " buf.limit:" + buf.limit());
658658 //long startAA = System.nanoTime();
659659 try {
660660
@@ -930,14 +930,16 @@
930930
931931 if (appendWriteDataBuf.containsKey(fh)) {
932932 Map appendData = (Map)appendWriteDataBuf.remove(fh);
933- String bPath = (String)appendData.get("path");
934- Object bFh = (Object)appendData.get("fh");
935- boolean bIsWritepage = ((Boolean)appendData.get("isWritepage")).booleanValue();
936- ByteArrayOutputStream bBuf = (ByteArrayOutputStream)appendData.get("buf");
937- long bOffset = ((Long)appendData.get("offset")).longValue();
938-
939- int realWriteRet = this.realWrite(bPath, bFh, bIsWritepage, bBuf, bOffset);
940- return realWriteRet;
933+ if (appendData != null) {
934+ String bPath = (String)appendData.get("path");
935+ Object bFh = (Object)appendData.get("fh");
936+ boolean bIsWritepage = ((Boolean)appendData.get("isWritepage")).booleanValue();
937+ ByteArrayOutputStream bBuf = (ByteArrayOutputStream)appendData.get("buf");
938+ long bOffset = ((Long)appendData.get("offset")).longValue();
939+
940+ int realWriteRet = this.realWrite(bPath, bFh, bIsWritepage, bBuf, bOffset);
941+ return realWriteRet;
942+ }
941943 }
942944 return 0;
943945 }
--- trunk/okuyamaFuse/src/fuse/okuyamafs/CoreMapFactory.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/CoreMapFactory.java (revision 1042)
@@ -45,8 +45,8 @@
4545 if (CoreMapFactory.factoryType == 1) {
4646 return new NativeFsMap(1, (String[])parameterMap.get("okuyamainfo"));
4747 } else if(CoreMapFactory.factoryType == 2) {
48- //return new OkuyamaFsMap(1, (String[])parameterMap.get("okuyamainfo")); //
49- return new MemoryBufferedFsMap(1, (String[])parameterMap.get("okuyamainfo"));
48+ return new OkuyamaFsMap(1, (String[])parameterMap.get("okuyamainfo")); //
49+ //return new MemoryBufferedFsMap(1, (String[])parameterMap.get("okuyamainfo"));
5050 } else if (CoreMapFactory.factoryType == 3) {
5151 return new LocalCacheOkuyamaFsMap(1, (String[])parameterMap.get("okuyamainfo"));
5252 }
@@ -58,8 +58,8 @@
5858 if (CoreMapFactory.factoryType == 1) {
5959 return new NativeFsMap(2, (String[])parameterMap.get("okuyamainfo"));
6060 } else if(CoreMapFactory.factoryType == 2) {
61- //return new OkuyamaFsMap(2, (String[])parameterMap.get("okuyamainfo"));
62- return new MemoryBufferedFsMap(2, (String[])parameterMap.get("okuyamainfo"));
61+ return new OkuyamaFsMap(2, (String[])parameterMap.get("okuyamainfo"));
62+ //return new MemoryBufferedFsMap(2, (String[])parameterMap.get("okuyamainfo"));
6363
6464 } else if (CoreMapFactory.factoryType == 3) {
6565 return new LocalCacheOkuyamaFsMap(2, (String[])parameterMap.get("okuyamainfo"));
@@ -72,8 +72,8 @@
7272 if (CoreMapFactory.factoryType == 1) {
7373 return new NativeFsMap(3, (String[])parameterMap.get("okuyamainfo"));
7474 } else if(CoreMapFactory.factoryType == 2) {
75- //return new OkuyamaFsMap(3, (String[])parameterMap.get("okuyamainfo"));
76- return new MemoryBufferedFsMap(3, (String[])parameterMap.get("okuyamainfo"));
75+ return new OkuyamaFsMap(3, (String[])parameterMap.get("okuyamainfo"));
76+ //return new MemoryBufferedFsMap(3, (String[])parameterMap.get("okuyamainfo"));
7777 } else if (CoreMapFactory.factoryType == 3) {
7878 return new LocalCacheOkuyamaFsMap(3, (String[])parameterMap.get("okuyamainfo"));
7979 }
--- trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFsMapUtil.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFsMapUtil.java (revision 1042)
@@ -20,12 +20,12 @@
2020 public static int multiDataAccessDaemons = 50;
2121 public static int multiDataAccessDaemonsQueue = 130;
2222
23- public static int okuyamaClientPoolSize = 350;
23+ public static int okuyamaClientPoolSize = 15000;
24+ public static int okuyamaFsMaxCacheTime = 100000; // ミリ秒
25+ public static int okuyamaFsMaxCacheLimit = 100000; // キャッシュ数
2426
25- public static int okuyamaFsMaxCacheLimit = 100000;
2627
2728
28-
2929 public static void setLargeDataMode(boolean type) {
3030 largeDataMode = type;
3131 multiDataAccessDaemons = 25;
--- trunk/okuyamaFuse/src/fuse/okuyamafs/BufferedDataStoredMap.java (nonexistent)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/BufferedDataStoredMap.java (revision 1042)
@@ -0,0 +1,178 @@
1+package fuse.okuyamafs;
2+
3+
4+import java.util.*;
5+import java.util.concurrent.locks.*;
6+import java.util.concurrent.*;
7+
8+import okuyama.imdst.client.*;
9+import okuyama.imdst.util.*;
10+
11+
12+/**
13+ * OkuyamaFuse.<br>
14+ * LinkedHashMapを継承してLRUキャッシュを実現.<br>
15+ * このLRUキャッシュは一定のデータ数でも自動的に消えるが、指定したExpireTimeが経過した
16+ * キャッシュも無効となり消えていく。
17+ *
18+ *
19+ * @author T.Okuyama
20+ * @license GPL(Lv3)
21+ */
22+public class BufferedDataStoredMap extends Thread {
23+
24+ private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
25+ private final Lock r = rwl.readLock();
26+ private final Lock w = rwl.writeLock();
27+ private DelayStoreDaemon delayStoreDaemon = null;
28+ private String[] masterNodeInfo = null;
29+
30+ private Map dataMap = new ConcurrentHashMap(100000);
31+ private Queue storeRequestQueue = new ArrayBlockingQueue(3000);
32+
33+ private String okuyamaTag = "d";
34+
35+ /**
36+ * コンストラクタ.<br>
37+ */
38+ public BufferedDataStoredMap(String[] masterNodeInfo) {
39+ this.masterNodeInfo = masterNodeInfo;
40+ this.start();
41+ }
42+
43+ public void run () {
44+ Object[] requestData = null;
45+
46+ while (true) {
47+
48+ try {
49+
50+ // リクエストがnullの場合だけQueueから取り出す。
51+ // 正常にokuyamaに伝播した場合、nullとするからである。Exception発生時はnull化されない
52+ if (requestData == null) {
53+ // [0] = type(1=put, 2=remove), [1]=DataType(1=byte, 2=String, 3=Object), [2]=Key, [3]=Value
54+
55+ while (true) {
56+ requestData = (Object[])this.storeRequestQueue.poll(1000, TimeUnit.MILLISECONDS);
57+
58+ if (requestData != null) break;
59+ if (OkuyamaFilesystem.jvmShutdownStatus == true) break;
60+ }
61+
62+ if (requestData == null && OkuyamaFilesystem.jvmShutdownStatus == true) break;
63+ if (DelayStoreDaemon.nowQueueJob.get() > 0) DelayStoreDaemon.nowQueueJob.decrementAndGet();
64+ }
65+ Object[] request = storeRequestQueue.
66+ } catch (Exception e) {
67+ e.printStackTrace();
68+ }
69+ }
70+ }
71+ /**
72+ * set<br>
73+ *
74+ * @param key
75+ * @param value
76+ */
77+ public Object put(String key, byte[] value) {
78+ w.lock();
79+ try {
80+ } finally {
81+ w.unlock();
82+ }
83+ return null;
84+ }
85+
86+
87+ /**
88+ * set<br>
89+ *
90+ * @param key
91+ * @param value
92+ */
93+ public Object put(String key, String value) {
94+ w.lock();
95+ try {
96+ } finally {
97+ w.unlock();
98+ }
99+ return null;
100+ }
101+
102+ /**
103+ * set<br>
104+ *
105+ * @param key
106+ * @param value
107+ */
108+ public Object put(String key, Map value) {
109+ w.lock();
110+ try {
111+ } finally {
112+ w.unlock();
113+ }
114+ return null;
115+ }
116+
117+
118+ /**
119+ * containsKey<br>
120+ *
121+ * @param key
122+ * @return boolean
123+ */
124+ public boolean containsKey(Object key) {
125+ r.lock();
126+ try {
127+ } finally {
128+ r.unlock();
129+ }
130+ return false;
131+ }
132+
133+
134+ /**
135+ * get<br>
136+ *
137+ * @param key
138+ * @return Object
139+ */
140+ public Object get(Object key) {
141+ r.lock();
142+ try {
143+ } finally {
144+ r.unlock();
145+ }
146+ return null;
147+ }
148+
149+
150+ /**
151+ * remove<br>
152+ *
153+ * @param key
154+ * @return Object
155+ */
156+ public Object remove(Object key) {
157+ w.lock();
158+ try {
159+ } finally {
160+ w.unlock();
161+ }
162+ return null;
163+ }
164+
165+ /**
166+ * clear<br>
167+ *
168+ */
169+ public void clear() {
170+ w.lock();
171+ try {
172+
173+ } finally {
174+ w.unlock();
175+ }
176+ }
177+
178+}
\ No newline at end of file
--- trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFsMap.java (revision 1041)
+++ trunk/okuyamaFuse/src/fuse/okuyamafs/OkuyamaFsMap.java (revision 1042)
@@ -29,7 +29,6 @@
2929 public static int allDelaySJobSize = 100000;
3030
3131 private ArrayBlockingQueue responseCheckDaemonQueue = null;
32-
3332 private ArrayBlockingQueue requestCheckDaemonQueue = null;
3433
3534
@@ -45,6 +44,7 @@
4544
4645 public OkuyamaClientFactory factory = null;
4746
47+ public boolean singleIOMode = true;
4848
4949 static {
5050 if (OkuyamaFilesystem.blockSize > (1024*24)) {
@@ -71,9 +71,9 @@
7171 this.factory = OkuyamaClientFactory.getFactory(this.masterNodeList, OkuyamaFsMapUtil.okuyamaClientPoolSize);
7272
7373 if (type == 1) {
74- this.dataCache = new ExpireCacheMap(OkuyamaFsMap.allDelaySJobSize, OkuyamaFsMapUtil.okuyamaFsMaxCacheLimit, this.factory, false);
74+ this.dataCache = new ExpireCacheMap(OkuyamaFsMapUtil.okuyamaFsMaxCacheLimit, OkuyamaFsMapUtil.okuyamaFsMaxCacheTime, this.factory, false);
7575 } else {
76- this.dataCache = new ExpireCacheMap(OkuyamaFsMap.allDelaySJobSize, 5*1000, false);
76+ this.dataCache = new ExpireCacheMap(OkuyamaFsMap.allDelaySJobSize, OkuyamaFsMapUtil.okuyamaFsMaxCacheTime, false);
7777 }
7878 /*this.delayStoreDaemon = new DelayStoreDaemon[delayStoreDaemonSize];
7979 for (int idx = 0; idx < delayStoreDaemonSize; idx++) {
@@ -80,12 +80,13 @@
8080 this.delayStoreDaemon[idx] = new DelayStoreDaemon(masterNodeInfos, (allDelaySJobSize / delayStoreDaemonSize), dataCache, this.factory);
8181 this.delayStoreDaemon[idx].start();
8282 }*/
83-
84- for (int idx = 0; idx < OkuyamaFsMapUtil.multiDataAccessDaemons; idx++) {
85-
86- ResponseCheckDaemon responseCheckDaemon = new ResponseCheckDaemon(this.factory);
87- responseCheckDaemon.start();
88- this.responseCheckDaemonQueue.put(responseCheckDaemon);
83+ if (!singleIOMode) {
84+ for (int idx = 0; idx < OkuyamaFsMapUtil.multiDataAccessDaemons; idx++) {
85+
86+ ResponseCheckDaemon responseCheckDaemon = new ResponseCheckDaemon(this.factory);
87+ responseCheckDaemon.start();
88+ this.responseCheckDaemonQueue.put(responseCheckDaemon);
89+ }
8990 }
9091
9192 for (int idx = 0; idx < OkuyamaFsMapUtil.multiDataAccessDaemons; idx++) {
@@ -415,7 +416,9 @@
415416
416417 public Map getMultiBytes(Object[] keyList) {
417418 //return (byte[])dumm.get(type + "\t" + (String)key);
418- //long start = System.nanoTime();
419+ System.out.println("getMulti:siez=" + keyList.length);
420+ long start = System.nanoTime();
421+
419422 Map retMap = new HashMap();
420423 Map okuyamaDataMap = new HashMap();
421424
@@ -435,6 +438,27 @@
435438 retMap.put((String)keyList[idx], data);
436439 }
437440 }
441+
442+ if (singleIOMode) {
443+ int tmpKeyListSize = tmpKeyList.size();
444+ if (tmpKeyListSize > 0) {
445+ BufferedOkuyamaClient client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
446+ for (int i = 0; i < tmpKeyListSize; i++) {
447+ String key = (String)tmpKeyList.get(i);
448+ Object[] responseSet = client.readByteValue(key);
449+
450+ if (responseSet[0].equals("true")) {
451+ Object[] retObj = new Object[2];
452+ byte[] decompBytes = OkuyamaFsMapUtil.dataDecompress((byte[])responseSet[1]);
453+ retMap.put((String)realTmpKeyList.get(i), decompBytes);
454+ dataCache.put(key, decompBytes);
455+ }
456+ }
457+ client.close();
458+ }
459+ return retMap;
460+ }
461+
438462 if (tmpKeyList.size() > 0) {
439463 keyStrList = (String[])tmpKeyList.toArray(new String[0]);
440464
@@ -480,7 +504,9 @@
480504
481505 if (responseObj.length > 0) {
482506 String objKey = (String)realTmpKeyList.get(i);
483- //if (!dataCache.containsKey(objKey)) dataCache.put(objKey, (byte[])responseObj[1]);
507+ if (!dataCache.containsKey(objKey)) {
508+ dataCache.put(keyStrList[i], (byte[])responseObj[1]);
509+ }
484510 retMap.put(objKey, (byte[])responseObj[1]);
485511 }
486512 if (!this.responseCheckDaemonQueue.offer(daemon)) daemon.endRequest();
@@ -490,8 +516,8 @@
490516 } catch (Exception e) {
491517 e.printStackTrace();
492518 }
493- //long end = System.nanoTime();
494- //System.out.println("Key count=" + keyList.length + " Time=" + ((end - start) / 1000));
519+ long end = System.nanoTime();
520+ System.out.println("Key count=" + keyList.length + " Time=" + ((end - start) / 1000));
495521 return retMap;
496522 }
497523
@@ -652,7 +678,7 @@
652678 }
653679
654680 public void run() {
655-
681+ long clientCreateTime = 0L;
656682 while (true) {
657683 try {
658684 String key = null;
@@ -672,8 +698,24 @@
672698 }
673699 break;
674700 }
675-
676- client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
701+
702+ if (client == null) {
703+ client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
704+ clientCreateTime = System.currentTimeMillis();
705+ } else {
706+ // 既に作成してから1分経過しているか確認
707+ if ((clientCreateTime + 60000) < System.currentTimeMillis()) {
708+ // 経過している
709+ // 作り直し
710+ client.close();
711+ client = null;
712+ client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
713+ clientCreateTime = System.currentTimeMillis();
714+ } else {
715+ // 経過していない
716+
717+ }
718+ }
677719 //long start = System.nanoTime();
678720 Object[] responseSet = client.readByteValue(key);
679721 //long end = System.nanoTime();
@@ -706,8 +748,12 @@
706748 } finally {
707749 try {
708750 if (client != null ) {
709- client.close();
710- client = null;
751+ if ((clientCreateTime + 60000) < System.currentTimeMillis()) {
752+ // 経過している
753+ // 作り直し
754+ client.close();
755+ client = null;
756+ }
711757 }
712758 } catch (Exception ee) {}
713759 }
@@ -759,7 +805,7 @@
759805 }
760806
761807 public void run() {
762-
808+ long clientCreateTime = 0L;
763809 while (true) {
764810 try {
765811 Object[] request = null;
@@ -780,14 +826,23 @@
780826 break;
781827 }
782828
783- if (clientUseCount > maxClientUseCount) {
784- if (client != null ) {
829+ if (client == null) {
830+ client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
831+ clientCreateTime = System.currentTimeMillis();
832+ } else {
833+ // 既に作成してから1分経過しているか確認
834+ if ((clientCreateTime + 60000) < System.currentTimeMillis()) {
835+ // 経過している
836+ // 作り直し
785837 client.close();
786838 client = null;
839+ client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
840+ clientCreateTime = System.currentTimeMillis();
841+ } else {
842+ // 経過していない
843+
787844 }
788- clientUseCount = 0;
789845 }
790- if (client == null) client = new BufferedOkuyamaClient(this.factory.getClient(300*1000));
791846
792847 clientUseCount++;
793848 boolean ret = client.sendByteValue((String)request[0], OkuyamaFsMapUtil.dataCompress((byte[])request[1]));
@@ -809,6 +864,17 @@
809864 try {
810865 responseBox.put(new Object[0]);
811866 } catch (Exception ee) {}
867+ } finally {
868+ try {
869+ if (client != null ) {
870+ if ((clientCreateTime + 60000) < System.currentTimeMillis()) {
871+ // 経過している
872+ // 作り直し
873+ client.close();
874+ client = null;
875+ }
876+ }
877+ } catch (Exception ee) {}
812878 }
813879 }
814880 }
--- trunk/build.xml (revision 1041)
+++ trunk/build.xml (revision 1042)
@@ -6,7 +6,7 @@
66 <property name="src.dir" value="src" />
77 <property name="build.dir" value="classes" />
88 <property name="install.dir" value="install" />
9- <property name="version" value="0.9.5" />
9+ <property name="version" value="0.9.6" />
1010 <property name="javadoc.dir" value="javadoc"/>
1111 <property name="lib.dir" value="lib"/>
1212 <property name="custom.dir" value="customserializer/release/MessagePackSerializer"/>
@@ -93,7 +93,7 @@
9393 <java classname="okuyama.base.JavaMain" fork="true" maxmemory="512m">
9494 <arg value="/Main.properties"/>
9595 <arg value="/DataNode_small.properties"/>
96- <arg value=" -s 4096"/>
96+ <arg value=" -s 4096 -vidf false -csf false"/>
9797 <classpath refid="project.class.path"/>
9898 </java>
9999 </target>
Show on old repository browser