项目作者: nextbreakpoint

项目描述 :
Java library for managing Apache Flink via the Monitoring REST API
高级语言: Java
项目地址: git://github.com/nextbreakpoint/flink-client.git
创建时间: 2019-03-29T20:14:29Z
项目社区:https://github.com/nextbreakpoint/flink-client

开源协议:BSD 3-Clause "New" or "Revised" License

下载


flink-client

This library provides a Java client for managing Apache Flink via the REST API.

The client is generated with Swagger Codegen from the
OpenAPI specification.

License

The library is distributed under the terms of BSD 3-Clause License.

  1. Copyright (c) 2019-2024, Andrea Medeghini
  2. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions are met:
  5. * Redistributions of source code must retain the above copyright notice, this
  6. list of conditions and the following disclaimer.
  7. * Redistributions in binary form must reproduce the above copyright notice,
  8. this list of conditions and the following disclaimer in the documentation
  9. and/or other materials provided with the distribution.
  10. * Neither the name of the copyright holder nor the names of its
  11. contributors may be used to endorse or promote products derived from
  12. this software without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  14. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  17. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  22. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

How to get the binaries

The library is available in Maven Central Repository, and GitHub.

If you are using Maven, add this dependency to your POM:

  1. <dependency>
  2. <groupId>com.nextbreakpoint</groupId>
  3. <artifactId>com.nextbreakpoint.flink.client</artifactId>
  4. <version>1.1.4</version>
  5. </dependency>

How to build the library

Install Java 11 and Maven 3.9.

Build the library using Maven:

  1. mvn clean package

How to generate the code

Generate the code using Maven:

  1. mvn clean compile

How to run the tests

Make sure you have Docker installed and create the required bridge network:

  1. docker network create flink-test

Run the tests using Maven:

  1. mvn clean verify

How to use the library

Create the Flink client:

  1. FlinkApi api = new FlinkApi();

Configure host and port of the server:

  1. api.getApiClient().setBasePath("http://localhost:8081");

Configure socket timeouts:

  1. api.getApiClient().setHttpClient(api.getApiClient().getHttpClient().newBuilder()
  2. .connectTimeout(Duration.ofSeconds(20))
  3. .writeTimeout(Duration.ofSeconds(30))
  4. .readTimeout(Duration.ofSeconds(30))
  5. .build());

Optionally enable debugging:

  1. api.getApiClient().setDebugging(true);

Get Flink cluster configuration:

  1. DashboardConfiguration config = api.getDashboardConfiguration();

Show list of uploaded jars:

  1. JarListInfo jars = api.getJarList();

Upload a jar which contain a Flink job:

  1. JarUploadResponseBody result = api.uploadJar(new File("flink-job.jar"));

Run an uploaded jar which some arguments:

  1. JarRunResponseBody response = api.submitJobFromJar("bf4afb3b-d662-435e-b465-5ddb40d68379_flink-job.jar", true, null, null, "--INPUT A --OUTPUT B", "your-main-class", null);

Get status of all jobs:

  1. JobIdsWithStatusOverview jobs = api.getJobIdsWithStatusesOverview();

Get details of a job:

  1. JobDetailsInfo details = api.getJobDetails("f370f5421e5254eed8d6fc6673829c83");

Terminate a job:

  1. api.cancelJob("f370f5421e5254eed8d6fc6673829c83", TerminationMode.CANCEL);

For all the remaining operations see the documentation of Flink’s REST API.

The library is compatible with Flink REST API v1.

The current version of the library has been tested against Flink 1.20.0, but the library is known to work with older versions too.
The library should be compatible with newer versions too, unless a breaking change is introduced in the Apache Flink REST API.

Known limitations

Please note that some operations haven’t been tested and not all fields in the responses are currently verified in the tests.