-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
Clear Job#finished_time when it is opened (#32605) #32755
Merged
benwtrent
merged 3 commits into
elastic:master
from
benwtrent:bug/clear-finished_time-on-job-open
Aug 10, 2018
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,11 +51,9 @@ | |
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
import org.elasticsearch.xpack.core.XPackPlugin; | ||
import org.elasticsearch.xpack.core.ml.MlMetaIndex; | ||
import org.elasticsearch.xpack.core.ml.MlMetadata; | ||
import org.elasticsearch.xpack.core.ml.MlTasks; | ||
import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction; | ||
import org.elasticsearch.xpack.core.ml.action.OpenJobAction; | ||
import org.elasticsearch.xpack.core.ml.action.PutJobAction; | ||
import org.elasticsearch.xpack.core.ml.action.UpdateJobAction; | ||
|
@@ -75,7 +73,6 @@ | |
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
@@ -480,7 +477,7 @@ protected void masterOperation(OpenJobAction.Request request, ClusterState state | |
// Step 6. Clear job finished time once the job is started and respond | ||
ActionListener<OpenJobAction.Response> clearJobFinishTime = ActionListener.wrap( | ||
response -> { | ||
if(response.isAcknowledged()) { | ||
if (response.isAcknowledged()) { | ||
clearJobFinishedTime(jobParams.getJobId(), listener); | ||
} else { | ||
listener.onResponse(response); | ||
|
@@ -593,10 +590,9 @@ public void onTimeout(TimeValue timeout) { | |
} | ||
|
||
private void clearJobFinishedTime(String jobId, ActionListener<OpenJobAction.Response> listener) { | ||
clusterService.submitStateUpdateTask("clearing_job_finish_time [" + jobId + "]", new ClusterStateUpdateTask() { | ||
clusterService.submitStateUpdateTask("clearing-job-finish-time [" + jobId + "]", new ClusterStateUpdateTask() { | ||
@Override | ||
public ClusterState execute(ClusterState currentState) { | ||
XPackPlugin.checkReadyForXPackCustomMetadata(currentState); | ||
MlMetadata mlMetadata = MlMetadata.getMlMetadata(currentState); | ||
MlMetadata.Builder mlMetadataBuilder = new MlMetadata.Builder(mlMetadata); | ||
Job.Builder jobBuilder = new Job.Builder(mlMetadata.getJobs().get(jobId)); | ||
|
@@ -611,7 +607,8 @@ public ClusterState execute(ClusterState currentState) { | |
|
||
@Override | ||
public void onFailure(String source, Exception e) { | ||
listener.onFailure(e); | ||
logger.error(source + "Failed to clear finished_time due to [" + e.getMessage() + "]", e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We tend to start the messages with the job_id. So, this could become:
|
||
listener.onResponse(new OpenJobAction.Response(true)); | ||
} | ||
|
||
@Override | ||
|
5 changes: 5 additions & 0 deletions
5
...s/src/test/java/org/elasticsearch/xpack/ml/integration/ReopenJobResetsFinishedTimeIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.ml.integration; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing license header |
||
|
||
import org.elasticsearch.xpack.core.ml.job.config.AnalysisConfig; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
sorry for insisting on that but so that task names are consistent (should make it easier to search through them) could you change to
"clearing-finish-time-for-job-" + jobId
?