YARN-10156. Destroy Jersey Client in TimelineConnector.
Contributed by Tanu Ajmera.
This commit is contained in:
parent
62c26b91fd
commit
9224568b0e
|
@ -78,7 +78,7 @@ public class TimelineConnector extends AbstractService {
|
|||
public final static int DEFAULT_SOCKET_TIMEOUT = 1 * 60 * 1000; // 1 minute
|
||||
|
||||
private SSLFactory sslFactory;
|
||||
private Client client;
|
||||
Client client;
|
||||
private ConnectionConfigurator connConfigurator;
|
||||
private DelegationTokenAuthenticator authenticator;
|
||||
private DelegationTokenAuthenticatedURL.Token token;
|
||||
|
@ -200,6 +200,9 @@ public class TimelineConnector extends AbstractService {
|
|||
}
|
||||
|
||||
protected void serviceStop() {
|
||||
if (this.client != null) {
|
||||
this.client.destroy();
|
||||
}
|
||||
if (this.sslFactory != null) {
|
||||
this.sslFactory.destroy();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import static org.mockito.Mockito.doThrow;
|
|||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
|
@ -492,6 +494,17 @@ public class TestTimelineClient {
|
|||
Assert.assertFalse("Reloader is still alive", reloaderStillAlive);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimelineConnectorDestroy() {
|
||||
YarnConfiguration conf = new YarnConfiguration();
|
||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||
TimelineClientImpl client = createTimelineClient(conf);
|
||||
Client mockJerseyClient = mock(Client.class);
|
||||
client.connector.client = mockJerseyClient;
|
||||
client.stop();
|
||||
verify(mockJerseyClient, times(1)).destroy();
|
||||
}
|
||||
|
||||
private void setupSSLConfig(YarnConfiguration conf) throws Exception {
|
||||
keystoresDir = TestGenericTestUtils.getTestDir().getAbsolutePath();
|
||||
sslConfDir =
|
||||
|
|
Loading…
Reference in New Issue