MCPcopy Create free account
hub / github.com/apache/iotdb-client-go / OpenCluster

Method OpenCluster

client/session.go:159–204  ·  view source on GitHub ↗
(enableRPCCompression bool)

Source from the content-addressed store, hash-verified

157}
158
159func (s *Session) OpenCluster(enableRPCCompression bool) error {
160 if s.config.FetchSize <= 0 {
161 s.config.FetchSize = DefaultFetchSize
162 }
163 if s.config.TimeZone == "" {
164 s.config.TimeZone = DefaultTimeZone
165 }
166
167 if s.config.ConnectRetryMax <= 0 {
168 s.config.ConnectRetryMax = DefaultConnectRetryMax
169 }
170
171 var err error
172
173 s.protocolFactory = getProtocolFactory(enableRPCCompression)
174 iprot := s.protocolFactory.GetProtocol(s.trans)
175 oprot := s.protocolFactory.GetProtocol(s.trans)
176 s.client = rpc.NewIClientRPCServiceClient(thrift.NewTStandardClient(iprot, oprot))
177 req := rpc.TSOpenSessionReq{
178 ClientProtocol: rpc.TSProtocolVersion_IOTDB_SERVICE_PROTOCOL_V3, ZoneId: s.config.TimeZone, Username: s.config.UserName,
179 Password: &s.config.Password,
180 }
181 req.Configuration = make(map[string]string)
182 req.Configuration["sql_dialect"] = s.config.sqlDialect
183 if s.config.Version == "" {
184 req.Configuration["version"] = string(DEFAULT_VERSION)
185 } else {
186 req.Configuration["version"] = string(s.config.Version)
187 }
188 if s.config.Database != "" {
189 req.Configuration["db"] = s.config.Database
190 }
191
192 resp, err := s.client.OpenSession(context.Background(), &req)
193 if err != nil {
194 return err
195 }
196 if timeFactor, err := getTimeFactor(resp); err != nil {
197 return err
198 } else {
199 s.timeFactor = timeFactor
200 }
201 s.sessionId = resp.GetSessionId()
202 s.requestStatementId, err = s.client.RequestStatementId(context.Background(), s.sessionId)
203 return err
204}
205
206func getProtocolFactory(enableRPCCompression bool) thrift.TProtocolFactory {
207 if enableRPCCompression {

Callers 3

connectClusterFunction · 0.80
NewClusterTableSessionFunction · 0.80
ConstructSessionMethod · 0.80

Calls 6

getProtocolFactoryFunction · 0.85
getTimeFactorFunction · 0.85
OpenSessionMethod · 0.65
RequestStatementIdMethod · 0.65
GetSessionIdMethod · 0.45

Tested by

no test coverage detected