mirror of https://github.com/apache/druid.git
RealtimePlumberSchool: Faster graceful shutdown
This commit is contained in:
parent
017278a5d5
commit
dc615ab795
|
@ -146,7 +146,7 @@ public class IndexerCoordinatorResource
|
||||||
return Response.serverError().build();
|
return Response.serverError().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok().build();
|
return Response.ok(ImmutableMap.of("task", taskid)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy endpoint
|
// Legacy endpoint
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class RealtimePlumberSchool implements PlumberSchool
|
||||||
private final Period windowPeriod;
|
private final Period windowPeriod;
|
||||||
private final File basePersistDirectory;
|
private final File basePersistDirectory;
|
||||||
private final IndexGranularity segmentGranularity;
|
private final IndexGranularity segmentGranularity;
|
||||||
|
private final Object handoffCondition = new Object();
|
||||||
|
|
||||||
private volatile VersioningPolicy versioningPolicy = null;
|
private volatile VersioningPolicy versioningPolicy = null;
|
||||||
private volatile RejectionPolicyFactory rejectionPolicyFactory = null;
|
private volatile RejectionPolicyFactory rejectionPolicyFactory = null;
|
||||||
|
@ -304,13 +305,12 @@ public class RealtimePlumberSchool implements PlumberSchool
|
||||||
@Override
|
@Override
|
||||||
public void finishJob()
|
public void finishJob()
|
||||||
{
|
{
|
||||||
log.info("Shutting down....");
|
log.info("Shutting down...");
|
||||||
|
|
||||||
while (!sinks.isEmpty()) {
|
while (!sinks.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
Duration retry = new Duration("PT60S");
|
|
||||||
log.info(
|
log.info(
|
||||||
"Cannot shut down yet! Sinks for %s remain! Next retry in %s",
|
"Cannot shut down yet! Sinks remain: %s",
|
||||||
Joiner.on(", ").join(
|
Joiner.on(", ").join(
|
||||||
Iterables.transform(
|
Iterables.transform(
|
||||||
sinks.values(),
|
sinks.values(),
|
||||||
|
@ -323,27 +323,18 @@ public class RealtimePlumberSchool implements PlumberSchool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
retry
|
|
||||||
);
|
);
|
||||||
Thread.sleep(retry.getMillis());
|
|
||||||
|
synchronized (handoffCondition) {
|
||||||
|
handoffCondition.wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Sink sink : sinks.values()) {
|
|
||||||
try {
|
|
||||||
segmentAnnouncer.unannounceSegment(sink.getSegment());
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
log.makeAlert("Failed to unannounce segment on shutdown")
|
|
||||||
.addData("segment", sink.getSegment())
|
|
||||||
.emit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// scheduledExecutor is shutdown here, but persistExecutor is shutdown when the
|
// scheduledExecutor is shutdown here, but persistExecutor is shutdown when the
|
||||||
// ServerView sends it a new segment callback
|
// ServerView sends it a new segment callback
|
||||||
|
|
||||||
|
@ -459,6 +450,10 @@ public class RealtimePlumberSchool implements PlumberSchool
|
||||||
FileUtils.deleteDirectory(computePersistDir(schema, sink.getInterval()));
|
FileUtils.deleteDirectory(computePersistDir(schema, sink.getInterval()));
|
||||||
log.info("Removing sinkKey %d for segment %s", sinkKey, sink.getSegment().getIdentifier());
|
log.info("Removing sinkKey %d for segment %s", sinkKey, sink.getSegment().getIdentifier());
|
||||||
sinks.remove(sinkKey);
|
sinks.remove(sinkKey);
|
||||||
|
|
||||||
|
synchronized (handoffCondition) {
|
||||||
|
handoffCondition.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
log.makeAlert(e, "Unable to delete old segment for dataSource[%s].", schema.getDataSource())
|
log.makeAlert(e, "Unable to delete old segment for dataSource[%s].", schema.getDataSource())
|
||||||
|
|
Loading…
Reference in New Issue