Skip to content
Snippets Groups Projects
Commit d8da28b4 authored by Martin Weise's avatar Martin Weise
Browse files

Added live producer

Former-commit-id: f3bd0643
parent 29c44e69
No related branches found
No related tags found
1 merge request!42Fixed the query service tests
Showing
with 62 additions and 105 deletions
......@@ -53,6 +53,9 @@ services:
environment:
SPRING_PROFILES_ACTIVE: docker
TZ: Europe/Vienna
depends_on:
fda-gateway-service:
condition: service_healthy
ports:
- "9090:9090"
logging:
......@@ -70,9 +73,6 @@ services:
environment:
SPRING_PROFILES_ACTIVE: docker
TZ: Europe/Vienna
depends_on:
fda-discovery-service:
condition: service_healthy
ports:
- "9095:9095"
logging:
......@@ -323,3 +323,21 @@ services:
TZ: Europe/Vienna
logging:
driver: json-file
fda-vienna-lines:
restart: on-failure
container_name: fda-vienna-lines
hostname: fda-vienna-lines
build: ./fda-vienna-lines
image: fda-vienna-lines
networks:
fda-public:
depends_on:
fda-query-service:
condition: service_healthy
environment:
TZ: Europe/Vienna
EXCHANGE: foo
KEY: vienna_public_transport_delays
logging:
driver: json-file
\ No newline at end of file
version: "3.6"
services:
fda-sensor-computer:
restart: on-failure
container_name: fda-sensor-computer
hostname: fda-sensor-computer
build: ./fda-sensor-computer
image: fda-sensor-computer
networks:
fda-public:
environment:
TZ: Europe/Vienna
EXCHANGE:
KEY:
volumes:
- /sys/class/thermal:/thermal
- /sys/class/hwmon:/hwmon
logging:
driver: json-file
\ No newline at end of file
default_user = guest
default_pass = guest
# user
default_vhost = /
default_user = fda
default_pass = fda
default_user_tags.administrator = true
default_permissions.configure = .*
default_permissions.read = .*
default_permissions.write = .*
# enable http outside localhost
listeners.tcp.1 = 0.0.0.0:5672
# logging
log.file.level = warning
\ No newline at end of file
......@@ -17,8 +17,8 @@ spring:
loadbalancer.ribbon.enabled: false
rabbitmq:
host: fda-broker-service
username: guest
password: guest
username: fda
password: fda
server.port: 9092
logging:
pattern.console: "%d %highlight(%-5level) %msg%n"
......
......@@ -17,8 +17,8 @@ spring:
loadbalancer.ribbon.enabled: false
rabbitmq:
host: fda-broker-service
username: guest
password: guest
username: fda
password: fda
server.port: 9092
logging:
pattern.console: "%d %highlight(%-5level) %msg%n"
......
......@@ -18,10 +18,18 @@ public class AmqpConfig {
@Value("${spring.rabbitmq.host}")
private String ampqHost;
@Value("${spring.rabbitmq.username}")
private String ampqUsername;
@Value("${spring.rabbitmq.password}")
private String ampqPassword;
@Bean
public Channel getChannel() throws IOException, TimeoutException {
final ConnectionFactory factory = new ConnectionFactory();
factory.setHost(ampqHost);
factory.setUsername(ampqUsername);
factory.setPassword(ampqPassword);
final Connection connection = factory.newConnection();
return connection.createChannel();
}
......
......@@ -7,7 +7,7 @@ import org.mapstruct.Mapper;
public interface AmqpMapper {
default String exchangeName(Database database) {
return "fda." + database.getInternalName();
return database.getInternalName();
}
}
......@@ -9,8 +9,8 @@ public abstract class AbstractSeeder {
public final static Long CONTAINER_2_ID = 2L;
public final static Long DATABASE_1_ID = 1L;
public final static String DATABASE_1_NAME = "Public Transport in Zürich";
public final static String DATABASE_1_DESCRIPTION = "Public transport routes and schedules for the city of Zurich https://www.kaggle.com/laa283/zurich-public-transport/version/2";
public final static String DATABASE_1_NAME = "Public Transport";
public final static String DATABASE_1_DESCRIPTION = "Public transport for various cities in the world";
public final static Boolean DATABASE_1_PUBLIC = true;
public final static DatabaseCreateDto DATABASE_1_CREATE_DTO = DatabaseCreateDto.builder()
......
......@@ -62,10 +62,10 @@ public class RabbitMqServiceImpl implements MessageQueueService {
}
public void create(Database database) throws IOException {
channel.exchangeDeclare(database.getExchange(), BuiltinExchangeType.FANOUT, true);
log.debug("declare fanout exchange {}", database.getExchange());
channel.exchangeBind(database.getExchange(), AMQP_EXCHANGE, database.getExchange());
log.debug("bind exchange {} to {}", database.getExchange(), AMQP_EXCHANGE);
channel.exchangeDeclare(AMQP_EXCHANGE + "." + database.getExchange(), BuiltinExchangeType.FANOUT, true);
log.debug("declare fanout exchange {}", AMQP_EXCHANGE + "." + database.getExchange());
channel.exchangeBind(AMQP_EXCHANGE + "." + database.getExchange(), AMQP_EXCHANGE, AMQP_EXCHANGE + "." + database.getExchange());
log.debug("bind exchange {} to {}", AMQP_EXCHANGE + "." + database.getExchange(), AMQP_EXCHANGE);
}
public void delete(Database database) throws IOException {
......
......@@ -5,6 +5,7 @@ import lombok.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Map;
@Getter
@Setter
......@@ -14,8 +15,8 @@ import java.util.List;
@NoArgsConstructor
public class TableCsvDto {
@NotNull
@NotNull(message = "data is required")
@ApiModelProperty(name = "data")
private List<Object> data;
private Map<String, Object> data;
}
......@@ -2,7 +2,7 @@ package at.tuwien;
import lombok.*;
import java.util.List;
import java.util.Collection;
@Getter
@Setter
......@@ -14,6 +14,6 @@ public class InsertTableRawQuery {
private String query;
private List<Object> data;
private Collection<Object> data;
}
......@@ -171,19 +171,14 @@
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<optional>true</optional><!-- IntelliJ -->
<optional>true</optional>
<!-- IntelliJ -->
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<!-- AMPQ -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>${rabbit-amqp-client.version}</version>
</dependency>
<!-- DTO -->
<dependency>
<groupId>com.opencsv</groupId>
......
package at.tuwien.config;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
@Configuration
public class MessageQueueConfig {
@Value("${spring.rabbitmq.host}")
private String ampqHost;
@Bean
public Channel ampqConnection() throws IOException, TimeoutException {
final ConnectionFactory factory = new ConnectionFactory();
factory.setHost(ampqHost);
final Connection connection = factory.newConnection();
return connection.createChannel();
}
}
\ No newline at end of file
......@@ -38,7 +38,6 @@ public class TableDataEndpoint {
}
@PostMapping
@PreAuthorize("hasRole('ROLE_RESEARCHER')")
@Transactional
@ApiOperation(value = "Insert values", notes = "Insert Data into a Table in the database. When the location string is set, the data argument is ignored and the location is used as data input")
@ApiResponses({
......
......@@ -13,10 +13,6 @@ spring:
open-in-view: false
application:
name: fda-query-service
rabbitmq:
host: fda-broker-service
username: guest
password: guest
cloud:
loadbalancer.ribbon.enabled: false
server.port: 9093
......@@ -25,7 +21,7 @@ logging:
level:
root: warn
at.tuwien.: debug
at.tuwien.mapper.: debug
at.tuwien.service.QueryService: trace
at.tuwien.config.: debug
eureka:
instance.hostname: fda-query-service
......
......@@ -13,10 +13,6 @@ spring:
open-in-view: false
application:
name: fda-query-service
rabbitmq:
host: localhost
username: guest
password: guest
cloud:
loadbalancer.ribbon.enabled: false
server.port: 9093
......@@ -25,7 +21,7 @@ logging:
level:
root: warn
at.tuwien.: debug
at.tuwien.mapper.: trace
at.tuwien.service.QueryService: trace
at.tuwien.config.: trace
eureka:
instance.hostname: fda-query-service
......
package at.tuwien.endpoint;
import at.tuwien.BaseUnitTest;
import at.tuwien.api.database.query.QueryResultDto;
import at.tuwien.api.database.table.TableCsvDto;
import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.*;
import at.tuwien.service.CommaValueService;
import at.tuwien.service.impl.QueryServiceImpl;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -20,7 +17,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.time.Instant;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
......@@ -29,9 +25,6 @@ import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
public class ExportEndpointUnitTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
......
......@@ -17,7 +17,6 @@ import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.exception.NotModifiedException;
import com.github.dockerjava.api.model.Bind;
import com.github.dockerjava.api.model.Network;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
......@@ -48,9 +47,6 @@ import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
public class QueryEndpointIntegrationTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
......
......@@ -9,7 +9,6 @@ import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.*;
import at.tuwien.service.StoreService;
import at.tuwien.service.impl.QueryServiceImpl;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -32,9 +31,6 @@ import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class)
public class QueryEndpointUnitTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
......
......@@ -6,7 +6,6 @@ import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.*;
import at.tuwien.service.QueryService;
import at.tuwien.service.impl.StoreServiceImpl;
import com.rabbitmq.client.Channel;
import lombok.extern.log4j.Log4j2;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -27,9 +26,6 @@ import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class)
public class StoreEndpointUnitTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment