public class RestClusterClient<T> extends Object implements ClusterClient<T>
ClusterClient
implementation that communicates via HTTP REST requests.Constructor and Description |
---|
RestClusterClient(Configuration config,
T clusterId) |
RestClusterClient(Configuration config,
T clusterId,
ClientHighAvailabilityServicesFactory factory) |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<Acknowledge> |
cancel(JobID jobID)
Cancels a job identified by the job id.
|
CompletableFuture<String> |
cancelWithSavepoint(JobID jobId,
String savepointDirectory,
SavepointFormatType formatType)
Cancels a job identified by the job id and triggers a savepoint.
|
void |
close() |
CompletableFuture<Acknowledge> |
disposeSavepoint(String savepointPath)
Dispose the savepoint under the given path.
|
CompletableFuture<Map<String,Object>> |
getAccumulators(JobID jobID,
ClassLoader loader)
Requests and returns the accumulators for the given job identifier.
|
T |
getClusterId()
Returns the cluster id identifying the cluster to which the client is connected.
|
CompletableFuture<ClusterOverviewWithVersion> |
getClusterOverview()
Get an overview of the Flink cluster.
|
Configuration |
getFlinkConfiguration()
Return the Flink configuration object.
|
CompletableFuture<JobDetailsInfo> |
getJobDetails(JobID jobId)
Requests the job details.
|
CompletableFuture<JobStatus> |
getJobStatus(JobID jobId)
|
String |
getWebInterfaceURL()
Returns an URL (as a string) to the cluster web interface.
|
CompletableFuture<Void> |
invalidateClusterDataset(AbstractID clusterDatasetId)
Invalidate the cached intermediate dataset with the given id.
|
CompletableFuture<Set<AbstractID>> |
listCompletedClusterDatasetIds()
Return a set of ids of the completed cluster datasets.
|
CompletableFuture<Collection<JobStatusMessage>> |
listJobs()
Lists the currently running and finished jobs on the cluster.
|
CompletableFuture<Void> |
reportHeartbeat(JobID jobId,
long expiredTimestamp)
The client reports the heartbeat to the dispatcher for aliveness.
|
CompletableFuture<JobResult> |
requestJobResult(JobID jobId)
|
CompletableFuture<CoordinationResponse> |
sendCoordinationRequest(JobID jobId,
OperatorID operatorId,
CoordinationRequest request)
Sends out a request to a specified coordinator and return the response.
|
<M extends MessageHeaders<R,P,U>,U extends MessageParameters,R extends RequestBody,P extends ResponseBody> |
sendRequest(M messageHeaders,
U messageParameters,
R request) |
void |
shutDownCluster()
Shut down the cluster that this client communicate with.
|
CompletableFuture<String> |
stopWithDetachedSavepoint(JobID jobId,
boolean advanceToEndOfTime,
String savepointDirectory,
SavepointFormatType formatType)
Stops a program on Flink cluster whose job-manager is configured in this client's
configuration.
|
CompletableFuture<String> |
stopWithSavepoint(JobID jobId,
boolean advanceToEndOfTime,
String savepointDirectory,
SavepointFormatType formatType)
Stops a program on Flink cluster whose job-manager is configured in this client's
configuration.
|
CompletableFuture<String> |
stopWithSavepoint(JobID jobId,
boolean advanceToEndOfTime,
String savepointDirectory,
SavepointFormatType formatType,
boolean isDetachedMode) |
CompletableFuture<JobID> |
submitJob(JobGraph jobGraph)
Submit the given
JobGraph to the cluster. |
CompletableFuture<Long> |
triggerCheckpoint(JobID jobId,
CheckpointType checkpointType)
Triggers a checkpoint for the job identified by the job id.
|
CompletableFuture<String> |
triggerDetachedSavepoint(JobID jobId,
String savepointDirectory,
SavepointFormatType formatType)
Triggers a detached savepoint for the job identified by the job id.
|
CompletableFuture<String> |
triggerSavepoint(JobID jobId,
String savepointDirectory,
SavepointFormatType formatType)
Triggers a savepoint for the job identified by the job id.
|
CompletableFuture<Acknowledge> |
updateJobResourceRequirements(JobID jobId,
JobResourceRequirements jobResourceRequirements)
Update
JobResourceRequirements of a given job. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAccumulators
public RestClusterClient(Configuration config, T clusterId) throws Exception
Exception
public RestClusterClient(Configuration config, T clusterId, ClientHighAvailabilityServicesFactory factory) throws Exception
Exception
public Configuration getFlinkConfiguration()
ClusterClient
getFlinkConfiguration
in interface ClusterClient<T>
public void close()
close
in interface AutoCloseable
close
in interface ClusterClient<T>
public CompletableFuture<JobDetailsInfo> getJobDetails(JobID jobId)
jobId
- The job idpublic CompletableFuture<JobStatus> getJobStatus(JobID jobId)
ClusterClient
getJobStatus
in interface ClusterClient<T>
public CompletableFuture<JobResult> requestJobResult(@Nonnull JobID jobId)
JobResult
for the given JobID
. The method retries multiple times
to poll the JobResult
before giving up.requestJobResult
in interface ClusterClient<T>
jobId
- specifying the job for which to retrieve the JobResult
JobResult
once the job has completed or
with a failure if the JobResult
could not be retrieved.public CompletableFuture<JobID> submitJob(@Nonnull JobGraph jobGraph)
ClusterClient
JobGraph
to the cluster.submitJob
in interface ClusterClient<T>
jobGraph
- to submitJobID
of the submitted jobpublic CompletableFuture<Acknowledge> cancel(JobID jobID)
ClusterClient
cancel
in interface ClusterClient<T>
jobID
- the job idpublic CompletableFuture<String> stopWithSavepoint(JobID jobId, boolean advanceToEndOfTime, @Nullable String savepointDirectory, SavepointFormatType formatType)
ClusterClient
stopWithSavepoint
in interface ClusterClient<T>
jobId
- the job ID of the streaming program to stopadvanceToEndOfTime
- flag indicating if the source should inject a MAX_WATERMARK
in the pipelinesavepointDirectory
- directory the savepoint should be written toformatType
- a binary format of the savepointCompletableFuture
containing the path where the savepoint is locatedpublic CompletableFuture<String> stopWithDetachedSavepoint(JobID jobId, boolean advanceToEndOfTime, @Nullable String savepointDirectory, SavepointFormatType formatType)
ClusterClient
stopWithDetachedSavepoint
in interface ClusterClient<T>
jobId
- the job ID of the streaming program to stopadvanceToEndOfTime
- flag indicating if the source should inject a MAX_WATERMARK
in the pipelinesavepointDirectory
- directory the savepoint should be written toformatType
- a binary format of the savepointpublic CompletableFuture<String> cancelWithSavepoint(JobID jobId, @Nullable String savepointDirectory, SavepointFormatType formatType)
ClusterClient
cancelWithSavepoint
in interface ClusterClient<T>
jobId
- the job idsavepointDirectory
- directory the savepoint should be written toformatType
- a binary format of the savepointpublic CompletableFuture<String> triggerSavepoint(JobID jobId, @Nullable String savepointDirectory, SavepointFormatType formatType)
ClusterClient
CheckpointingOptions.SAVEPOINT_DIRECTORY
if it is null.triggerSavepoint
in interface ClusterClient<T>
jobId
- job idsavepointDirectory
- directory the savepoint should be written toformatType
- a binary format of the savepointpublic CompletableFuture<Long> triggerCheckpoint(JobID jobId, CheckpointType checkpointType)
ClusterClient
triggerCheckpoint
in interface ClusterClient<T>
jobId
- job idcheckpointType
- the checkpoint type (configured / full / incremental)public CompletableFuture<String> triggerDetachedSavepoint(JobID jobId, @Nullable String savepointDirectory, SavepointFormatType formatType)
ClusterClient
CheckpointingOptions.SAVEPOINT_DIRECTORY
if it is null.
Notice that: the detached savepoint will return with a savepoint trigger id instead of the
path future, that means the client will return very quickly.triggerDetachedSavepoint
in interface ClusterClient<T>
jobId
- job idsavepointDirectory
- directory the savepoint should be written toformatType
- a binary format of the savepointpublic CompletableFuture<CoordinationResponse> sendCoordinationRequest(JobID jobId, OperatorID operatorId, CoordinationRequest request)
ClusterClient
sendCoordinationRequest
in interface ClusterClient<T>
jobId
- specifies the job which the coordinator belongs tooperatorId
- specifies which coordinator to receive the requestrequest
- the request to sendpublic CompletableFuture<String> stopWithSavepoint(JobID jobId, boolean advanceToEndOfTime, @Nullable String savepointDirectory, SavepointFormatType formatType, boolean isDetachedMode)
public CompletableFuture<Map<String,Object>> getAccumulators(JobID jobID, ClassLoader loader)
ClusterClient
getAccumulators
in interface ClusterClient<T>
jobID
- The job identifier of a job.loader
- The class loader for deserializing the accumulator results.public CompletableFuture<Collection<JobStatusMessage>> listJobs()
ClusterClient
listJobs
in interface ClusterClient<T>
public T getClusterId()
ClusterClient
getClusterId
in interface ClusterClient<T>
public CompletableFuture<Acknowledge> disposeSavepoint(String savepointPath)
ClusterClient
disposeSavepoint
in interface ClusterClient<T>
savepointPath
- path to the savepoint to be disposedpublic CompletableFuture<Set<AbstractID>> listCompletedClusterDatasetIds()
ClusterClient
listCompletedClusterDatasetIds
in interface ClusterClient<T>
public CompletableFuture<Void> invalidateClusterDataset(AbstractID clusterDatasetId)
ClusterClient
invalidateClusterDataset
in interface ClusterClient<T>
clusterDatasetId
- id of the cluster dataset to be invalidated.public CompletableFuture<Void> reportHeartbeat(JobID jobId, long expiredTimestamp)
ClusterClient
reportHeartbeat
in interface ClusterClient<T>
jobId
- The jobId for the client and the job.public void shutDownCluster()
ClusterClient
shutDownCluster
in interface ClusterClient<T>
public CompletableFuture<Acknowledge> updateJobResourceRequirements(JobID jobId, JobResourceRequirements jobResourceRequirements)
JobResourceRequirements
of a given job.jobId
- jobId specifies the job for which to change the resource requirementsjobResourceRequirements
- new resource requirements for the provided jobpublic CompletableFuture<ClusterOverviewWithVersion> getClusterOverview()
cluster overview
.public String getWebInterfaceURL()
ClusterClient
getWebInterfaceURL
in interface ClusterClient<T>
@VisibleForTesting public <M extends MessageHeaders<R,P,U>,U extends MessageParameters,R extends RequestBody,P extends ResponseBody> CompletableFuture<P> sendRequest(M messageHeaders, U messageParameters, R request)
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.