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);
  3. // close a session
  4. TSStatus closeSession(1:TSCloseSessionReq req);
  5. // run an SQL statement in batch
  6. TSExecuteStatementResp executeStatement(1:TSExecuteStatementReq req);
  7. // execute SQL statement in batch
  8. TSStatus executeBatchStatement(1:TSExecuteBatchStatementReq req);
  9. // execute query SQL statement
  10. TSExecuteStatementResp executeQueryStatement(1:TSExecuteStatementReq req);
  11. // execute insert, delete and update SQL statement
  12. TSExecuteStatementResp executeUpdateStatement(1:TSExecuteStatementReq req);
  13. // fetch next query result
  14. TSFetchResultsResp fetchResults(1:TSFetchResultsReq req)
  15. // fetch meta data
  16. TSFetchMetadataResp fetchMetadata(1:TSFetchMetadataReq req)
  17. // cancel a query
  18. TSStatus cancelOperation(1:TSCancelOperationReq req);
  19. // close a query dataset
  20. TSStatus closeOperation(1:TSCloseOperationReq req);
  21. // get time zone
  22. TSGetTimeZoneResp getTimeZone(1:i64 sessionId);
  23. // set time zone
  24. TSStatus setTimeZone(1:TSSetTimeZoneReq req);
  25. // get server's properties
  26. ServerProperties getProperties();
  27. // set storage group
  28. TSStatus setStorageGroup(1:i64 sessionId, 2:string storageGroup);
  29. // create timeseries
  30. TSStatus createTimeseries(1:TSCreateTimeseriesReq req);
  31. // create multi timeseries
  32. TSStatus createMultiTimeseries(1:TSCreateMultiTimeseriesReq req);
  33. // delete timeseries
  34. TSStatus deleteTimeseries(1:i64 sessionId, 2:list<string> path)
  35. // delete sttorage groups
  36. TSStatus deleteStorageGroups(1:i64 sessionId, 2:list<string> storageGroup);
  37. // insert record
  38. TSStatus insertRecord(1:TSInsertRecordReq req);
  39. // insert record in string format
  40. TSStatus insertStringRecord(1:TSInsertStringRecordReq req);
  41. // insert tablet
  42. TSStatus insertTablet(1:TSInsertTabletReq req);
  43. // insert tablets in batch
  44. TSStatus insertTablets(1:TSInsertTabletsReq req);
  45. // insert records in batch
  46. TSStatus insertRecords(1:TSInsertRecordsReq req);
  47. // insert records of one device
  48. TSStatus insertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq req);
  49. // insert records in batch as string format
  50. TSStatus insertStringRecords(1:TSInsertStringRecordsReq req);
  51. // test the latency of innsert tablet,caution:no data will be inserted, only for test latency
  52. TSStatus testInsertTablet(1:TSInsertTabletReq req);
  53. // test the latency of innsert tablets,caution:no data will be inserted, only for test latency
  54. TSStatus testInsertTablets(1:TSInsertTabletsReq req);
  55. // test the latency of innsert record,caution:no data will be inserted, only for test latency
  56. TSStatus testInsertRecord(1:TSInsertRecordReq req);
  57. // test the latency of innsert record in string format,caution:no data will be inserted, only for test latency
  58. TSStatus testInsertStringRecord(1:TSInsertStringRecordReq req);
  59. // test the latency of innsert records,caution:no data will be inserted, only for test latency
  60. TSStatus testInsertRecords(1:TSInsertRecordsReq req);
  61. // test the latency of innsert records of one device,caution:no data will be inserted, only for test latency
  62. TSStatus testInsertRecordsOfOneDevice(1:TSInsertRecordsOfOneDeviceReq req);
  63. // test the latency of innsert records in string formate,caution:no data will be inserted, only for test latency
  64. TSStatus testInsertStringRecords(1:TSInsertStringRecordsReq req);
  65. // delete data
  66. TSStatus deleteData(1:TSDeleteDataReq req);
  67. // execute raw data query
  68. TSExecuteStatementResp executeRawDataQuery(1:TSRawDataQueryReq req);
  69. // request a statement id from server
  70. 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”