public class RestClusterClient<T> extends ClusterClient<T> implements NewClusterClient
ClusterClient implementation that communicates via HTTP REST requests.ClusterClient.LazyActorSystemLoaderactorSystemLoader, flinkConfig, highAvailabilityServices, lastJobExecutionResult, log, MAX_SLOTS_UNKNOWN, timeout| Constructor and Description |
|---|
RestClusterClient(org.apache.flink.configuration.Configuration config,
T clusterId) |
RestClusterClient(org.apache.flink.configuration.Configuration config,
T clusterId,
org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService webMonitorRetrievalService) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(org.apache.flink.api.common.JobID jobID)
Cancels a job identified by the job id.
|
String |
cancelWithSavepoint(org.apache.flink.api.common.JobID jobId,
String savepointDirectory)
Cancels a job identified by the job id and triggers a savepoint.
|
CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> |
disposeSavepoint(String savepointPath) |
Map<String,org.apache.flink.util.OptionalFailure<Object>> |
getAccumulators(org.apache.flink.api.common.JobID jobID,
ClassLoader loader)
Requests and returns the accumulators for the given job identifier.
|
org.apache.flink.runtime.util.LeaderConnectionInfo |
getClusterConnectionInfo()
Gets the current cluster connection info (may change in case of a HA setup).
|
T |
getClusterId()
Returns the cluster id identifying the cluster to which the client is connected.
|
org.apache.flink.runtime.clusterframework.messages.GetClusterStatusResponse |
getClusterStatus()
Returns the latest cluster status, with number of Taskmanagers and slots.
|
CompletableFuture<org.apache.flink.runtime.jobgraph.JobStatus> |
getJobStatus(org.apache.flink.api.common.JobID jobId)
Requests the
JobStatus of the job with the given JobID. |
int |
getMaxSlots()
The client may define an upper limit on the number of slots to use.
|
List<String> |
getNewMessages()
May return new messages from the cluster.
|
String |
getWebInterfaceURL()
Returns an URL (as a string) to the JobManager web interface.
|
boolean |
hasUserJarsInClassPath(List<URL> userJarFiles)
Returns true if the client already has the user jar and providing it again would
result in duplicate uploading of the jar.
|
CompletableFuture<Collection<org.apache.flink.runtime.client.JobStatusMessage>> |
listJobs()
Lists the currently running and finished jobs on the cluster.
|
CompletableFuture<org.apache.flink.runtime.jobmaster.JobResult> |
requestJobResult(org.apache.flink.api.common.JobID jobId)
Requests the
JobResult for the given JobID. |
CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> |
rescaleJob(org.apache.flink.api.common.JobID jobId,
int newParallelism)
Rescales the specified job such that it will have the new parallelism.
|
void |
shutdown()
Shuts down the client.
|
void |
shutDownCluster() |
void |
stop(org.apache.flink.api.common.JobID jobID)
Stops a program on Flink cluster whose job-manager is configured in this client's configuration.
|
CompletableFuture<org.apache.flink.api.common.JobSubmissionResult> |
submitJob(org.apache.flink.runtime.jobgraph.JobGraph jobGraph)
Submits the given
JobGraph to the dispatcher. |
org.apache.flink.api.common.JobSubmissionResult |
submitJob(org.apache.flink.runtime.jobgraph.JobGraph jobGraph,
ClassLoader classLoader)
Calls the subclasses' submitJob method.
|
CompletableFuture<String> |
triggerSavepoint(org.apache.flink.api.common.JobID jobId,
String savepointDirectory)
Triggers a savepoint for the job identified by the job id.
|
void |
waitForClusterToBeReady()
Blocks until the client has determined that the cluster is ready for Job submission.
|
connectToJob, endSession, endSessions, getAccumulators, getFlinkConfiguration, getJobGraph, getJobGraph, getJobManagerGateway, getOptimizedPlan, getOptimizedPlan, getOptimizedPlanAsJson, getPrintStatusDuringExecution, isDetached, logAndSysout, retrieveJob, run, run, run, run, run, run, runDetached, setDetached, setPrintStatusDuringExecutionpublic RestClusterClient(org.apache.flink.configuration.Configuration config,
T clusterId)
throws Exception
Exceptionpublic void shutdown()
ClusterClientshutdown in class ClusterClient<T>public org.apache.flink.api.common.JobSubmissionResult submitJob(org.apache.flink.runtime.jobgraph.JobGraph jobGraph,
ClassLoader classLoader)
throws ProgramInvocationException
ClusterClientsubmitJob in class ClusterClient<T>jobGraph - The JobGraph to be submittedProgramInvocationExceptionpublic CompletableFuture<org.apache.flink.runtime.jobgraph.JobStatus> getJobStatus(org.apache.flink.api.common.JobID jobId)
ClusterClientJobStatus of the job with the given JobID.getJobStatus in class ClusterClient<T>public CompletableFuture<org.apache.flink.runtime.jobmaster.JobResult> requestJobResult(@Nonnull org.apache.flink.api.common.JobID jobId)
JobResult for the given JobID. The method retries multiple
times to poll the JobResult before giving up.requestJobResult in interface NewClusterClientjobId - specifying the job for which to retrieve the JobResultJobResult once the job has completed or
with a failure if the JobResult could not be retrieved.public CompletableFuture<org.apache.flink.api.common.JobSubmissionResult> submitJob(@Nonnull org.apache.flink.runtime.jobgraph.JobGraph jobGraph)
JobGraph to the dispatcher.submitJob in interface NewClusterClientjobGraph - to submitpublic void stop(org.apache.flink.api.common.JobID jobID)
throws Exception
ClusterClientstop in class ClusterClient<T>jobID - the job ID of the streaming program to stopException - If the job ID is invalid (ie, is unknown or refers to a batch job) or if sending the stop signal
failed. That might be due to an I/O problem, ie, the job-manager is unreachable.public void cancel(org.apache.flink.api.common.JobID jobID)
throws Exception
ClusterClientcancel in class ClusterClient<T>jobID - the job idException - In case an error occurred.public String cancelWithSavepoint(org.apache.flink.api.common.JobID jobId, @Nullable String savepointDirectory) throws Exception
ClusterClientcancelWithSavepoint in class ClusterClient<T>jobId - the job idsavepointDirectory - directory the savepoint should be written toException - In case an error occurred.public CompletableFuture<String> triggerSavepoint(org.apache.flink.api.common.JobID jobId, @Nullable String savepointDirectory)
ClusterClientCheckpointingOptions.SAVEPOINT_DIRECTORY if it is null.triggerSavepoint in class ClusterClient<T>jobId - job idsavepointDirectory - directory the savepoint should be written topublic Map<String,org.apache.flink.util.OptionalFailure<Object>> getAccumulators(org.apache.flink.api.common.JobID jobID, ClassLoader loader) throws Exception
ClusterClientgetAccumulators in class ClusterClient<T>jobID - The job identifier of a job.loader - The class loader for deserializing the accumulator results.Exceptionpublic CompletableFuture<Collection<org.apache.flink.runtime.client.JobStatusMessage>> listJobs()
ClusterClientlistJobs in class ClusterClient<T>public T getClusterId()
ClusterClientgetClusterId in class ClusterClient<T>public org.apache.flink.runtime.util.LeaderConnectionInfo getClusterConnectionInfo()
throws org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException
ClusterClientgetClusterConnectionInfo in class ClusterClient<T>org.apache.flink.runtime.leaderretrieval.LeaderRetrievalException - if the leader could not be retrievedpublic CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> rescaleJob(org.apache.flink.api.common.JobID jobId, int newParallelism)
ClusterClientrescaleJob in class ClusterClient<T>jobId - specifying the job to modifynewParallelism - specifying the new parallelism of the rescaled jobpublic CompletableFuture<org.apache.flink.runtime.messages.Acknowledge> disposeSavepoint(String savepointPath)
disposeSavepoint in class ClusterClient<T>public void shutDownCluster()
shutDownCluster in class ClusterClient<T>public boolean hasUserJarsInClassPath(List<URL> userJarFiles)
ClusterClienthasUserJarsInClassPath in class ClusterClient<T>public void waitForClusterToBeReady()
ClusterClientThis is delayed until right before job submission to report any other errors first (e.g. invalid job definitions/errors in the user jar)
waitForClusterToBeReady in class ClusterClient<T>public String getWebInterfaceURL()
ClusterClientgetWebInterfaceURL in class ClusterClient<T>public org.apache.flink.runtime.clusterframework.messages.GetClusterStatusResponse getClusterStatus()
ClusterClientgetClusterStatus in class ClusterClient<T>public List<String> getNewMessages()
ClusterClientgetNewMessages in class ClusterClient<T>public int getMaxSlots()
ClusterClientgetMaxSlots in class ClusterClient<T>ClusterClient.MAX_SLOTS_UNKNOWN) if unknownCopyright © 2014–2018 The Apache Software Foundation. All rights reserved.