ATEST-81:
- added dummy write method for REST interface
This commit is contained in:
@@ -3,11 +3,13 @@ package ch.psi.daq.rest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import ch.psi.daq.cassandra.writer.CassandraWriter;
|
||||
import ch.psi.daq.cassandra.writer.CassandraWriterImpl;
|
||||
import ch.psi.daq.common.statistic.StorelessStatistics;
|
||||
import ch.psi.daq.domain.cassandra.ChannelEvent;
|
||||
import ch.psi.daq.hazelcast.query.processor.QueryProcessor;
|
||||
import ch.psi.daq.hazelcast.query.processor.cassandra.CassandraQueryProcessorLocal;
|
||||
import ch.psi.daq.rest.model.PropertyFilterMixin;
|
||||
import ch.psi.daq.test.rest.query.DummyQueryProcessor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
@@ -18,9 +20,15 @@ public class DaqRestConfiguration {
|
||||
|
||||
@Bean
|
||||
public QueryProcessor queryProcessor() {
|
||||
return new DummyQueryProcessor();
|
||||
// return new DummyQueryProcessor();
|
||||
return new CassandraQueryProcessorLocal();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CassandraWriter cassandraWriter() {
|
||||
return new CassandraWriterImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JsonFactory jsonFactory() {
|
||||
return new JsonFactory();
|
||||
|
||||
@@ -2,6 +2,8 @@ package ch.psi.daq.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import ch.psi.daq.cassandra.writer.CassandraWriter;
|
||||
import ch.psi.daq.domain.cassandra.ChannelEvent;
|
||||
import ch.psi.daq.domain.cassandra.DataEvent;
|
||||
import ch.psi.daq.hazelcast.query.processor.QueryProcessor;
|
||||
import ch.psi.daq.rest.queries.AbstractQuery;
|
||||
@@ -23,11 +27,13 @@ import ch.psi.daq.rest.queries.TimeRangeQuery;
|
||||
public class DaqRestController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DaqRestController.class);
|
||||
|
||||
|
||||
@Autowired
|
||||
private CassandraWriter cassandraWriter;
|
||||
|
||||
@Autowired
|
||||
private ResponseStreamWriter responseStreamWriter;
|
||||
|
||||
// TODO: just a dummy test implementation - remove when the real processor is ready
|
||||
@Autowired
|
||||
private QueryProcessor queryProcessor;
|
||||
|
||||
@@ -67,6 +73,7 @@ public class DaqRestController {
|
||||
* @throws IOException
|
||||
*/
|
||||
private void executeQuery(AbstractQuery query, HttpServletResponse res) throws IOException {
|
||||
|
||||
// all the magic happens here
|
||||
Map<String, Stream<? extends DataEvent>> process = queryProcessor.process(query);
|
||||
|
||||
@@ -77,4 +84,21 @@ public class DaqRestController {
|
||||
// write the response back to the client using java 8 streams
|
||||
responseStreamWriter.respond(flatStreams, query, res);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/write")
|
||||
public void writeDummyEntry() {
|
||||
int pulseId = 100;
|
||||
ChannelEvent event = new ChannelEvent(
|
||||
"dummy-test",
|
||||
pulseId,
|
||||
0,
|
||||
pulseId,
|
||||
pulseId,
|
||||
0,
|
||||
"data_" + UUID.randomUUID().toString());
|
||||
|
||||
CompletableFuture<Void> future = cassandraWriter.writeAsync(3, 0, event);
|
||||
future.join();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,12 +57,9 @@ public class ResponseStreamWriter {
|
||||
.stream()
|
||||
.map(a -> {
|
||||
return a.getType().toString();
|
||||
})
|
||||
.collect(Collectors.toSet()));
|
||||
}).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
ObjectWriter writer = configureWriter(includedFields);
|
||||
|
||||
respondInternal(stream, response, writer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user