ATEST-81:

- trying to fix bug re react stream and closed queue
This commit is contained in:
Zellweger Christof Ralf
2015-07-03 16:04:14 +02:00
parent 6dfa14082d
commit 3157082262
3 changed files with 25 additions and 1 deletions

View File

@ -1,15 +1,21 @@
package ch.psi.daq.rest.config;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Sets;
import ch.psi.daq.common.statistic.StorelessStatistics;
import ch.psi.daq.domain.cassandra.ChannelEvent;
@ -56,5 +62,14 @@ public class RestConfig {
mapper.addMixIn(StorelessStatistics.class, PropertyFilterMixin.class);
return mapper;
}
@Bean
private Set<String> defaultResponseFields() {
List<String> defaultFields = Arrays.asList(
StringUtils.commaDelimitedListToStringArray(
env.getProperty("rest.default.response.fields")
));
Set<String> defaultResponseFields = Sets.newHashSet(defaultFields.iterator());
return defaultResponseFields;
}
}

View File

@ -39,6 +39,8 @@ public class ResponseStreamWriter {
@Autowired
private ObjectMapper mapper;
@Autowired
private Set<String> defaultResponseFields;
/**
* Responding with the the contents of the stream by writing into the output stream of the
* {@link ServletResponse}.
@ -51,6 +53,9 @@ public class ResponseStreamWriter {
public void respond(Stream<DataEvent> stream, AbstractQuery query, ServletResponse response) throws IOException {
Set<String> includedFields = query.getFields();
if (includedFields == null) {
includedFields = defaultResponseFields;
}
if (query.getAggregations() != null) {
includedFields.addAll(query.getAggregations()

View File

@ -1,2 +1,6 @@
# port for the Spring boot application's embedded Tomcat server
server.port=8080
# defines the fields that are included in the response
# if no fields have been specified by the user
rest.default.response.fields=channel,pulseId,globalMillis,globalNanos,value