Skip to content

Commit 91fd0cf

Browse files
committed
Update Prepare.java
1 parent 44c473a commit 91fd0cf

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

test/com/xxdb/Prepare.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.xxdb.data.BasicTable;
44
import java.io.IOException;
5+
import java.util.Arrays;
56
import java.util.ResourceBundle;
67

78
import 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-
"\ttry{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-
"\treturn select name from objs(true) where shared=1\n" +
23-
"\t}\n" +
24-
"\n" +
25-
"def clearShare(){\n" +
26-
"\tlogin(`admin,`123456)\n" +
27-
"\tallShare=exec name from pnodeRun(getAllShare)\n" +
28-
"\tfor(i in allShare){\n" +
29-
"\t\ttry{\n" +
30-
"\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" +
31-
"\t\t\t}catch(ex1){}\n" +
32-
"\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" +
33-
"\t}\n" +
34-
"\ttry{\n" +
35-
"\t\tPST_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+
"\ttry{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+
"\treturn select name from objs(true) where shared=1\n" +
26+
"\t}\n" +
27+
"\n" +
28+
"def clearShare(){\n" +
29+
"\tlogin(`admin,`123456)\n" +
30+
"\tallShare=exec name from pnodeRun(getAllShare)\n" +
31+
"\tfor(i in allShare){\n" +
32+
"\t\ttry{\n" +
33+
"\t\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],clearTablePersistence,objByName(i))\n" +
34+
"\t\t\t}catch(ex1){}\n" +
35+
"\t\trpc((exec node from pnodeRun(getAllShare) where name =i)[0],undef,i,SHARED)\n" +
36+
"\t}\n" +
37+
"\ttry{\n" +
38+
"\t\tPST_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

Comments
 (0)