ATEST-81:
- trying to fix bug re react stream and closed queue
This commit is contained in:
@ -1,15 +1,21 @@
|
|||||||
package ch.psi.daq.rest.config;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import ch.psi.daq.common.statistic.StorelessStatistics;
|
import ch.psi.daq.common.statistic.StorelessStatistics;
|
||||||
import ch.psi.daq.domain.cassandra.ChannelEvent;
|
import ch.psi.daq.domain.cassandra.ChannelEvent;
|
||||||
@ -56,5 +62,14 @@ public class RestConfig {
|
|||||||
mapper.addMixIn(StorelessStatistics.class, PropertyFilterMixin.class);
|
mapper.addMixIn(StorelessStatistics.class, PropertyFilterMixin.class);
|
||||||
return mapper;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ public class ResponseStreamWriter {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ObjectMapper mapper;
|
private ObjectMapper mapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Set<String> defaultResponseFields;
|
||||||
/**
|
/**
|
||||||
* Responding with the the contents of the stream by writing into the output stream of the
|
* Responding with the the contents of the stream by writing into the output stream of the
|
||||||
* {@link ServletResponse}.
|
* {@link ServletResponse}.
|
||||||
@ -51,6 +53,9 @@ public class ResponseStreamWriter {
|
|||||||
public void respond(Stream<DataEvent> stream, AbstractQuery query, ServletResponse response) throws IOException {
|
public void respond(Stream<DataEvent> stream, AbstractQuery query, ServletResponse response) throws IOException {
|
||||||
|
|
||||||
Set<String> includedFields = query.getFields();
|
Set<String> includedFields = query.getFields();
|
||||||
|
if (includedFields == null) {
|
||||||
|
includedFields = defaultResponseFields;
|
||||||
|
}
|
||||||
|
|
||||||
if (query.getAggregations() != null) {
|
if (query.getAggregations() != null) {
|
||||||
includedFields.addAll(query.getAggregations()
|
includedFields.addAll(query.getAggregations()
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
# port for the Spring boot application's embedded Tomcat server
|
# port for the Spring boot application's embedded Tomcat server
|
||||||
server.port=8080
|
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
|
Reference in New Issue
Block a user