Skip to content

Commit c264409

Browse files
committed
REMOVE-COMPATIBLE-HADOOP-VERSION
1 parent 89f9c5a commit c264409

File tree

4 files changed

+261
-277
lines changed

4 files changed

+261
-277
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/pom.xml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
<dependency>
9090
<groupId>org.apache.hadoop</groupId>
9191
<artifactId>hadoop-common</artifactId>
92-
<version>${hbase-compatible-hadoop.version}</version>
9392
<scope>test</scope>
9493
<exclusions>
9594
<exclusion>
@@ -104,10 +103,6 @@
104103
<groupId>org.apache.hadoop</groupId>
105104
<artifactId>hadoop-hdfs-client</artifactId>
106105
</exclusion>
107-
<exclusion>
108-
<groupId>com.sun.jersey</groupId>
109-
<artifactId>jersey-json</artifactId>
110-
</exclusion>
111106
</exclusions>
112107
</dependency>
113108

@@ -131,13 +126,22 @@
131126
<artifactId>junit-platform-launcher</artifactId>
132127
<scope>test</scope>
133128
</dependency>
129+
<dependency>
130+
<groupId>org.junit.vintage</groupId>
131+
<artifactId>junit-vintage-engine</artifactId>
132+
<scope>test</scope>
133+
</dependency>
134+
<dependency>
135+
<groupId>org.glassfish.jersey.core</groupId>
136+
<artifactId>jersey-server</artifactId>
137+
<scope>test</scope>
138+
</dependency>
134139

135140
<!-- 'mvn dependency:analyze' fails to detect use of this direct
136141
dependency -->
137142
<dependency>
138143
<groupId>org.apache.hadoop</groupId>
139144
<artifactId>hadoop-auth</artifactId>
140-
<version>${hbase-compatible-hadoop.version}</version>
141145
<scope>test</scope>
142146
<exclusions>
143147
<exclusion>
@@ -242,13 +246,6 @@
242246
<scope>runtime</scope>
243247
</dependency>
244248

245-
<dependency>
246-
<groupId>com.sun.jersey</groupId>
247-
<artifactId>jersey-client</artifactId>
248-
<version>1.19.4</version>
249-
<scope>test</scope>
250-
</dependency>
251-
252249
<dependency>
253250
<groupId>javax.ws.rs</groupId>
254251
<artifactId>jsr311-api</artifactId>
@@ -369,18 +366,13 @@
369366
<dependency>
370367
<groupId>org.apache.hadoop</groupId>
371368
<artifactId>hadoop-common</artifactId>
372-
<version>${hbase-compatible-hadoop.version}</version>
373369
<type>test-jar</type>
374370
<scope>test</scope>
375371
<exclusions>
376372
<exclusion>
377373
<groupId>org.apache.hadoop</groupId>
378374
<artifactId>hadoop-auth</artifactId>
379375
</exclusion>
380-
<exclusion>
381-
<groupId>com.sun.jersey</groupId>
382-
<artifactId>jersey-json</artifactId>
383-
</exclusion>
384376
<exclusion>
385377
<groupId>commons-logging</groupId>
386378
<artifactId>commons-logging</artifactId>
@@ -393,7 +385,6 @@
393385
<dependency>
394386
<groupId>org.apache.hadoop</groupId>
395387
<artifactId>hadoop-hdfs</artifactId>
396-
<version>${hbase-compatible-hadoop.version}</version>
397388
<scope>test</scope>
398389
<exclusions>
399390
<exclusion>
@@ -412,7 +403,6 @@
412403
<dependency>
413404
<groupId>org.apache.hadoop</groupId>
414405
<artifactId>hadoop-hdfs</artifactId>
415-
<version>${hbase-compatible-hadoop.version}</version>
416406
<type>test-jar</type>
417407
<scope>test</scope>
418408
<exclusions>
@@ -430,7 +420,6 @@
430420
<dependency>
431421
<groupId>org.apache.hadoop</groupId>
432422
<artifactId>hadoop-hdfs-client</artifactId>
433-
<version>${hbase-compatible-hadoop.version}</version>
434423
<scope>test</scope>
435424
</dependency>
436425

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice-hbase-tests/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/AbstractTimelineReaderHBaseTestBase.java

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,28 @@
2222
import static org.junit.Assert.assertNotNull;
2323
import static org.junit.Assert.assertTrue;
2424

25+
import javax.ws.rs.client.Client;
26+
import javax.ws.rs.client.ClientBuilder;
27+
2528
import java.io.IOException;
26-
import java.lang.reflect.UndeclaredThrowableException;
2729
import java.net.HttpURLConnection;
2830
import java.net.URI;
29-
import java.net.URL;
3031
import java.util.List;
3132

33+
import javax.ws.rs.core.GenericType;
3234
import javax.ws.rs.core.MediaType;
35+
import javax.ws.rs.core.Response;
3336

37+
import org.apache.hadoop.classification.VisibleForTesting;
3438
import org.apache.hadoop.conf.Configuration;
3539
import org.apache.hadoop.hbase.HBaseTestingUtility;
3640
import org.apache.hadoop.yarn.api.records.timelineservice.FlowActivityEntity;
3741
import org.apache.hadoop.yarn.conf.YarnConfiguration;
3842
import org.apache.hadoop.yarn.server.timelineservice.storage.DataGeneratorForTest;
39-
import org.apache.hadoop.yarn.webapp.YarnJacksonJaxbJsonProvider;
43+
import org.glassfish.jersey.client.ClientConfig;
44+
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
4045
import org.junit.Assert;
4146

42-
import com.sun.jersey.api.client.Client;
43-
import com.sun.jersey.api.client.ClientResponse;
44-
import com.sun.jersey.api.client.ClientResponse.Status;
45-
import com.sun.jersey.api.client.GenericType;
46-
import com.sun.jersey.api.client.config.ClientConfig;
47-
import com.sun.jersey.api.client.config.DefaultClientConfig;
48-
import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory;
49-
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
50-
5147
/**
5248
* Test Base for TimelineReaderServer HBase tests.
5349
*/
@@ -109,19 +105,17 @@ protected void addFilters(Configuration conf) {
109105
}
110106

111107
protected Client createClient() {
112-
ClientConfig cfg = new DefaultClientConfig();
113-
cfg.getClasses().add(YarnJacksonJaxbJsonProvider.class);
114-
return new Client(
115-
new URLConnectionClientHandler(new DummyURLConnectionFactory()), cfg);
108+
final ClientConfig cc = new ClientConfig();
109+
cc.connectorProvider(getHttpURLConnectionFactory());
110+
return ClientBuilder.newClient(cc);
116111
}
117112

118-
protected ClientResponse getResponse(Client client, URI uri)
113+
protected Response getResponse(Client client, URI uri)
119114
throws Exception {
120-
ClientResponse resp =
121-
client.resource(uri).accept(MediaType.APPLICATION_JSON)
122-
.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
115+
Response resp =
116+
client.target(uri).request(MediaType.APPLICATION_JSON).get();
123117
if (resp == null || resp.getStatusInfo()
124-
.getStatusCode() != ClientResponse.Status.OK.getStatusCode()) {
118+
.getStatusCode() != HttpURLConnection.HTTP_OK) {
125119
String msg = "";
126120
if (resp != null) {
127121
msg = String.valueOf(resp.getStatusInfo().getStatusCode());
@@ -132,39 +126,38 @@ protected ClientResponse getResponse(Client client, URI uri)
132126
return resp;
133127
}
134128

135-
protected void verifyHttpResponse(Client client, URI uri, Status status) {
136-
ClientResponse resp =
137-
client.resource(uri).accept(MediaType.APPLICATION_JSON)
138-
.type(MediaType.APPLICATION_JSON).get(ClientResponse.class);
129+
protected void verifyHttpResponse(Client client, URI uri, Response.Status status) {
130+
Response resp = client.target(uri).request(MediaType.APPLICATION_JSON).get();
139131
assertNotNull(resp);
140132
assertTrue("Response from server should have been " + status,
141-
resp.getStatusInfo().getStatusCode() == status.getStatusCode());
142-
System.out.println("Response is: " + resp.getEntity(String.class));
133+
resp.getStatusInfo().getStatusCode() == HttpURLConnection.HTTP_OK);
134+
System.out.println("Response is: " + resp.readEntity(String.class));
143135
}
144136

145137
protected List<FlowActivityEntity> verifyFlowEntites(Client client, URI uri,
146138
int noOfEntities) throws Exception {
147-
ClientResponse resp = getResponse(client, uri);
139+
Response resp = getResponse(client, uri);
148140
List<FlowActivityEntity> entities =
149-
resp.getEntity(new GenericType<List<FlowActivityEntity>>() {
141+
resp.readEntity(new GenericType<List<FlowActivityEntity>>() {
150142
});
151143
assertNotNull(entities);
152144
assertEquals(noOfEntities, entities.size());
153145
return entities;
154146
}
155147

156-
protected static class DummyURLConnectionFactory
157-
implements HttpURLConnectionFactory {
158-
159-
@Override
160-
public HttpURLConnection getHttpURLConnection(final URL url)
161-
throws IOException {
162-
try {
163-
return (HttpURLConnection) url.openConnection();
164-
} catch (UndeclaredThrowableException e) {
165-
throw new IOException(e.getCause());
166-
}
167-
}
148+
@VisibleForTesting
149+
protected HttpUrlConnectorProvider getHttpURLConnectionFactory() {
150+
return new HttpUrlConnectorProvider().connectionFactory(
151+
url -> {
152+
HttpURLConnection conn;
153+
try {
154+
HttpURLConnection.setFollowRedirects(false);
155+
conn = (HttpURLConnection) url.openConnection();
156+
} catch (Exception e) {
157+
throw new IOException(e);
158+
}
159+
return conn;
160+
});
168161
}
169162

170163
protected static HBaseTestingUtility getHBaseTestingUtility() {

0 commit comments

Comments
 (0)