66using Apache . IoTDB . DataStructure ;
77using ConsoleTableExt ;
88using System . Net . Sockets ;
9+ using System . Diagnostics ;
910
1011namespace Apache . IoTDB . Samples
1112{
@@ -15,6 +16,7 @@ public partial class SessionPoolTest
1516 public int port = 6667 ;
1617 public string user = "root" ;
1718 public string passwd = "root" ;
19+ public List < string > node_urls = new ( ) ;
1820 public int fetch_size = 500 ;
1921 public int processed_size = 4 ;
2022 public bool debug = false ;
@@ -36,10 +38,17 @@ public partial class SessionPoolTest
3638 public SessionPoolTest ( string _host = "localhost" )
3739 {
3840 host = _host ;
41+ node_urls . Add ( host + ":" + port ) ;
3942 }
4043
4144 public async Task Test ( )
4245 {
46+ await TestOpenWithNodeUrls ( ) ;
47+
48+ await TestOpenWith2NodeUrls ( ) ;
49+
50+ await TestOpenWithNodeUrlsAndInsertOneRecord ( ) ;
51+
4352 await TestInsertOneRecord ( ) ;
4453
4554 await TestInsertAlignedRecord ( ) ;
@@ -112,6 +121,50 @@ public async Task Test()
112121
113122 await TestNonSqlBy_ADO ( ) ;
114123 }
124+ public async Task TestOpenWithNodeUrls ( )
125+ {
126+ var session_pool = new SessionPool ( node_urls , 8 ) ;
127+ await session_pool . Open ( false ) ;
128+ Debug . Assert ( session_pool . IsOpen ( ) ) ;
129+ if ( debug ) session_pool . OpenDebugMode ( ) ;
130+ await session_pool . Close ( ) ;
131+ Console . WriteLine ( "TestOpenWithNodeUrls Passed!" ) ;
132+ }
133+ public async Task TestOpenWith2NodeUrls ( )
134+ {
135+ var session_pool = new SessionPool ( new List < string > ( ) { host + ":" + port , host + ":" + ( port + 1 ) } , 8 ) ;
136+ await session_pool . Open ( false ) ;
137+ Debug . Assert ( session_pool . IsOpen ( ) ) ;
138+ if ( debug ) session_pool . OpenDebugMode ( ) ;
139+ await session_pool . Close ( ) ;
140+
141+ session_pool = new SessionPool ( new List < string > ( ) { host + ":" + ( port + 1 ) , host + ":" + port } , 8 ) ;
142+ await session_pool . Open ( false ) ;
143+ Debug . Assert ( session_pool . IsOpen ( ) ) ;
144+ if ( debug ) session_pool . OpenDebugMode ( ) ;
145+ await session_pool . Close ( ) ;
146+ Console . WriteLine ( "TestOpenWith2NodeUrls Passed!" ) ;
147+ }
148+ public async Task TestOpenWithNodeUrlsAndInsertOneRecord ( )
149+ {
150+ var session_pool = new SessionPool ( node_urls , 8 ) ;
151+ await session_pool . Open ( false ) ;
152+ if ( debug ) session_pool . OpenDebugMode ( ) ;
153+ await session_pool . DeleteStorageGroupAsync ( test_group_name ) ;
154+ var status = await session_pool . CreateTimeSeries (
155+ string . Format ( "{0}.{1}.{2}" , test_group_name , test_device , test_measurements [ 0 ] ) ,
156+ TSDataType . TEXT , TSEncoding . PLAIN , Compressor . SNAPPY ) ;
157+ status = await session_pool . CreateTimeSeries (
158+ string . Format ( "{0}.{1}.{2}" , test_group_name , test_device , test_measurements [ 1 ] ) ,
159+ TSDataType . TEXT , TSEncoding . PLAIN , Compressor . SNAPPY ) ;
160+ status = await session_pool . CreateTimeSeries (
161+ string . Format ( "{0}.{1}.{2}" , test_group_name , test_device , test_measurements [ 2 ] ) ,
162+ TSDataType . TEXT , TSEncoding . PLAIN , Compressor . SNAPPY ) ;
163+ var rowRecord = new RowRecord ( 1668404120807 , new ( ) { "1111111" , "22222" , "333333" } , new ( ) { test_measurements [ 0 ] , test_measurements [ 1 ] , test_measurements [ 2 ] } ) ;
164+ status = await session_pool . InsertRecordsAsync ( new List < string > ( ) { string . Format ( "{0}.{1}" , test_group_name , test_device ) } , new List < RowRecord > ( ) { rowRecord } ) ;
165+ Debug . Assert ( status == 0 ) ;
166+ Console . WriteLine ( "TestOpenWithNodeUrlsAndInsertOneRecord Passed!" ) ;
167+ }
115168 public async Task TestInsertOneRecord ( )
116169 {
117170 var session_pool = new SessionPool ( host , port , 1 ) ;
0 commit comments