keylist add
@@ -978,6 +978,9 @@ | ||
978 | 978 | } |
979 | 979 | retParamBuf.append(this.keyMapManager.keyObjectExport(memoryObjBkupFilePath)); |
980 | 980 | break; |
981 | + case 103 : | |
982 | + this.keyMapManager.outputKeyData2Stream(pw); | |
983 | + break; | |
981 | 984 | case 887 : |
982 | 985 | |
983 | 986 | // データ復旧を強制終了 |
@@ -2398,6 +2398,38 @@ | ||
2398 | 2398 | } |
2399 | 2399 | |
2400 | 2400 | |
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 | + } | |
2401 | 2433 | // 引数で渡されてストリームに対しkeyMapObjを書き出す |
2402 | 2434 | public void outputKeyMapObj2Stream(PrintWriter pw) throws BatchException { |
2403 | 2435 | if (!blocking) { |
@@ -28,6 +28,8 @@ | ||
28 | 28 | System.out.println("Command2. TruncateData args1=truncatedata args2=MainMasterNode-IPAdress args3=MainMasterNode-Port args4=IsolationName or 'all'"); |
29 | 29 | System.out.println("Command3. MasterNodeConfigCheck args1=masterconfig args2=MainMasterNode-IPAdress args3=MainMasterNode-Port"); |
30 | 30 | 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 | + | |
31 | 33 | System.exit(1); |
32 | 34 | } |
33 | 35 |
@@ -110,6 +112,16 @@ | ||
110 | 112 | addMasterNode(args[1], args[2]); |
111 | 113 | } |
112 | 114 | |
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 | + | |
113 | 125 | } |
114 | 126 | |
115 | 127 |
@@ -335,4 +347,45 @@ | ||
335 | 347 | } |
336 | 348 | } |
337 | 349 | |
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 | + | |
338 | 391 | } |