# REST API

## Coordinator

Coordinator 上的 API 主要用于作业管理、配置管理以及集群管理。

### 分布式加载

#### 列出所有加载作业

**方法:** `GET`

**路径:** `/api/v1/load`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {...}
    ]
  }
  ```

  了解更多作业信息，请参阅“**获取加载作业进度**” 。
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取加载作业进度

**方法:** `GET`

**路径:** `/api/v1/load`

**参数:**

| **名称** | **描述**            |
| ------ | ----------------- |
| `id`   | 由 POST 请求返回的作业 id |

**响应:**

* `200 - OK`: 操作成功(空值将被省略)

  ```json
  {
    "id": "54b88939-de49-46ef-acab-fe489f46d1a0",
    "startTime": "2024-11-21T20:58:26.957+08:00",
    "state": "SUCCEEDED",
    "runningState": "",
    "errorMessage": {},
    "failedFileListPath": "",
    "paths": [
      "s3://my-bucket/dir/to/path"
    ],
    "index": "",
    "skipIfExists": false,
    "loadMetadataOnly": false,
    "verify": false,
    "bandwidth": 0,
    "timeElapsedMilliseconds": 10949,
    "loadedBytes": 10485760,
    "skippedBytes": 0,
    "totalBytes": 10485760,
    "loadedNonEmptyFiles": 1,
    "failedFiles": 0,
    "scannedFiles": 1,
    "quota": {
      "totalBytes": 0,
      "remaining": 0
    }
    "quotaCheckError": ""
  }
  ```
* `404 - Not Found`: 未找到作业

  ```json
  {
    "status": "No job found..."
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 提交或恢复加载作业

**方法:** `POST`

**路径:** `/api/v1/load`

**参数:** 无

**请求体 :** `Content-Type: application/json`

最多只需提供一个参数。

| **名称**  | **描述**              |
| ------- | ------------------- |
| `paths` | 要加载的 UFS 路径列表       |
| `index` | UFS 上索引文件的路径（必须已挂载） |

可以使用 `options` JSON 来配置加载作业的选项。所有选项均为可选项。可配置项包括：

| **名称**            | **描述**                                      |
| ----------------- | ------------------------------------------- |
| `batchSize`       | Worker 从 UFS 加载数据时使用的批处理大小                  |
| `fileFilterRegex` | 筛选要加载文件的正则表达式                               |
| `replicas`        | 要加载的副本数量，默认值为 1。如果启用了多副本功能，可以通过此参数指定所需的副本数。 |
| `skipIfExists`    | 如果文件已存在，则跳过加载过程                             |
| `loadPolicy`      | 当前仅支持IF\_CHANGED，如果文件发生变更，则更新文件             |

JSON 请求负载示例如下：

```json
{
  "paths": [
    "s3://my-bucket/dir/to/path"
  ],
  "options": {
    "batchSize": 0,
    "fileFilterRegx": "",
    "replicas": 0,
    "sync": true,
    "skipIfExists": false
  }
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "id": "54b88939-de49-46ef-acab-fe489f46d1a0"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `409 - Conflict`: 使用相同路径恢复加载作业，并返回之前的作业 id

  ```json
  {
    "id": "54b88939-de49-46ef-acab-fe489f46d1a0"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 停止加载作业

**方法:** `DELETE`

**路径:** `/api/v1/load`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "id": "54b88939-de49-46ef-acab-fe489f46d1a0"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `410 - Gone`: 该作业不存在或已完成

  ```json
  {
    "status": "The job doesn't exist or has already finished"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 清理缓存（Free Cache)

#### 列出所有清理缓存的作业

**方法:** `GET`

**路径:** `/api/v1/free`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {...}
    ]
  }
  ```

  有关作业的更多信息，请参阅 “**获取清理缓存作业进度”。**
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取清理缓存作业进度

**方法:** `GET`

**路径:** `/api/v1/free`

**参数:**

| **名称** | **描述**            |
| ------ | ----------------- |
| `id`   | 由 POST 请求返回的作业 id |

**响应:**

* `200 - OK`: 操作成功 (空值将被省略)

  ```json
  {
    "id": "464050c3-9900-4b2f-8716-9220cd5eb495",
    "startTime": "2024-11-21T21:21:55.764+08:00",
    "state": "SUCCEEDED",
    "errorMessage": {},
    "paths": [
      "s3://my-bucket/dir/to/path"
    ],
    "timeElapsedMilliseconds": 4197,
    "freedBytes": 10485760,
    "failedBytes": 0,
    "totalBytes": 10485760,
    "freedFiles": 1,
    "failedFiles": 0,
    "totalFiles": 10485760
  }
  ```
* `404 - Not Found`: 未找到作业

  ```json
  {
    "status": "No job found..."
  }
  ```
* `500 - Internal Server Error`:意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 提交或恢复清理缓存作业

**方法:** `POST`

**路径:** `/api/v1/free`

**参数:** 无

**请求体:** `Content-Type: application/json`

最多只需提供一个参数。

| **名称**  | **描述**              |
| ------- | ------------------- |
| `paths` | 要加载的 UFS 路径列表       |
| `index` | UFS 上索引文件的路径（必须已挂载） |

JSON 请求负载示例如下：

```json
{
  "paths": [
    "s3://my-bucket/dir/to/path"
  ],
  "index": "",
  "options": {
    "batchSize": 0,
    "sync": true,
    "recursive": true
  }
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "id": "464050c3-9900-4b2f-8716-9220cd5eb495"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `409 - Conflict`: 使用相同路径恢复清理缓存作业，并返回之前的作业 id

  ```json
  {
    "id": "464050c3-9900-4b2f-8716-9220cd5eb495"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 停止清理缓存作业

**方法:** `DELETE`

**路径:** `/api/v1/free`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "id": "464050c3-9900-4b2f-8716-9220cd5eb495"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `410 - Gone`: 该作业不存在或已完成

  ```json
  {
    "status": "The job doesn't exist or has already finished"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 重平衡（Rebalance）

#### 列出所有重平衡作业

**方法:** `GET`

**路径:** `/api/v1/rebalance`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {...}
    ]
  }
  ```

  有关作业的更多信息，请参阅“**获取重平衡作业进度**”。
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取重平衡作业进度

**方法:** `GET`

**路径:** `/api/v1/rebalance`

**参数:**

最多只需提供一个参数。

| **名称**   | **描述**                                                                                                 |
| -------- | ------------------------------------------------------------------------------------------------------ |
| `id`     | 由 POST 请求返回的作业 id                                                                                      |
| `target` | 重平衡作业的目标 Worker，可以是指定的 worker id（例如：`worker-54b88939-de49-46ef-acab-fe489f46d1a0`）或者`ALL`（表示所有 Worker） |

**响应:**

* `200 - OK`: 操作成功 (空值将被省略)

  ```json
  {
     "succeededWorkers":2,
     "bytesPreserved":4,
     "filesLoaded":0,
     "filesPreserved":1,
     "filesFailed":0,
     "totalWorkers":2,
     "bytesPruned":226,
     "filesPruned":5,
     "bytesLoaded":0,
     "timeElapsedMilliseconds":4536,
     "runningWorkers":0,
     "startTime":"2024-12-19T23:15:07.043+08:00",
     "id":"8de63d3a-63c8-4f08-bbc1-c87e3c0fb6d9",
     "state":"SUCCEEDED",
     "failedWorkers":0
  }
  ```
* `404 - Not Found`: 未找到作业

  ```json
  {
    "status": "No job found..."
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 提交或恢复重平衡作业

**方法:** `POST`

**路径:** `/api/v1/rebalance`

**参数:** 无

**请求体:** `Content-Type: application/json`

必填字段

| **名称**   | **描述**                                                                                                  |
| -------- | ------------------------------------------------------------------------------------------------------- |
| `target` | 重平衡作业的目标 Worker，可以是指定的 worker id（例如：`worker-54b88939-de49-46ef-acab-fe489f46d1a0`）或者`ALL`（表示所有 Worker）。 |

可以使用 `options` JSON 来配置加载作业的选项。所有选项均为可选项。可配置项包括：

| **名称**           | **描述**                                            |
| ---------------- | ------------------------------------------------- |
| `loadBatchSize`  | 加载阶段的批处理大小，与加载作业中的 `batchSize` 选项相同               |
| `loadBandwidth`  | 每个 Worker 每秒的加载带宽（单位：字节），例如：10485746000...        |
| `pruneBandwidth` | 每个 Worker 每秒的清理（prune）带宽（单位：字节），例如：10485746000... |
| `skipPrune`      | 是否仅执行数据加载，跳过清理不属于该 Worker(s) 的数据                  |

JSON 请求负载示例如下：

```json
{
  "target": "ALL",
  "options": {
    "loadBatchSize": 1000,
    "loadBandwidth": 10485746000,
    "pruneBandwidth": 10485746000,
    "skipPrune": false,
  }
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "id": "54b88939-de49-46ef-acab-fe489f46d1a0"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `409 - Conflict`: 使用相同路径恢复清理缓存作业，并返回之前的作业 id

  ```json
  {
    "id": "54b88939-de49-46ef-acab-fe489f46d1a0"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 停止重平衡作业

**方法:** `DELETE`

**路径:** `/api/v1/rebalance`

**参数:** 无

**请求体:** `Content-Type: application/json`

最多只需提供一个参数。

| **名称**   | **描述**                                                                                                  |
| -------- | ------------------------------------------------------------------------------------------------------- |
| `id`     | 由 POST 请求返回的作业 id                                                                                       |
| `target` | 重平衡作业的目标 Worker，可以是指定的 worker id（例如：`worker-54b88939-de49-46ef-acab-fe489f46d1a0`）或者`ALL`（表示所有 Worker）。 |

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `410 - Gone`: 该作业不存在或已完成

  ```json
  {
    "status": "The job doesn't exist or has already finished"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 清理过期缓存（Clear Stale Cache）

> 该操作与[清理缓存](#qing-li-huan-cun-free-cache)（Free Cache）操作有所不同：
>
> * **Free Cache** 需要输入文件或目录列表，指定需要从 Worker 节点释放（清理）的缓存内容。**Clear Stale Cache** 不需要输入参数，系统会自动扫描 Worker 缓存存储，并结合当前的一致性哈希环判断哪些缓存是“过期”的。
> * Free Cache 需要正确设置副本数，否则在启用文件副本功能时，可能会释放少于预期的副本数量。Clear Stale Cache 操作会向集群中所有 Worker 广播命令，无论副本数量多少，都会触发所有 Worker 上过期缓存的清理。

#### 开始清理过期缓存

**方法:** `POST`

**路径:** `/api/v1/cache`

**参数:**&#x65E0;

**请求体:** `Content-Type: application/json`

```json
{
  "op": "clear-stale"
}
```

**响应:**

* `200 - OK`: 空的 errors 对象表示该操作已成功提交给所有 Worker 执行。

  ```json
  {
    "errors": {}
  }
  ```
* `200 - OK`: 非空的 errors 对象表示该操作未能成功提交给至少一个 Worker 执行

  ```json
  {
    "errors": {
      "worker-host": "error message"
    }
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 指定的操作类型尚未实现

  ```json
  {
    "status": "OP not implemented"
  }
  ```

#### 停止清理过期缓存

**方法:** `DELETE`

**路径:** `/api/v1/cache`

**参数:**&#x65E0;

**请求体:** `Content-Type: application/json`

```json
{
  "op": "clear-stale"
}
```

**响应:**

* `200 - OK`: 空的 errors 对象表示所有 Worker 均已成功接收到停止清理过期缓存的通知

  ```json
  {
    "errors": {}
  }
  ```
* `200 - OK`: 非空的 errors 对象表示coordinator未能成功通知至少一个 Worker 停止清理过期缓存

  ```json
  {
    "errors": {
      "worker-host": "error message"
    }
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 指定的操作类型尚未实现

  ```json
  {
    "status": "OP not implemented"
  }
  ```

### 挂载表

#### 列出挂载点

**方法:** `GET`

**路径:** `/api/v1/mount`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功（空选项将被省略）

  ```json
  {
    "results": [
      {
        "path": "/data/",
        "ufs": "s3://my-bucket/",
        "options": {
          "s3a.secretKey": "string",
          "s3a.accessKeyId": "string"
        }
      }
    ]
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取挂载点信息

**方法:** `GET`

**路径:** `/api/v1/mount`

**参数:**

| **名称** | **描述**            |
| ------ | ----------------- |
| `path` | 挂载点对应的 Alluxio 路径 |

**响应:**

* `200 - OK`: 操作成功（空选项将被省略）

  ```json
  {
    "path": "/data/",
    "ufs": "s3://my-bucket/",
    "options": {
      "s3a.secretKey": "string",
      "s3a.accessKeyId": "string"
    }
  }
  ```
* `404 - Not Found`: 未找到挂载点

  ```json
  {
    "status": "No mount point found for path: /data/"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 创建挂载点

**方法:** `POST`

**路径:** `/api/v1/mount`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data",
  "ufs": "s3://my-bucket",
  "options": {
    "s3a.secretKey": "string",
    "s3a.accessKeyId": "string"
  }
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `409 - Conflict`: 该路径已被挂载，或者UFS已挂载到其他路径

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 挂载表不支持通过 API 管理（例如：静态文件挂载表）

  ```json
  {
    "status": "string"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 删除挂载点

**方法:** `DELETE`

**路径:** `/api/v1/mount`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `410 - Gone`: 该路径未挂载到任何UFS

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 挂载表不支持通过 API 管理（例如：静态文件挂载表）

  ```json
  {
    "status": "string"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 配额

#### 列出所有配额状态

**方法:** `GET`

**路径:** `/api/v1/quota`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {
        "path": "/data/dir/to/path",
        "state": "Available",
        "quotaBytes": 10737418240,
        "usedBytes": 9663676416,
        "reservedBytes": 1073741824
      }
    ]
  }
  ```
* `501 - Not Implemented`: 配额功能未启用

  ```json
  {
    "status": "Quota not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取配额状态

**方法:** `GET`

**路径:** `/api/v1/quota`

**参数:**

| **名称** | **描述**           |
| ------ | ---------------- |
| `path` | 数据对应的 Alluxio 路径 |

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "path": "/data/dir/to/path",
    "state": "Available",
    "quotaBytes": 10737418240,
    "usedBytes": 9663676416,
    "reservedBytes": 1073741824
  }
  ```
* `404 - Not Found`: 未找到配额

  ```json
  {
    "status": "No quota item found for path: /data/dir/to/path"
  }
  ```
* `501 - Not Implemented`: 配额功能未启用

  ```json
  {
    "status": "Quota not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 添加或更新配额

**方法:** `POST`

**路径:** `/api/v1/quota`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path",
  "quotaBytes": 10737418240
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `400 - Bad Request`: 该路径未指向已挂载的UFS，但必须绑定到现有的 UFS上

  ```json
  {
    "status": "No mounted UFS found"
  }
  ```
* `501 - Not Implemented`: 配额功能未启用

  ```json
  {
    "status": "Quota not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 删除配额

**方法:** `DELETE`

**路径:** `/api/v1/quota`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `400 - Bad Request`: 未找到配额或发生其他问题

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 配额功能未启用

  ```json
  {
    "status": "Quota not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### TTL

#### 列出所有 TTL 策略

**方法:** `GET`

**路径:** `/api/v1/ttl`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {
        "path": "/data/dir/to/path",
        "ttlSeconds": 600
      }
    ]
  }
  ```
* `501 - Not Implemented`: TTL 策略未启用

  ```json
  {
    "status": "TTL not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取 TTL 策略

**方法:** `GET`

**路径:** `/api/v1/ttl`

**参数:**

| **名称** | **描述**           |
| ------ | ---------------- |
| `path` | 数据对应的 Alluxio 路径 |

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "path": "/data/dir/to/path",
    "ttlSeconds": 600
  }
  ```
* `404 - Not Found`: 未找到 TTL 策略

  ```json
  {
    "status": "No TTL policy found for path: /data/dir/to/path"
  }
  ```
* `501 - Not Implemented`: TTL 策略未启用

  ```json
  {
    "status": "TTL not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 添加或更新 TTL 策略

**方法:** `POST`

**路径:** `/api/v1/ttl`

**参数:**&#x65E0;

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path",
  "ttlSeconds": 600
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `400 - Bad Request`: 该路径未指向已挂载的UFS，但必须绑定到现有的 UFS上

  ```json
  {
    "status": "No mounted UFS found"
  }
  ```
* `501 - Not Implemented`: TTL 策略未启用

  ```json
  {
    "status": "TTL not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 删除 TTL 策略

**方法:** `DELETE`

**路径:** `/api/v1/ttl`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `400 - Bad Request`: 未找到 TTL 策略

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: TTL 策略未启用

  ```json
  {
    "status": "TTL not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 优先级驱逐

#### 列出所有优先级驱逐策略

**方法:** `GET`

**路径:** `/api/v1/priority`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      {
        "path": "/data/dir/to/path",
        "priority": "high"
      }
    ]
  }
  ```
* `501 - Not Implemented`: 优先级驱逐功能未启用

  ```json
  {
    "status": "Priority eviction not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 获取优先级驱逐策略

**方法:** `GET`

**路径:** `/api/v1/priority`

**参数:**

| **名称** | **描述**           |
| ------ | ---------------- |
| `path` | 数据对应的 Alluxio 路径 |

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "path": "/data/dir/to/path",
    "priority": "high"
  }
  ```
* `404 - Not Found`: 未找到优先级驱逐策略

  ```json
  {
    "status": "No priority rule found for path: /data/dir/to/path"
  }
  ```
* `501 - Not Implemented`: 优先级驱逐功能未启用

  ```json
  {
    "status": "Priority eviction not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 添加或更新优先级驱逐策略

**方法:** `POST`

**路径:** `/api/v1/priority`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path",
  "priority": "high"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `400 - Bad Request`: 优先级字符串格式错误或存在其他问题

  ```json
  {
    "status": "string"
  }
  ```
* `501 - Not Implemented`: 优先级驱逐功能未启用

  ```json
  {
    "status": "Priority eviction not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 删除优先级驱逐策略

**方法:** `DELETE`

**路径:** `/api/v1/priority`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "path": "/data/dir/to/path"
}
```

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `400 - Bad Request`: 请求中没有包含请求体或缺少必填字段

  ```json
  {
    "status": "Required parameters not provided"
  }
  ```
* `501 - Not Implemented`: 优先级驱逐功能未启用

  ```json
  {
    "status": "Priority eviction not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 节点管理

#### 列出所有节点

**方法:**`GET`

**路径:** `/api/v1/nodes`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "result": [
      {
        "identity": "worker-587899dd-5da5-45d4-af40-ce481acc4087",
        "address": "192.168.1.19:29989",
        "status": "ONLINE"
      },
      {
        "identity": "worker-844db66c-d7fd-46cc-8de0-2f3989360828",
        "address": "192.168.1.19:29999",
        "status": "OFFLINE"
      }
    ]
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 查询节点信息

**方法:** `GET`

**路径:** `/api/v1/nodes`

**参数:**

| **名称** | **描述**                                                     |
| ------ | ---------------------------------------------------------- |
| `id`   | worker id (例如 worker-587899dd-5da5-45d4-af40-ce481acc4087) |

**响应:**

* `200 - OK`: 操作成功 (空值将被省略)

  ```json
  {
    "identity": "worker-587899dd-5da5-45d4-af40-ce481acc4087",
    "address": "192.168.1.19:29989",
    "status": "ONLINE"
  }
  ```
* `404 - Not Found`: 未找到 worker 节点

  ```json
  {
    "status": "worker not found..."
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 注销节点 (从 etcd 中删除节点)

**方法:** `DELETE`

**路径:** `/api/v1/nodes`

**参数:**

| **名称** | **描述**                                                     |
| ------ | ---------------------------------------------------------- |
| `id`   | worker id (例如 worker-587899dd-5da5-45d4-af40-ce481acc4087) |

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "status": "ok"
  }
  ```
* `404 - Not Found`: 未找到 worker 节点

  ```json
  {
    "status": "worker not found..."
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

### 全局文件索引

#### 列出所有节点

**方法:** `GET`

**路径:** `/api/v1/file_index`

**参数:** 无

**响应:**

* `200 - OK`: 操作成功

  ```json
  {
    "results": [
      "file:///home/yimin/alluxio/ufs/10MB",
      "file:///home/yimin/alluxio/ufs/to_load/f1"
    ]
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 将文件添加到全局索引

**方法:** `POST`

**路径:** `/api/v1/file_index`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "files": [
    "s3://foo/bar/f1",
    "s3://foo/bar/f2"
  ]
}
```

**响应:**

* `200 - OK`: 操作成功 (添加到索引的条目数)

  ```json
  {
    "entries": 10
  }
  ```
* `404 - Not Found`: 功能未启用

  ```json
  {
    "status": "Global file index is not enabled"
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```

#### 将文件从全局文件索引中移除

**方法:** `DELETE`

**路径:** `/api/v1/file_index`

**参数:** 无

**请求体:** `Content-Type: application/json`

```json
{
  "files": [
    "s3://foo/bar/f1",
    "s3://foo/bar/f2"
  ]
}
```

**响应:**

* `200 - OK`: 操作成功 (从索引中移除的条目数)

  ```json
  {
    "entries": 10
  }
  ```
* `404 - Not Found`: 功能未启用

  ```json
  {
    "status": "worker not found..."
  }
  ```
* `500 - Internal Server Error`: 意外错误

  ```json
  {
    "status": "string"
  }
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.alluxio.io/ee-ai-cn/ai-3.6/reference/rest-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
