From 560a9b81442332d8d3a53ca861038603508bcc57 Mon Sep 17 00:00:00 2001 From: Laszlo Bodor Date: Wed, 17 Sep 2025 13:18:10 +0200 Subject: [PATCH 1/5] TEZ-4649: Java21 upgrade made TestAnalyzer#testWithATS flaky - change entry to nanotime precision --- .../src/main/java/org/apache/tez/history/ATSImportTool.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java index 48d61a7a7b..94e0449929 100644 --- a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java +++ b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java @@ -264,7 +264,9 @@ private void downloadJSONArrayFromATS(String url, ZipOutputStream zos, String ta //write downloaded part to zipfile. This is done to avoid any memory pressure when // downloading and writing 1000s of tasks. - ZipEntry zipEntry = new ZipEntry("part-" + System.currentTimeMillis() + ".json"); + String zipEntryName = "part-" + System.nanoTime() + ".json"; + ZipEntry zipEntry = new ZipEntry(zipEntryName); + LOG.debug("Putting {} entities to a zip entry: {}", entities.length(), zipEntryName); zos.putNextEntry(zipEntry); JSONObject finalJson = new JSONObject(); finalJson.put(tag, entities); From e7f3c1dc6188c125214290890a359c5959071002 Mon Sep 17 00:00:00 2001 From: Laszlo Bodor Date: Mon, 15 Sep 2025 11:45:26 +0200 Subject: [PATCH 2/5] TEZ-4648: Upgrade jersey to 2.x --- pom.xml | 8 ++++---- tez-api/pom.xml | 6 +++--- tez-plugins/tez-history-parser/pom.xml | 5 +++-- tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml | 4 ++-- tez-plugins/tez-yarn-timeline-history-with-fs/pom.xml | 4 ++-- tez-plugins/tez-yarn-timeline-history/pom.xml | 4 ++-- tez-tools/analyzers/job-analyzer/pom.xml | 5 +++-- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pom.xml b/pom.xml index f539f9af34..7fa52c014a 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 32.0.1-jre 3.4.1 1.8 - 1.19.4 + 2.46 1.5.4 3.0.0 4.13.2 @@ -780,13 +780,13 @@ ${jettison.version} - com.sun.jersey + org.glassfish.jersey.core jersey-client ${jersey.version} - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson ${jersey.version} diff --git a/tez-api/pom.xml b/tez-api/pom.xml index ff1f9d2e6a..b6e0e394d0 100644 --- a/tez-api/pom.xml +++ b/tez-api/pom.xml @@ -91,12 +91,12 @@ junit - com.sun.jersey + org.glassfish.jersey.core jersey-client - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson org.apache.hadoop diff --git a/tez-plugins/tez-history-parser/pom.xml b/tez-plugins/tez-history-parser/pom.xml index 4bb312eee9..f5c597e5b0 100644 --- a/tez-plugins/tez-history-parser/pom.xml +++ b/tez-plugins/tez-history-parser/pom.xml @@ -145,8 +145,9 @@ test - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson + test org.apache.hadoop diff --git a/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml b/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml index dc8ecc1cb4..6a0da4f749 100644 --- a/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml +++ b/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml @@ -135,8 +135,8 @@ test - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson test diff --git a/tez-plugins/tez-yarn-timeline-history-with-fs/pom.xml b/tez-plugins/tez-yarn-timeline-history-with-fs/pom.xml index 19930ccda0..251ae2b9e2 100644 --- a/tez-plugins/tez-yarn-timeline-history-with-fs/pom.xml +++ b/tez-plugins/tez-yarn-timeline-history-with-fs/pom.xml @@ -143,8 +143,8 @@ test - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson test diff --git a/tez-plugins/tez-yarn-timeline-history/pom.xml b/tez-plugins/tez-yarn-timeline-history/pom.xml index 1be2c44bfd..e155625e36 100644 --- a/tez-plugins/tez-yarn-timeline-history/pom.xml +++ b/tez-plugins/tez-yarn-timeline-history/pom.xml @@ -129,8 +129,8 @@ test - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson test diff --git a/tez-tools/analyzers/job-analyzer/pom.xml b/tez-tools/analyzers/job-analyzer/pom.xml index e797842e6c..c072f3fba4 100644 --- a/tez-tools/analyzers/job-analyzer/pom.xml +++ b/tez-tools/analyzers/job-analyzer/pom.xml @@ -153,8 +153,9 @@ test - com.sun.jersey - jersey-json + org.glassfish.jersey.media + jersey-media-json-jackson + test org.apache.hadoop From 40ab54976d49e5ea25df71b7abe294536a829210 Mon Sep 17 00:00:00 2001 From: Laszlo Bodor Date: Mon, 15 Sep 2025 17:00:51 +0200 Subject: [PATCH 3/5] hadoop.version 3.5.0-SNAPSHOT WIP --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7fa52c014a..5a110b28e1 100644 --- a/pom.xml +++ b/pom.xml @@ -75,7 +75,7 @@ 4.9.3.0 1.8.0 32.0.1-jre - 3.4.1 + 3.5.0-SNAPSHOT 1.8 2.46 1.5.4 From 8b2e57f541df8d1fbb7fbc6de84d6aedc845b707 Mon Sep 17 00:00:00 2001 From: Laszlo Bodor Date: Mon, 15 Sep 2025 16:24:49 +0200 Subject: [PATCH 4/5] jersey2 migration wip --- .../dag/api/client/DAGClientTimelineImpl.java | 35 +++----- .../dag/api/client/TimelineReaderFactory.java | 85 ++----------------- .../api/client/TestTimelineReaderFactory.java | 19 ++--- .../org/apache/tez/history/ATSImportTool.java | 73 +++++----------- .../ats/acls/TestATSHistoryWithACLs.java | 54 ++++++------ .../ats/TestATSHistoryWithMiniCluster.java | 22 ++--- .../org/apache/tez/analyzer/utils/Utils.java | 4 +- 7 files changed, 88 insertions(+), 204 deletions(-) diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/client/DAGClientTimelineImpl.java b/tez-api/src/main/java/org/apache/tez/dag/api/client/DAGClientTimelineImpl.java index 46112cdf80..76e16b5cdd 100644 --- a/tez-api/src/main/java/org/apache/tez/dag/api/client/DAGClientTimelineImpl.java +++ b/tez-api/src/main/java/org/apache/tez/dag/api/client/DAGClientTimelineImpl.java @@ -29,6 +29,8 @@ import java.util.Set; import javax.annotation.Nullable; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; import org.apache.hadoop.classification.InterfaceAudience.Private; @@ -52,11 +54,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.client.WebResource; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; @@ -212,7 +209,7 @@ public DAGStatus waitForCompletionWithStatusUpdates( @Override public void close() throws IOException { if (httpClient != null) { - httpClient.destroy(); + httpClient.close(); httpClient = null; } if (timelineReaderStrategy != null) { @@ -426,26 +423,14 @@ protected Map parseTaskStatsForVertexes() @VisibleForTesting protected JSONObject getJsonRootEntity(String url) throws TezException { try { - WebResource wr = getCachedHttpClient().resource(url); - ClientResponse response = wr.accept(MediaType.APPLICATION_JSON_TYPE) - .type(MediaType.APPLICATION_JSON_TYPE) - .get(ClientResponse.class); - - final ClientResponse.Status clientResponseStatus = response.getClientResponseStatus(); - if (clientResponseStatus != ClientResponse.Status.OK) { - throw new TezException("Failed to get response from YARN Timeline:" + - " errorCode:" + clientResponseStatus + ", url:" + url); - } - - return response.getEntity(JSONObject.class); - } catch (ClientHandlerException e) { + Client client = getCachedHttpClient(); + WebTarget target = client.target(url); + String json = target.request(MediaType.APPLICATION_JSON_TYPE) + .accept(MediaType.APPLICATION_JSON_TYPE) + .get(String.class); + return new JSONObject(json); + } catch (Exception e) { throw new TezException("Error processing response from YARN Timeline", e); - } catch (UniformInterfaceException e) { - throw new TezException("Error accessing content from YARN Timeline - unexpected response", e); - } catch (IllegalArgumentException e) { - throw new TezException("Error accessing content from YARN Timeline - invalid url", e); - } catch (IOException e) { - throw new TezException("Error failed to get http client", e); } } diff --git a/tez-api/src/main/java/org/apache/tez/dag/api/client/TimelineReaderFactory.java b/tez-api/src/main/java/org/apache/tez/dag/api/client/TimelineReaderFactory.java index de1c157183..22f4cd6972 100644 --- a/tez-api/src/main/java/org/apache/tez/dag/api/client/TimelineReaderFactory.java +++ b/tez-api/src/main/java/org/apache/tez/dag/api/client/TimelineReaderFactory.java @@ -24,17 +24,17 @@ import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.URL; -import java.net.URLEncoder; import java.security.GeneralSecurityException; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.security.authentication.client.AuthenticatedURL; import org.apache.hadoop.security.authentication.client.Authenticator; import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; import org.apache.hadoop.security.ssl.SSLFactory; @@ -42,13 +42,9 @@ import org.apache.tez.dag.api.TezException; import com.google.common.annotations.VisibleForTesting; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory; -import com.sun.jersey.client.urlconnection.URLConnectionClientHandler; -import com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider; +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.jackson.JacksonFeature; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -164,7 +160,7 @@ public Client getHttpClient() throws IOException { UserGroupInformation ugi = UserGroupInformation.getCurrentUser(); UserGroupInformation realUgi = ugi.getRealUser(); String doAsUser; - ClientConfig clientConfig = new DefaultClientConfig(JSONRootElementProvider.App.class); + ClientConfig clientConfig = new ClientConfig().register(JacksonFeature.class); ConnectionConfigurator connectionConfigurator = getNewConnectionConf(useHttps, connTimeout, sslFactory); @@ -181,14 +177,7 @@ public Client getHttpClient() throws IOException { doAsUser = null; } - HttpURLConnectionFactory connectionFactory; - try { - connectionFactory = new TokenAuthenticatedURLConnectionFactory(connectionConfigurator, authenticator, - doAsUser); - } catch (TezException e) { - throw new IOException("Fail to create TokenAuthenticatedURLConnectionFactory", e); - } - return new Client(new URLConnectionClientHandler(connectionFactory), clientConfig); + return ClientBuilder.newClient(clientConfig); } private static Authenticator getTokenAuthenticator() throws TezException { @@ -203,42 +192,6 @@ private static Authenticator getTokenAuthenticator() throws TezException { return ReflectionUtils.createClazzInstance(authenticatorClazzName); } - private static class TokenAuthenticatedURLConnectionFactory implements HttpURLConnectionFactory { - - private final Authenticator authenticator; - private final ConnectionConfigurator connConfigurator; - private final String doAsUser; - private final AuthenticatedURL.Token token; - - public TokenAuthenticatedURLConnectionFactory(ConnectionConfigurator connConfigurator, - Authenticator authenticator, - String doAsUser) throws TezException { - this.connConfigurator = connConfigurator; - this.authenticator = authenticator; - this.doAsUser = doAsUser; - this.token = ReflectionUtils.createClazzInstance( - DELEGATION_TOKEN_AUTHENTICATED_URL_TOKEN_CLASS_NAME, null, null); - } - - @Override - public HttpURLConnection getHttpURLConnection(URL url) throws IOException { - try { - AuthenticatedURL authenticatedURL= ReflectionUtils.createClazzInstance( - DELEGATION_TOKEN_AUTHENTICATED_URL_CLAZZ_NAME, new Class[] { - delegationTokenAuthenticatorClazz, - ConnectionConfigurator.class - }, new Object[] { - authenticator, - connConfigurator - }); - return ReflectionUtils.invokeMethod(authenticatedURL, - delegationTokenAuthenticateURLOpenConnectionMethod, url, token, doAsUser); - } catch (Exception e) { - throw new IOException(e); - } - } - } - @Override public void close() { if (sslFactory != null) { @@ -265,31 +218,11 @@ public TimelineReaderPseudoAuthenticatedStrategy(final Configuration conf, @Override public Client getHttpClient() { - ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class); - HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory(connectionConf); - return new Client(new URLConnectionClientHandler(urlFactory), config); + ClientConfig config = new ClientConfig().register(JacksonFeature.class); + return ClientBuilder.newClient(config); } - @VisibleForTesting - protected static class PseudoAuthenticatedURLConnectionFactory implements HttpURLConnectionFactory { - private final ConnectionConfigurator connectionConf; - - public PseudoAuthenticatedURLConnectionFactory(ConnectionConfigurator connectionConf) { - this.connectionConf = connectionConf; - } - - @Override - public HttpURLConnection getHttpURLConnection(URL url) throws IOException { - String tokenString = (url.getQuery() == null ? "?" : "&") + "user.name=" + - URLEncoder.encode(UserGroupInformation.getCurrentUser().getShortUserName(), "UTF8"); - - HttpURLConnection httpURLConnection = - (HttpURLConnection) (new URL(url + tokenString)).openConnection(); - this.connectionConf.configure(httpURLConnection); - - return httpURLConnection; - } - } + // PseudoAuthenticatedURLConnectionFactory removed in Jersey 2 migration @Override public void close() { diff --git a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java index e40e87e912..b7bb017c16 100644 --- a/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java +++ b/tez-api/src/test/java/org/apache/tez/dag/api/client/TestTimelineReaderFactory.java @@ -20,12 +20,7 @@ import static org.mockito.Mockito.mock; -import java.net.HttpURLConnection; -import java.net.URL; - import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; import org.apache.tez.dag.api.TezException; import org.apache.tez.dag.api.client.TimelineReaderFactory.TimelineReaderPseudoAuthenticatedStrategy; @@ -48,15 +43,11 @@ public void testShouldUseTokenDelegationAuthStrategyForHadoop26() throws TezExce } @Test(timeout = 5000) - public void testPseudoAuthenticatorConnectionUrlShouldHaveUserName() throws Exception { - ConnectionConfigurator connConf = mock(ConnectionConfigurator.class); - TimelineReaderPseudoAuthenticatedStrategy.PseudoAuthenticatedURLConnectionFactory - connectionFactory = new TimelineReaderPseudoAuthenticatedStrategy - .PseudoAuthenticatedURLConnectionFactory(connConf); - String inputUrl = "http://host:8080/path"; - String expectedUrl = inputUrl + "?user.name=" + UserGroupInformation.getCurrentUser().getShortUserName(); - HttpURLConnection httpURLConnection = connectionFactory.getHttpURLConnection(new URL(inputUrl)); - Assert.assertEquals(expectedUrl, httpURLConnection.getURL().toString()); + public void testPseudoStrategyCreatesJersey2Client() { + TimelineReaderPseudoAuthenticatedStrategy strategy = + new TimelineReaderPseudoAuthenticatedStrategy(new Configuration(), false, 1000); + Assert.assertNotNull(strategy.getHttpClient()); + strategy.close(); } } diff --git a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java index 94e0449929..ea71941fd3 100644 --- a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java +++ b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java @@ -23,17 +23,18 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLEncoder; import java.util.Iterator; import java.util.Objects; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; @@ -42,11 +43,9 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.io.IOUtils; -import org.apache.commons.io.LineIterator; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.http.HttpConfig; -import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -60,16 +59,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; import com.google.common.base.Strings; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.UniformInterfaceException; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory; -import com.sun.jersey.client.urlconnection.URLConnectionClientHandler; -import com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; @@ -169,7 +158,7 @@ private void download() throws Exception { throw e; } finally { if (httpClient != null) { - httpClient.destroy(); + httpClient.close(); } IOUtils.closeQuietly(fos); } @@ -288,67 +277,47 @@ private void downloadJSONArrayFromATS(String url, ZipOutputStream zos, String ta } } - private void logErrorMessage(ClientResponse response) throws IOException { - LOG.error("Response status={}", response.getClientResponseStatus().toString()); - LineIterator it = null; + private void logErrorMessage(Response response) { + LOG.error("Response status={}", Integer.toString(response.getStatus())); try { - it = IOUtils.lineIterator(response.getEntityInputStream(), UTF8); - while (it.hasNext()) { - String line = it.nextLine(); - LOG.error(line); - } - } finally { - if (it != null) { - it.close(); + String entity = response.readEntity(String.class); + if (entity != null) { + LOG.error(entity); } + } catch (Exception ignore) { + // ignore } } //For secure cluster, this should work as long as valid ticket is available in the node. private JSONObject getJsonRootEntity(String url) throws TezException, IOException { try { - WebResource wr = getHttpClient().resource(url); - ClientResponse response = wr.accept(MediaType.APPLICATION_JSON_TYPE) - .type(MediaType.APPLICATION_JSON_TYPE) - .get(ClientResponse.class); + WebTarget target = getHttpClient().target(url); + Response response = target.request(MediaType.APPLICATION_JSON_TYPE) + .accept(MediaType.APPLICATION_JSON_TYPE) + .get(); - if (response.getClientResponseStatus() != ClientResponse.Status.OK) { + if (response.getStatus() != Response.Status.OK.getStatusCode()) { // In the case of secure cluster, if there is any auth exception it sends the data back as // a html page and JSON parsing could throw exceptions. Instead, get the stream contents // completely and log it in case of error. logErrorMessage(response); throw new TezException("Failed to get response from YARN Timeline: url: " + url); } - return response.getEntity(JSONObject.class); - } catch (ClientHandlerException e) { + String json = response.readEntity(String.class); + return new JSONObject(json); + } catch (Exception e) { throw new TezException("Error processing response from YARN Timeline. URL=" + url, e); - } catch (UniformInterfaceException e) { - throw new TezException("Error accessing content from YARN Timeline - unexpected response. " - + "URL=" + url, e); - } catch (IllegalArgumentException e) { - throw new TezException("Error accessing content from YARN Timeline - invalid url. URL=" + url, - e); } } private Client getHttpClient() { if (httpClient == null) { - ClientConfig config = new DefaultClientConfig(JSONRootElementProvider.App.class); - HttpURLConnectionFactory urlFactory = new PseudoAuthenticatedURLConnectionFactory(); - return new Client(new URLConnectionClientHandler(urlFactory), config); + return ClientBuilder.newClient(); } return httpClient; } - static class PseudoAuthenticatedURLConnectionFactory implements HttpURLConnectionFactory { - @Override - public HttpURLConnection getHttpURLConnection(URL url) throws IOException { - String tokenString = (url.getQuery() == null ? "?" : "&") + "user.name=" + - URLEncoder.encode(UserGroupInformation.getCurrentUser().getShortUserName(), "UTF8"); - return (HttpURLConnection) (new URL(url.toString() + tokenString)).openConnection(); - } - } - @Override public int run(String[] args) throws Exception { try { diff --git a/tez-plugins/tez-yarn-timeline-history-with-acls/src/test/java/org/apache/tez/dag/history/ats/acls/TestATSHistoryWithACLs.java b/tez-plugins/tez-yarn-timeline-history-with-acls/src/test/java/org/apache/tez/dag/history/ats/acls/TestATSHistoryWithACLs.java index 6b29169cf7..1da841c0ee 100644 --- a/tez-plugins/tez-yarn-timeline-history-with-acls/src/test/java/org/apache/tez/dag/history/ats/acls/TestATSHistoryWithACLs.java +++ b/tez-plugins/tez-yarn-timeline-history-with-acls/src/test/java/org/apache/tez/dag/history/ats/acls/TestATSHistoryWithACLs.java @@ -31,7 +31,11 @@ import java.util.List; import java.util.Random; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -66,9 +70,6 @@ import org.apache.tez.tests.MiniTezClusterWithTimeline; import com.google.common.collect.Sets; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; @@ -148,23 +149,25 @@ public static void tearDown() throws InterruptedException { // To be replaced after Timeline has java APIs for domains private K getTimelineData(String url, Class clazz) { - Client client = new Client(); - WebResource resource = client.resource(url); + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(url); - ClientResponse response = resource.accept(MediaType.APPLICATION_JSON) - .get(ClientResponse.class); + Response response = target.request(MediaType.APPLICATION_JSON).get(); assertEquals(200, response.getStatus()); - assertTrue(MediaType.APPLICATION_JSON_TYPE.isCompatible(response.getType())); + assertTrue(MediaType.APPLICATION_JSON_TYPE.isCompatible(response.getMediaType())); - JSONObject entity = response.getEntity(JSONObject.class); - K converted = null; + String entityStr = response.readEntity(String.class); try { - converted = convertJSONObjectToTimelineObject(entity, clazz); + JSONObject entity = new JSONObject(entityStr); + K converted = convertJSONObjectToTimelineObject(entity, clazz); + assertNotNull(converted); + return converted; } catch (JSONException e) { throw new RuntimeException(e); + } finally { + response.close(); + client.close(); } - assertNotNull(converted); - return converted; } private K convertJSONObjectToTimelineObject(JSONObject jsonObj, Class clazz) throws JSONException { @@ -453,12 +456,12 @@ public void testDagLoggingDisabled() throws Exception { historyLoggingService.handle(new DAGHistoryEvent(tezDAGID, submittedEvent)); Thread.sleep(1000l); String url = "http://" + timelineAddress + "/ws/v1/timeline/TEZ_DAG_ID/"+event.getDAGID(); - Client client = new Client(); - WebResource resource = client.resource(url); - - ClientResponse response = resource.accept(MediaType.APPLICATION_JSON) - .get(ClientResponse.class); + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(url); + Response response = target.request(MediaType.APPLICATION_JSON).get(); assertEquals(404, response.getStatus()); + response.close(); + client.close(); } /** @@ -498,17 +501,18 @@ public void testDagLoggingEnabled() throws Exception { historyLoggingService.handle(new DAGHistoryEvent(tezDAGID, submittedEvent)); Thread.sleep(1000l); String url = "http://" + timelineAddress + "/ws/v1/timeline/TEZ_DAG_ID/"+event.getDAGID(); - Client client = new Client(); - WebResource resource = client.resource(url); - - ClientResponse response = resource.accept(MediaType.APPLICATION_JSON) - .get(ClientResponse.class); + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(url); + Response response = target.request(MediaType.APPLICATION_JSON).get(); assertEquals(200, response.getStatus()); - assertTrue(MediaType.APPLICATION_JSON_TYPE.isCompatible(response.getType())); - JSONObject entityJson = response.getEntity(JSONObject.class); + assertTrue(MediaType.APPLICATION_JSON_TYPE.isCompatible(response.getMediaType())); + String entityStr = response.readEntity(String.class); + JSONObject entityJson = new JSONObject(entityStr); TimelineEntity entity = convertJSONObjectToTimelineObject(entityJson, TimelineEntity.class); assertEquals(entity.getEntityType(), "TEZ_DAG_ID"); assertEquals(entity.getEvents().get(0).getEventType(), HistoryEventType.DAG_SUBMITTED.toString()); + response.close(); + client.close(); } private static final String atsHistoryACLManagerClassName = diff --git a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java index 451f281c5b..938a6f610b 100644 --- a/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java +++ b/tez-plugins/tez-yarn-timeline-history/src/test/java/org/apache/tez/dag/history/logging/ats/TestATSHistoryWithMiniCluster.java @@ -21,7 +21,11 @@ import java.io.IOException; import java.util.Random; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -40,10 +44,6 @@ import org.apache.tez.runtime.library.processor.SleepProcessor.SleepProcessorConfig; import org.apache.tez.tests.MiniTezClusterWithTimeline; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.WebResource; - import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -115,16 +115,18 @@ public static void tearDown() throws InterruptedException { // To be replaced after Timeline has java APIs for domains private K getTimelineData(String url, Class clazz) { - Client client = new Client(); - WebResource resource = client.resource(url); + Client client = ClientBuilder.newClient(); + WebTarget target = client.target(url); - ClientResponse response = resource.accept(MediaType.APPLICATION_JSON) - .get(ClientResponse.class); + Response response = target.request(MediaType.APPLICATION_JSON) + .get(); Assert.assertEquals(200, response.getStatus()); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + Assert.assertTrue(MediaType.APPLICATION_JSON_TYPE.isCompatible(response.getMediaType())); - K entity = response.getEntity(clazz); + K entity = response.readEntity(clazz); Assert.assertNotNull(entity); + response.close(); + client.close(); return entity; } diff --git a/tez-tools/analyzers/job-analyzer/src/main/java/org/apache/tez/analyzer/utils/Utils.java b/tez-tools/analyzers/job-analyzer/src/main/java/org/apache/tez/analyzer/utils/Utils.java index 4fb8ebb354..00aeba88f6 100644 --- a/tez-tools/analyzers/job-analyzer/src/main/java/org/apache/tez/analyzer/utils/Utils.java +++ b/tez-tools/analyzers/job-analyzer/src/main/java/org/apache/tez/analyzer/utils/Utils.java @@ -23,14 +23,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nullable; + import org.apache.tez.dag.utils.Graph; import org.apache.tez.history.parser.datamodel.AdditionalInputOutputDetails; import org.apache.tez.history.parser.datamodel.DagInfo; import org.apache.tez.history.parser.datamodel.EdgeInfo; import org.apache.tez.history.parser.datamodel.VertexInfo; -import com.sun.istack.Nullable; - public final class Utils { private static Pattern sanitizeLabelPattern = Pattern.compile("[:\\-\\W]+"); From e7da4ab57765d55a67f307694a073efd761d0da9 Mon Sep 17 00:00:00 2001 From: Laszlo Bodor Date: Tue, 16 Sep 2025 10:38:26 +0200 Subject: [PATCH 5/5] jupiter fixes --- pom.xml | 13 +++++++++++++ tez-plugins/tez-history-parser/pom.xml | 10 ++++++++++ .../tez-yarn-timeline-history-with-acls/pom.xml | 10 ++++++++++ tez-tools/analyzers/job-analyzer/pom.xml | 10 ++++++++++ 4 files changed, 43 insertions(+) diff --git a/pom.xml b/pom.xml index 5a110b28e1..4a91f354d3 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,7 @@ 1.5.4 3.0.0 4.13.2 + 5.9.3 1.8 1.0.0 3.1.1 @@ -764,6 +765,18 @@ ${junit.version} test + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit.jupiter.version} + test + com.google.protobuf protobuf-java diff --git a/tez-plugins/tez-history-parser/pom.xml b/tez-plugins/tez-history-parser/pom.xml index f5c597e5b0..17502c55d8 100644 --- a/tez-plugins/tez-history-parser/pom.xml +++ b/tez-plugins/tez-history-parser/pom.xml @@ -144,6 +144,16 @@ junit test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.vintage + junit-vintage-engine + test + org.glassfish.jersey.media jersey-media-json-jackson diff --git a/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml b/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml index 6a0da4f749..819e543519 100644 --- a/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml +++ b/tez-plugins/tez-yarn-timeline-history-with-acls/pom.xml @@ -134,6 +134,16 @@ junit test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.vintage + junit-vintage-engine + test + org.glassfish.jersey.media jersey-media-json-jackson diff --git a/tez-tools/analyzers/job-analyzer/pom.xml b/tez-tools/analyzers/job-analyzer/pom.xml index c072f3fba4..e9d199aadb 100644 --- a/tez-tools/analyzers/job-analyzer/pom.xml +++ b/tez-tools/analyzers/job-analyzer/pom.xml @@ -152,6 +152,16 @@ junit test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.vintage + junit-vintage-engine + test + org.glassfish.jersey.media jersey-media-json-jackson