http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js.gz ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js.gz b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js.gz deleted file mode 100644 index 2aac85f..0000000 Binary files a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/jt/jquery.jstree.js.gz and /dev/null differ
http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java index f37b01a..74623a4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/MyTestWebService.java @@ -27,12 +27,13 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import com.google.inject.Singleton; +import org.apache.hadoop.http.JettyUtils; @Singleton @Path("/ws/v1/test") public class MyTestWebService { @GET - @Produces({ MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public MyInfo get() { return new MyInfo(); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml index f772c77..1474c19 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/pom.xml @@ -38,7 +38,7 @@ <dependencies> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> </dependency> <!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <dependency> http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java index fd63787..6e6e98b 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/ApplicationHistoryServer.java @@ -56,8 +56,8 @@ import org.apache.hadoop.yarn.server.timeline.webapp.CrossOriginFilterInitialize import org.apache.hadoop.yarn.webapp.WebApp; import org.apache.hadoop.yarn.webapp.WebApps; import org.apache.hadoop.yarn.webapp.util.WebAppUtils; -import org.mortbay.jetty.servlet.FilterHolder; -import org.mortbay.jetty.webapp.WebAppContext; +import org.eclipse.jetty.servlet.FilterHolder; +import org.eclipse.jetty.webapp.WebAppContext; import com.google.common.annotations.VisibleForTesting; @@ -316,27 +316,31 @@ public class ApplicationHistoryServer extends CompositeService { YarnConfiguration.TIMELINE_SERVICE_UI_NAMES); WebAppContext webAppContext = httpServer.getWebAppContext(); - for (String name : names) { - String webPath = conf.get( - YarnConfiguration.TIMELINE_SERVICE_UI_WEB_PATH_PREFIX + name); - String onDiskPath = conf.get( - YarnConfiguration.TIMELINE_SERVICE_UI_ON_DISK_PATH_PREFIX + name); - WebAppContext uiWebAppContext = new WebAppContext(); - uiWebAppContext.setContextPath(webPath); - uiWebAppContext.setWar(onDiskPath); - final String[] ALL_URLS = { "/*" }; - FilterHolder[] filterHolders = - webAppContext.getServletHandler().getFilters(); - for (FilterHolder filterHolder: filterHolders) { - if (!"guice".equals(filterHolder.getName())) { - HttpServer2.defineFilter(uiWebAppContext, filterHolder.getName(), - filterHolder.getClassName(), filterHolder.getInitParameters(), - ALL_URLS); - } - } - LOG.info("Hosting " + name + " from " + onDiskPath + " at " + webPath); - httpServer.addContext(uiWebAppContext, true); - } + for (String name : names) { + String webPath = conf.get( + YarnConfiguration.TIMELINE_SERVICE_UI_WEB_PATH_PREFIX + name); + String onDiskPath = conf.get( + YarnConfiguration.TIMELINE_SERVICE_UI_ON_DISK_PATH_PREFIX + name); + WebAppContext uiWebAppContext = new WebAppContext(); + uiWebAppContext.setContextPath(webPath); + if (onDiskPath.endsWith(".war")) { + uiWebAppContext.setWar(onDiskPath); + } else { + uiWebAppContext.setResourceBase(onDiskPath); + } + final String[] ALL_URLS = {"/*"}; + FilterHolder[] filterHolders = + webAppContext.getServletHandler().getFilters(); + for (FilterHolder filterHolder : filterHolders) { + if (!"guice".equals(filterHolder.getName())) { + HttpServer2.defineFilter(uiWebAppContext, filterHolder.getName(), + filterHolder.getClassName(), filterHolder.getInitParameters(), + ALL_URLS); + } + } + LOG.info("Hosting " + name + " from " + onDiskPath + " at " + webPath); + httpServer.addHandlerAtFront(uiWebAppContext); + } httpServer.start(); conf.updateConnectAddr(YarnConfiguration.TIMELINE_SERVICE_BIND_HOST, YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS, http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java index 04fe7bc..ccc5ff9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/AHSWebServices.java @@ -46,6 +46,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.RemoteIterator; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; @@ -90,7 +91,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/about") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public TimelineAbout about( @Context HttpServletRequest req, @Context HttpServletResponse res) { @@ -99,7 +101,8 @@ public class AHSWebServices extends WebServices { } @GET - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public AppsInfo get(@Context HttpServletRequest req, @Context HttpServletResponse res) { return getApps(req, res, null, Collections.<String> emptySet(), null, null, @@ -108,7 +111,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppsInfo getApps(@Context HttpServletRequest req, @Context HttpServletResponse res, @QueryParam("state") String stateQuery, @@ -131,7 +135,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps/{appid}") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppInfo getApp(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("appid") String appId) { @@ -141,7 +146,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps/{appid}/appattempts") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppAttemptsInfo getAppAttempts(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("appid") String appId) { @@ -151,7 +157,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps/{appid}/appattempts/{appattemptid}") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public AppAttemptInfo getAppAttempt(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("appid") String appId, @@ -162,7 +169,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps/{appid}/appattempts/{appattemptid}/containers") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public ContainersInfo getContainers(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("appid") String appId, @@ -173,7 +181,8 @@ public class AHSWebServices extends WebServices { @GET @Path("/apps/{appid}/appattempts/{appattemptid}/containers/{containerid}") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) @Override public ContainerInfo getContainer(@Context HttpServletRequest req, @Context HttpServletResponse res, @PathParam("appid") String appId, @@ -206,7 +215,7 @@ public class AHSWebServices extends WebServices { @GET @Path("/containerlogs/{containerid}/{filename}") - @Produces({ MediaType.TEXT_PLAIN }) + @Produces({ MediaType.TEXT_PLAIN + "; " + JettyUtils.UTF_8 }) @Public @Unstable public Response getLogs(@Context HttpServletRequest req, http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/TimelineWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/TimelineWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/TimelineWebServices.java index 5c80132..d4acbe4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/TimelineWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/main/java/org/apache/hadoop/yarn/server/timeline/webapp/TimelineWebServices.java @@ -45,6 +45,7 @@ import javax.ws.rs.core.Response; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.yarn.api.records.timeline.TimelineDomain; @@ -86,7 +87,8 @@ public class TimelineWebServices { * Return the description of the timeline web services. */ @GET - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineAbout about( @Context HttpServletRequest req, @Context HttpServletResponse res) { @@ -99,7 +101,8 @@ public class TimelineWebServices { */ @GET @Path("/{entityType}") - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineEntities getEntities( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -142,7 +145,8 @@ public class TimelineWebServices { */ @GET @Path("/{entityType}/{entityId}") - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineEntity getEntity( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -177,7 +181,8 @@ public class TimelineWebServices { */ @GET @Path("/{entityType}/events") - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineEvents getEvents( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -214,6 +219,8 @@ public class TimelineWebServices { */ @POST @Consumes({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelinePutResponse postEntities( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -243,6 +250,8 @@ public class TimelineWebServices { @PUT @Path("/domain") @Consumes({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelinePutResponse putDomain( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -274,7 +283,8 @@ public class TimelineWebServices { */ @GET @Path("/domain/{domainId}") - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineDomain getDomain( @Context HttpServletRequest req, @Context HttpServletResponse res, @@ -305,7 +315,8 @@ public class TimelineWebServices { */ @GET @Path("/domain") - @Produces({ MediaType.APPLICATION_JSON /* , MediaType.APPLICATION_XML */}) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 + /* , MediaType.APPLICATION_XML */}) public TimelineDomains getDomains( @Context HttpServletRequest req, @Context HttpServletResponse res, http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java index 4940c50..c575e70 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java @@ -43,6 +43,7 @@ import javax.ws.rs.core.MediaType; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.security.authentication.server.AuthenticationFilter; import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler; @@ -314,7 +315,8 @@ public class TestAHSWebServices extends JerseyTestBase { .path("ws").path("v1").path("applicationhistory").path("about") .queryParam("user.name", USERS[round]) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineAbout actualAbout = response.getEntity(TimelineAbout.class); TimelineAbout expectedAbout = TimelineUtils.createTimelineAbout("Generic History Service API"); @@ -343,7 +345,8 @@ public class TestAHSWebServices extends JerseyTestBase { .queryParam("state", YarnApplicationState.FINISHED.toString()) .queryParam("user.name", USERS[round]) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject apps = json.getJSONObject("apps"); @@ -362,7 +365,8 @@ public class TestAHSWebServices extends JerseyTestBase { .queryParam("user.name", USERS[round]) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject app = json.getJSONObject("app"); @@ -391,7 +395,8 @@ public class TestAHSWebServices extends JerseyTestBase { assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); return; } - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject appAttempts = json.getJSONObject("appAttempts"); @@ -417,7 +422,8 @@ public class TestAHSWebServices extends JerseyTestBase { assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); return; } - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject appAttempt = json.getJSONObject("appAttempt"); @@ -446,7 +452,8 @@ public class TestAHSWebServices extends JerseyTestBase { assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); return; } - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject containers = json.getJSONObject("containers"); @@ -474,7 +481,8 @@ public class TestAHSWebServices extends JerseyTestBase { assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); return; } - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("incorrect number of elements", 1, json.length()); JSONObject container = json.getJSONObject("container"); http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java index 956e9e9..ab5d7ae 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/TestRollingLevelDBTimelineStore.java @@ -42,7 +42,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mortbay.log.Log; +import org.eclipse.jetty.util.log.Log; /** Test class to verify RollingLevelDBTimelineStore. */ @InterfaceAudience.Private @@ -368,7 +368,7 @@ public class TestRollingLevelDBTimelineStore extends TimelineStoreTestUtils { long start = System.currentTimeMillis(); int num = 1000000; - Log.info("Start test for " + num); + Log.getLog().info("Start test for " + num); final String tezTaskAttemptId = "TEZ_TA"; final String tezEntityId = "attempt_1429158534256_0001_1_00_000000_"; @@ -414,7 +414,7 @@ public class TestRollingLevelDBTimelineStore extends TimelineStoreTestUtils { } long duration = System.currentTimeMillis() - start; - Log.info("Duration for " + num + ": " + duration); + Log.getLog().info("Duration for " + num + ": " + duration); } public static void main(String[] args) throws Exception { http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestTimelineWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestTimelineWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestTimelineWebServices.java index 6fd39dc..80d801d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestTimelineWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/timeline/webapp/TestTimelineWebServices.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response.Status; import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.security.authentication.server.AuthenticationFilter; import org.apache.hadoop.security.authentication.server.PseudoAuthenticationHandler; import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticationHandler; @@ -120,7 +121,7 @@ public class TestTimelineWebServices extends JerseyTestBase { PseudoAuthenticationHandler.ANONYMOUS_ALLOWED)).thenReturn("true"); ServletContext context = mock(ServletContext.class); when(filterConfig.getServletContext()).thenReturn(context); - Enumeration<Object> names = mock(Enumeration.class); + Enumeration<String> names = mock(Enumeration.class); when(names.hasMoreElements()).thenReturn(true, true, true, false); when(names.nextElement()).thenReturn( AuthenticationFilter.AUTH_TYPE, @@ -187,7 +188,8 @@ public class TestTimelineWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("timeline") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineAbout actualAbout = response.getEntity(TimelineAbout.class); TimelineAbout expectedAbout = TimelineUtils.createTimelineAbout("Timeline API"); @@ -244,7 +246,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -255,7 +258,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("fromId", "id_2") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertEquals(2, response.getEntity(TimelineEntities.class).getEntities() .size()); @@ -263,7 +267,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("fromId", "id_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertEquals(3, response.getEntity(TimelineEntities.class).getEntities() .size()); } @@ -275,7 +280,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("fromTs", Long.toString(beforeTime)) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertEquals(0, response.getEntity(TimelineEntities.class).getEntities() .size()); @@ -284,7 +290,8 @@ public class TestTimelineWebServices extends JerseyTestBase { System.currentTimeMillis())) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertEquals(3, response.getEntity(TimelineEntities.class).getEntities() .size()); } @@ -296,7 +303,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("primaryFilter", "user:username") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -308,7 +316,8 @@ public class TestTimelineWebServices extends JerseyTestBase { "appname:" + Integer.toString(Integer.MAX_VALUE)) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -320,7 +329,8 @@ public class TestTimelineWebServices extends JerseyTestBase { "long:" + Long.toString((long) Integer.MAX_VALUE + 1l)) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -333,7 +343,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("primaryFilter", "other:123abc") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertEquals(0, response.getEntity(TimelineEntities.class).getEntities() .size()); } @@ -345,7 +356,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").queryParam("primaryFilter", "other:\"123abc\"") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -358,7 +370,8 @@ public class TestTimelineWebServices extends JerseyTestBase { "user:username,appname:" + Integer.toString(Integer.MAX_VALUE)) .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); verifyEntities(response.getEntity(TimelineEntities.class)); } @@ -369,7 +382,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").path("id_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineEntity entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("id_1", entity.getEntityId()); @@ -387,7 +401,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("type_1").path("id_1").queryParam("fields", "events,otherinfo") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineEntity entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("id_1", entity.getEntityId()); @@ -406,7 +421,8 @@ public class TestTimelineWebServices extends JerseyTestBase { "primaryfilters,relatedentities") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineEntity entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("id_1", entity.getEntityId()); @@ -425,7 +441,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("entityId", "id_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineEvents events = response.getEntity(TimelineEvents.class); Assert.assertNotNull(events); Assert.assertEquals(1, events.getAllEvents().size()); @@ -479,7 +496,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); response = r.path("ws").path("v1").path("timeline") @@ -487,7 +505,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResposne = response.getEntity(TimelinePutResponse.class); Assert.assertNotNull(putResposne); @@ -497,7 +516,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("test type 1").path("test id 1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("test id 1", entity.getEntityId()); @@ -520,7 +540,8 @@ public class TestTimelineWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("timeline") .queryParam("user.name", "tester").accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON).post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); } @@ -542,7 +563,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertNotNull(putResponse); @@ -554,7 +576,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertNotNull(putResponse); Assert.assertEquals(1, putResponse.getErrors().size()); @@ -577,7 +600,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertNotNull(putResponse); Assert.assertEquals(1, putResponse.getErrors().size()); @@ -591,7 +615,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "reader_user_3") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("test id 3", entity.getEntityId()); @@ -618,7 +643,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResposne = response.getEntity(TimelinePutResponse.class); Assert.assertNotNull(putResposne); @@ -629,7 +655,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "any_body_2") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNotNull(entity); Assert.assertEquals("test id 7", entity.getEntityId()); @@ -659,7 +686,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertEquals(0, putResponse.getErrors().size()); @@ -670,7 +698,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "reader_user_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNull(entity.getPrimaryFilters().get( TimelineStore.SystemFilter.ENTITY_OWNER.toString())); @@ -681,7 +710,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "reader_user_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNull(entity.getPrimaryFilters().get( TimelineStore.SystemFilter.ENTITY_OWNER.toString())); @@ -692,7 +722,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "reader_user_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entity = response.getEntity(TimelineEntity.class); Assert.assertNull(entity.getPrimaryFilters().get( TimelineStore.SystemFilter.ENTITY_OWNER.toString())); @@ -703,7 +734,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "reader_user_2") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo()); } finally { timelineACLsManager.setAdminACLsManager(oldAdminACLsManager); @@ -729,7 +761,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertEquals(0, putResponse.getErrors().size()); @@ -748,7 +781,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertEquals(0, putResponse.getErrors().size()); @@ -758,7 +792,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("test type 4") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); entities = response.getEntity(TimelineEntities.class); // Reader 1 should just have the access to entity [4, 4] assertEquals(1, entities.getEntities().size()); @@ -792,7 +827,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelinePutResponse putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertEquals(0, putResponse.getErrors().size()); @@ -815,7 +851,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .post(ClientResponse.class, entities); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); putResponse = response.getEntity(TimelinePutResponse.class); Assert.assertEquals(0, putResponse.getErrors().size()); @@ -826,7 +863,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("entityId", "test id 5,test id 6") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineEvents events = response.getEntity(TimelineEvents.class); // Reader 1 should just have the access to the events of entity [5, 5] assertEquals(1, events.getAllEvents().size()); @@ -843,7 +881,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("domain").path("domain_id_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineDomain domain = response.getEntity(TimelineDomain.class); verifyDomain(domain, "domain_id_1"); } @@ -859,7 +898,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "owner_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineDomain domain = response.getEntity(TimelineDomain.class); verifyDomain(domain, "domain_id_1"); @@ -868,7 +908,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "tester") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo()); } finally { timelineACLsManager.setAdminACLsManager(oldAdminACLsManager); @@ -883,7 +924,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("owner", "owner_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineDomains domains = response.getEntity(TimelineDomains.class); Assert.assertEquals(2, domains.getDomains().size()); for (int i = 0; i < domains.getDomains().size(); ++i) { @@ -903,7 +945,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "owner_1") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); TimelineDomains domains = response.getEntity(TimelineDomains.class); Assert.assertEquals(2, domains.getDomains().size()); for (int i = 0; i < domains.getDomains().size(); ++i) { @@ -917,7 +960,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .queryParam("user.name", "tester") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); domains = response.getEntity(TimelineDomains.class); Assert.assertEquals(0, domains.getDomains().size()); } finally { @@ -936,7 +980,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .accept(MediaType.APPLICATION_JSON) .type(MediaType.APPLICATION_JSON) .put(ClientResponse.class, domain); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); assertResponseStatusCode(Status.FORBIDDEN, response.getStatusInfo()); response = r.path("ws").path("v1") @@ -952,7 +997,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("domain").path("test_domain_id") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); domain = response.getEntity(TimelineDomain.class); Assert.assertNotNull(domain); Assert.assertEquals("test_domain_id", domain.getId()); @@ -974,7 +1020,8 @@ public class TestTimelineWebServices extends JerseyTestBase { .path("domain").path("test_domain_id") .accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - Assert.assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); domain = response.getEntity(TimelineDomain.class); Assert.assertNotNull(domain); Assert.assertEquals("test_domain_id", domain.getId()); http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml index f10fa08..6fbe39e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/pom.xml @@ -66,7 +66,7 @@ </dependency> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> </dependency> <dependency> <groupId>commons-codec</groupId> @@ -81,7 +81,7 @@ <artifactId>jersey-client</artifactId> </dependency> <dependency> - <groupId>org.mortbay.jetty</groupId> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</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-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java index afbf0d4..a32f06f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java @@ -40,6 +40,7 @@ import javax.ws.rs.core.UriInfo; import org.apache.commons.io.IOUtils; import org.apache.hadoop.classification.InterfaceAudience.Public; import org.apache.hadoop.classification.InterfaceStability.Unstable; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.exceptions.YarnException; @@ -95,14 +96,16 @@ public class NMWebServices { } @GET - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public NodeInfo get() { return getNodeInfo(); } @GET @Path("/info") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public NodeInfo getNodeInfo() { init(); return new NodeInfo(this.nmContext, this.rview); @@ -110,7 +113,8 @@ public class NMWebServices { @GET @Path("/apps") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public AppsInfo getNodeApps(@QueryParam("state") String stateQuery, @QueryParam("user") String userQuery) { init(); @@ -141,7 +145,8 @@ public class NMWebServices { @GET @Path("/apps/{appid}") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public AppInfo getNodeApp(@PathParam("appid") String appId) { init(); ApplicationId id = WebAppUtils.parseApplicationId(recordFactory, appId); @@ -155,7 +160,8 @@ public class NMWebServices { @GET @Path("/containers") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public ContainersInfo getNodeContainers(@javax.ws.rs.core.Context HttpServletRequest hsr) { init(); @@ -175,7 +181,8 @@ public class NMWebServices { @GET @Path("/containers/{containerid}") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public ContainerInfo getNodeContainer(@javax.ws.rs.core.Context HttpServletRequest hsr, @PathParam("containerid") String id) { ContainerId containerId = null; @@ -207,7 +214,8 @@ public class NMWebServices { */ @GET @Path("/containers/{containerid}/logs") - @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + @Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 }) public ContainerLogsInfo getContainerLogsInfo(@javax.ws.rs.core.Context HttpServletRequest hsr, @PathParam("containerid") String containerIdStr) { @@ -246,7 +254,7 @@ public class NMWebServices { */ @GET @Path("/containers/{containerid}/logs/{filename}") - @Produces({ MediaType.TEXT_PLAIN }) + @Produces({ MediaType.TEXT_PLAIN + "; " + JettyUtils.UTF_8 }) @Public @Unstable public Response getContainerLogFile( @@ -277,7 +285,7 @@ public class NMWebServices { */ @GET @Path("/containerlogs/{containerid}/{filename}") - @Produces({ MediaType.TEXT_PLAIN }) + @Produces({ MediaType.TEXT_PLAIN + "; " + JettyUtils.UTF_8 }) @Public @Unstable public Response getLogs(@PathParam("containerid") String containerIdStr, @@ -363,7 +371,7 @@ public class NMWebServices { } }; ResponseBuilder resp = Response.ok(stream); - resp.header("Content-Type", contentType); + resp.header("Content-Type", contentType + "; " + JettyUtils.UTF_8); // Sending the X-Content-Type-Options response header with the value // nosniff will prevent Internet Explorer from MIME-sniffing a response // away from the declared content-type. http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java index 2ccf827..f02e306 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/amrmproxy/MockResourceManagerFacade.java @@ -113,7 +113,7 @@ import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.security.AMRMTokenIdentifier; import org.apache.hadoop.yarn.util.Records; import org.junit.Assert; -import org.mortbay.log.Log; +import org.eclipse.jetty.util.log.Log; /** * Mock Resource Manager facade implementation that exposes all the methods @@ -156,7 +156,7 @@ public class MockResourceManagerFacade implements RegisterApplicationMasterRequest request) throws YarnException, IOException { String amrmToken = getAppIdentifier(); - Log.info("Registering application attempt: " + amrmToken); + Log.getLog().info("Registering application attempt: " + amrmToken); synchronized (applicationContainerIdMap) { Assert.assertFalse("The application id is already registered: " @@ -175,7 +175,7 @@ public class MockResourceManagerFacade implements FinishApplicationMasterRequest request) throws YarnException, IOException { String amrmToken = getAppIdentifier(); - Log.info("Finishing application attempt: " + amrmToken); + Log.getLog().info("Finishing application attempt: " + amrmToken); synchronized (applicationContainerIdMap) { // Remove the containers that were being tracked for this application @@ -252,7 +252,8 @@ public class MockResourceManagerFacade implements if (request.getReleaseList() != null && request.getReleaseList().size() > 0) { - Log.info("Releasing containers: " + request.getReleaseList().size()); + Log.getLog().info("Releasing containers: " + + request.getReleaseList().size()); synchronized (applicationContainerIdMap) { Assert.assertTrue( "The application id is not registered before allocate(): " @@ -292,7 +293,7 @@ public class MockResourceManagerFacade implements } } - Log.info("Allocating containers: " + containerList.size() + Log.getLog().info("Allocating containers: " + containerList.size() + " for application attempt: " + conf.get("AMRMTOKEN")); return AllocateResponse.newInstance(0, new ArrayList<ContainerStatus>(), containerList, http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java index b9d18a3..e7330aa 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/logaggregation/TestLogAggregationService.java @@ -132,7 +132,7 @@ import org.junit.Assert; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; -import org.mortbay.util.MultiException; +import org.eclipse.jetty.util.MultiException; import com.google.common.base.Supplier; http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java index 80ccf53..49e410e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.yarn.webapp.GuiceServletConfig; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileUtil; @@ -233,7 +234,8 @@ public class TestNMWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -244,7 +246,8 @@ public class TestNMWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node/") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -256,7 +259,8 @@ public class TestNMWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -266,7 +270,8 @@ public class TestNMWebServices extends JerseyTestBase { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("node").path("info") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -277,7 +282,8 @@ public class TestNMWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .path("info/").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -288,7 +294,8 @@ public class TestNMWebServices extends JerseyTestBase { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("node").path("info") .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeInfo(json); } @@ -299,7 +306,8 @@ public class TestNMWebServices extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .path("info/").accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML+ "; " + JettyUtils.UTF_8, + response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -400,7 +408,7 @@ public class TestNMWebServices extends JerseyTestBase { .queryParam("size", "-10000") .accept(MediaType.TEXT_PLAIN).get(ClientResponse.class); responseText = response.getEntity(String.class); - assertEquals("text/plain", response.getType().toString()); + assertEquals("text/plain; charset=utf-8", response.getType().toString()); assertEquals(fullTextSize, responseText.getBytes().length); assertEquals(logMessage, responseText); @@ -411,7 +419,8 @@ public class TestNMWebServices extends JerseyTestBase { responseText = response.getEntity(String.class); assertEquals(logMessage, responseText); assertEquals(200, response.getStatus()); - assertEquals("application/octet-stream", response.getType().toString()); + assertEquals("application/octet-stream; charset=utf-8", + response.getType().toString()); // specify a invalid format value response = r.path(filename) http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java index 3b7694a..6316282 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesApps.java @@ -34,6 +34,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileUtil; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -182,7 +183,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { WebResource r = resource(); ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("apps isn't empty", new JSONObject().toString(), json.get("apps").toString()); @@ -241,7 +243,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path(path) .accept(media).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); JSONObject info = json.getJSONObject("apps"); assertEquals("incorrect number of elements", 1, info.length()); @@ -270,7 +273,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .queryParam("user", "mockUser").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); JSONObject info = json.getJSONObject("apps"); @@ -293,7 +297,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .queryParam("user", "george").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("apps is not empty", new JSONObject().toString(), json.get("apps").toString()); @@ -317,7 +322,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -351,7 +357,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { .queryParam("state", ApplicationState.RUNNING.toString()) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); JSONObject info = json.getJSONObject("apps"); @@ -375,7 +382,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .queryParam("state", ApplicationState.INITING.toString()) .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("apps is not empty", @@ -401,7 +409,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -431,7 +440,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -462,7 +472,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); String msg = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -517,7 +528,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .path(app.getAppId().toString()).accept(media) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeAppInfo(json.getJSONObject("app"), app, hash); } @@ -535,7 +547,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { .path(app.getAppId().toString() + "/") .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeAppInfo(json.getJSONObject("app"), app, hash); } @@ -557,7 +570,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { } catch (UniformInterfaceException ue) { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -594,7 +608,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { } catch (UniformInterfaceException ue) { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -623,7 +638,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .accept(MediaType.APPLICATION_XML).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -647,7 +663,8 @@ public class TestNMWebServicesApps extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path("apps") .path(app.getAppId().toString() + "/") .accept(MediaType.APPLICATION_XML).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesContainers.java ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesContainers.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesContainers.java index 06a3995..36acfe0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesContainers.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServicesContainers.java @@ -39,6 +39,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import com.sun.jersey.api.client.filter.LoggingFilter; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileUtil; +import org.apache.hadoop.http.JettyUtils; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ContainerId; import org.apache.hadoop.yarn.api.records.NodeId; @@ -194,7 +195,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .path("containers").accept(MediaType.APPLICATION_JSON) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); assertEquals("apps isn't empty", new JSONObject().toString(), json.get("containers").toString()); @@ -269,7 +271,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node").path(path) .accept(media).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); JSONObject info = json.getJSONObject("containers"); assertEquals("incorrect number of elements", 1, info.length()); @@ -313,7 +316,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { for (String id : hash.keySet()) { ClientResponse response = r.path("ws").path("v1").path("node") .path("containers").path(id).accept(media).get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject json = response.getEntity(JSONObject.class); verifyNodeContainerInfo(json.getJSONObject("container"), nmContext .getContainers().get(ContainerId.fromString(id))); @@ -337,7 +341,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { } catch (UniformInterfaceException ue) { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -371,7 +376,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { } catch (UniformInterfaceException ue) { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.BAD_REQUEST, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -405,7 +411,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { } catch (UniformInterfaceException ue) { ClientResponse response = ue.getResponse(); assertResponseStatusCode(Status.NOT_FOUND, response.getStatusInfo()); - assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); JSONObject msg = response.getEntity(JSONObject.class); JSONObject exception = msg.getJSONObject("RemoteException"); assertEquals("incorrect number of elements", 3, exception.length()); @@ -439,7 +446,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .path("containers").path(id).accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -467,7 +475,8 @@ public class TestNMWebServicesContainers extends JerseyTestBase { ClientResponse response = r.path("ws").path("v1").path("node") .path("containers").accept(MediaType.APPLICATION_XML) .get(ClientResponse.class); - assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType()); + assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); String xml = response.getEntity(String.class); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); http://git-wip-us.apache.org/repos/asf/hadoop/blob/5877f20f/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml index 56fb075..8e83a15 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/pom.xml @@ -35,7 +35,7 @@ <dependencies> <dependency> <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> + <artifactId>javax.servlet-api</artifactId> </dependency> <!-- 'mvn dependency:analyze' fails to detect use of this dependency --> <dependency> @@ -143,10 +143,14 @@ <artifactId>jersey-client</artifactId> </dependency> <dependency> - <groupId>org.mortbay.jetty</groupId> + <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-util</artifactId> </dependency> <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-util-ajax</artifactId> + </dependency> + <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> </dependency> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
