ATEST-75: simple testing whether externally configuring the cassandra

application works
This commit is contained in:
Zellweger Christof Ralf 2015-06-11 18:12:03 +02:00
parent 467968cdd7
commit 59f5aa0777
5 changed files with 43 additions and 6 deletions

View File

@ -2,7 +2,7 @@ version = '1.0.0'
dependencies { dependencies {
compile project(':ch.psi.daq.cassandra') compile project(':ch.psi.daq.cassandra')
compile 'org.springframework.boot:spring-boot-starter-web:1.2.3.RELEASE' compile 'org.springframework.boot:spring-boot-starter-web:1.2.4.RELEASE'
compile 'org.apache.commons:commons-lang3:3.4' compile 'org.apache.commons:commons-lang3:3.4'
} }

Binary file not shown.

View File

@ -1,13 +1,32 @@
package ch.psi.daq.rest; package ch.psi.daq.rest;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import ch.psi.daq.cassandra.ops.CassandraWriter; import ch.psi.daq.cassandra.writer.CassandraWriter;
import ch.psi.daq.domain.cassandra.ChannelEvent;
@RestController @RestController
public class DaqController { public class DaqController {
@Autowired private static final Logger logger = LoggerFactory.getLogger(DaqController.class);
private CassandraWriter writer;
@Autowired
private CassandraWriter writer;
@RequestMapping(value = "/test")
public void queryIndices() {
logger.info("TEST endpoint invoked");
long pulseId = System.currentTimeMillis();
String value = "data_" + UUID.randomUUID().toString();
writer.writeAsync(1, 0, new ChannelEvent("dummyChannel", pulseId, 0, pulseId, pulseId, 0, value));
}
} }

View File

@ -5,6 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer; import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import ch.psi.daq.cassandra.config.CassandraConfig;
/** /**
* Entry point to our rest-frontend of the Swissfel application which most importantly wires all the @RestController annotated classes. * Entry point to our rest-frontend of the Swissfel application which most importantly wires all the @RestController annotated classes.
@ -31,9 +34,16 @@ import org.springframework.context.annotation.ComponentScan;
* them accordingly. * them accordingly.
*/ */
@SpringBootApplication @SpringBootApplication
@ComponentScan(basePackages = { "ch.psi.daq" }) //@Import(CassandraConfig.class) // either define the context to be imported, or see ComponentScan comment below
@ComponentScan(basePackages = {
"ch.psi.daq.rest",
"ch.psi.daq.cassandra.config", // define the package name with the CassandraConfig configuration, or @Import it (see above)
"ch.psi.daq.cassandra.reader",
"ch.psi.daq.cassandra.writer"
})
public class DaqRestApplication extends SpringBootServletInitializer { public class DaqRestApplication extends SpringBootServletInitializer {
public static void main(final String[] args) { public static void main(final String[] args) {
SpringApplication.run(DaqRestApplication.class, args); SpringApplication.run(DaqRestApplication.class, args);
} }
@ -42,4 +52,11 @@ public class DaqRestApplication extends SpringBootServletInitializer {
protected final SpringApplicationBuilder configure(final SpringApplicationBuilder application) { protected final SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
return application.sources(DaqRestApplication.class); return application.sources(DaqRestApplication.class);
} }
// a nested configuration
// this guarantees that the ordering of the properties file is as expected
// see: https://jira.spring.io/browse/SPR-10409?focusedCommentId=101393&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-101393
// @Configuration
// @Import(CassandraConfig.class)
// static class InnerConfiguration { }
} }

View File

@ -0,0 +1 @@
cassandra.basekeyspace=daq_zellweger_rest