MINOR: AbstractSegments should not swallow exceptions#21636
MINOR: AbstractSegments should not swallow exceptions#21636mjsax merged 2 commits intoapache:trunkfrom
Conversation
| public abstract class AbstractRocksDBWindowStoreTest extends AbstractWindowBytesStoreTest { | ||
|
|
||
| private static final String STORE_NAME = "rocksDB window store"; | ||
| private static final String STORE_NAME = "rocksDB-windowstore"; |
There was a problem hiding this comment.
not related -- but avoiding spaces sound like a good idea
|
|
||
| // remove local store image | ||
| Utils.delete(baseDir); | ||
| Utils.delete(new File(baseDir, STORE_NAME)); |
There was a problem hiding this comment.
We delete a directory "too high" in the hierarchy, and thus when we later try to create a segment we cannot, because the parent directory does not exist.
| final File oldSegment = new File(storeDirectoryPath + File.separator + storeName + "-" + formatter.format(new Date(segmentId * segmentInterval))); | ||
| //noinspection ResultOfMethodCallIgnored | ||
| Files.createFile(oldSegment.toPath()); | ||
| Files.createDirectory(oldSegment.toPath()); |
There was a problem hiding this comment.
Segments are directories -- if we create it here as a file, we later fail trying to create it as directory (create dir passed if dir already exists)
chia7712
left a comment
There was a problem hiding this comment.
LGTM, but I'm feeling a bit nitpicky today
| Arrays.stream(list) | ||
| .map(segment -> segmentIdFromSegmentName(segment, dir)) | ||
| .sorted() // open segments in the id order | ||
| .filter(segmentId -> segmentId >= 0) |
There was a problem hiding this comment.
Nit: it would be better to apply filter before sort
| throw new ProcessorStateException(String.format("dir %s doesn't exist and cannot be created for segments %s", dir, name)); | ||
| } | ||
| final File dir = new File(context.stateDir(), name); | ||
| if (dir.exists()) { |
There was a problem hiding this comment.
should we ensure the dir is a directory rather than regular file?
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: TengYao Chi frankvicky@apache.org, Chia-Ping Tsai
chia7712@gmail.com