|
| 1 | +Clusters |
| 2 | +-------- |
| 3 | + |
| 4 | +The cluster-specific API lets you get information about individual |
| 5 | +cluster nodes and the cluster as a whole, as well as monitor and |
| 6 | +administrate cluster deployments. For more information on the design |
| 7 | +and architecture, refer to `ArangoDB Manual`_. |
| 8 | + |
| 9 | +.. _ArangoDB Manual: https://docs.arangodb.com |
| 10 | + |
| 11 | +.. code-block:: python |
| 12 | +
|
| 13 | + from arangoasync import ArangoClient |
| 14 | + from arangoasync.auth import Auth |
| 15 | +
|
| 16 | + # Initialize the client for ArangoDB. |
| 17 | + async with ArangoClient(hosts="http://localhost:8529") as client: |
| 18 | + auth = Auth(username="root", password="passwd") |
| 19 | +
|
| 20 | + # Connect to "_system" database as root user. |
| 21 | + db = await client.db("_system", auth=auth) |
| 22 | + cluster = db.cluster |
| 23 | +
|
| 24 | + # Cluster health |
| 25 | + health = await cluster.health() |
| 26 | +
|
| 27 | + # DB-Server statistics |
| 28 | + db_server = "PRMR-2716c9d0-4b22-4c66-ba3d-f9cd3143e52b" |
| 29 | + stats = await cluster.statistics(db_server) |
| 30 | +
|
| 31 | + # Cluster endpoints |
| 32 | + endpoints = await cluster.endpoints() |
| 33 | +
|
| 34 | + # Cluster server ID and role |
| 35 | + server_id = await cluster.server_id() |
| 36 | + server_role = await cluster.server_role() |
| 37 | +
|
| 38 | + # Maintenance mode |
| 39 | + await cluster.toggle_maintenance_mode("on") |
| 40 | + await cluster.toggle_maintenance_mode("off") |
| 41 | + await cluster.toggle_server_maintenance_mode( |
| 42 | + db_server, "maintenance", timeout=30 |
| 43 | + ) |
| 44 | + status = await cluster.server_maintenance_mode(db_server) |
| 45 | + await cluster.toggle_server_maintenance_mode(db_server, "normal") |
| 46 | +
|
| 47 | + # Rebalance |
| 48 | + result = await cluster.calculate_imbalance() |
| 49 | + result = await cluster.calculate_rebalance_plan() |
| 50 | + result = await cluster.execute_rebalance_plan(moves=[]) |
| 51 | + result = await cluster.rebalance() |
| 52 | +
|
| 53 | +See :class:`arangoasync.cluster.Cluster` for API specification. |
0 commit comments