You are viewing the documentation for a prerelease version.

View Latest

Getting Cluster Tasks

A list of ongoing cluster tasks can be returned with the POST /pools/default/tasks HTTP method and URI.

HTTP method and URI

GET /pools/default/tasks

Description

Ongoing cluster-tasks can be reported; with status, id, and additional information returned for each.

Curl Syntax

curl -v -X GET -u [admin]:[password]
  http://[localhost]:8091/pools/default/tasks

Response

Success gives the response code 200 OK, and returns an object containing information on the current status of ongoing tasks. See the examples provided below.

Examples

The following examples show output returned in accordance with whether tasks are in progress; and if so, which.

No Tasks Underway

When the cluster has no tasks underway, the method verifies this. Here, the output is piped to the jq tool, to enhance readability.

curl -u Administrator:password -v -X GET \
http://10.143.190.101:8091/pools/default/tasks | jq '.'

Output is as follows:

[
  {
    "statusId": "28452d665fce646c98385fb590a30adc",
    "type": "rebalance",
    "status": "notRunning",
    "statusIsStale": false,
    "masterRequestTimedOut": false
  }
]

The default output indicates that no rebalance is underway. A statusId and task type are provided.

Adding a Bucket

When a bucket is being added (in this case, the sample bucket beer-sample), status can be returned by entering the method in the standard way, specifying the IP address of the cluster, or localhost, as appropriate:

curl -u Administrator:password -v -X GET http://localhost:8091/pools/default/tasks | jq '.'

Output is as follows:

[
  {
    "statusId": "1f05320a7b359e1672ffc8b7ee69a8b5",
    "type": "rebalance",
    "status": "notRunning",
    "statusIsStale": false,
    "masterRequestTimedOut": false
  },
  {
    "status": "running",
    "type": "loadingSampleBucket",
    "bucket": "beer-sample",
    "pid": "<0.24849.21>"
  }
]

The output indicates that no rebalance is underway, but that the loadingSampleBucket operation is ongoing.

Compacting a Bucket

When a bucket (in this case, the sample bucket beer-sample) is being compacted, the method can be used to return status as follows:

curl -u Administrator:password -v -X GET \
http://localhost:8091/pools/default/tasks | jq '.'

The following output is provided:

[
  {
    "statusId": "28452d665fce646c98385fb590a30adc",
    "type": "rebalance",
    "status": "notRunning",
    "statusIsStale": false,
    "masterRequestTimedOut": false
  },
  {
    "cancelURI": "/pools/default/buckets/beer-sample/controller/cancelBucketCompaction",
    "type": "bucket_compaction",
    "recommendedRefreshPeriod": 2,
    "status": "running",
    "bucket": "beer-sample",
    "changesDone": 177,
    "totalChanges": 682,
    "progress": 25
  }
]

The output indicates that the beer-sample bucket is being compacted. Progress is reported in terms of changesDone, totalChanges, and a progress figure that is a percentage of total completion. A URI is provided for cancelling compaction, if required.

Rebalance Following Node-Addition

When rebalance is used to eject node 10.143.190.103 from a cluster of three nodes, which has included 10.143.190.101 and 10.143.190.102 in addition to itself, and which is hosting the travel-sample and beer-sample sample buckets, the progress of the task can be retrieved as follows:

curl -u Administrator:password -v -X GET \
http://10.143.190.101:8091/pools/default/tasks | jq '.'

Depending on at what point in the rebalance the method is run, the output might be as follows:

[
  {
    "statusId": "f48ed1db5b4bf75e7bff06b1e59fa397",
    "type": "rebalance",
    "subtype": "rebalance",
    "recommendedRefreshPeriod": 0.25,
    "status": "running",
    "progress": 47.96302747933775,
    "perNode": {
      "ns_1@10.143.190.101": {
        "progress": 49.51171875
      },
      "ns_1@10.143.190.102": {
        "progress": 48.04305283757338
      },
      "ns_1@10.143.190.103": {
        "progress": 46.33431085043988
      }
    },
    "detailedProgress": {
      "bucket": "beer-sample",
      "bucketNumber": 1,
      "bucketsCount": 2,
      "perNode": {
        "ns_1@10.143.190.103": {
          "ingoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 0
          },
          "outgoing": {
            "docsTotal": 2479,
            "docsTransferred": 2302,
            "activeVBucketsLeft": 25,
            "replicaVBucketsLeft": 0
          }
        },
        "ns_1@10.143.190.102": {
          "ingoing": {
            "docsTotal": 2419,
            "docsTransferred": 2379,
            "activeVBucketsLeft": 20,
            "replicaVBucketsLeft": 5
          },
          "outgoing": {
            "docsTotal": 1259,
            "docsTransferred": 1259,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 20
          }
        },
        "ns_1@10.143.190.101": {
          "ingoing": {
            "docsTotal": 2495,
            "docsTransferred": 2358,
            "activeVBucketsLeft": 5,
            "replicaVBucketsLeft": 20
          },
          "outgoing": {
            "docsTotal": 1176,
            "docsTransferred": 1176,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 5
          }
        }
      }
    }
  }
]

The response object provides a statusId for the ongoing rebalance operation. The value of progress indicates that at the time of running the method, overall progress was slightly below 48 percent. Progress is also give perNode: each value is a percentage: note that these values are represented as percentages in Couchbase Web Console, when it is itself used to monitor rebalance. All progress values are represented as floating-point numbers with fourteen places. A detailedProgress object is also provided for each node, with indications of the status of documents and vBuckets. Note that at any one time, it indicates which of the buckets is currently being redistributed: in this case, it is beer-sample.

Note that a recommendedRefreshPeriod of 0.25 seconds is given. If the same method is entered subsequently, output indicates that progress has continued:

[
  {
    "statusId": "f48ed1db5b4bf75e7bff06b1e59fa397",
    "type": "rebalance",
    "subtype": "rebalance",
    "recommendedRefreshPeriod": 0.25,
    "status": "running",
    "progress": 55.67450906550226,
    "perNode": {
      "ns_1@10.143.190.101": {
        "progress": 57.37704918032787
      },
      "ns_1@10.143.190.102": {
        "progress": 52.75498241500587
      },
      "ns_1@10.143.190.103": {
        "progress": 56.89149560117301
      }
    },
    "detailedProgress": {
      "bucket": "travel-sample",
      "bucketNumber": 2,
      "bucketsCount": 2,
      "perNode": {
        "ns_1@10.143.190.103": {
          "ingoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 0
          },
          "outgoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 294,
            "replicaVBucketsLeft": 620
          }
        },
        "ns_1@10.143.190.102": {
          "ingoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 124,
            "replicaVBucketsLeft": 0
          },
          "outgoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 124
          }
        },
        "ns_1@10.143.190.101": {
          "ingoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 170,
            "replicaVBucketsLeft": 0
          },
          "outgoing": {
            "docsTotal": 0,
            "docsTransferred": 0,
            "activeVBucketsLeft": 0,
            "replicaVBucketsLeft": 170
          }
        }
      }
    }
  }
]

Note that the output indicates that, at this point, the travel-sample bucket is being redistributed. This indicates that redistribution of the beer-sample bucket has concluded.

Rebalance Failure

If rebalance fails, the method can be used to retrieve the following confirmation of failure:

[
  {
    "statusId": "1f05321a7b359e1743ffc8b7ee69a8b9",
    "type": "rebalance",
    "status": "notRunning",
    "errorMessage": "Rebalance failed. See logs for detailed reason. You can try rebalance again."
  }
]

See Also

Examples of adding a node and rebalancing by means of the UI, CLI, and REST API are provided in Add a Node and Rebalance. The REST method and URI for rebalance is explained in Rebalancing Nodes. The REST method and URI for bucket-compaction is documented in Compacting Buckets.

For additional information on retrieving the progress of the rebalance operation, see Getting Rebalance Progress.