调用MergeShards接口合并两个相邻的readwrite状态的Shards。在参数中指定一个shardid,服务端自动找相邻的下一个Shard。

请求语法

POST /logstores/<logstorename>/shards/<shardid>?action=merge HTTP/1.1
Authorization: <AuthorizationString>
Date: <GMT Date>
Host: <Project Endpoint>
x-log-apiversion: 0.6.0
x-log-signaturemethod: hmac-sha1

请求参数

  • 请求头

    MergeShards接口无特有请求头。关于Log Service API的公共请求头,请参见公共请求头

  • 参数列表
    参数名称 类型 是否必须 示例值 描述
    logstoreName string logstorename 日志库名称。
    shardid int 30 shard ID。

返回数据

  • 响应头

    MergeShards接口无特有响应头。关于Log Service API的公共响应头,请参见公共响应头

  • 响应元素
    3个Shard元素组成的数组,第一个Shard为merge之后的Shard,后两个为merge之前的Shard。
    [
        {
            'shardID': 167, 
            'status': 'readwrite', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000',
            'createTime': 1453953105,
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }, 
        {
            'shardID': 30, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000', 
            'createTime': 0, 
            'exclusiveEndKey': 
            'e7000000000000000000000000000000'
        },
        {
            'shardID': 166, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e7000000000000000000000000000000', 
            'createTime': 1453953073, 
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }
    ]

示例

  • 请求示例
    POST /logstores/logstorename/shards/30?action=merge
    Header :
    {
        "Content-Length": 0, 
        "x-log-signaturemethod": "hmac-sha1", 
        "x-log-bodyrawsize": 0, 
        "User-Agent": "log-python-sdk-v-0.6.0", 
        "Host": "ali-test-project.cn-hangzhou.sls.aliyuncs.com", 
        "Date": "Thu, 12 Nov 2015 03:40:31 GMT", 
        "x-log-apiversion": "0.6.0", 
        "Authorization": "LOG <yourAccessKeyId>:<yourSignature>"
    }
  • 正常返回示例
    Header:
    {
        "content-length": "57", 
        "server": "nginx/1.6.1", 
        "connection": "close", 
        "date": "Thu, 12 Nov 2015 03:40:31 GMT", 
        "content-type": "application/json", 
        "x-log-requestid": "56440A2F99248C050600C74C"
    }
    Body :
    [
        {
            'shardID': 167, 
            'status': 'readwrite', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000',
            'createTime': 1453953105,
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }, 
        {
            'shardID': 30, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e0000000000000000000000000000000', 
            'createTime': 0, 
            'exclusiveEndKey': 
            'e7000000000000000000000000000000'
        },
        {
            'shardID': 166, 
            'status': 'readonly', 
            'inclusiveBeginKey': 'e7000000000000000000000000000000', 
            'createTime': 1453953073, 
            'exclusiveEndKey': 'ffffffffffffffffffffffffffffffff'
        }
    ]

错误码

HTTP状态码 错误码 错误信息 描述
404 LogStoreNotExist logstore {logstoreName} does not exist. 日志库不存在。
400 ParameterInvalid invalid shard id. 无效shard ID。
400 ParameterInvalid can not merge the last shard. 无效merge。
500 InternalServerError Specified Server Error Message. 内部服务调用错误。
400 LogStoreWithoutShard logstore has no shard. 日志库没有Shard。

更多错误码,请参见通用错误码