(node endPoint)
| 1352 | } |
| 1353 | |
| 1354 | func (s *Session) initClusterConn(node endPoint) error { |
| 1355 | var err error |
| 1356 | |
| 1357 | s.trans = thrift.NewTSocketConf(net.JoinHostPort(node.Host, node.Port), &thrift.TConfiguration{ |
| 1358 | ConnectTimeout: time.Duration(0), // Use 0 for no timeout |
| 1359 | }) |
| 1360 | if err == nil { |
| 1361 | // s.trans = thrift.NewTFramedTransport(s.trans) // deprecated |
| 1362 | tmp_conf := thrift.TConfiguration{MaxFrameSize: thrift.DEFAULT_MAX_FRAME_SIZE} |
| 1363 | s.trans = thrift.NewTFramedTransportConf(s.trans, &tmp_conf) |
| 1364 | if !s.trans.IsOpen() { |
| 1365 | err = s.trans.Open() |
| 1366 | if err != nil { |
| 1367 | return err |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | |
| 1372 | if s.config.FetchSize < 1 { |
| 1373 | s.config.FetchSize = DefaultFetchSize |
| 1374 | } |
| 1375 | |
| 1376 | if s.config.TimeZone == "" { |
| 1377 | s.config.TimeZone = DefaultTimeZone |
| 1378 | } |
| 1379 | |
| 1380 | if s.config.ConnectRetryMax < 1 { |
| 1381 | s.config.ConnectRetryMax = DefaultConnectRetryMax |
| 1382 | } |
| 1383 | |
| 1384 | iprot := s.protocolFactory.GetProtocol(s.trans) |
| 1385 | oprot := s.protocolFactory.GetProtocol(s.trans) |
| 1386 | s.client = rpc.NewIClientRPCServiceClient(thrift.NewTStandardClient(iprot, oprot)) |
| 1387 | req := rpc.TSOpenSessionReq{ |
| 1388 | ClientProtocol: rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3, ZoneId: s.config.TimeZone, Username: s.config.UserName, |
| 1389 | Password: &s.config.Password, |
| 1390 | } |
| 1391 | |
| 1392 | resp, err := s.client.OpenSession(context.Background(), &req) |
| 1393 | if err != nil { |
| 1394 | return err |
| 1395 | } |
| 1396 | s.sessionId = resp.GetSessionId() |
| 1397 | s.requestStatementId, err = s.client.RequestStatementId(context.Background(), s.sessionId) |
| 1398 | return err |
| 1399 | } |
| 1400 | |
| 1401 | func getConfig(host string, port string, userName string, passWord string, fetchSize int32, timeZone string, connectRetryMax int, database string, sqlDialect string) *Config { |
| 1402 | return &Config{ |
no test coverage detected