@@ -17,16 +17,13 @@ insert into trades values(timev, symv, take(-1, 1), pricev, exchv,x)
17
17
*/
18
18
package com .xxdb .streaming .reverse ;
19
19
20
- import com . xxdb . BasicDBTask ;
20
+
21
21
import com .xxdb .DBConnection ;
22
- import com .xxdb .DBTask ;
23
- import com .xxdb .ExclusiveDBConnectionPool ;
24
22
import com .xxdb .data .*;
25
23
import com .xxdb .data .Vector ;
26
24
import com .xxdb .streaming .client .*;
27
25
import org .javatuples .Pair ;
28
26
import org .junit .*;
29
-
30
27
import java .io .IOException ;
31
28
import java .net .SocketException ;
32
29
import java .util .*;
@@ -99,35 +96,22 @@ public void after() throws IOException, InterruptedException {
99
96
try {clear_env ();}catch (Exception e ){}
100
97
//client.close();
101
98
conn .close ();
102
- Thread .sleep (2000 );
103
99
}
104
100
105
101
@ AfterClass
106
102
public static void clear_conn () {
107
103
try {clear_env_1 ();}catch (Exception e ){}
108
104
}
109
105
110
- public void wait_data (String table_name ,int data_row ) throws IOException , InterruptedException {
111
- BasicInt row_num ;
112
- while (true ){
113
- row_num = (BasicInt )conn .run ("(exec count(*) from " +table_name +")[0]" );
114
- // System.out.println(row_num.getInt());
115
- if (row_num .getInt () == data_row ){
116
- break ;
117
- }
118
- Thread .sleep (100 );
119
- }
120
- }
121
-
122
106
public static void checkResult () throws IOException , InterruptedException {
123
- for (int i = 0 ; i < 10 ; i ++)
107
+ for (int i = 0 ; i < 20 ; i ++)
124
108
{
125
109
BasicInt tmpNum = (BasicInt )conn .run ("exec count(*) from sub1" );
126
110
if (tmpNum .getInt ()==(1000 ))
127
111
{
128
112
break ;
129
113
}
130
- Thread .sleep (1000 );
114
+ Thread .sleep (200 );
131
115
}
132
116
BasicTable except = (BasicTable )conn .run ("select * from Trades order by permno" );
133
117
BasicTable res = (BasicTable )conn .run ("select * from sub1 order by permno" );
@@ -138,15 +122,15 @@ public static void checkResult() throws IOException, InterruptedException {
138
122
}
139
123
}
140
124
public static void checkResult1 () throws IOException , InterruptedException {
141
- for (int i = 0 ; i < 10 ; i ++)
125
+ for (int i = 0 ; i < 20 ; i ++)
142
126
{
143
127
BasicInt tmpNum = (BasicInt )conn .run ("exec count(*) from sub1 " );
144
128
BasicInt tmpNum1 = (BasicInt )conn .run ("exec count(*) from sub2 " );
145
129
if (tmpNum .getInt ()==(1000 )&& tmpNum1 .getInt ()==(1000 ))
146
130
{
147
131
break ;
148
132
}
149
- Thread .sleep (3000 );
133
+ Thread .sleep (100 );
150
134
}
151
135
BasicTable except = (BasicTable )conn .run ("select * from pub_t1 order by timestampv" );
152
136
BasicTable res = (BasicTable )conn .run ("select * from sub1 order by timestampv" );
@@ -179,7 +163,7 @@ public void test_size() throws IOException {
179
163
try {
180
164
for (int i =0 ;i <10 ;i ++){//data<size
181
165
conn .run ("n=50;t=table(1..n as tag,now()+1..n as ts,rand(100.0,n) as data);" + "Trades1.append!(t)" );
182
- msgs = poller1 .poll (100 ,1000 );
166
+ msgs = poller1 .poll (1000 ,1000 );
183
167
if (msgs ==null ){
184
168
continue ;
185
169
}
@@ -189,7 +173,7 @@ else if (msgs.size() > 0) {
189
173
}
190
174
for (int i =0 ;i <10 ;i ++){//data>size
191
175
conn .run ("n=5000;t=table(1..n as tag,now()+1..n as ts,rand(100.0,n) as data);" + "Trades1.append!(t)" );
192
- msgs = poller1 .poll (100000 ,1000 );
176
+ msgs = poller1 .poll (1000 ,1000 );
193
177
if (msgs ==null ){
194
178
continue ;
195
179
}
@@ -200,7 +184,7 @@ else if (msgs.size() > 0) {
200
184
}
201
185
for (int i =0 ;i <10 ;i ++){//data=size
202
186
conn .run ("n=5000;t=table(1..n as tag,now()+1..n as ts,rand(100.0,n) as data);" + "Trades1.append!(t)" );
203
- msgs = poller1 .poll (1000000 ,5000 );
187
+ msgs = poller1 .poll (5000 ,5000 );
204
188
if (msgs ==null ){
205
189
continue ;
206
190
}
@@ -344,7 +328,7 @@ public void test_subscribe_other_user() throws IOException, InterruptedException
344
328
PrepareUser ("test1" ,"123456" );
345
329
TopicPoller poller1 = client .subscribe (HOST ,PORT ,"Trades1" ,"subTread1" ,-1 ,true ,null ,"test1" ,"123456" );
346
330
conn .run ("n=10000;t=table(1..n as tag,now()+1..n as ts,rand(100.0,n) as data);" + "Trades1.append!(t)" );
347
- Thread .sleep (5000 );
331
+ // Thread.sleep(5000);
348
332
ArrayList <IMessage > msgs1 = poller1 .poll (500 , 10000 );
349
333
assertEquals (10000 , msgs1 .size ());
350
334
client .unsubscribe (HOST ,PORT ,"Trades1" ,"subTread1" );
@@ -2198,15 +2182,15 @@ public void run() {
2198
2182
MessageHandler_handler1 (messages );
2199
2183
Thread .sleep (1000 );
2200
2184
thread .join ();
2201
- Thread .sleep (10000 );
2185
+ Thread .sleep (8000 );
2202
2186
controller_conn .run ("try{startDataNode('" +HOST +":" +port_list [1 ]+"')}catch(ex){}" );
2203
2187
//Thread.sleep(1000);
2204
2188
List <IMessage > messages1 = poller .poll (1000 ,1000 );
2205
- Thread .sleep (1000 );
2189
+ // Thread.sleep(1000);
2206
2190
System .out .println (messages1 .size ());
2207
2191
//Assert.assertEquals(1000,messages1.size());
2208
2192
MessageHandler_handler1 (messages1 );
2209
- Thread .sleep (1000 );
2193
+ // Thread.sleep(1000);
2210
2194
BasicTable re = (BasicTable )conn .run ("select tag ,now,deltas(now) from Receive order by deltas(now) desc \n " );
2211
2195
System .out .println (re .getString ());
2212
2196
Assert .assertEquals (1000 ,re .rows ());
@@ -2246,31 +2230,31 @@ public void test_PollingClient_subscribe_resubTimeout_subOnce_not_set() throws I
2246
2230
System .out .println ("Successful subscribe" );
2247
2231
conn1 .run ("n=1000;t=table(1..n as tag,timestamp(1..n) as ts,take(100.0,n) as data);" + "Trades.append!(t)" );
2248
2232
conn2 .run ("n=1000;t=table(1..n as tag,timestamp(1..n) as ts,take(100.0,n) as data);" + "Trades.append!(t)" );
2249
- Thread .sleep (1000 );
2233
+ // Thread.sleep(1000);
2250
2234
//List<IMessage> messages = poller.poll(1000,1000);
2251
2235
//MessageHandler_handler(messages);
2252
2236
controller_conn .run ("try{stopDataNode('" +HOST +":" +port_list [1 ]+"')}catch(ex){}" );
2253
2237
System .out .println (port_list [1 ]+"断掉啦---------------------------------------------------" );
2254
- Thread .sleep (10000 );
2238
+ Thread .sleep (8000 );
2255
2239
conn2 .run ("n=2000;t=table(1001..n as tag,timestamp(1001..n) as ts,take(100.0,1000) as data);" + "Trades.append!(t)" );
2256
2240
Thread .sleep (2000 );
2257
2241
//List<IMessage> messages1 = poller.poll(2000,2000);
2258
2242
// MessageHandler_handler(messages1);
2259
2243
controller_conn .run ("try{startDataNode('" +HOST +":" +port_list [1 ]+"')}catch(ex){}" );
2260
- Thread .sleep (10000 );
2244
+ Thread .sleep (8000 );
2261
2245
DBConnection conn3 = new DBConnection ();
2262
2246
conn3 .connect (HOST ,port_list [1 ],"admin" ,"123456" );
2263
2247
conn3 .run (script1 );
2264
2248
conn3 .run (script2 );
2265
2249
controller_conn .run ("try{stopDataNode('" +HOST +":" +port_list [2 ]+"')}catch(ex){}" );
2266
2250
System .out .println (port_list [2 ]+"节点断掉啦---------------------------------------------------" );
2267
- Thread .sleep (20000 );
2251
+ Thread .sleep (8000 );
2268
2252
conn3 .run ("n=3000;t=table(1..n as tag,timestamp(1..n) as ts,take(100.0,n) as data);" + "Trades.append!(t)" );
2269
2253
Thread .sleep (5000 );
2270
2254
List <IMessage > messages2 = poller .poll (3000 ,3000 );
2271
2255
MessageHandler_handler (messages2 );
2272
2256
controller_conn .run ("try{startDataNode('" +HOST +":" +port_list [2 ]+"')}catch(ex){}" );
2273
- Thread .sleep (10000 );
2257
+ Thread .sleep (8000 );
2274
2258
2275
2259
BasicTable row_num = (BasicTable )conn .run ("select count(*) from Receive" );
2276
2260
System .out .println (row_num .getColumn (0 ).get (0 ));
0 commit comments