# Perform a batch failover
Description
You can call this operation to perform a batch failover between the primary and standby tenants.
Call description
Prerequisites
You have the permission to modify tenants.
For more information about the permissions, see Overview and Overview.
You have passed the authentication for the OceanBase Cloud Platform (OCP) application service.
Request path
POST /api/v2/ob/clusters/{id}/tenants/failover
Request parameters
Path parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| id | Integer | Yes | 1 | The ID of the cluster. |
Body parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| failoverTenantItemList | FailoverTenantItem | No | SERVICE_A | A list of standby tenants for a batch failover. For more information, see Data structure of FailoverTenantItem. |
Data structure of FailoverTenantItem
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| tenantId | Long | Yes | 1 | The ID of the standby tenant. |
| serviceName | String | No | SERVICE_B | The service name of the new primary tenant. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | TaskInstance | The information about the asynchronous task. For more information, see Task return structure. |
| successful | Boolean | Indicates whether the request was successful. |
| timestamp | Datetime | The timestamp when the server completed the request. |
| duration | Integer | The amount of time taken by the server to process the request, in milliseconds. |
| status | Integer | The HTTP status code. |
| traceId | String | The trace ID of the request. This trace ID is used for troubleshooting. |
| server | String | The address of the application server that responded to the request. |
Examples
Sample request
POST /api/v2/ob/clusters/{id}/tenants/failover
Body:
{
"failoverTenantItemList": [
{
"tenantId" : 1,
"serviceName": "serviceA"
}
]
}
Sample response
{
"data": {
"contents": [
{
"clusterId": 3000010,
"creator": "admin",
"executor": "xxx.xxx.xxx.xxx",
"id": 12022226,
"name": "Failover tenant",
"operation": "EXECUTE",
"prohibitRollback": false,
"startTime": "2024-07-23T17:42:34.056+08:00",
"status": "RUNNING",
"subtasks": [
{
"description": "Failover to primary tenant",
"downstreams": [
13025785
],
"id": 13025788,
"name": "Failover to primary tenant",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": true,
"runTime": 1,
"seriesId": 2,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025787
]
},
{
"description": "Reset log restore source",
"downstreams": [
13025788
],
"id": 13025787,
"name": "Reset log restore source",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 3,
"status": "READY",
"timeout": 1800,
"upstreams": []
},
{
"description": "Create tenant service name",
"downstreams": [
13025789
],
"id": 13025786,
"name": "Create tenant service name",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 0,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025785
]
},
{
"description": "Update primary tenant info task",
"downstreams": [],
"id": 13025789,
"name": "Update primary tenant info task",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": true,
"runTime": 1,
"seriesId": 4,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025786
]
},
{
"description": "Upgrade tenant data version",
"downstreams": [
13025786
],
"id": 13025785,
"name": "Upgrade tenant data version",
"nodeType": "JAVA_TASK",
"operation": "EXECUTE",
"parallelIdx": -1,
"prohibitRollback": false,
"runTime": 1,
"seriesId": 1,
"status": "PENDING",
"timeout": 1800,
"upstreams": [
13025788
]
}
],
"taskDefinitionId": -1,
"tenantId": 2000025,
"type": "MANUAL"
}
]
},
"duration": 154,
"server": "3af57a8e6b",
"status": 200,
"successful": true,
"timestamp": "2024-07-23T17:42:34.069+08:00",
"traceId": "2692bd8d54b25810"
}