mirror of https://github.com/apache/druid.git
fix previous fix because multithread is not correct
This commit is contained in:
parent
5ff216838d
commit
5cb1475a91
|
@ -37,6 +37,7 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -50,6 +51,7 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer
|
|||
private final String liveSegmentLocation;
|
||||
|
||||
private final Object lock = new Object();
|
||||
private final AtomicLong counter = new AtomicLong(0);
|
||||
|
||||
private final Set<SegmentZNode> availableZNodes = new ConcurrentSkipListSet<SegmentZNode>();
|
||||
private final Map<DataSegment, SegmentZNode> segmentLookup = Maps.newConcurrentMap();
|
||||
|
@ -118,6 +120,7 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer
|
|||
return;
|
||||
}
|
||||
|
||||
synchronized (lock) {
|
||||
segmentZNode.removeSegment(segment);
|
||||
|
||||
log.info("Unannouncing segment[%s] at path[%s]", segment.getIdentifier(), segmentZNode.getPath());
|
||||
|
@ -129,6 +132,7 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer
|
|||
availableZNodes.add(segmentZNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void announceSegments(Iterable<DataSegment> segments) throws IOException
|
||||
|
@ -176,7 +180,7 @@ public class BatchDataSegmentAnnouncer extends AbstractDataSegmentAnnouncer
|
|||
|
||||
private String makeServedSegmentPath(String zNode)
|
||||
{
|
||||
return ZKPaths.makePath(liveSegmentLocation, zNode);
|
||||
return ZKPaths.makePath(liveSegmentLocation, String.format("%s%s", zNode, counter.getAndIncrement()));
|
||||
}
|
||||
|
||||
private class SegmentZNode implements Comparable<SegmentZNode>
|
||||
|
|
Loading…
Reference in New Issue