• R/O
  • SSH
  • HTTPS

okuyama: 提交


Commit MetaInfo

修訂967 (tree)
時間2012-09-05 18:43:09
作者okuyamaoo

Log Message

(empty log message)

Change Summary

差異

--- trunk/src/okuyama/imdst/helper/KeyManagerHelper.java (revision 966)
+++ trunk/src/okuyama/imdst/helper/KeyManagerHelper.java (revision 967)
@@ -1047,7 +1047,7 @@
10471047 retStrs[2] = "NG:Max Data Size Over";
10481048 }
10491049 } catch (BatchException be) {
1050-
1050+be.printStackTrace();
10511051 logger.debug("KeyManagerHelper - setDatanode - Error = [" + key + "]", be);
10521052 //logger.debug("KeyManagerHelper - setDatanode - Error", be);
10531053 retStrs[0] = "1";
--- trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 966)
+++ trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 967)
@@ -360,6 +360,31 @@
360360 retParams = this.getKeyValue(clientParameterList[1]);
361361
362362 break;
363+ case 201 :
364+ //System.out.println(new String(BASE64DecoderStream.decode(clientParameterList[1].getBytes())));
365+ // Key値でValueを取得する
366+ retParams = this.getKeyValue(clientParameterList[1]);
367+
368+ if (retParams.length > 1 && retParams[1].equals("true")) {
369+
370+
371+ String[] realRetParams = new String[4];
372+ realRetParams[0] = "201";
373+ realRetParams[1] = "true";
374+ byte[] valLenBytes = new Integer(retParams[2].length()).toString().getBytes();
375+ byte[] valLenInfo = {48,48,48,48,48,48,48,48,48};
376+ int idx = 0;
377+ for (int i = (9 - valLenBytes.length); i < 9; i++) {
378+ valLenInfo[i] = valLenBytes[idx];
379+ idx++;
380+ }
381+ realRetParams[2] = new String(valLenInfo);
382+ realRetParams[3] = retParams[2];
383+ retParams = realRetParams;
384+ }
385+
386+ break;
387+
363388 case 3 :
364389
365390 // Tag値でキー値群を取得する
--- trunk/src/okuyama/imdst/util/SystemUtil.java (revision 966)
+++ trunk/src/okuyama/imdst/util/SystemUtil.java (revision 967)
@@ -789,7 +789,7 @@
789789 ByteArrayOutputStream bao = null;
790790 ObjectOutput oo = null;
791791 try {
792- bao = new ByteArrayOutputStream(5000);
792+ bao = new ByteArrayOutputStream(17000);
793793
794794 for (Iterator it = ((Map)data).entrySet().iterator(); it.hasNext(); ) {
795795
--- trunk/src/okuyama/imdst/client/OkuyamaClient.java (revision 966)
+++ trunk/src/okuyama/imdst/client/OkuyamaClient.java (revision 967)
@@ -174,10 +174,20 @@
174174
175175 // サーバへの出力用
176176 protected PrintWriter pw = null;
177+ protected BufferedOutputStream bos = null;
177178
178179 // サーバからの受信用
179180 protected BufferedReader br = null;
181+ protected BufferedInputStream bis = null;
180182
183+
184+ protected byte[] getMethodTypeBytes = "201".getBytes();
185+ protected byte[] clientMethodSepBytes = OkuyamaClient.sepStr.getBytes();
186+ protected byte[] clientMethodEndSep = "\n".getBytes();
187+
188+ protected byte[] readBytesRetHeaderBytes = "201,true,".getBytes();
189+
190+
181191 protected String transactionCode = "0";
182192
183193 public static final String SEARCH_VALUE_TYPE_AND = "1";
@@ -332,7 +342,11 @@
332342
333343 this.socket.setSoTimeout(ImdstDefine.clientConnectionTimeout);
334344 this.pw = new ClientCustomPrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), OkuyamaClient.connectDefaultEncoding)));
345+ this.bos = new BufferedOutputStream(socket.getOutputStream());
346+
335347 this.br = new BufferedReader(new InputStreamReader(socket.getInputStream(), OkuyamaClient.connectDefaultEncoding));
348+ this.bis = new BufferedInputStream(socket.getInputStream());
349+
336350 this.initClient();
337351 this.nowConnectServerInfo = nodeStr;
338352 break;
@@ -467,6 +481,19 @@
467481 this.br = null;
468482 }
469483
484+
485+ if (this.bos != null) {
486+ this.bos.close();
487+ this.bos = null;
488+ }
489+
490+
491+ if (this.bis != null) {
492+ this.bis.close();
493+ this.bis = null;
494+ }
495+
496+
470497 if (this.socket != null) {
471498 this.socket.close();
472499 this.socket = null;
@@ -6595,6 +6622,7 @@
65956622 }
65966623
65976624
6625+
65986626 /**
65996627 * MasterNodeからKeyでデータを取得する(バイナリ).<br>
66006628 * sendByteValueで登録したValueはこちらで取得する.<br>
@@ -6736,11 +6764,12 @@
67366764 if (keyStr == null || keyStr.trim().equals(""))
67376765 throw new OkuyamaClientException("The blank is not admitted on a key");
67386766
6767+ byte[] keyBytes = keyStr.getBytes();
67396768 // Keyに対するLengthチェック
6740- if (keyStr.getBytes().length > maxKeySize) throw new OkuyamaClientException("Save Key Max Size " + keyStr + " Byte");
6769+ if (keyBytes.length > maxKeySize) throw new OkuyamaClientException("Save Key Max Size " + keyStr + " Byte");
67416770
67426771 // 文字列バッファ初期化
6743- serverRequestBuf = new StringBuilder(ImdstDefine.stringBufferSmallSize);
6772+/* serverRequestBuf = new StringBuilder(ImdstDefine.stringBufferSmallSize);
67446773
67456774 // 処理番号連結
67466775 serverRequestBuf.append("2");
@@ -6748,12 +6777,21 @@
67486777 serverRequestBuf.append(OkuyamaClient.sepStr);
67496778
67506779 // Key連結(Keyはデータ送信時には必ず文字列が必要)
6751- serverRequestBuf.append(new String(this.dataEncoding(keyStr.getBytes())));
6780+ serverRequestBuf.append(new String(this.dataEncoding(keyBytes)));
67526781
67536782 // サーバ送信
67546783 pw.println(serverRequestBuf.toString());
67556784 pw.flush();
6785+*/
6786+ byte[] valueDataBytes = this.dataEncoding(keyBytes);
6787+ this.bos.write(this.getMethodTypeBytes, 0 ,this.getMethodTypeBytes.length);
6788+ this.bos.write(this.clientMethodSepBytes, 0 ,this.clientMethodSepBytes.length);
6789+ this.bos.write(valueDataBytes, 0 ,valueDataBytes.length);
6790+ this.bos.write(this.clientMethodEndSep, 0 ,this.clientMethodEndSep.length);
67566791
6792+ this.bos.flush();
6793+
6794+
67576795 ret = true;
67586796 } catch (OkuyamaClientException ice) {
67596797 throw ice;
@@ -6793,6 +6831,47 @@
67936831 if (this.socket == null) throw new OkuyamaClientException("No ServerConnect!!");
67946832
67956833 // サーバから結果受け取り
6834+ byte[] realRetParams = new byte[9];
6835+ this.bis.read(realRetParams, 0, 9);
6836+ boolean checkRet = true;
6837+ for (int i = 0; i < readBytesRetHeaderBytes.length; i++) {
6838+ if (realRetParams[i] != this.readBytesRetHeaderBytes[i]) {
6839+ checkRet = false;
6840+ break;
6841+ }
6842+ }
6843+
6844+ if (checkRet == true) {
6845+ byte[] valueLenInfo = new byte[9];
6846+ this.bis.read(valueLenInfo, 0, 9);
6847+ this.bis.read();
6848+ int valLen = Integer.parseInt(new String(valueLenInfo));
6849+
6850+ byte[] valueBytes = new byte[valLen];
6851+ int readCount = 0;
6852+ int totalReadByte = 0;
6853+ while (true) {
6854+ int readByte = this.bis.read(valueBytes, totalReadByte, (valLen - totalReadByte));
6855+ if (readByte == -1) break;
6856+ totalReadByte = totalReadByte + readByte;
6857+ readCount++;
6858+ if (totalReadByte == valLen) break;
6859+ }
6860+
6861+ /*
6862+ for (readCount = 0; readCount < valLen; readCount++) {
6863+ this.bis.read(valueBytes, readCount, 1);
6864+ }*/
6865+ this.bis.read();
6866+ ret[0] = "true";
6867+ ret[1] = this.dataDecoding(valueBytes);
6868+ } else {
6869+ // データなし
6870+ ret[0] = "false";
6871+ ret[1] = null;
6872+ }
6873+
6874+ /*
67966875 serverRetStr = br.readLine();
67976876
67986877 boolean responseSuccess = false;
@@ -6837,6 +6916,7 @@
68376916 // 妥当性違反
68386917 throw new OkuyamaClientException("Execute Violation of validity");
68396918 }
6919+*/
68406920 } catch (OkuyamaClientException ice) {
68416921 throw ice;
68426922 } catch (ConnectException ce) {
Show on old repository browser