HADOOP-15025. Ensure singleton for ResourceEstimatorService. (Rui Li via Subru).
This commit is contained in:
parent
49b4c0b334
commit
f2df6b8983
@ -34,6 +34,7 @@
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import com.sun.jersey.spi.resource.Singleton;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.resourceestimator.common.api.RecurrenceId;
|
||||
import org.apache.hadoop.resourceestimator.common.api.ResourceSkyline;
|
||||
@ -56,13 +57,13 @@
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Resource Estimator Service which provides a set of REST APIs for users to
|
||||
* use the estimation service.
|
||||
*/
|
||||
@Singleton @Path("/resourceestimator") public class ResourceEstimatorService {
|
||||
@Singleton
|
||||
@Path("/resourceestimator") public class ResourceEstimatorService {
|
||||
private static final Logger LOGGER =
|
||||
LoggerFactory.getLogger(ResourceEstimatorService.class);
|
||||
private final SkylineStore skylineStore;
|
||||
|
@ -37,18 +37,12 @@
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import com.sun.jersey.api.client.WebResource;
|
||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||
import com.sun.jersey.test.framework.JerseyTest;
|
||||
import com.sun.jersey.test.framework.WebAppDescriptor;
|
||||
|
||||
/**
|
||||
* Test ResourceEstimatorService.
|
||||
@ -70,29 +64,12 @@ public class TestResourceEstimatorService extends JerseyTest {
|
||||
private long containerMemAlloc;
|
||||
private int containerCPUAlloc;
|
||||
|
||||
private static class WebServletModule extends ServletModule {
|
||||
@Override protected void configureServlets() {
|
||||
bind(ResourceEstimatorService.class);
|
||||
serve("/*").with(GuiceContainer.class);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
GuiceServletConfig
|
||||
.setInjector(Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
public TestResourceEstimatorService() {
|
||||
super(new WebAppDescriptor.Builder(
|
||||
"org.apache.hadoop.resourceestimator.service")
|
||||
.contextListenerClass(GuiceServletConfig.class)
|
||||
.filterClass(com.google.inject.servlet.GuiceFilter.class).build());
|
||||
super("org.apache.hadoop.resourceestimator.service");
|
||||
}
|
||||
|
||||
@Before @Override public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
GuiceServletConfig
|
||||
.setInjector(Guice.createInjector(new WebServletModule()));
|
||||
containerMemAlloc = 1024;
|
||||
containerCPUAlloc = 1;
|
||||
containerSpec = Resource.newInstance(containerMemAlloc, containerCPUAlloc);
|
||||
|
Loading…
Reference in New Issue
Block a user