• R/O
  • SSH
  • HTTPS

okuyama: 提交


Commit MetaInfo

修訂1022 (tree)
時間2013-04-22 20:50:29
作者okuyamaoo

Log Message

keylist add

Change Summary

差異

--- trunk/src/okuyama/imdst/helper/KeyManagerHelper.java (revision 1021)
+++ trunk/src/okuyama/imdst/helper/KeyManagerHelper.java (revision 1022)
@@ -978,6 +978,9 @@
978978 }
979979 retParamBuf.append(this.keyMapManager.keyObjectExport(memoryObjBkupFilePath));
980980 break;
981+ case 103 :
982+ this.keyMapManager.outputKeyData2Stream(pw);
983+ break;
981984 case 887 :
982985
983986 // データ復旧を強制終了
--- trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 1021)
+++ trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 1022)
@@ -2398,6 +2398,38 @@
23982398 }
23992399
24002400
2401+ // 引数で渡されてストリームに対し全Keyを書き出す
2402+ public void outputKeyData2Stream(PrintWriter pw) throws BatchException {
2403+ if (!blocking) {
2404+ try {
2405+
2406+ synchronized(poolKeyLock) {
2407+
2408+ Set entrySet = this.keyMapObj.entrySet();
2409+
2410+ Iterator entryIte = entrySet.iterator();
2411+
2412+ long counter = 0;
2413+ int sendCounter = 0;
2414+
2415+ while(entryIte.hasNext()) {
2416+ Map.Entry obj = (Map.Entry)entryIte.next();
2417+ if (obj == null) continue;
2418+ String key = null;
2419+ key = (String)obj.getKey();
2420+ pw.println(key);
2421+ pw.flush();
2422+ }
2423+
2424+ pw.println("-1");
2425+ pw.flush();
2426+ }
2427+
2428+ } catch (Exception e) {
2429+ e.printStackTrace();
2430+ }
2431+ }
2432+ }
24012433 // 引数で渡されてストリームに対しkeyMapObjを書き出す
24022434 public void outputKeyMapObj2Stream(PrintWriter pw) throws BatchException {
24032435 if (!blocking) {
--- trunk/src/okuyama/imdst/client/UtilClient.java (revision 1021)
+++ trunk/src/okuyama/imdst/client/UtilClient.java (revision 1022)
@@ -28,6 +28,8 @@
2828 System.out.println("Command2. TruncateData args1=truncatedata args2=MainMasterNode-IPAdress args3=MainMasterNode-Port args4=IsolationName or 'all'");
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");
31+ System.out.println("Command5. DataNode save key list output args1=keylist args2=DataNode-IPAdress:PortNo");
32+
3133 System.exit(1);
3234 }
3335
@@ -110,6 +112,16 @@
110112 addMasterNode(args[1], args[2]);
111113 }
112114
115+
116+ if (args[0].equals("keylist")) {
117+ if (args.length < 2) {
118+ System.out.println("Argument Error! args[0]=Command, args[1]=DataNodeIp:Port");
119+ System.exit(1);
120+ }
121+
122+ keylist(args[1]);
123+ }
124+
113125 }
114126
115127
@@ -335,4 +347,45 @@
335347 }
336348 }
337349
350+
351+ public static void keylist(String dataNodeIpPort) {
352+ OkuyamaClient client = null;
353+
354+ Socket socket = null;
355+ PrintWriter pw = null;
356+ BufferedReader br = null;
357+
358+ try {
359+ client = new OkuyamaClient();
360+ String[] datanodeAddr = dataNodeIpPort.split(":");
361+
362+
363+ socket = new Socket();
364+ InetSocketAddress inetAddr = new InetSocketAddress(datanodeAddr[0], Integer.parseInt(datanodeAddr[1]));
365+ socket.connect(inetAddr, 10000);
366+ socket.setSoTimeout(10000);
367+ pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8")));
368+ br = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
369+
370+ pw.println("103");
371+ pw.flush();
372+ String line = null;
373+ while ((line = br.readLine()) != null) {
374+ if (line.equals("-1")) break;
375+ System.out.println(new String(client.dataDecoding(line.getBytes())));
376+ }
377+ pw.println("");
378+ pw.close();
379+ br.close();
380+ } catch (Exception e) {
381+ e.printStackTrace();
382+ } finally {
383+ try {
384+ if (socket != null) socket.close();
385+ } catch (Exception e2) {
386+ e2.printStackTrace();
387+ }
388+ }
389+ }
390+
338391 }
Show on old repository browser