22
33import com .xxdb .data .BasicTable ;
44import java .io .IOException ;
5+ import java .util .Arrays ;
56import java .util .ResourceBundle ;
67
78import static org .junit .Assert .assertEquals ;
@@ -10,33 +11,36 @@ public class Prepare {
1011 static ResourceBundle bundle = ResourceBundle .getBundle ("com/xxdb/setup/settings" );
1112 static String HOST = bundle .getString ("HOST" );
1213 static int PORT = Integer .parseInt (bundle .getString ("PORT" ));
14+ static int [] port_list = Arrays .stream (bundle .getString ("PORTS" ).split ("," )).mapToInt (Integer ::parseInt ).toArray ();
1315
1416 public static void clear_env () throws IOException {
15- DBConnection conn = new DBConnection ();
16- conn .connect (HOST ,PORT ,"admin" ,"123456" );
17- conn .run ("a = getStreamingStat().pubTables\n " +
18- "for(i in a){\n " +
19- "\t try{stopPublishTable(i.subscriber.split(\" :\" )[0],int(i.subscriber.split(\" :\" )[1]),i.tableName,i.actions)}catch(ex){}\n " +
20- "}" );
21- conn .run ("def getAllShare(){\n " +
22- "\t return select name from objs(true) where shared=1\n " +
23- "\t }\n " +
24- "\n " +
25- "def clearShare(){\n " +
26- "\t login(`admin,`123456)\n " +
27- "\t allShare=exec name from pnodeRun(getAllShare)\n " +
28- "\t for(i in allShare){\n " +
29- "\t \t try{\n " +
30- "\t \t \t rpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n " +
31- "\t \t \t }catch(ex1){}\n " +
32- "\t \t rpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n " +
33- "\t }\n " +
34- "\t try{\n " +
35- "\t \t PST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n " +
36- "\t }catch(ex1){}\n " +
37- "}\n " +
38- "clearShare()" );
39- conn .run ("try{dropStreamEngine(\" serInput\" );\n }catch(ex){\n }\n " );
17+ for (int i = 0 ; i < port_list .length ; i ++) {
18+ DBConnection conn = new DBConnection ();
19+ conn .connect (HOST , port_list [i ], "admin" , "123456" );
20+ conn .run ("a = getStreamingStat().pubTables\n " +
21+ "for(i in a){\n " +
22+ "\t try{stopPublishTable(i.subscriber.split(\" :\" )[0],int(i.subscriber.split(\" :\" )[1]),i.tableName,i.actions)}catch(ex){}\n " +
23+ "}" );
24+ conn .run ("def getAllShare(){\n " +
25+ "\t return select name from objs(true) where shared=1\n " +
26+ "\t }\n " +
27+ "\n " +
28+ "def clearShare(){\n " +
29+ "\t login(`admin,`123456)\n " +
30+ "\t allShare=exec name from pnodeRun(getAllShare)\n " +
31+ "\t for(i in allShare){\n " +
32+ "\t \t try{\n " +
33+ "\t \t \t rpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n " +
34+ "\t \t \t }catch(ex1){}\n " +
35+ "\t \t rpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n " +
36+ "\t }\n " +
37+ "\t try{\n " +
38+ "\t \t PST_DIR=rpc(getControllerAlias(),getDataNodeConfig{getNodeAlias()})['persistenceDir']\n " +
39+ "\t }catch(ex1){}\n " +
40+ "}\n " +
41+ "clearShare()" );
42+ conn .run ("try{dropStreamEngine(\" serInput\" );\n }catch(ex){\n }\n " );
43+ }
4044 }
4145
4246 public static void Preparedata (long count ) throws IOException {
0 commit comments