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
Add ability to provide taskResource for IndexTask. #1630
Conversation
@@ -40,6 +40,16 @@ protected AbstractFixedIntervalTask( | |||
|
|||
protected AbstractFixedIntervalTask( | |||
String id, | |||
TaskResource taskResource, |
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.
there is already a constr, which takes (id,groupId,resource, dataSource,interval)
Can we use that in indexTask, instead of adding a new one ?
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.
Good point, Nishant. I was hyper-focused on getting access to the "resource" node. 😀 It does make more sense to use the existing constructor. I can just modify IndexTask to do something similar to RealTimeIndexTask for the groupId...
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.
ie:
super(
// _not_ the version, just something uniqueish
makeId(id, ingestionSchema),
String.format("index_%s", makeDataSource(ingestionSchema)),
taskResource == null ? new TaskResource(makeId(id, ingestionSchema), 1) : taskResource,
makeDataSource(ingestionSchema),
makeInterval(ingestionSchema)
);
89f32fa
to
673a0ba
Compare
Good point made by Nishant. I was hyper-focused on getting access to the "resource" node. 😀 It does make more sense to use the existing constructor. I've force-pushed a new submission which leaves the abstract unchanged and does the needful from IndexTask. |
👍 |
@@ -141,9 +141,19 @@ static RealtimeTuningConfig convertTuningConfig(ShardSpec spec, IndexTuningConfi | |||
|
|||
private final ObjectMapper jsonMapper; | |||
|
|||
public IndexTask( |
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.
Is this constructor just for unit tests?
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.
Hmm, apparently so - I did a search for implementers and thought I had hits, but it was late. It is, indeed, only tests that directly instantiate IndexTask. I can update the implementations in IndexTaskTest, TaskSerdeTest, and TaskLifecycleTest and eliminate the constr overload.
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.
Or you can just comment that its only used in unit tests. Whichever makes it easier to read.
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've added a comment:
/**
* This overloaded constructor without @JsonCreator exists to allow for
* unit tests simulating a call to IndexTask without taskResource.
*/
@potto007 you'll also need to sign the CLA here: |
@fjy It's there |
b518511
to
8e79e02
Compare
@@ -151,6 +165,8 @@ public IndexTask( | |||
super( | |||
// _not_ the version, just something uniqueish | |||
makeId(id, ingestionSchema), | |||
makeId(id, ingestionSchema), |
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.
These three makeId's are not guaranteed to fire in the same millisecond. You'll need to orchestrate it such that makeId fires once, and that value is re-used.
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.
So I've gone back to the way I initially had it, with the taskResource logic pushed up into AbstractFixedIntervalTask - doing so allows for the passed id value to be reused for groupId and for generating a new taskResource if passed as null.
8e79e02
to
af03fd8
Compare
So I've gone back to the way I initially had it, with the taskResource logic pushed up into AbstractFixedIntervalTask - doing so allows for the passed id value to be reused for groupId and for generating a new taskResource if passed as null. |
@@ -141,9 +141,25 @@ static RealtimeTuningConfig convertTuningConfig(ShardSpec spec, IndexTuningConfi | |||
|
|||
private final ObjectMapper jsonMapper; | |||
|
|||
private String taskId; |
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.
This variable is not used.
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.
Crap - that got left over from something else I was doing. Must have wound up in there with the rebasing and force pushing. Sorry, will remove.
Closed and reopened for travis. This looks good to me modulo the two comments I had in the diff, and assuming the travis build comes back ok. @potto007 I can make those changes when merging the PR if that makes life easier for you. Please let me know. |
If you don't mind, that works for me. Otherwise, I can get to it within the hour. |
I had the need to specify requiredCapacity for ingestSegment IndexTask. I added another overloaded constructor to the AbstractFixedIntervalTask class to handle an incoming taskResource attribute. I overloaded the IndexTask constructor to support all internal implementations of IndexTask. I added a new @JsonProperty for taskResource to the primary constructor, with an inline if to handle the case when someone does not use the resource JSON node. I am using this on some of my systems, and I also added a unit test to verify that this works.