ATEST-81:
- added dummy write method for REST interface
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user