|
@@ -22,8 +22,6 @@ import com.google.inject.Guice;
|
|
|
import com.google.inject.servlet.ServletModule;
|
|
|
import com.sun.jersey.api.client.ClientResponse;
|
|
|
import com.sun.jersey.api.client.WebResource;
|
|
|
-import com.sun.jersey.api.json.JSONJAXBContext;
|
|
|
-import com.sun.jersey.api.json.JSONMarshaller;
|
|
|
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
|
|
import com.sun.jersey.test.framework.WebAppDescriptor;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
@@ -35,11 +33,12 @@ import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
|
|
|
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.QueueConfigInfo;
|
|
|
-import org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.SchedConfUpdateInfo;
|
|
|
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
|
|
|
import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
|
|
|
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
|
|
|
+import org.apache.hadoop.yarn.webapp.dao.QueueConfigInfo;
|
|
|
+import org.apache.hadoop.yarn.webapp.dao.SchedConfUpdateInfo;
|
|
|
+import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils;
|
|
|
import org.junit.After;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
@@ -50,7 +49,6 @@ import javax.ws.rs.core.Response.Status;
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
-import java.io.StringWriter;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -183,8 +181,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -218,8 +216,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -244,8 +242,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -269,8 +267,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -300,8 +298,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -332,8 +330,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
@@ -360,8 +358,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
CapacitySchedulerConfiguration newCSConf =
|
|
@@ -395,8 +393,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
CapacitySchedulerConfiguration newCSConf = cs.getConfiguration();
|
|
@@ -413,8 +411,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
newCSConf = cs.getConfiguration();
|
|
@@ -443,8 +441,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
CapacitySchedulerConfiguration newCSConf =
|
|
@@ -468,8 +466,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
CapacitySchedulerConfiguration newCSConf =
|
|
@@ -483,8 +481,8 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
r.path("ws").path("v1").path("cluster")
|
|
|
.path("sched-conf").queryParam("user.name", userName)
|
|
|
.accept(MediaType.APPLICATION_JSON)
|
|
|
- .entity(toJson(updateInfo, SchedConfUpdateInfo.class),
|
|
|
- MediaType.APPLICATION_JSON)
|
|
|
+ .entity(YarnWebServiceUtils.toJson(updateInfo,
|
|
|
+ SchedConfUpdateInfo.class), MediaType.APPLICATION_JSON)
|
|
|
.put(ClientResponse.class);
|
|
|
assertEquals(Status.OK.getStatusCode(), response.getStatus());
|
|
|
newCSConf =
|
|
@@ -506,13 +504,4 @@ public class TestRMWebServicesConfigurationMutation extends JerseyTestBase {
|
|
|
}
|
|
|
super.tearDown();
|
|
|
}
|
|
|
-
|
|
|
- @SuppressWarnings("rawtypes")
|
|
|
- private String toJson(Object nsli, Class klass) throws Exception {
|
|
|
- StringWriter sw = new StringWriter();
|
|
|
- JSONJAXBContext ctx = new JSONJAXBContext(klass);
|
|
|
- JSONMarshaller jm = ctx.createJSONMarshaller();
|
|
|
- jm.marshallToJSON(nsli, sw);
|
|
|
- return sw.toString();
|
|
|
- }
|
|
|
}
|