http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServices.java index a2a9c28..4bd37f8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServices.java @@ -35,6 +35,7 @@ import javax.ws.rs.core.MediaType; import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.yarn.api.records.timeline.TimelineAbout; import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity; import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType; @@ -184,7 +185,8 @@ public class TestTimelineReaderWebServices { "timeline/clusters/cluster1/apps/app1/entities/app/id_1"); ClientResponse resp = getResponse(client, uri); TimelineEntity entity = resp.getEntity(TimelineEntity.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entity); assertEquals("id_1", entity.getId()); assertEquals("app", entity.getType()); @@ -207,7 +209,8 @@ public class TestTimelineReaderWebServices { "userid=user1&flowname=flow1&flowrunid=1"); ClientResponse resp = getResponse(client, uri); TimelineEntity entity = resp.getEntity(TimelineEntity.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entity); assertEquals("id_1", entity.getId()); assertEquals("app", entity.getType()); @@ -227,7 +230,8 @@ public class TestTimelineReaderWebServices { "fields=CONFIGS,Metrics,info"); ClientResponse resp = getResponse(client, uri); TimelineEntity entity = resp.getEntity(TimelineEntity.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entity); assertEquals("id_1", entity.getId()); assertEquals("app", entity.getType()); @@ -253,7 +257,8 @@ public class TestTimelineReaderWebServices { "fields=ALL"); ClientResponse resp = getResponse(client, uri); TimelineEntity entity = resp.getEntity(TimelineEntity.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entity); assertEquals("id_1", entity.getId()); assertEquals("app", entity.getType()); @@ -289,7 +294,8 @@ public class TestTimelineReaderWebServices { "timeline/apps/app1/entities/app/id_1"); ClientResponse resp = getResponse(client, uri); TimelineEntity entity = resp.getEntity(TimelineEntity.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entity); assertEquals("id_1", entity.getId()); assertEquals("app", entity.getType()); @@ -299,7 +305,8 @@ public class TestTimelineReaderWebServices { resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(4, entities.size()); } finally { @@ -316,7 +323,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(4, entities.size()); assertTrue("Entities id_1, id_2, id_3 and id_4 should have been" + @@ -339,7 +347,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(2, entities.size()); // Entities returned are based on most recent created time. @@ -352,7 +361,8 @@ public class TestTimelineReaderWebServices { "clusters/cluster1/apps/app1/entities/app?limit=3"); resp = getResponse(client, uri); entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); // Even though 2 entities out of 4 have same created time, one entity // is left out due to limit @@ -372,7 +382,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_4 should have been present in response.", @@ -383,7 +394,8 @@ public class TestTimelineReaderWebServices { "=1425016502010"); resp = getResponse(client, uri); entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(3, entities.size()); assertFalse("Entity with id_4 should not have been present in response.", @@ -394,7 +406,8 @@ public class TestTimelineReaderWebServices { "1425016502010"); resp = getResponse(client, uri); entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_4 should have been present in response.", @@ -414,7 +427,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_1 should have been present in response.", @@ -425,7 +439,8 @@ public class TestTimelineReaderWebServices { "type1:tid1_2,type2:tid2_1%60"); resp = getResponse(client, uri); entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_1 should have been present in response.", @@ -436,7 +451,8 @@ public class TestTimelineReaderWebServices { "type1:tid1_1:tid1_2,type2:tid2_1%60"); resp = getResponse(client, uri); entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_1 should have been present in response.", @@ -456,7 +472,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_3 should have been present in response.", @@ -476,7 +493,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_3 should have been present in response.", @@ -496,7 +514,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(2, entities.size()); assertTrue("Entities with id_1 and id_2 should have been present" + @@ -518,7 +537,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(1, entities.size()); assertTrue("Entity with id_3 should have been present in response.", @@ -541,7 +561,8 @@ public class TestTimelineReaderWebServices { ClientResponse resp = getResponse(client, uri); Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>(){}); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); assertEquals(0, entities.size()); } finally { @@ -580,7 +601,8 @@ public class TestTimelineReaderWebServices { Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() { }); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); int totalEntities = entities.size(); assertEquals(2, totalEntities); @@ -633,7 +655,8 @@ public class TestTimelineReaderWebServices { TimelineEntity entities1 = resp.getEntity(new GenericType<TimelineEntity>() { }); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities1); uri = URI.create("http://localhost:" + serverPort + "/ws/v2/" @@ -663,7 +686,8 @@ public class TestTimelineReaderWebServices { Set<TimelineEntity> entities = resp.getEntity(new GenericType<Set<TimelineEntity>>() { }); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities); int totalEntities = entities.size(); assertEquals(3, totalEntities); @@ -734,7 +758,8 @@ public class TestTimelineReaderWebServices { TimelineEntity entities1 = resp.getEntity(new GenericType<TimelineEntity>() { }); - assertEquals(MediaType.APPLICATION_JSON_TYPE, resp.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + resp.getType().toString()); assertNotNull(entities1); uri = URI.create("http://localhost:" + serverPort + "/ws/v2/"
http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml index 844d8d9..cb9759b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml @@ -35,7 +35,7 @@ <dependencies> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> <scope>compile</scope> </dependency> <!-- 'mvn dependency:analyze' fails to detect use of this dependency --> @@ -87,8 +87,8 @@ <artifactId>commons-logging</artifactId> </dependency> <dependency> - <groupId>org.mortbay.jetty</groupId> - <artifactId>jetty</artifactId> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java index 7236982..fc97387 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/test/java/org/apache/hadoop/yarn/server/webproxy/TestWebAppProxyServlet.java @@ -55,12 +55,14 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.ApplicationNotFoundException; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.webapp.util.WebAppUtils; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.servlet.Context; -import org.mortbay.jetty.servlet.ServletHolder; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,13 +88,14 @@ public class TestWebAppProxyServlet { @BeforeClass public static void start() throws Exception { server = new Server(0); - Context context = new Context(); + ((QueuedThreadPool)server.getThreadPool()).setMaxThreads(10); + ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/foo"); server.setHandler(context); context.addServlet(new ServletHolder(TestServlet.class), "/bar"); - server.getConnectors()[0].setHost("localhost"); + ((ServerConnector)server.getConnectors()[0]).setHost("localhost"); server.start(); - originalPort = server.getConnectors()[0].getLocalPort(); + originalPort = ((ServerConnector)server.getConnectors()[0]).getLocalPort(); LOG.info("Running embedded servlet container at: http://localhost:" + originalPort); // This property needs to be set otherwise CORS Headers will be dropped @@ -140,12 +143,12 @@ public class TestWebAppProxyServlet { @Test(timeout=5000) public void testWebAppProxyServlet() throws Exception { configuration.set(YarnConfiguration.PROXY_ADDRESS, "localhost:9090"); - // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS - configuration.setInt("hadoop.http.max.threads", 5); + // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS + configuration.setInt("hadoop.http.max.threads", 10); WebAppProxyServerForTest proxy = new WebAppProxyServerForTest(); proxy.init(configuration); proxy.start(); - + int proxyPort = proxy.proxy.proxyServer.getConnectorAddress(0).getPort(); AppReportFetcherForTest appReportFetcher = proxy.proxy.appReportFetcher; @@ -252,7 +255,7 @@ public class TestWebAppProxyServlet { public void testAppReportForEmptyTrackingUrl() throws Exception { configuration.set(YarnConfiguration.PROXY_ADDRESS, "localhost:9090"); // overriding num of web server threads, see HttpServer.HTTP_MAXTHREADS - configuration.setInt("hadoop.http.max.threads", 5); + configuration.setInt("hadoop.http.max.threads", 10); WebAppProxyServerForTest proxy = new WebAppProxyServerForTest(); proxy.init(configuration); proxy.start(); @@ -310,7 +313,7 @@ public class TestWebAppProxyServlet { public void testWebAppProxyPassThroughHeaders() throws Exception { Configuration configuration = new Configuration(); configuration.set(YarnConfiguration.PROXY_ADDRESS, "localhost:9091"); - configuration.setInt("hadoop.http.max.threads", 5); + configuration.setInt("hadoop.http.max.threads", 10); WebAppProxyServerForTest proxy = new WebAppProxyServerForTest(); proxy.init(configuration); proxy.start(); @@ -390,14 +393,14 @@ public class TestWebAppProxyServlet { return new String(data.toByteArray(), "UTF-8"); } - private boolean isResponseCookiePresent(HttpURLConnection proxyConn, + private boolean isResponseCookiePresent(HttpURLConnection proxyConn, String expectedName, String expectedValue) { Map<String, List<String>> headerFields = proxyConn.getHeaderFields(); List<String> cookiesHeader = headerFields.get("Set-Cookie"); if (cookiesHeader != null) { for (String cookie : cookiesHeader) { HttpCookie c = HttpCookie.parse(cookie).get(0); - if (c.getName().equals(expectedName) + if (c.getName().equals(expectedName) && c.getValue().equals(expectedValue)) { return true; } @@ -437,7 +440,7 @@ public class TestWebAppProxyServlet { } private class WebAppProxyForTest extends WebAppProxy { - + HttpServer2 proxyServer; AppReportFetcherForTest appReportFetcher; @@ -447,7 +450,7 @@ public class TestWebAppProxyServlet { String bindAddress = conf.get(YarnConfiguration.PROXY_ADDRESS); bindAddress = StringUtils.split(bindAddress, ':')[0]; AccessControlList acl = new AccessControlList( - conf.get(YarnConfiguration.YARN_ADMIN_ACL, + conf.get(YarnConfiguration.YARN_ADMIN_ACL, YarnConfiguration.DEFAULT_YARN_ADMIN_ACL)); proxyServer = new HttpServer2.Builder() .setName("proxy") @@ -464,11 +467,11 @@ public class TestWebAppProxyServlet { proxyServer.setAttribute(FETCHER_ATTRIBUTE, appReportFetcher ); proxyServer.setAttribute(IS_SECURITY_ENABLED_ATTRIBUTE, Boolean.TRUE); - + String proxy = WebAppUtils.getProxyHostAndPort(conf); String[] proxyParts = proxy.split(":"); String proxyHost = proxyParts[0]; - + proxyServer.setAttribute(PROXY_HOST_ATTRIBUTE, proxyHost); proxyServer.start(); LOG.info("Proxy server is started at port {}", @@ -479,7 +482,7 @@ public class TestWebAppProxyServlet { private class AppReportFetcherForTest extends AppReportFetcher { int answer = 0; - + public AppReportFetcherForTest(Configuration conf) { super(conf); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 860c2d7..0bdef7b 100644 --- a/pom.xml +++ b/pom.xml @@ -372,8 +372,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs <exclude>.gitignore</exclude> <exclude>.git/**</exclude> <exclude>.idea/**</exclude> - <exclude>**/build/**</exclude> + <exclude>**/build/**</exclude> <exclude>**/patchprocess/**</exclude> + <exclude>**/*.js</exclude> </excludes> </configuration> </plugin> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
