文档首页/
MapReduce服务 MRS/
开发指南(LTS版)/
Flink开发指南(安全模式)/
开发Flink应用/
FlinkServer REST API样例程序/
FlinkServer REST API样例程序(Java)
更新时间:2024-06-05 GMT+08:00
FlinkServer REST API样例程序(Java)
功能介绍
通过调用FlinkServer RestAPI创建租户。
代码样例
具体代码参见com.huawei.bigdata.flink.examples.TestCreateTenants。
public class TestCreateTenants { public static void main(String[] args) { ParameterTool paraTool = ParameterTool.fromArgs(args); final String hostName = paraTool.get("hostName"); // 修改hosts文件,使用主机名 final String keytab = paraTool.get("keytab文件路径"); // user.keytab路径 final String krb5 = paraTool.get("krb5文件路径"); // krb5.conf路径 final String principal = paraTool.get("认证用户名"); // 认证用户 System.setProperty("java.security.krb5.conf", krb5); String url = "https://"+hostName+":28943/flink/v1/tenants"; String jsonstr = "{" + "\n\t \"tenantId\":\"92\"," + "\n\t \"tenantName\":\"test92\"," + "\n\t \"remark\":\"test tenant remark1\"," + "\n\t \"updateUser\":\"test_updateUser1\"," + "\n\t \"createUser\":\"test_createUser1\"" + "\n}"; try { LoginClient.getInstance().setConfigure(url, principal, keytab, ""); LoginClient.getInstance().login(); System.out.println(HttpClientUtil.doPost(url, jsonstr, "utf-8", true)); } catch (Exception e) { System.out.println(e); } } }