66using System . Diagnostics ;
77using System . Globalization ;
88using System . Reflection ;
9+ using System . Threading ;
910
1011namespace Apache . IoTDB . Data
1112{
@@ -23,7 +24,8 @@ public class IoTDBConnectionStringBuilder : DbConnectionStringBuilder
2324 private const string CompressionKeyword = "Compression" ;
2425 private const string PoolSizeKeyword = "PoolSize" ;
2526 private const string ZoneIdKeyword = "ZoneId" ;
26-
27+ private const string TimeOutKeyword = "TimeOut" ;
28+
2729 private enum Keywords
2830 {
2931 DataSource ,
@@ -33,7 +35,8 @@ private enum Keywords
3335 FetchSize ,
3436 Compression ,
3537 PoolSize ,
36- ZoneId
38+ ZoneId ,
39+ TimeOut
3740 }
3841
3942 private static readonly IReadOnlyList < string > _validKeywords ;
@@ -47,9 +50,11 @@ private enum Keywords
4750 private string _zoneId = "UTC+08:00" ;
4851 private int _port = 6667 ;
4952 private int _poolSize = 8 ;
53+ private int _timeOut = 10000 ;
54+
5055 static IoTDBConnectionStringBuilder ( )
5156 {
52- var validKeywords = new string [ 8 ] ;
57+ var validKeywords = new string [ 9 ] ;
5358 validKeywords [ ( int ) Keywords . DataSource ] = DataSourceKeyword ;
5459 validKeywords [ ( int ) Keywords . Username ] = UserNameKeyword ;
5560 validKeywords [ ( int ) Keywords . Password ] = PasswordKeyword ;
@@ -58,9 +63,10 @@ static IoTDBConnectionStringBuilder()
5863 validKeywords [ ( int ) Keywords . Compression ] = CompressionKeyword ;
5964 validKeywords [ ( int ) Keywords . PoolSize ] = PoolSizeKeyword ;
6065 validKeywords [ ( int ) Keywords . ZoneId ] = ZoneIdKeyword ;
66+ validKeywords [ ( int ) Keywords . TimeOut ] = TimeOutKeyword ;
6167 _validKeywords = validKeywords ;
6268
63- _keywords = new Dictionary < string , Keywords > ( 6 , StringComparer . OrdinalIgnoreCase )
69+ _keywords = new Dictionary < string , Keywords > ( 9 , StringComparer . OrdinalIgnoreCase )
6470 {
6571 [ DataSourceKeyword ] = Keywords . DataSource ,
6672 [ UserNameKeyword ] = Keywords . Username ,
@@ -69,7 +75,8 @@ static IoTDBConnectionStringBuilder()
6975 [ FetchSizeKeyword ] = Keywords . FetchSize ,
7076 [ CompressionKeyword ] = Keywords . Compression ,
7177 [ PoolSizeKeyword ] = Keywords . PoolSize ,
72- [ ZoneIdKeyword ] = Keywords . ZoneId
78+ [ ZoneIdKeyword ] = Keywords . ZoneId ,
79+ [ TimeOutKeyword ] = Keywords . TimeOut
7380 } ;
7481 }
7582
@@ -135,8 +142,12 @@ public virtual string ZoneId
135142 get => _zoneId ;
136143 set => base [ ZoneIdKeyword ] = _zoneId = value ;
137144 }
138-
139-
145+
146+ public virtual int TimeOut
147+ {
148+ get => _timeOut ;
149+ set => base [ PoolSizeKeyword ] = _timeOut = value ;
150+ }
140151
141152 /// <summary>
142153 /// Gets a collection containing the keys used by the connection string.
@@ -162,8 +173,10 @@ public override ICollection Values
162173 return new ReadOnlyCollection < object > ( values ) ;
163174 }
164175 }
165-
166-
176+
177+
178+
179+
167180
168181
169182
@@ -211,6 +224,9 @@ public override object this[string keyword]
211224 case Keywords . ZoneId :
212225 ZoneId = Convert . ToString ( value , CultureInfo . InvariantCulture ) ;
213226 return ;
227+ case Keywords . TimeOut :
228+ TimeOut = Convert . ToInt32 ( value , CultureInfo . InvariantCulture ) ;
229+ return ;
214230 default :
215231 Debug . WriteLine ( false , "Unexpected keyword: " + keyword ) ;
216232 return ;
@@ -339,6 +355,8 @@ private object GetAt(Keywords index)
339355 return PoolSize ;
340356 case Keywords . ZoneId :
341357 return ZoneId ;
358+ case Keywords . TimeOut :
359+ return TimeOut ;
342360 default :
343361 Debug . Assert ( false , "Unexpected keyword: " + index ) ;
344362 return null ;
@@ -378,6 +396,9 @@ private void Reset(Keywords index)
378396 case Keywords . ZoneId :
379397 _zoneId = "UTC+08:00" ;
380398 return ;
399+ case Keywords . TimeOut :
400+ _timeOut = 10000 ; //10sec.
401+ return ;
381402 default :
382403 Debug . Assert ( false , "Unexpected keyword: " + index ) ;
383404 return ;
0 commit comments