samarthjain commented on a change in pull request #7088: Improve parallelism of
zookeeper based segment change processing
URL: https://github.com/apache/incubator-druid/pull/7088#discussion_r279482586
##########
File path:
server/src/main/java/org/apache/druid/server/coordinator/CuratorLoadQueuePeon.java
##########
@@ -219,199 +220,182 @@ public void unmarkSegmentToDrop(DataSegment
dataSegment)
segmentsMarkedToDrop.remove(dataSegment);
}
- private void processSegmentChangeRequest()
+ private class SegmentChangeProcessor implements Runnable
{
- if (currentlyProcessing != null) {
- log.debug(
- "Server[%s] skipping processSegmentChangeRequest because something
is currently loading[%s].",
- basePath,
- currentlyProcessing.getSegmentId()
- );
+ private final SegmentHolder segmentHolder;
- return;
- }
-
- if (!segmentsToDrop.isEmpty()) {
- currentlyProcessing = segmentsToDrop.firstEntry().getValue();
- log.debug("Server[%s] dropping [%s]", basePath,
currentlyProcessing.getSegmentId());
- } else if (!segmentsToLoad.isEmpty()) {
- currentlyProcessing = segmentsToLoad.firstEntry().getValue();
- log.debug("Server[%s] loading [%s]", basePath,
currentlyProcessing.getSegmentId());
- } else {
- return;
+ private SegmentChangeProcessor(SegmentHolder segmentHolder)
+ {
+ this.segmentHolder = segmentHolder;
}
- try {
- final String path = ZKPaths.makePath(basePath,
currentlyProcessing.getSegmentId().toString());
- final byte[] payload =
jsonMapper.writeValueAsBytes(currentlyProcessing.getChangeRequest());
- curator.create().withMode(CreateMode.EPHEMERAL).forPath(path, payload);
-
- processingExecutor.schedule(
- () -> {
- try {
- if (curator.checkExists().forPath(path) != null) {
- failAssign(new ISE("%s was never removed! Failing this
operation!", path));
+ @Override
+ public void run()
+ {
+ try {
+ final String path = ZKPaths.makePath(basePath,
segmentHolder.getSegmentIdentifier());
+ final byte[] payload =
jsonMapper.writeValueAsBytes(segmentHolder.getChangeRequest());
+ curator.create().withMode(CreateMode.EPHEMERAL).forPath(path, payload);
+ log.debug(
+ "ZKNode created for server to [%s] %s [%s]",
+ basePath,
+ segmentHolder.getType() == LOAD ? "load" : "drop",
+ segmentHolder.getSegmentIdentifier()
+ );
+ final ScheduledFuture<?> future = monitorNodeRemovedExecutor.schedule(
Review comment:
I agree with @gianm . Comments like these, if need be, should be made
towards the start of the review. It adds unnecessary friction and discourages
contributors in general. Refactoring like this doesn't contribute anything to
the functionality, increases the scope of changes and makes figuring out issues
in the code through reviews difficult. Having said that, I appreciate issues
you identified and some other changes you have suggested @leventov .
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]