mirror of
https://github.com/apache/druid.git
synced 2025-03-07 01:39:28 +00:00
move jetty module to Lifecycle.Stage.LAST to allow graceful shutdown to work with lookups and stuff, put http-clint on lifecycle modules lifecycle (#7215)
This commit is contained in:
parent
9bebf113ba
commit
5cc171419c
@ -24,7 +24,6 @@ import com.google.common.base.Throwables;
|
||||
import com.google.inject.Inject;
|
||||
import org.apache.druid.guice.annotations.Client;
|
||||
import org.apache.druid.guice.http.DruidHttpClientConfig;
|
||||
import org.apache.druid.guice.http.LifecycleUtils;
|
||||
import org.apache.druid.https.SSLClientConfig;
|
||||
import org.apache.druid.java.util.common.ISE;
|
||||
import org.apache.druid.java.util.common.StringUtils;
|
||||
@ -391,7 +390,7 @@ public class ITTLSTest
|
||||
|
||||
HttpClient client = HttpClientInit.createClient(
|
||||
builder.build(),
|
||||
LifecycleUtils.asMmxLifecycle(lifecycle)
|
||||
lifecycle
|
||||
);
|
||||
|
||||
HttpClient adminClient = new CredentialedHttpClient(
|
||||
@ -418,7 +417,7 @@ public class ITTLSTest
|
||||
|
||||
HttpClient client = HttpClientInit.createClient(
|
||||
builder.build(),
|
||||
LifecycleUtils.asMmxLifecycle(lifecycle)
|
||||
lifecycle
|
||||
);
|
||||
|
||||
HttpClient adminClient = new CredentialedHttpClient(
|
||||
|
@ -150,7 +150,7 @@ public class HttpClientModule implements Module
|
||||
|
||||
HttpClient client = HttpClientInit.createClient(
|
||||
builder.build(),
|
||||
LifecycleUtils.asMmxLifecycle(getLifecycleProvider().get())
|
||||
getLifecycleProvider().get()
|
||||
);
|
||||
|
||||
if (isEscalated) {
|
||||
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.druid.guice.http;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import org.apache.druid.java.util.common.lifecycle.Lifecycle;
|
||||
|
||||
public class LifecycleUtils
|
||||
{
|
||||
public static Lifecycle asMmxLifecycle(Lifecycle lifecycle)
|
||||
{
|
||||
final Lifecycle metamxLifecycle = new Lifecycle("http-client");
|
||||
try {
|
||||
lifecycle.addMaybeStartHandler(new Lifecycle.Handler()
|
||||
{
|
||||
@Override
|
||||
public void start() throws Exception
|
||||
{
|
||||
metamxLifecycle.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
metamxLifecycle.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
|
||||
return metamxLifecycle;
|
||||
}
|
||||
}
|
@ -440,7 +440,8 @@ public class JettyServerModule extends JerseyServletModule
|
||||
log.warn(e, "Unable to stop Jetty server.");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Lifecycle.Stage.LAST
|
||||
);
|
||||
|
||||
return server;
|
||||
|
@ -24,7 +24,6 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.servlet.GuiceFilter;
|
||||
import org.apache.druid.guice.annotations.Self;
|
||||
import org.apache.druid.guice.http.LifecycleUtils;
|
||||
import org.apache.druid.java.util.common.lifecycle.Lifecycle;
|
||||
import org.apache.druid.java.util.http.client.HttpClient;
|
||||
import org.apache.druid.java.util.http.client.HttpClientConfig;
|
||||
@ -119,7 +118,7 @@ public abstract class BaseJettyTest
|
||||
try {
|
||||
this.client = HttpClientInit.createClient(
|
||||
new HttpClientConfig(maxClientConnections, SSLContext.getDefault(), Duration.ZERO),
|
||||
LifecycleUtils.asMmxLifecycle(druidLifecycle)
|
||||
druidLifecycle
|
||||
);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user