Skip to content

Commit

Permalink
Final steps for better all in one runner... partial fix of existing t…
Browse files Browse the repository at this point in the history
…ests after prep for aio.(request mappings introduced)

Strict checks for date format in query strings.
  • Loading branch information
benni committed Nov 7, 2019
1 parent 300afa3 commit 7bf41b3
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 124 deletions.
7 changes: 4 additions & 3 deletions AllInOneRunner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>OverallParent</artifactId>
<artifactId>BrokerParent</artifactId>
<version>0.9.2-SNAPSHOT</version>
<relativePath>../OverallParent</relativePath>
<relativePath>../BrokerParent</relativePath>
</parent>
<artifactId>AllInOneRunner</artifactId>
<version>0.0.4-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>


Expand All @@ -36,7 +37,7 @@
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
<artifactId>RegistryManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.9.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.neclab.ngsildbroker</groupId>
Expand Down
42 changes: 28 additions & 14 deletions AllInOneRunner/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ broker:
parent:
location:
url: SELF

query:
result:
topic: QUERY_RESULT
topic: QUERY


csource:
stopListenerIfDbFails: false
topic: CONTEXT_SOURCE
registry:
topic: CONTEXT_REGISTRY
source:
topic: CONTEXT_SOURCE
notification:
topic: CONTEXT_SOURCE_NOTIFICATION
query:
topic: CONTEXT_REGISTRY_QUERY
result:
topic: CONTEXT_REGISTRY_QUERY_RESULT
topic: CONTEXT_REGISTRY_QUERY
registry:
topic: CONTEXT_REGISTRY
source:
topic: CONTEXT_SOURCE
stopListenerIfDbFails: false
topic: CONTEXT_SOURCE

csources:
registration:
topic: CONTEXT_REGISTRY
Expand Down Expand Up @@ -62,17 +70,14 @@ management:
web:
exposure:
include: "*"
#max:
# request:
# size: 104857600
max:
request:
size: 104857600
maxLimit: 500
ngb:
debugmode: false

query:
result:
topic: QUERY_RESULT
topic: QUERY

reader:
datasource:
hikari:
Expand Down Expand Up @@ -138,6 +143,15 @@ spring:
SUBSCRIPTIONS_WRITE_CHANNEL:
destination: SUBSCRIPTIONS
contentType: application/json
CSOURCE_SUBSCRIPTION_WRITE_CHANNEL:
destination: CSOURCE_SUBSCRIPTIONS
contentType: application/json
CSOURCE_REGISTRATION_WRITE_CHANNEL:
destination: CONTEXT_SOURCE
contentType: application/json
CSOURCE_NOTIFICATION_WRITE_CHANNEL:
destination: CONTEXT_SOURCE_NOTIFICATION
contentType: application/json
application.name: aio-runner
datasource:
hikari:
Expand Down
69 changes: 38 additions & 31 deletions AllInOneRunner/resources/log4j2-spring.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<appender name="RollingFile"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>./logs/spring-boot-logger-log4j2.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz
</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>10MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger{0}
%X{akkaSource} %msg%n</pattern>
</encoder>
</appender>
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger{0}
%X{akkaSource} %msg%n</pattern>
</encoder>
</appender>
<!-- <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}]
%style{%C{1.}}{bright,yellow}: %msg%n%throwable" /> </Console> <RollingFile
name="RollingFile" fileName="./logs/spring-boot-logger-log4j2.log" filePattern="./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz">
<PatternLayout> <pattern>%d %p %C{1.} [%t] %m%n</pattern> </PatternLayout>
<Policies> rollover on startup, daily and when the file reaches 10 MegaBytes
<OnStartupTriggeringPolicy /> <SizeBasedTriggeringPolicy size="10 MB" />
<TimeBasedTriggeringPolicy /> </Policies> </RollingFile> </Appenders> -->

<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%style{%d{ISO8601}}{black} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{bright,yellow}: %msg%n%throwable" />
</Console>

<RollingFile name="RollingFile"
fileName="./logs/spring-boot-logger-log4j2.log"
filePattern="./logs/$${date:yyyy-MM}/spring-boot-logger-log4j2-%d{-dd-MMMM-yyyy}-%i.log.gz">
<PatternLayout>
<pattern>%d %p %C{1.} [%t] %m%n</pattern>
</PatternLayout>
<Policies>
<!-- rollover on startup, daily and when the file reaches
10 MegaBytes -->
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy
size="10 MB" />
<TimeBasedTriggeringPolicy />
</Policies>
</RollingFile>
</Appenders>
<root level="INFO">
<appender-ref ref="Console" />
<appender-ref ref="RollingFile" />
</root>

<Loggers>
<!-- LOG everything at INFO level -->
<Root level="ERROR">
<AppenderRef ref="Console" />
<AppenderRef ref="RollingFile" />
</Root>
<!--
<Logger name="eu.neclab.ngsildbroker" level="INFO"></Logger> -->

<!-- LOG "eu.neclab" at TRACE level -->
<Logger name="eu.neclab.ngsildbroker" level="ERROR"></Logger>

</Loggers>

</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,19 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;

import eu.neclab.ngsildbroker.commons.stream.service.KafkaConfig;

import org.springframework.context.annotation.ComponentScans;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;

@SpringBootApplication
@ComponentScan(basePackages = {
"eu.neclab.ngsildbroker.*" }, excludeFilters = @Filter(type = FilterType.REGEX, pattern = {
"eu.neclab.ngsildbroker.commons.*" }))

// @EntityScan(basePackages = { "eu.neclab.ngsildbroker.entityhandler.*",
// "eu.neclab.ngsildbroker.atcontextserver.*",
// "eu.neclab.ngsildbroker.historymanager.*",
// "eu.neclab.ngsildbroker.queryhandler.*",
// "eu.neclab.ngsildbroker.registryhandler.*",
// "eu.neclab.ngsildbroker.storagemanager.*",
// "eu.neclab.ngsildbroker.subscriptionmanager.*" })
// @EnableJpaRepositories(basePackages = {
// "eu.neclab.ngsildbroker.entityhandler.*",
// "eu.neclab.ngsildbroker.atcontextserver.*",
// "eu.neclab.ngsildbroker.historymanager.*",
// "eu.neclab.ngsildbroker.queryhandler.*",
// "eu.neclab.ngsildbroker.registryhandler.*",
// "eu.neclab.ngsildbroker.storagemanager.*",
// "eu.neclab.ngsildbroker.subscriptionmanager.*" })
//@Import(KafkaConfig.class)
public class Runner {

public static void main(String[] args) {
public static void main(String[] args) throws Exception{
SpringApplication.run(Runner.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public interface NGSIConstants {
public final static String QUERY_LESS = "<";
public final static String QUERY_PATTERNOP = "~=";
public final static String QUERY_NOTPATTERNOP = "!~=";
public final static String CHECK_QUERY_STRING_URI = "/";
//public final static String CHECK_QUERY_STRING_URI = "/";

public static final String NGSI_LD_UNIT_CODE = "https://uri.etsi.org/ngsi-ld/unitCode";
public static final String NGSI_LD_DATA_SET_ID = "https://uri.etsi.org/ngsi-ld/datasetId";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;
import eu.neclab.ngsildbroker.commons.constants.DBConstants;
import eu.neclab.ngsildbroker.commons.constants.NGSIConstants;
import eu.neclab.ngsildbroker.commons.enums.ErrorType;
import eu.neclab.ngsildbroker.commons.exceptions.BadRequestException;
import eu.neclab.ngsildbroker.commons.exceptions.ResponseException;
import eu.neclab.ngsildbroker.commons.ngsiqueries.ParamsResolver;
Expand Down Expand Up @@ -120,7 +121,11 @@ private boolean calculate(List<BaseProperty> properties, String attribute, Strin
return false;
}
if (TIME_PROPS.contains(myAttribName)) {
operant = SerializationTools.date2Long(operant).toString();
try {
operant = SerializationTools.date2Long(operant).toString();
} catch (Exception e) {
throw new ResponseException(ErrorType.BadRequestData, e.getMessage());
}
}
value = getValue(myProperty);
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ public void testObservedModifiedCreated() throws URISyntaxException {
stringProp.setId(new URI("http://mytestprop.org/teststring"));

stringProp.setSingleValue("test");
stringProp.setCreatedAt(SerializationTools.date2Long(dateTime));
stringProp.setObservedAt(SerializationTools.date2Long(dateTime));
stringProp.setModifiedAt(SerializationTools.date2Long(dateTime));
try {
stringProp.setCreatedAt(SerializationTools.date2Long(dateTime));
stringProp.setObservedAt(SerializationTools.date2Long(dateTime));
stringProp.setModifiedAt(SerializationTools.date2Long(dateTime));
} catch (Exception e1) {
throw new AssertionError();
}
String qString = "teststring.observedAt==" + dateTime;
try {
QueryTerm term = parser.parseQuery(qString, null);
Expand Down

0 comments on commit 7bf41b3

Please sign in to comment.