Package org.apache.flink.client.program
Class MiniClusterClient
- java.lang.Object
-
- org.apache.flink.client.program.MiniClusterClient
-
- All Implemented Interfaces:
AutoCloseable,ClusterClient<MiniClusterClient.MiniClusterId>
public class MiniClusterClient extends Object implements ClusterClient<MiniClusterClient.MiniClusterId>
Client to interact with aMiniCluster.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMiniClusterClient.MiniClusterIdThe type of the Cluster ID for the localMiniCluster.
-
Constructor Summary
Constructors Constructor Description MiniClusterClient(org.apache.flink.configuration.Configuration configuration, org.apache.flink.runtime.minicluster.MiniCluster miniCluster)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<org.apache.flink.runtime.messages.Acknowledge>cancel(org.apache.flink.api.common.JobID jobId)Cancels a job identified by the job id.CompletableFuture<String>cancelWithSavepoint(org.apache.flink.api.common.JobID jobId, String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)Cancels a job identified by the job id and triggers a savepoint.voidclose()CompletableFuture<org.apache.flink.runtime.messages.Acknowledge>disposeSavepoint(String savepointPath)Dispose the savepoint under the given path.CompletableFuture<Map<String,Object>>getAccumulators(org.apache.flink.api.common.JobID jobID, ClassLoader loader)Requests and returns the accumulators for the given job identifier.MiniClusterClient.MiniClusterIdgetClusterId()Returns the cluster id identifying the cluster to which the client is connected.org.apache.flink.configuration.ConfigurationgetFlinkConfiguration()Return the Flink configuration object.CompletableFuture<org.apache.flink.api.common.JobStatus>getJobStatus(org.apache.flink.api.common.JobID jobId)Requests theJobStatusof the job with the givenJobID.StringgetWebInterfaceURL()Returns an URL (as a string) to the cluster web interface.CompletableFuture<Void>invalidateClusterDataset(org.apache.flink.util.AbstractID clusterDatasetId)Invalidate the cached intermediate dataset with the given id.CompletableFuture<Set<org.apache.flink.util.AbstractID>>listCompletedClusterDatasetIds()Return a set of ids of the completed cluster datasets.CompletableFuture<Collection<org.apache.flink.runtime.client.JobStatusMessage>>listJobs()Lists the currently running and finished jobs on the cluster.CompletableFuture<Void>reportHeartbeat(org.apache.flink.api.common.JobID jobId, long expiredTimestamp)The client reports the heartbeat to the dispatcher for aliveness.CompletableFuture<org.apache.flink.runtime.jobmaster.JobResult>requestJobResult(org.apache.flink.api.common.JobID jobId)Request theJobResultfor the givenJobID.CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse>sendCoordinationRequest(org.apache.flink.api.common.JobID jobId, org.apache.flink.runtime.jobgraph.OperatorID operatorId, org.apache.flink.runtime.operators.coordination.CoordinationRequest request)Sends out a request to a specified coordinator and return the response.voidshutDownCluster()Shut down the cluster that this client communicate with.CompletableFuture<String>stopWithSavepoint(org.apache.flink.api.common.JobID jobId, boolean advanceToEndOfEventTime, String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)Stops a program on Flink cluster whose job-manager is configured in this client's configuration.CompletableFuture<org.apache.flink.api.common.JobID>submitJob(org.apache.flink.runtime.jobgraph.JobGraph jobGraph)Submit the givenJobGraphto the cluster.CompletableFuture<String>triggerSavepoint(org.apache.flink.api.common.JobID jobId, String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)Triggers a savepoint for the job identified by the job id.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.client.program.ClusterClient
getAccumulators
-
-
-
-
Method Detail
-
getFlinkConfiguration
public org.apache.flink.configuration.Configuration getFlinkConfiguration()
Description copied from interface:ClusterClientReturn the Flink configuration object.- Specified by:
getFlinkConfigurationin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Returns:
- The Flink configuration object
-
submitJob
public CompletableFuture<org.apache.flink.api.common.JobID> submitJob(@Nonnull org.apache.flink.runtime.jobgraph.JobGraph jobGraph)
Description copied from interface:ClusterClientSubmit the givenJobGraphto the cluster.- Specified by:
submitJobin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobGraph- to submit- Returns:
JobIDof the submitted job
-
requestJobResult
public CompletableFuture<org.apache.flink.runtime.jobmaster.JobResult> requestJobResult(@Nonnull org.apache.flink.api.common.JobID jobId)
Description copied from interface:ClusterClientRequest theJobResultfor the givenJobID.- Specified by:
requestJobResultin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- for which to request theJobResult- Returns:
- Future which is completed with the
JobResult
-
cancel
public CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> cancel(org.apache.flink.api.common.JobID jobId)
Description copied from interface:ClusterClientCancels a job identified by the job id.- Specified by:
cancelin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- the job id
-
cancelWithSavepoint
public CompletableFuture<String> cancelWithSavepoint(org.apache.flink.api.common.JobID jobId, @Nullable String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)
Description copied from interface:ClusterClientCancels a job identified by the job id and triggers a savepoint.- Specified by:
cancelWithSavepointin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- the job idsavepointDirectory- directory the savepoint should be written toformatType- a binary format of the savepoint- Returns:
- future of path where the savepoint is located
-
stopWithSavepoint
public CompletableFuture<String> stopWithSavepoint(org.apache.flink.api.common.JobID jobId, boolean advanceToEndOfEventTime, @Nullable String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)
Description copied from interface:ClusterClientStops a program on Flink cluster whose job-manager is configured in this client's configuration. Stopping works only for streaming programs. Be aware, that the program might continue to run for a while after sending the stop command, because after sources stopped to emit data all operators need to finish processing.- Specified by:
stopWithSavepointin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- the job ID of the streaming program to stopadvanceToEndOfEventTime- flag indicating if the source should inject aMAX_WATERMARKin the pipelinesavepointDirectory- directory the savepoint should be written toformatType- a binary format of the savepoint- Returns:
- a
CompletableFuturecontaining the path where the savepoint is located
-
triggerSavepoint
public CompletableFuture<String> triggerSavepoint(org.apache.flink.api.common.JobID jobId, @Nullable String savepointDirectory, org.apache.flink.core.execution.SavepointFormatType formatType)
Description copied from interface:ClusterClientTriggers a savepoint for the job identified by the job id. The savepoint will be written to the given savepoint directory, orCheckpointingOptions.SAVEPOINT_DIRECTORYif it is null.- Specified by:
triggerSavepointin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- job idsavepointDirectory- directory the savepoint should be written toformatType- a binary format of the savepoint- Returns:
- path future where the savepoint is located
-
disposeSavepoint
public CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> disposeSavepoint(String savepointPath)
Description copied from interface:ClusterClientDispose the savepoint under the given path.- Specified by:
disposeSavepointin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
savepointPath- path to the savepoint to be disposed- Returns:
- acknowledge future of the dispose action
-
listJobs
public CompletableFuture<Collection<org.apache.flink.runtime.client.JobStatusMessage>> listJobs()
Description copied from interface:ClusterClientLists the currently running and finished jobs on the cluster.- Specified by:
listJobsin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Returns:
- future collection of running and finished jobs
-
getAccumulators
public CompletableFuture<Map<String,Object>> getAccumulators(org.apache.flink.api.common.JobID jobID, ClassLoader loader)
Description copied from interface:ClusterClientRequests and returns the accumulators for the given job identifier. Accumulators can be requested while a is running or after it has finished.- Specified by:
getAccumulatorsin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobID- The job identifier of a job.loader- The class loader for deserializing the accumulator results.- Returns:
- A Map containing the accumulator's name and its value.
-
getJobStatus
public CompletableFuture<org.apache.flink.api.common.JobStatus> getJobStatus(org.apache.flink.api.common.JobID jobId)
Description copied from interface:ClusterClientRequests theJobStatusof the job with the givenJobID.- Specified by:
getJobStatusin interfaceClusterClient<MiniClusterClient.MiniClusterId>
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceClusterClient<MiniClusterClient.MiniClusterId>
-
getClusterId
public MiniClusterClient.MiniClusterId getClusterId()
Description copied from interface:ClusterClientReturns the cluster id identifying the cluster to which the client is connected.- Specified by:
getClusterIdin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Returns:
- cluster id of the connected cluster
-
shutDownCluster
public void shutDownCluster()
Description copied from interface:ClusterClientShut down the cluster that this client communicate with.- Specified by:
shutDownClusterin interfaceClusterClient<MiniClusterClient.MiniClusterId>
-
getWebInterfaceURL
public String getWebInterfaceURL()
Description copied from interface:ClusterClientReturns an URL (as a string) to the cluster web interface.- Specified by:
getWebInterfaceURLin interfaceClusterClient<MiniClusterClient.MiniClusterId>
-
sendCoordinationRequest
public CompletableFuture<org.apache.flink.runtime.operators.coordination.CoordinationResponse> sendCoordinationRequest(org.apache.flink.api.common.JobID jobId, org.apache.flink.runtime.jobgraph.OperatorID operatorId, org.apache.flink.runtime.operators.coordination.CoordinationRequest request)
Description copied from interface:ClusterClientSends out a request to a specified coordinator and return the response.- Specified by:
sendCoordinationRequestin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- specifies the job which the coordinator belongs tooperatorId- specifies which coordinator to receive the requestrequest- the request to send- Returns:
- the response from the coordinator
-
listCompletedClusterDatasetIds
public CompletableFuture<Set<org.apache.flink.util.AbstractID>> listCompletedClusterDatasetIds()
Description copied from interface:ClusterClientReturn a set of ids of the completed cluster datasets.- Specified by:
listCompletedClusterDatasetIdsin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Returns:
- A set of ids of the completely cached intermediate dataset.
-
invalidateClusterDataset
public CompletableFuture<Void> invalidateClusterDataset(org.apache.flink.util.AbstractID clusterDatasetId)
Description copied from interface:ClusterClientInvalidate the cached intermediate dataset with the given id.- Specified by:
invalidateClusterDatasetin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
clusterDatasetId- id of the cluster dataset to be invalidated.- Returns:
- Future which will be completed when the cached dataset is invalidated.
-
reportHeartbeat
public CompletableFuture<Void> reportHeartbeat(org.apache.flink.api.common.JobID jobId, long expiredTimestamp)
Description copied from interface:ClusterClientThe client reports the heartbeat to the dispatcher for aliveness.- Specified by:
reportHeartbeatin interfaceClusterClient<MiniClusterClient.MiniClusterId>- Parameters:
jobId- The jobId for the client and the job.- Returns:
-
-