(empty log message)
@@ -1047,7 +1047,7 @@ | ||
1047 | 1047 | retStrs[2] = "NG:Max Data Size Over"; |
1048 | 1048 | } |
1049 | 1049 | } catch (BatchException be) { |
1050 | - | |
1050 | +be.printStackTrace(); | |
1051 | 1051 | logger.debug("KeyManagerHelper - setDatanode - Error = [" + key + "]", be); |
1052 | 1052 | //logger.debug("KeyManagerHelper - setDatanode - Error", be); |
1053 | 1053 | retStrs[0] = "1"; |
@@ -360,6 +360,31 @@ | ||
360 | 360 | retParams = this.getKeyValue(clientParameterList[1]); |
361 | 361 | |
362 | 362 | 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 | + | |
363 | 388 | case 3 : |
364 | 389 | |
365 | 390 | // Tag値でキー値群を取得する |
@@ -789,7 +789,7 @@ | ||
789 | 789 | ByteArrayOutputStream bao = null; |
790 | 790 | ObjectOutput oo = null; |
791 | 791 | try { |
792 | - bao = new ByteArrayOutputStream(5000); | |
792 | + bao = new ByteArrayOutputStream(17000); | |
793 | 793 | |
794 | 794 | for (Iterator it = ((Map)data).entrySet().iterator(); it.hasNext(); ) { |
795 | 795 |
@@ -174,10 +174,20 @@ | ||
174 | 174 | |
175 | 175 | // サーバへの出力用 |
176 | 176 | protected PrintWriter pw = null; |
177 | + protected BufferedOutputStream bos = null; | |
177 | 178 | |
178 | 179 | // サーバからの受信用 |
179 | 180 | protected BufferedReader br = null; |
181 | + protected BufferedInputStream bis = null; | |
180 | 182 | |
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 | + | |
181 | 191 | protected String transactionCode = "0"; |
182 | 192 | |
183 | 193 | public static final String SEARCH_VALUE_TYPE_AND = "1"; |
@@ -332,7 +342,11 @@ | ||
332 | 342 | |
333 | 343 | this.socket.setSoTimeout(ImdstDefine.clientConnectionTimeout); |
334 | 344 | this.pw = new ClientCustomPrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), OkuyamaClient.connectDefaultEncoding))); |
345 | + this.bos = new BufferedOutputStream(socket.getOutputStream()); | |
346 | + | |
335 | 347 | this.br = new BufferedReader(new InputStreamReader(socket.getInputStream(), OkuyamaClient.connectDefaultEncoding)); |
348 | + this.bis = new BufferedInputStream(socket.getInputStream()); | |
349 | + | |
336 | 350 | this.initClient(); |
337 | 351 | this.nowConnectServerInfo = nodeStr; |
338 | 352 | break; |
@@ -467,6 +481,19 @@ | ||
467 | 481 | this.br = null; |
468 | 482 | } |
469 | 483 | |
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 | + | |
470 | 497 | if (this.socket != null) { |
471 | 498 | this.socket.close(); |
472 | 499 | this.socket = null; |
@@ -6595,6 +6622,7 @@ | ||
6595 | 6622 | } |
6596 | 6623 | |
6597 | 6624 | |
6625 | + | |
6598 | 6626 | /** |
6599 | 6627 | * MasterNodeからKeyでデータを取得する(バイナリ).<br> |
6600 | 6628 | * sendByteValueで登録したValueはこちらで取得する.<br> |
@@ -6736,11 +6764,12 @@ | ||
6736 | 6764 | if (keyStr == null || keyStr.trim().equals("")) |
6737 | 6765 | throw new OkuyamaClientException("The blank is not admitted on a key"); |
6738 | 6766 | |
6767 | + byte[] keyBytes = keyStr.getBytes(); | |
6739 | 6768 | // 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"); | |
6741 | 6770 | |
6742 | 6771 | // 文字列バッファ初期化 |
6743 | - serverRequestBuf = new StringBuilder(ImdstDefine.stringBufferSmallSize); | |
6772 | +/* serverRequestBuf = new StringBuilder(ImdstDefine.stringBufferSmallSize); | |
6744 | 6773 | |
6745 | 6774 | // 処理番号連結 |
6746 | 6775 | serverRequestBuf.append("2"); |
@@ -6748,12 +6777,21 @@ | ||
6748 | 6777 | serverRequestBuf.append(OkuyamaClient.sepStr); |
6749 | 6778 | |
6750 | 6779 | // Key連結(Keyはデータ送信時には必ず文字列が必要) |
6751 | - serverRequestBuf.append(new String(this.dataEncoding(keyStr.getBytes()))); | |
6780 | + serverRequestBuf.append(new String(this.dataEncoding(keyBytes))); | |
6752 | 6781 | |
6753 | 6782 | // サーバ送信 |
6754 | 6783 | pw.println(serverRequestBuf.toString()); |
6755 | 6784 | 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); | |
6756 | 6791 | |
6792 | + this.bos.flush(); | |
6793 | + | |
6794 | + | |
6757 | 6795 | ret = true; |
6758 | 6796 | } catch (OkuyamaClientException ice) { |
6759 | 6797 | throw ice; |
@@ -6793,6 +6831,47 @@ | ||
6793 | 6831 | if (this.socket == null) throw new OkuyamaClientException("No ServerConnect!!"); |
6794 | 6832 | |
6795 | 6833 | // サーバから結果受け取り |
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 | + /* | |
6796 | 6875 | serverRetStr = br.readLine(); |
6797 | 6876 | |
6798 | 6877 | boolean responseSuccess = false; |
@@ -6837,6 +6916,7 @@ | ||
6837 | 6916 | // 妥当性違反 |
6838 | 6917 | throw new OkuyamaClientException("Execute Violation of validity"); |
6839 | 6918 | } |
6919 | +*/ | |
6840 | 6920 | } catch (OkuyamaClientException ice) { |
6841 | 6921 | throw ice; |
6842 | 6922 | } catch (ConnectException ce) { |