Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

potto007
Copy link
Contributor

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.

@@ -40,6 +40,16 @@ protected AbstractFixedIntervalTask(

protected AbstractFixedIntervalTask(
String id,
TaskResource taskResource,
Copy link
Member

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 ?

Copy link
Contributor Author

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...

Copy link
Contributor Author

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)
    );

@potto007
Copy link
Contributor Author

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.

@nishantmonu51
Copy link
Member

👍

@@ -141,9 +141,19 @@ static RealtimeTuningConfig convertTuningConfig(ShardSpec spec, IndexTuningConfi

private final ObjectMapper jsonMapper;

public IndexTask(
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.
   */

@fjy
Copy link
Contributor

fjy commented Aug 17, 2015

@potto007 you'll also need to sign the CLA here:
http://druid.io/community/cla.html

@drcrallen
Copy link
Contributor

@fjy It's there

@potto007 potto007 force-pushed the index-add-taskResource branch 2 times, most recently from b518511 to 8e79e02 Compare August 18, 2015 05:19
@@ -151,6 +165,8 @@ public IndexTask(
super(
// _not_ the version, just something uniqueish
makeId(id, ingestionSchema),
makeId(id, ingestionSchema),
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@potto007
Copy link
Contributor Author

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.

@gianm gianm closed this Aug 21, 2015
@gianm gianm reopened this Aug 21, 2015
@@ -141,9 +141,25 @@ static RealtimeTuningConfig convertTuningConfig(ShardSpec spec, IndexTuningConfi

private final ObjectMapper jsonMapper;

private String taskId;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@gianm
Copy link
Contributor

gianm commented Aug 21, 2015

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.

@potto007
Copy link
Contributor Author

If you don't mind, that works for me. Otherwise, I can get to it within the hour.

@gianm
Copy link
Contributor

gianm commented Aug 21, 2015

@potto007 sure, I don't mind. The new PR is #1654, and you'll still get credit for the actual commit.

@gianm gianm closed this Aug 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants