mirror of https://github.com/apache/druid.git
Make CliPeon run shutdown hooks properly
* Also make jetty threads daemon
This commit is contained in:
parent
798c3320d0
commit
2b87ad307d
|
@ -157,6 +157,7 @@ public class JettyServerModule extends JerseyServletModule
|
|||
final QueuedThreadPool threadPool = new QueuedThreadPool();
|
||||
threadPool.setMinThreads(config.getNumThreads());
|
||||
threadPool.setMaxThreads(config.getNumThreads());
|
||||
threadPool.setDaemon(true);
|
||||
|
||||
final Server server = new Server(threadPool);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ import com.metamx.common.logger.Logger;
|
|||
import io.airlift.command.Arguments;
|
||||
import io.airlift.command.Command;
|
||||
import io.airlift.command.Option;
|
||||
import io.druid.metadata.IndexerSQLMetadataStorageCoordinator;
|
||||
import io.druid.guice.Binders;
|
||||
import io.druid.guice.IndexingServiceFirehoseModule;
|
||||
import io.druid.guice.Jerseys;
|
||||
|
@ -56,6 +55,7 @@ import io.druid.indexing.overlord.TaskStorage;
|
|||
import io.druid.indexing.overlord.ThreadPoolTaskRunner;
|
||||
import io.druid.indexing.worker.executor.ExecutorLifecycle;
|
||||
import io.druid.indexing.worker.executor.ExecutorLifecycleConfig;
|
||||
import io.druid.metadata.IndexerSQLMetadataStorageCoordinator;
|
||||
import io.druid.query.QuerySegmentWalker;
|
||||
import io.druid.segment.loading.DataSegmentArchiver;
|
||||
import io.druid.segment.loading.DataSegmentKiller;
|
||||
|
@ -71,7 +71,6 @@ import io.druid.segment.realtime.firehose.NoopChatHandlerProvider;
|
|||
import io.druid.segment.realtime.firehose.ServiceAnnouncingChatHandlerProvider;
|
||||
import io.druid.server.QueryResource;
|
||||
import io.druid.server.initialization.jetty.JettyServerInitializer;
|
||||
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -125,7 +124,8 @@ public class CliPeon extends GuiceRunnable
|
|||
.to(ServiceAnnouncingChatHandlerProvider.class).in(LazySingleton.class);
|
||||
handlerProviderBinder.addBinding("noop")
|
||||
.to(NoopChatHandlerProvider.class).in(LazySingleton.class);
|
||||
binder.bind(ServiceAnnouncingChatHandlerProvider.class).in(LazySingleton.class);;
|
||||
binder.bind(ServiceAnnouncingChatHandlerProvider.class).in(LazySingleton.class);
|
||||
|
||||
binder.bind(NoopChatHandlerProvider.class).in(LazySingleton.class);
|
||||
|
||||
binder.bind(TaskToolboxFactory.class).in(LazySingleton.class);
|
||||
|
@ -190,7 +190,9 @@ public class CliPeon extends GuiceRunnable
|
|||
JsonConfigProvider.bind(binder, "druid.indexer.storage", TaskStorageConfig.class);
|
||||
binder.bind(TaskStorage.class).to(HeapMemoryTaskStorage.class).in(LazySingleton.class);
|
||||
binder.bind(TaskActionToolbox.class).in(LazySingleton.class);
|
||||
binder.bind(IndexerMetadataStorageCoordinator.class).to(IndexerSQLMetadataStorageCoordinator.class).in(LazySingleton.class);
|
||||
binder.bind(IndexerMetadataStorageCoordinator.class).to(IndexerSQLMetadataStorageCoordinator.class).in(
|
||||
LazySingleton.class
|
||||
);
|
||||
taskActionBinder.addBinding("remote")
|
||||
.to(RemoteTaskActionClientFactory.class).in(LazySingleton.class);
|
||||
|
||||
|
@ -205,17 +207,28 @@ public class CliPeon extends GuiceRunnable
|
|||
{
|
||||
try {
|
||||
Injector injector = makeInjector();
|
||||
|
||||
try {
|
||||
Lifecycle lifecycle = initLifecycle(injector);
|
||||
|
||||
final Lifecycle lifecycle = initLifecycle(injector);
|
||||
Runtime.getRuntime().addShutdownHook(
|
||||
new Thread(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
log.info("Running shutdown hook");
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
injector.getInstance(ExecutorLifecycle.class).join();
|
||||
lifecycle.stop();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
log.error(t, "Error when starting up. Failing.");
|
||||
System.exit(1);
|
||||
}
|
||||
log.info("Finished peon task");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
|
|
Loading…
Reference in New Issue