1. 程式人生 > 其它 >【TcaplusDB知識庫】如何(批量)申請通過xml、tdr、proto檔案新增表

【TcaplusDB知識庫】如何(批量)申請通過xml、tdr、proto檔案新增表

【TcaplusDB知識庫】如何(批量)申請通過xml/tdr/proto檔案新增表

 

申請加表介面支援在同一個業務的不同遊戲區下新增多張表,其介面的cmd值為10002。

請求地址

POST
http://OmsAddress/app/newoms.php/webservice/business/table/batchapply?cmd=10002&ip-type=webservicerest&access-token=AccessTokenVal

POST請求引數說明

引數名稱 資料型別 說明 是否必填欄位 備註
app_id 整型 加表所在的業務id  
attachment_id 陣列
定義表結構的xml檔案id列表  
attention_man 字串 用分號";"分隔關注人,欄位最大長度為200  
table_info 陣列 table_info各陣列項是在指定的app_id各zone下申請的加表資訊,其資料結構見如下表格  

 

申請加表時,table_info各資料項的結構:

zone_id 表所在的zone的id        
tables 陣列,陣列中一個數據項是一張表的資訊,表所填資訊如右 引數名稱 欄位名稱 陣列型別 說明
    table_name 表名稱 字串 長度1-31,只能包含字母、數字、下劃線,首字母為字母、下劃線
    table_type 表型別 整型 0為generic,1為list 預設0
    table_maxnum List最多元素個數 整型 table_type為1時,必填,範圍1-1024
    auto_approve_add_table_trans 是否自動稽核此申請單 整型 若自動稽核,需要加表所在的叢集的許可權允許
    auto_execute_add_table_trans 是否自動執行此申請單對應的事務 整型 auto_approve_add_table_trans=1時,此處自動執行才有效,且需要加表所在的叢集許可權允許
    compress 表壓縮
整型 0不開啟表壓縮,1開啟表壓縮 預設0
    calc_resource_type 計算表資源的模型 整型 1,簡單模型;2,專家模式 預設1
    active_record_num 活躍記錄數 整型 calc_resource_type為1時必填,範圍1-2147483647
    total_record_num 總記錄數 整型 calc_resource_type為1、2時必填
    estimated_read_load 讀頻率 整型 calc_resource_type為1時必填
    estimated_write_load 寫頻率 整型 calc_resource_type為1時必填
    key_avarage_record_size 最大key大小 整型 calc_resource_type為1、2時必填
    value_avarage_record_size Value平均大小 整型 calc_resource_type為1、2時必填
    pcu 最高線上(PCU) 整型 calc_resource_type為2時必填
    relationship_chain_interval 每玩家關係鏈讀取間隔(秒) 整型 calc_resource_type為2時必填
    relationship_chain_count 玩家關係鏈一次性讀取記錄條數(條) 整型 calc_resource_type為2時必填
    index_count 索引/List數目 整型 calc_resource_type為2時必填
    read_index_interval 每玩家索引/List讀取間隔(秒) 整型 calc_resource_type為2時必填
    read_index_count 平均每次索引/List讀取時讀取的記錄條數(條) 整型 calc_resource_type為2時必填
    read_interval 每玩家觸發單條讀取間隔(秒) 整型 calc_resource_type為2時必填
    write_interval 每玩家觸發單條寫入間隔(秒) 整型 calc_resource_type為2時必填

 

Data引數

使用json格式表示記錄相關資訊,示例如下:

{
  "table_info": [
      {
          "tables": [
              {
                  "relationship_chain_count": 1,
                  "table_type": 0,
                  "compress": 0,
                  "value_avarage_record_size": 1,
                  "active_record_num": "2",
                  "total_record_num": "3",
                  "estimated_read_load": "4",
                  "read_index_interval": 60,
                  "index_count": 1,
                  "calc_resource_type": 2,
                  "write_interval": 60,
                  "pcu": 1,
                  "relationship_chain_interval": 60,
                  "table_name": "test_table_generic_modify",
                  "estimated_write_load": "5",
                  "key_avarage_record_size": 1,
                  "read_interval": 60,
                  "read_index_count": 1
              }
          ],
          "zone_id": "3"
      }
  ],
  "memo": "by auto test",
  "attachment_id": [
      99
  ],
  "app_id": "2"
}

返回說明

  1. http請求的Status為200,請求成功,返回加表資訊;返回資料結構見“請求示例”

  2. http請求的Status 不等於200,請求失敗,返回的資料為json格式,內容為錯誤資訊描述 | |

請求示例

通過 curl 方法發起請求

命令中的紅色部分是需要使用者自行填寫的引數,請參閱url中GET引數說明

curl -H "Content-type: application/json" -X "POST" -d '{ "table_info": [ { "tables": [ { "relationship_chain_count": 1, "table_type": 0, "compress": 0, "value_avarage_record_size": 1, "active_record_num": "2", "total_record_num": "3", "estimated_read_load": "4", "read_index_interval": 60, "index_count": 1, "calc_resource_type": 2, "write_interval": 60, "pcu": 1, "relationship_chain_interval": 60, "table_name": "test_table_generic_modify", "estimated_write_load": "5", "key_avarage_record_size": 1, "read_interval": 60, "read_index_count": 1 } ], "zone_id": "3" } ], "memo": "by auto test", "attachment_id": [ 99 ], "app_id": "2" }' http://omsaddress/app/newoms.php/webservice/business/table/batchapply?cmd=10002&ip-type=webservicerest&access-token=<access-token>

返回示例

成功返回示例

http請求的Status=200

[
  {
      "relationship_chain_count": 1,
      "table_type": 0, //表型別,0:generic;1:list
      "compress": 0,
      "value_avarage_record_size": 1,
      "active_record_num": "2",
      "total_record_num": "3",
      "estimated_read_load": "4",
      "read_index_interval": 60,
      "index_count": 1,
      "calc_resource_type": 2,
      "write_interval": 60,
      "pcu": 1,
      "relationship_chain_interval": 60,
      "table_name": "test_table_generic_modify",//表名稱
      "estimated_write_load": "5",
      "key_avarage_record_size": 1,
      "read_interval": 60,
      "read_index_count": 1,
      "resource_ratio": 1,
      "zone_list": "3",//表所在的遊戲區id
      "set_id": 126,//表所在的叢集id
      "app_id": "2",//表所在的業務id
      "app_name": "t_app",
      "memo": "by auto test",
      "attention_man": "",
      "user": "tcaplus",
      "type": "xml",
      "apply_type": "0",
      "tdr": "99",
      "write_time": "2017-03-02 20:20:10",
      "dm_ratio": 5,
      "kelly_id": 0,
      "table_maxnum": 0,
      "id": 108//加表申請單id
  }
]

錯誤返回

http請求的Status!=200

[
  "ip(10.29.89.51) not in whitelist for applying to add table(cmd:10002) of set_id:126 app_id:2 zone_id:3"
]
{
  "name": "Unauthorized",
  "message": "you are not allowed to access this app:app_id:2",
  "code": 0,
  "status": 401,
  "type": "yii\\web ForbiddenHttpException"
}
[
  "table_name:已經申請其他表操作 app:2 zone:3 table_name:test_table_generic_modify apply id:108 apply type:{applytype} error type:{errortype}"
]
[
  "table_name:已經申請其他表操作 app:2 zone:3 table_name:test_table_generic_modify apply id:108 apply type:{applytype} error type:{errortype}"
]

 


 

TcaplusDB是騰訊出品的分散式NoSQL資料庫,儲存和排程的程式碼完全自研。具備快取+落地融合架構、PB級儲存、毫秒級時延、無損水平擴充套件和複雜資料結構等特性。同時具備豐富的生態、便捷的遷移、極低的運維成本和五個九高可用等特點。客戶覆蓋遊戲、網際網路、政務、金融、製造和物聯網等領域。