REST API
Ignite 3 集群提供了一套符合 OpenAPI 规范的API,可用于通过标准 REST 方法与 Ignite 3 交互。
1.REST连接器配置
REST连接器默认监听 10300 端口,可以在节点配置的ignite.rest
配置项中调整此端口。
2.使用HTTP工具
集群启动后,可以使用外部工具通过 HTTP 监控集群或管理集群。在下面的示例中将使用 curl 来获取集群状态:
bash
curl 'http://localhost:10300/management/v1/cluster/state'
不仅限于监控,因为 Ignite REST API 还提供了可用于管理集群的端点,例如可以通过 REST 创建快照:
bash
curl -H "Content-Type: application/json" -d '{"snapshotType": "FULL","tableNames": "table1,table2","startTimeEpochMilli": 0}' http://localhost:10300/management/v1/snapshot/create
3.Java项目配置
如果想将 Ignite REST API 更紧密地集成到业务应用中,建议使用 OpenAPI 生成器来生成 Java 客户端,之后就可以通过代码访问 REST API,例如:
java
ApiClient client = Configuration.getDefaultApiClient();
// Set base URL
client.setBasePath("http://localhost:10300");
// Get cluster configuration.
ClusterConfigurationApi clusterConfigurationApi = new ClusterConfigurationApi(client);
String configuration = clusterConfigurationApi.getClusterConfiguration();
18624049226