@@ -583,9 +583,7 @@ public void test_EventClient_commonKeys_two_column() throws IOException, Interr
583
583
eventSchemas .add (scheme1 );
584
584
List <String > eventTimeKeys = new ArrayList <>();
585
585
List <String > commonKeys = Arrays .asList (new String []{"time" ,"market" });
586
- EventSender sender = EventSender .createEventSender (eventSchemas , eventTimeKeys , commonKeys );
587
-
588
- sender .connect (conn , "inputTable" );
586
+ EventSender sender = new EventSender (conn , "inputTable" ,eventSchemas , eventTimeKeys , commonKeys );
589
587
List <Entity > attributes = new ArrayList <>();
590
588
attributes .add (new BasicString ("123456" ));
591
589
attributes .add (new BasicTime (LocalTime .from (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 ))));
@@ -614,7 +612,7 @@ public static void subscribePrepare() throws IOException {
614
612
eventSchemas .add (scheme );
615
613
List <String > eventTimeKeys = Arrays .asList (new String []{"timestamp" });
616
614
List <String > commonKeys = Arrays .asList (new String []{"comment1" });
617
- sender = EventSender . createEventSender ( eventSchemas , eventTimeKeys , commonKeys );
615
+ sender = new EventSender ( conn , "inputTable" , eventSchemas , eventTimeKeys , commonKeys );
618
616
client = new EventClient (eventSchemas , eventTimeKeys , commonKeys );
619
617
}
620
618
@ Test
@@ -721,7 +719,6 @@ public void test_EventClient_subscribe_handler_null() throws IOException, Inter
721
719
public void test_EventClient_subscribe_offset_negative_1 () throws IOException , InterruptedException {
722
720
subscribePrepare ();
723
721
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
724
- sender .connect (conn ,"inputTable" );
725
722
List <Entity > attributes = new ArrayList <>();
726
723
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
727
724
attributes .add (new BasicString ("123456" ));
@@ -736,7 +733,6 @@ public void test_EventClient_subscribe_offset_negative_1() throws IOException,
736
733
public void test_EventClient_subscribe_offset_negative_2 () throws IOException , InterruptedException {
737
734
subscribePrepare ();
738
735
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
739
- sender .connect (conn ,"inputTable" );
740
736
List <Entity > attributes = new ArrayList <>();
741
737
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
742
738
attributes .add (new BasicString ("123456" ));
@@ -751,7 +747,6 @@ public void test_EventClient_subscribe_offset_negative_2() throws IOException,
751
747
public void test_EventClient_subscribe_offset_0 () throws IOException , InterruptedException {
752
748
subscribePrepare ();
753
749
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
754
- sender .connect (conn ,"inputTable" );
755
750
List <Entity > attributes = new ArrayList <>();
756
751
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
757
752
attributes .add (new BasicString ("123456" ));
@@ -767,7 +762,6 @@ public void test_EventClient_subscribe_offset_0() throws IOException, Interrupt
767
762
public void test_EventClient_subscribe_offset_1 () throws IOException , InterruptedException {
768
763
subscribePrepare ();
769
764
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
770
- sender .connect (conn ,"inputTable" );
771
765
List <Entity > attributes = new ArrayList <>();
772
766
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
773
767
attributes .add (new BasicString ("123456" ));
@@ -782,7 +776,6 @@ public void test_EventClient_subscribe_offset_1() throws IOException, Interrupt
782
776
public void test_EventClient_subscribe_offset_not_match () throws IOException , InterruptedException {
783
777
subscribePrepare ();
784
778
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
785
- sender .connect (conn ,"inputTable" );
786
779
List <Entity > attributes = new ArrayList <>();
787
780
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
788
781
attributes .add (new BasicString ("123456" ));
@@ -799,7 +792,6 @@ public void test_EventClient_subscribe_offset_not_match() throws IOException, I
799
792
public void test_EventClient_subscribe_reconnect_true () throws IOException , InterruptedException {
800
793
subscribePrepare ();
801
794
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
802
- sender .connect (conn ,"inputTable" );
803
795
List <Entity > attributes = new ArrayList <>();
804
796
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
805
797
attributes .add (new BasicString ("123456" ));
@@ -813,7 +805,6 @@ public void test_EventClient_subscribe_reconnect_true() throws IOException, Int
813
805
public void test_EventClient_subscribe_reconnect_false () throws IOException , InterruptedException {
814
806
subscribePrepare ();
815
807
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
816
- sender .connect (conn ,"inputTable" );
817
808
List <Entity > attributes = new ArrayList <>();
818
809
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
819
810
attributes .add (new BasicString ("123456" ));
@@ -853,15 +844,15 @@ public void test_EventClient_subscribe_admin() throws IOException, InterruptedE
853
844
PrepareUser ("user1" ,"123456" );
854
845
DBConnection conn = new DBConnection ();
855
846
conn .connect (HOST , PORT ,"user1" ,"123456" );
856
- subscribePrepare ();
857
- conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable1;" );
858
- conn .run ("addAccessControl(`inputTable1)" );
847
+ conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;" );
848
+ conn .run ("addAccessControl(`inputTable)" );
859
849
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
860
- sender .connect (conn ,"inputTable1" );
850
+ subscribePrepare ();
851
+
861
852
List <Entity > attributes = new ArrayList <>();
862
853
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
863
854
attributes .add (new BasicString ("123456" ));
864
- client .subscribe (HOST , PORT , "inputTable1 " , "test1" , handler , -1 , true , "admin" , "123456" );
855
+ client .subscribe (HOST , PORT , "inputTable " , "test1" , handler , -1 , true , "admin" , "123456" );
865
856
sender .sendEvent ("MarketData" , attributes );
866
857
Thread .sleep (1000 );
867
858
BasicTable re = (BasicTable )conn .run ("select * from outputTable" );
@@ -872,15 +863,15 @@ public void test_EventClient_subscribe_other_user() throws IOException, Interru
872
863
PrepareUser ("user1" ,"123456" );
873
864
DBConnection conn = new DBConnection ();
874
865
conn .connect (HOST , PORT ,"user1" ,"123456" );
875
- subscribePrepare ();
876
- conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable1;" );
877
- conn .run ("addAccessControl(`inputTable1)" );
866
+ conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;" );
867
+ conn .run ("addAccessControl(`inputTable)" );
878
868
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
879
- sender .connect (conn ,"inputTable1" );
869
+ subscribePrepare ();
870
+
880
871
List <Entity > attributes = new ArrayList <>();
881
872
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
882
873
attributes .add (new BasicString ("123456" ));
883
- client .subscribe (HOST , PORT , "inputTable1 " , "test1" , handler , -1 , true , "user1" , "123456" );
874
+ client .subscribe (HOST , PORT , "inputTable " , "test1" , handler , -1 , true , "user1" , "123456" );
884
875
sender .sendEvent ("MarketData" , attributes );
885
876
Thread .sleep (1000 );
886
877
BasicTable re = (BasicTable )conn .run ("select * from outputTable" );
@@ -892,22 +883,31 @@ public void test_EventClient_other_user_unallow() throws IOException, Interrupt
892
883
PrepareUser ("user2" ,"123456" );
893
884
DBConnection conn = new DBConnection ();
894
885
conn .connect (HOST , PORT ,"user1" ,"123456" );
895
- subscribePrepare ();
896
- conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable1;" );
897
- conn .run ("addAccessControl(`inputTable1)" );
886
+ conn .run ("share streamTable(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;" );
887
+ conn .run ("addAccessControl(`inputTable)" );
888
+ EventSchema scheme = new EventSchema ();
889
+ scheme .setEventType ("MarketData" );
890
+ scheme .setFieldNames (Arrays .asList ("timestamp" , "comment1" ));
891
+ scheme .setFieldTypes (Arrays .asList ( DT_TIMESTAMP ,DT_STRING ));
892
+ scheme .setFieldForms (Arrays .asList (DF_SCALAR , DF_SCALAR ));
893
+ List <EventSchema > eventSchemas = new ArrayList <>();
894
+ eventSchemas .add (scheme );
895
+ List <String > eventTimeKeys = Arrays .asList (new String []{"timestamp" });
896
+ List <String > commonKeys = Arrays .asList (new String []{"comment1" });
897
+ sender = new EventSender (conn , "inputTable" , eventSchemas , eventTimeKeys , commonKeys );
898
+ client = new EventClient (eventSchemas , eventTimeKeys , commonKeys );
898
899
String re = null ;
899
900
try {
900
- client .subscribe (HOST , PORT , "inputTable1 " , "test1" , handler1 , -1 , true , "user2" , "123456" );
901
+ client .subscribe (HOST , PORT , "inputTable " , "test1" , handler1 , -1 , true , "user2" , "123456" );
901
902
}catch (Exception ex ){
902
903
re = ex .getMessage ();
903
904
}
904
- Assert .assertEquals (true , re .contains ("No access to shared table [inputTable1 ]" ));
905
+ Assert .assertEquals (true , re .contains ("No access to shared table [inputTable ]" ));
905
906
}
906
907
@ Test
907
908
public void test_EventClient_subscribe_unsubscribe_resubscribe () throws IOException , InterruptedException {
908
909
subscribePrepare ();
909
910
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
910
- sender .connect (conn ,"inputTable" );
911
911
List <Entity > attributes = new ArrayList <>();
912
912
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
913
913
attributes .add (new BasicString ("123456" ));
@@ -955,23 +955,22 @@ public void test_EventClient_unsubscribe_duplicated() throws IOException, Inter
955
955
956
956
@ Test
957
957
public void test_EventClient_subscribe_haStreamTable () throws IOException , InterruptedException {
958
- subscribePrepare ();
959
- conn .run ("table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable1;" );
960
- conn .run ("haStreamTable(11, table, `inputTable1, 100000)" );
958
+ conn .run ("table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]) as inputTable;" );
959
+ conn .run ("haStreamTable(11, table, `inputTable, 100000)" );
961
960
conn .run ("share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;" );
962
- sender .connect (conn ,"inputTable1" );
961
+ subscribePrepare ();
962
+
963
963
List <Entity > attributes = new ArrayList <>();
964
964
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
965
965
attributes .add (new BasicString ("123456" ));
966
- client .subscribe (HOST , PORT , "inputTable1 " , "test1" , handler , -1 , true , "user1" , "123456" );
966
+ client .subscribe (HOST , PORT , "inputTable " , "test1" , handler , -1 , true , "user1" , "123456" );
967
967
sender .sendEvent ("MarketData" , attributes );
968
968
Thread .sleep (1000 );
969
969
BasicTable re = (BasicTable )conn .run ("select * from outputTable" );
970
970
Assert .assertEquals (1 ,re .rows ());
971
971
}
972
972
@ Test
973
973
public void test_EventClient_subscribe_haStreamTable_leader () throws IOException , InterruptedException {
974
- subscribePrepare ();
975
974
BasicString StreamLeaderTmp = (BasicString )conn .run (String .format ("getStreamingLeader(%d)" , GROUP_ID ));
976
975
String StreamLeader = StreamLeaderTmp .getString ();
977
976
BasicString StreamLeaderHostTmp = (BasicString )conn .run (String .format ("(exec host from rpc(getControllerAlias(), getClusterPerf) where name=\" %s\" )[0]" , StreamLeader ));
@@ -982,28 +981,28 @@ public void test_EventClient_subscribe_haStreamTable_leader() throws IOExceptio
982
981
System .out .println (StreamLeaderPort );
983
982
DBConnection conn1 = new DBConnection ();
984
983
conn1 .connect (StreamLeaderHost , StreamLeaderPort , "admin" , "123456" );
985
- String script = "try{\n dropStreamTable(`inputTable1 )\n }catch(ex){\n }\n " +
984
+ String script = "try{\n dropStreamTable(`inputTable )\n }catch(ex){\n }\n " +
986
985
"table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n " +
987
- "haStreamTable(" +GROUP_ID +", table, `inputTable1 , 100000);\n " +
986
+ "haStreamTable(" +GROUP_ID +", table, `inputTable , 100000);\n " +
988
987
"share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;;\n " ;
989
988
conn1 .run (script );
990
- sender .connect (conn ,"inputTable1" );
989
+ subscribePrepare ();
990
+
991
991
List <Entity > attributes = new ArrayList <>();
992
992
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
993
993
attributes .add (new BasicString ("123456" ));
994
- client .subscribe (StreamLeaderHost , StreamLeaderPort , "inputTable1 " , "test1" , handler , -1 , true , "user1" , "123456" );
994
+ client .subscribe (StreamLeaderHost , StreamLeaderPort , "inputTable " , "test1" , handler , -1 , true , "user1" , "123456" );
995
995
sender .sendEvent ("MarketData" , attributes );
996
996
Thread .sleep (1000 );
997
997
BasicTable re = (BasicTable )conn1 .run ("select * from outputTable" );
998
998
Assert .assertEquals (1 ,re .rows ());
999
999
Assert .assertEquals ("2024.03.22T10:45:03.100" ,re .getColumn (0 ).get (0 ).getString ());
1000
1000
Assert .assertEquals ("123456" ,re .getColumn (1 ).get (0 ).getString ());
1001
- client .unsubscribe (StreamLeaderHost , StreamLeaderPort , "inputTable1 " , "test1" );
1001
+ client .unsubscribe (StreamLeaderHost , StreamLeaderPort , "inputTable " , "test1" );
1002
1002
}
1003
1003
1004
1004
@ Test //not support
1005
1005
public void test_EventClient_subscribe_haStreamTable_follower () throws IOException , InterruptedException {
1006
- subscribePrepare ();
1007
1006
String script0 ="leader = getStreamingLeader(" +GROUP_ID +");\n " +
1008
1007
"groupSitesStr = (exec sites from getStreamingRaftGroups() where id ==" +GROUP_ID +")[0];\n " +
1009
1008
"groupSites = split(groupSitesStr, \" ,\" );\n " +
@@ -1017,23 +1016,24 @@ public void test_EventClient_subscribe_haStreamTable_follower() throws IOExcept
1017
1016
System .out .println (StreamFollowerPort );
1018
1017
DBConnection conn1 = new DBConnection ();
1019
1018
conn1 .connect (StreamFollowerHost , StreamFollowerPort , "admin" , "123456" );
1020
- String script = "try{\n dropStreamTable(`inputTable1 )\n }catch(ex){\n }\n " +
1019
+ String script = "try{\n dropStreamTable(`inputTable )\n }catch(ex){\n }\n " +
1021
1020
"table = table(1000000:0, `timestamp`eventType`event`comment1, [TIMESTAMP,STRING,BLOB,STRING]);\n " +
1022
- "haStreamTable(" +GROUP_ID +", table, `inputTable1 , 100000);\n " +
1021
+ "haStreamTable(" +GROUP_ID +", table, `inputTable , 100000);\n " +
1023
1022
"share table(100:0, `timestamp`comment1, [TIMESTAMP,STRING]) as outputTable;\n " ;
1024
1023
conn1 .run (script );
1025
- sender .connect (conn ,"inputTable1" );
1024
+
1025
+ subscribePrepare ();
1026
1026
List <Entity > attributes = new ArrayList <>();
1027
1027
attributes .add (new BasicTimestamp (LocalDateTime .of (2024 ,3 ,22 ,10 ,45 ,3 ,100000000 )));
1028
1028
attributes .add (new BasicString ("123456" ));
1029
- client .subscribe (StreamFollowerHost , StreamFollowerPort , "inputTable1 " , "test1" , handler , -1 , true , "user1" , "123456" );
1029
+ client .subscribe (StreamFollowerHost , StreamFollowerPort , "inputTable " , "test1" , handler , -1 , true , "user1" , "123456" );
1030
1030
sender .sendEvent ("MarketData" , attributes );
1031
1031
Thread .sleep (1000 );
1032
1032
BasicTable re = (BasicTable )conn1 .run ("select * from outputTable" );
1033
1033
Assert .assertEquals (1 ,re .rows ());
1034
1034
Assert .assertEquals ("2024.03.22T10:45:03.100" ,re .getColumn (0 ).get (0 ).getString ());
1035
1035
Assert .assertEquals ("123456" ,re .getColumn (1 ).get (0 ).getString ());
1036
- client .unsubscribe (StreamFollowerHost , StreamFollowerPort , "inputTable1 " , "test1" );
1036
+ client .unsubscribe (StreamFollowerHost , StreamFollowerPort , "inputTable " , "test1" );
1037
1037
}
1038
1038
1039
1039
@ Test
@@ -1441,8 +1441,7 @@ public void test_EventClient_all_dateType_vector_no_decimal() throws IOExceptio
1441
1441
List <EventSchema > eventSchemes = Collections .singletonList (scheme );
1442
1442
List <String > eventTimeKeys = new ArrayList <>();
1443
1443
List <String > commonKeys = new ArrayList <>();
1444
- EventSender sender = EventSender .createEventSender (eventSchemes , eventTimeKeys , commonKeys );
1445
- sender .connect (conn ,"inputTable" );
1444
+ EventSender sender = new EventSender (conn , "inputTable" , eventSchemes , eventTimeKeys , commonKeys );
1446
1445
1447
1446
EventClient client = new EventClient (eventSchemes , eventTimeKeys , commonKeys );
1448
1447
client .subscribe (HOST , PORT , "intput1" , "test1" , handler_array_no_decimal , -1 , true , "admin" , "123456" );
@@ -1515,8 +1514,7 @@ public void test_EventClient_all_dateType_vector_decimal() throws IOException,
1515
1514
List <EventSchema > eventSchemes = Collections .singletonList (scheme );
1516
1515
List <String > eventTimeKeys = new ArrayList <>();
1517
1516
List <String > commonKeys = new ArrayList <>();
1518
- EventSender sender = EventSender .createEventSender (eventSchemes , eventTimeKeys , commonKeys );
1519
- sender .connect (conn ,"inputTable" );
1517
+ EventSender sender = new EventSender (conn , "inputTable" , eventSchemes , eventTimeKeys , commonKeys );
1520
1518
1521
1519
EventClient client = new EventClient (eventSchemes , eventTimeKeys , commonKeys );
1522
1520
client .subscribe (HOST , PORT , "intput1" , "test1" , handler_array_decimal , -1 , true , "admin" , "123456" );
@@ -1568,10 +1566,9 @@ public void test_EventClient_all_dateType_array() throws IOException, Interrupt
1568
1566
List <EventSchema > eventSchemas = Collections .singletonList (scheme );
1569
1567
List <String > eventTimeKeys = new ArrayList <>();
1570
1568
List <String > commonKeys = new ArrayList <>();
1571
- EventSender sender = EventSender .createEventSender (eventSchemas , eventTimeKeys , commonKeys );
1572
1569
String script = "share streamTable(1000000:0, `eventType`event, [STRING,BLOB]) as inputTable;\n " ;
1573
1570
conn .run (script );
1574
- sender . connect (conn ,"inputTable" );
1571
+ EventSender sender = new EventSender (conn , "inputTable" , eventSchemas , eventTimeKeys , commonKeys );
1575
1572
EventClient client = new EventClient (eventSchemas , eventTimeKeys , commonKeys );
1576
1573
client .subscribe (HOST , PORT , "inputTable" , "test1" , handler_array , -1 , true , "admin" , "123456" );
1577
1574
Preparedata_array (100 ,10 );
0 commit comments