Communication Service protocol

Thrift rpc interface

introduction

Thrift is a remote procedure call software framework for the development of extensible and cross-language services. It combines a powerful software stack and code generation engine, In order to build seamlessly integrated and efficient services among programming languages ​​such as C++, Java, Go, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml.

IoTDB server and client use thrift for communication. In actual use, it is recommended to use the native client package provided by IoTDB: Session or Session Pool. If you have special needs, you can also program directly against the RPC interface

The default IoTDB server uses port 6667 as the RPC communication port, you can modify the configuration item

1. rpc_port=6667

to change the default thrift port

rpc interface

1. // open a session
2. TSOpenSessionResp openSession(1:TSOpenSessionReq req);

4. // close a session
5. TSStatus closeSession(1:TSCloseSessionReq req);

7. // run an SQL statement in batch
8. TSExecuteStatementResp executeStatement(1:TSExecuteStatementReq req);

10. // execute SQL statement in batch
11. TSStatus executeBatchStatement(1:TSExecuteBatchStatementReq req);

13. // execute query SQL statement
14. TSExecuteStatementResp executeQueryStatement(1:TSExecuteStatementReq req);

16. // execute insert, delete and update SQL statement
17. TSExecuteStatementResp executeUpdateStatement(1:TSExecuteStatementReq req);

19. // fetch next query result
20. TSFetchResultsResp fetchResults(1:TSFetchResultsReq req)

22. // fetch meta data
23. TSFetchMetadataResp fetchMetadata(1:TSFetchMetadataReq req)

25. // cancel a query
26. TSStatus cancelOperation(1:TSCancelOperationReq req);

28. // close a query dataset
29. TSStatus closeOperation(1:TSCloseOperationReq req);

31. // get time zone
32. TSGetTimeZoneResp getTimeZone(1:i64 sessionId);

34. // set time zone
35. TSStatus setTimeZone(1:TSSetTimeZoneReq req);

37. // get server's properties
38. ServerProperties getProperties();

40. // set storage group
41. TSStatus setStorageGroup(1:i64 sessionId, 2:string storageGroup);

43. // create timeseries
44. TSStatus createTimeseries(1:TSCreateTimeseriesReq req);

46. // create multi timeseries
47. TSStatus createMultiTimeseries(1:TSCreateMultiTimeseriesReq req);

49. // delete timeseries
50. TSStatus deleteTimeseries(1:i64 sessionId, 2:list<string> path)

52. // delete sttorage groups
53. TSStatus deleteStorageGroups(1:i64 sessionId, 2:list<string> storageGroup);

55. // insert record
56. TSStatus insertRecord(1:TSInsertRecordReq req);

58. // insert record in string format
59. TSStatus insertStringRecord(1:TSInsertStringRecordReq req);

61. // insert tablet
62. TSStatus insertTablet(1:TSInsertTabletReq req);

64. // insert tablets in batch
65. TSStatus insertTablets(1:TSInsertTabletsReq req);

67. // insert records in batch
68. TSStatus insertRecords(1:TSInsertRecordsReq req);

70. // insert records of one device
71. TSStatus insertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq req);

73. // insert records in batch as string format
74. TSStatus insertStringRecords(1:TSInsertStringRecordsReq req);

76. // test the latency of innsert tablet,caution:no data will be inserted, only for test latency
77. TSStatus testInsertTablet(1:TSInsertTabletReq req);

79. // test the latency of innsert tablets,caution:no data will be inserted, only for test latency
80. TSStatus testInsertTablets(1:TSInsertTabletsReq req);

82. // test the latency of innsert record,caution:no data will be inserted, only for test latency
83. TSStatus testInsertRecord(1:TSInsertRecordReq req);

85. // test the latency of innsert record in string format,caution:no data will be inserted, only for test latency
86. TSStatus testInsertStringRecord(1:TSInsertStringRecordReq req);

88. // test the latency of innsert records,caution:no data will be inserted, only for test latency
89. TSStatus testInsertRecords(1:TSInsertRecordsReq req);

91. // test the latency of innsert records of one device,caution:no data will be inserted, only for test latency
92. TSStatus testInsertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq req);

94. // test the latency of innsert records in string formate,caution:no data will be inserted, only for test latency
95. TSStatus testInsertStringRecords(1:TSInsertStringRecordsReq req);

97. // delete data
98. TSStatus deleteData(1:TSDeleteDataReq req);

100. // execute raw data query
101. TSExecuteStatementResp executeRawDataQuery(1:TSRawDataQueryReq req);

103. // request a statement id from server
104. i64 requestStatementId(1:i64 sessionId);

IDL file path

IDL file path is “thrift/src/main/thrift/rpc.thrift” which includes interface and struct

target file path

We will use thrift compile IDL file in mvn Compilation, in which generate target .class file target file path is “thrift/target/classes/org/apache/iotdb/service/rpc/thrift”