diff --git a/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java b/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java index fd2dcf0..4ed4607 100644 --- a/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java +++ b/src/main/java/ch/psi/daq/queryrest/config/QueryRestConfig.java @@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.http.converter.HttpMessageConverter; @@ -57,7 +56,6 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter { private static final String QUERYREST_DEFAULT_RESPONSE_FIELDS = "queryrest.default.response.fields"; private static final String QUERYREST_CORS_ALLOWEDORIGINS = "queryrest.cors.allowedorigins"; private static final String QUERYREST_CORS_FORCEALLHEADERS = "queryrest.cors.forceallheaders"; - private static final String QUERYREST_READTIMOUT = "queryrest.readtimeout"; // a nested configuration // this guarantees that the ordering of the properties file is as expected @@ -74,7 +72,6 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter { public static final String BEAN_NAME_DEFAULT_RESPONSE_AGGREGATIONS = "defaultResponseAggregations"; public static final String BEAN_NAME_CORS_ALLOWEDORIGINS = "corsAllowedorigins"; public static final String BEAN_NAME_CORS_FORCEALLHEADERS = "corsForceallheaders"; - public static final String BEAN_NAME_READ_TIMOUT = "queryRestReadTimout"; @Resource private Environment env; @@ -194,12 +191,4 @@ public class QueryRestConfig extends WebMvcConfigurerAdapter { LOGGER.debug("Load '{}={}'", QUERYREST_CORS_FORCEALLHEADERS, value); return value; } - - @Bean(name = BEAN_NAME_READ_TIMOUT) - @Lazy - public Integer readTimeout() { - Integer value = env.getProperty(QUERYREST_READTIMOUT, Integer.class, 10); - LOGGER.debug("Load '{}={}'", QUERYREST_READTIMOUT, value); - return value; - } } diff --git a/src/main/java/ch/psi/daq/queryrest/controller/QueryRestController.java b/src/main/java/ch/psi/daq/queryrest/controller/QueryRestController.java index 8ec4213..5ae3b21 100644 --- a/src/main/java/ch/psi/daq/queryrest/controller/QueryRestController.java +++ b/src/main/java/ch/psi/daq/queryrest/controller/QueryRestController.java @@ -30,7 +30,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; -import ch.psi.daq.cassandra.config.CassandraConfig; import ch.psi.daq.common.ordering.Ordering; import ch.psi.daq.domain.config.DomainConfig; import ch.psi.daq.domain.json.ChannelName; @@ -54,7 +53,6 @@ import ch.psi.daq.query.config.QueryConfig; import ch.psi.daq.query.model.Query; import ch.psi.daq.query.processor.ChannelNameCache; import ch.psi.daq.query.processor.QueryProcessor; -import ch.psi.daq.queryrest.config.QueryRestConfig; import ch.psi.daq.queryrest.query.QueryManager; import ch.psi.daq.queryrest.response.AbstractHTTPResponse; import ch.psi.daq.queryrest.response.PolymorphicResponseMixIn; @@ -91,7 +89,7 @@ public class QueryRestController { @Resource private Function queryAnalizerFactory; - @Resource(name = QueryRestConfig.BEAN_NAME_READ_TIMOUT) + @Resource(name = DomainConfig.BEAN_NAME_READ_TIMEOUT) private Integer readTimeout; private Map queryProcessors = new LinkedHashMap<>(); @@ -165,7 +163,7 @@ public class QueryRestController { } channelNameCache = - new ChannelNameCache(queryProcessors, appContext.getBean(CassandraConfig.BEAN_NAME_READ_TIMEOUT, + new ChannelNameCache(queryProcessors, appContext.getBean(DomainConfig.BEAN_NAME_READ_TIMEOUT, Integer.class).longValue()); } diff --git a/src/main/java/ch/psi/daq/queryrest/query/QueryManagerImpl.java b/src/main/java/ch/psi/daq/queryrest/query/QueryManagerImpl.java index e463ceb..02bf407 100644 --- a/src/main/java/ch/psi/daq/queryrest/query/QueryManagerImpl.java +++ b/src/main/java/ch/psi/daq/queryrest/query/QueryManagerImpl.java @@ -21,6 +21,7 @@ import org.springframework.context.ApplicationContext; import ch.psi.daq.cassandra.config.CassandraConfig; import ch.psi.daq.domain.DataEvent; +import ch.psi.daq.domain.config.DomainConfig; import ch.psi.daq.domain.json.ChannelName; import ch.psi.daq.domain.query.DAQQueries; import ch.psi.daq.domain.query.DAQQueryElement; @@ -86,7 +87,7 @@ public class QueryManagerImpl implements QueryManager { } channelNameCache = - new ChannelNameCache(queryProcessors, appContext.getBean(CassandraConfig.BEAN_NAME_READ_TIMEOUT, + new ChannelNameCache(queryProcessors, appContext.getBean(DomainConfig.BEAN_NAME_READ_TIMEOUT, Integer.class).longValue()); } diff --git a/src/main/resources/queryrest.properties b/src/main/resources/queryrest.properties index baaec0b..5fbaf69 100644 --- a/src/main/resources/queryrest.properties +++ b/src/main/resources/queryrest.properties @@ -16,6 +16,3 @@ queryrest.cors.forceallheaders=false # If this is set to '*', then all requests are allowed, from any source. If it's set to, say, http://ui-data-api.psi.ch, then only requests # originating from that domain (Origin header set to that value) will be allowed. Otherwise a 403 error will be returned. queryrest.cors.allowedorigins=* - -# Timeout for read operations in seconds -queryrest.readtimeout=30 diff --git a/src/test/java/ch/psi/daq/test/queryrest/controller/QueryRestControllerJsonTest.java b/src/test/java/ch/psi/daq/test/queryrest/controller/QueryRestControllerJsonTest.java index 15e7677..0a61124 100644 --- a/src/test/java/ch/psi/daq/test/queryrest/controller/QueryRestControllerJsonTest.java +++ b/src/test/java/ch/psi/daq/test/queryrest/controller/QueryRestControllerJsonTest.java @@ -151,7 +151,7 @@ public class QueryRestControllerJsonTest extends AbstractDaqRestTest { .andExpect(MockMvcResultMatchers.jsonPath("$[0].backend").value(Backend.SF_DATABUFFER.getKey())) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels").isArray()) .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[23]").exists()) - .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[24]").doesNotExist()) + .andExpect(MockMvcResultMatchers.jsonPath("$[0].channels[25]").doesNotExist()) // .andExpect(MockMvcResultMatchers.jsonPath("$[1]").exists()) // .andExpect(MockMvcResultMatchers.jsonPath("$[1].backend").value(Backend.archiverappliance.name())) // .andExpect(MockMvcResultMatchers.jsonPath("$[1].channels").isArray())