mirror of https://github.com/apache/druid.git
persist-n-merge in separate pool
persist-n-merge in separate pool, do not block intermediate persists
This commit is contained in:
parent
bfeed26765
commit
db60353cac
|
@ -68,7 +68,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
public class RealtimePlumber implements Plumber
|
||||
{
|
||||
private static final EmittingLogger log = new EmittingLogger(RealtimePlumber.class);
|
||||
|
||||
private final Period windowPeriod;
|
||||
private final File basePersistDirectory;
|
||||
private final IndexGranularity segmentGranularity;
|
||||
|
@ -84,16 +83,15 @@ public class RealtimePlumber implements Plumber
|
|||
private final SegmentPublisher segmentPublisher;
|
||||
private final ServerView serverView;
|
||||
private final int maxPendingPersists;
|
||||
|
||||
private final Object handoffCondition = new Object();
|
||||
private final Map<Long, Sink> sinks = Maps.newConcurrentMap();
|
||||
private final VersionedIntervalTimeline<String, Sink> sinkTimeline = new VersionedIntervalTimeline<String, Sink>(
|
||||
String.CASE_INSENSITIVE_ORDER
|
||||
);
|
||||
|
||||
private volatile boolean shuttingDown = false;
|
||||
private volatile boolean stopped = false;
|
||||
private volatile ExecutorService persistExecutor = null;
|
||||
private volatile ExecutorService mergeExecutor = null;
|
||||
private volatile ScheduledExecutorService scheduledExecutor = null;
|
||||
|
||||
public RealtimePlumber(
|
||||
|
@ -306,7 +304,7 @@ public class RealtimePlumber implements Plumber
|
|||
final String threadName = String.format(
|
||||
"%s-%s-persist-n-merge", schema.getDataSource(), new DateTime(truncatedTime)
|
||||
);
|
||||
persistExecutor.execute(
|
||||
mergeExecutor.execute(
|
||||
new ThreadRenamingRunnable(threadName)
|
||||
{
|
||||
@Override
|
||||
|
@ -431,6 +429,13 @@ public class RealtimePlumber implements Plumber
|
|||
"plumber_persist_%d", maxPendingPersists
|
||||
);
|
||||
}
|
||||
if (persistExecutor == null) {
|
||||
// use a blocking single threaded executor to throttle the firehose when write to disk is slow
|
||||
mergeExecutor = Execs.newBlockingSingleThreaded(
|
||||
"plumber_persist_%d", maxPendingPersists
|
||||
);
|
||||
}
|
||||
|
||||
if (scheduledExecutor == null) {
|
||||
scheduledExecutor = Executors.newScheduledThreadPool(
|
||||
1,
|
||||
|
@ -592,7 +597,11 @@ public class RealtimePlumber implements Plumber
|
|||
log.info("Adding entry[%s] for merge and push.", entry);
|
||||
sinksToPush.add(entry);
|
||||
} else {
|
||||
log.warn("[%s] < [%s] Skipping persist and merge.", new DateTime(intervalStart), minTimestampAsDate);
|
||||
log.warn(
|
||||
"[%s] < [%s] Skipping persist and merge.",
|
||||
new DateTime(intervalStart),
|
||||
minTimestampAsDate
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -660,6 +669,7 @@ public class RealtimePlumber implements Plumber
|
|||
*/
|
||||
protected int persistHydrant(FireHydrant indexToPersist, Schema schema, Interval interval)
|
||||
{
|
||||
synchronized (indexToPersist) {
|
||||
if (indexToPersist.hasSwapped()) {
|
||||
log.info(
|
||||
"DataSource[%s], Interval[%s], Hydrant[%s] already swapped. Ignoring request to persist.",
|
||||
|
@ -668,7 +678,12 @@ public class RealtimePlumber implements Plumber
|
|||
return 0;
|
||||
}
|
||||
|
||||
log.info("DataSource[%s], Interval[%s], persisting Hydrant[%s]", schema.getDataSource(), interval, indexToPersist);
|
||||
log.info(
|
||||
"DataSource[%s], Interval[%s], persisting Hydrant[%s]",
|
||||
schema.getDataSource(),
|
||||
interval,
|
||||
indexToPersist
|
||||
);
|
||||
try {
|
||||
int numRows = indexToPersist.getIndex().size();
|
||||
|
||||
|
@ -695,6 +710,7 @@ public class RealtimePlumber implements Plumber
|
|||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerServerViewCallback()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue