-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-7791] [REST][client] Integrate LIST command into RestClusterClient #4802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The only thing I was wondering about was whether the ClusterClient
should return a Collection<JobStatus>
instead of a CompletableFuture<Collection<JobStatus>>
. I would assume that the user would want this operation to be executed synchronously, but I'm not entirely sure.
} | ||
catch (Exception e) { | ||
throw new Exception("Could not retrieve running jobs from the JobManager.", e); | ||
CompletableFuture<Collection<JobDetails>> jobDetailsFuture = client.listJobs(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we hide the fact that we are retrieving JobDetails
internally and still only return a Collection<JobStatus>
? The reason is that in the future we might change how we retrieve the job ids, job names plus their state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we change how we retrieve it we can still wrap them in a JobDetails object; it doesn't necessarily leak to the outside how we retrieve them. Given that the CLI requires the job id, job name, start/end timestamp and job status we aren't saving much by creating a slimmed down JobDetails class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the JobStatusMessage
class. I'm not entirely sure, because whatever you expose can be used and once we change that we no longer retrieve the full set of details for a job, it will be difficult to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change it to that.
headers | ||
); | ||
return jobDetailsFuture | ||
.thenApply(MultipleJobsDetails::getRunning); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also have to return the list of completed jobs not only the running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have to, as the LIST command only cares about running jobs, but we certainly could just return all. The CLI is filtering the jobs anyway.
import static org.powermock.api.mockito.PowerMockito.when; | ||
|
||
/** | ||
* Tests for the CANCEL command. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: LIST command.
Collection<JobDetails> jobDetails = jobDetailsFuture.get(); | ||
Assert.assertTrue(gateway.messageArrived); | ||
// finished jobs should be ignored | ||
Assert.assertEquals(1, jobDetails.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also retrieve the finished jobs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the LIST command only lists running/scheduled jobs.
* | ||
* @return future collection of running jobs | ||
* @throws Exception if no connection to the cluster could be established | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether the ClusterClient
should issue a synchronous operation instead of a asynchronous operation (simply waiting on the futures completion). So far all the ClusterClient
operations are blocking and wait for the completion. Not entirely sure which is more intuitive to use for the user. Of course the asynchronous variant gives more freedom.
The reason why i went for the CompletableFuture route is to stay closer to the current code. The CliFrontend is waiting the the response and prints "Waiting...", which we can't do when doing the call synchronously since the ClusterClient shouldn't print anything. That said, i do like making them asynchronous in general. |
I've modified the clients to return both running and finished jobs. |
I'm not entirely sure whether printing "Waiting..." is consistent with the status quo. The current |
triggerSavepoint is also asynchronous. It is true that the list command does not print waiting, but the savepoint commands do. |
But |
What do you mean when you say triggerSavepoint is not a command of the ClusterClient? It does have a |
True, you're right. I guess I overlooked it. But it also includes the |
merging. |
What is the purpose of the change
This PR integrates the LIST command into the RestClusterClient. This is a fully working implementation and leverages the CurrentJobsOverviewHeaders.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
For manual verification:
start-cluster.sh flip6
flink run -flip <jar>
flink list -flip6
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation