-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adjust HadoopIndexTask temp segment renaming to avoid potential race conditions #11075
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
Merged
jon-wei
merged 25 commits into
apache:master
from
zachjsh:hadoop-segment-index-file-rename
Apr 21, 2021
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a7a6fe0
Do stuff
zachjsh dcd9663
Do more stuff
zachjsh fd26c73
* Do more stuff
zachjsh ab45103
* Do more stuff
zachjsh 78f2958
* working
zachjsh 9f5bc94
* cleanup
zachjsh 2f71523
* more cleanup
zachjsh 22061c3
* more cleanup
zachjsh 44f0707
* add license header
zachjsh ce168cf
* Add unit tests
zachjsh 2d41899
* add java docs
zachjsh 063d3f8
Merge remote-tracking branch 'apache/master' into hadoop-segment-inde…
zachjsh 0b4bfbd
* add more unit tests
zachjsh c7fa3e8
* Cleanup test
zachjsh cf26d35
* Move removing of workingPath to index task rather than in hadoop job.
zachjsh 2dd3c56
Merge remote-tracking branch 'apache/master' into hadoop-segment-inde…
zachjsh ed2e4ff
* Address review comments
zachjsh 3692fe6
* remove unused import
zachjsh da82fa1
Merge remote-tracking branch 'apache/master' into hadoop-segment-inde…
zachjsh 219ceb9
* Address review comments
zachjsh 8d0ef20
Do not overwrite segment descriptor for segment if it already exists.
zachjsh b529b82
Merge remote-tracking branch 'apache/master' into hadoop-segment-inde…
zachjsh 883402a
* add comments to FileSystemHelper class
zachjsh 66713ee
Merge remote-tracking branch 'apache/master' into hadoop-segment-inde…
zachjsh de48276
* fix local hadoop integration test
zachjsh 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 hidden or 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
97 changes: 97 additions & 0 deletions
97
indexing-hadoop/src/main/java/org/apache/druid/indexer/DataSegmentAndIndexZipFilePath.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.indexer; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import org.apache.druid.timeline.DataSegment; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * holds a {@link DataSegment} with the temporary file path where the corresponding index zip file is currently stored | ||
| * and the final path where the index zip file should eventually be moved to. | ||
| * see {@link JobHelper#renameIndexFilesForSegments(HadoopIngestionSpec, List)} | ||
| */ | ||
| public class DataSegmentAndIndexZipFilePath | ||
| { | ||
| private final DataSegment segment; | ||
| private final String tmpIndexZipFilePath; | ||
| private final String finalIndexZipFilePath; | ||
|
|
||
| @JsonCreator | ||
| public DataSegmentAndIndexZipFilePath( | ||
| @JsonProperty("segment") DataSegment segment, | ||
| @JsonProperty("tmpIndexZipFilePath") String tmpIndexZipFilePath, | ||
| @JsonProperty("finalIndexZipFilePath") String finalIndexZipFilePath | ||
| ) | ||
| { | ||
| this.segment = segment; | ||
| this.tmpIndexZipFilePath = tmpIndexZipFilePath; | ||
| this.finalIndexZipFilePath = finalIndexZipFilePath; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public DataSegment getSegment() | ||
| { | ||
| return segment; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public String getTmpIndexZipFilePath() | ||
| { | ||
| return tmpIndexZipFilePath; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public String getFinalIndexZipFilePath() | ||
| { | ||
| return finalIndexZipFilePath; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) | ||
| { | ||
| if (o instanceof DataSegmentAndIndexZipFilePath) { | ||
| DataSegmentAndIndexZipFilePath that = (DataSegmentAndIndexZipFilePath) o; | ||
| return segment.equals(((DataSegmentAndIndexZipFilePath) o).getSegment()) | ||
| && tmpIndexZipFilePath.equals(that.getTmpIndexZipFilePath()) | ||
| && finalIndexZipFilePath.equals(that.getFinalIndexZipFilePath()); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| { | ||
| return Objects.hash(segment.getId(), tmpIndexZipFilePath); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() | ||
| { | ||
| return "DataSegmentAndIndexZipFilePath{" + | ||
| "segment=" + segment + | ||
| ", tmpIndexZipFilePath=" + tmpIndexZipFilePath + | ||
| ", finalIndexZipFilePath=" + finalIndexZipFilePath + | ||
| '}'; | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
indexing-hadoop/src/main/java/org/apache/druid/indexer/FileSystemHelper.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.indexer; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.URI; | ||
|
|
||
| /** | ||
| * This class exists for testing purposes, see {@link JobHelperPowerMockTest}. Using the | ||
| * raw {@link FileSystem} class resulted in errors with java assist. | ||
| */ | ||
| public class FileSystemHelper | ||
| { | ||
| public static FileSystem get(URI uri, Configuration conf) throws IOException | ||
| { | ||
| return FileSystem.get(uri, conf); | ||
| } | ||
| } | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
This class seems unnecessary
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 needed it for the test that I'm using it in. I wasnt able to mock the raw Filesystem.get routine, kept running into assist issues.
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.
Can you add a comment here about that?
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.
Added comment