Commit 0ae28408c9feacb0e79862d10c73e07dd614ffc2

Authored by Igor Kulikov
1 parent 5242864c

Docker build for transports.

... ... @@ -16,6 +16,8 @@
16 16 package org.thingsboard.server.common.transport.service;
17 17
18 18 import lombok.extern.slf4j.Slf4j;
  19 +import org.apache.kafka.clients.admin.CreateTopicsResult;
  20 +import org.apache.kafka.clients.admin.NewTopic;
19 21 import org.apache.kafka.clients.consumer.ConsumerRecords;
20 22 import org.apache.kafka.clients.producer.Callback;
21 23 import org.apache.kafka.clients.producer.RecordMetadata;
... ... @@ -42,12 +44,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.ToRuleEngineMsg;
42 44 import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceCredentialsResponseMsg;
43 45 import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceTokenRequestMsg;
44 46 import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceX509CertRequestMsg;
45   -import org.thingsboard.server.kafka.AsyncCallbackTemplate;
46   -import org.thingsboard.server.kafka.TBKafkaConsumerTemplate;
47   -import org.thingsboard.server.kafka.TBKafkaProducerTemplate;
48   -import org.thingsboard.server.kafka.TbKafkaRequestTemplate;
49   -import org.thingsboard.server.kafka.TbKafkaSettings;
50   -import org.thingsboard.server.kafka.TbNodeIdProvider;
  47 +import org.thingsboard.server.kafka.*;
51 48
52 49 import javax.annotation.PostConstruct;
53 50 import javax.annotation.PreDestroy;
... ... @@ -136,9 +133,19 @@ public class RemoteTransportService extends AbstractTransportService {
136 133 ruleEngineProducer = ruleEngineProducerBuilder.build();
137 134 ruleEngineProducer.init();
138 135
  136 + String notificationsTopicName = notificationsTopic + "." + nodeIdProvider.getNodeId();
  137 +
  138 + try {
  139 + TBKafkaAdmin admin = new TBKafkaAdmin(kafkaSettings);
  140 + CreateTopicsResult result = admin.createTopic(new NewTopic(notificationsTopicName, 1, (short) 1));
  141 + result.all().get();
  142 + } catch (Exception e) {
  143 + log.trace("Failed to create topic: {}", e.getMessage(), e);
  144 + }
  145 +
139 146 TBKafkaConsumerTemplate.TBKafkaConsumerTemplateBuilder<ToTransportMsg> mainConsumerBuilder = TBKafkaConsumerTemplate.builder();
140 147 mainConsumerBuilder.settings(kafkaSettings);
141   - mainConsumerBuilder.topic(notificationsTopic + "." + nodeIdProvider.getNodeId());
  148 + mainConsumerBuilder.topic(notificationsTopicName);
142 149 mainConsumerBuilder.clientId("transport-" + nodeIdProvider.getNodeId());
143 150 mainConsumerBuilder.groupId("transport");
144 151 mainConsumerBuilder.autoCommit(true);
... ...
... ... @@ -5,6 +5,8 @@ JS_EXECUTOR_DOCKER_NAME=tb-js-executor
5 5 TB_NODE_DOCKER_NAME=tb-node
6 6 WEB_UI_DOCKER_NAME=tb-web-ui
7 7 MQTT_TRANSPORT_DOCKER_NAME=tb-mqtt-transport
  8 +HTTP_TRANSPORT_DOCKER_NAME=tb-http-transport
  9 +COAP_TRANSPORT_DOCKER_NAME=tb-coap-transport
8 10
9 11 TB_VERSION=2.2.0-SNAPSHOT
10 12
... ...
... ... @@ -56,7 +56,6 @@ services:
56 56 image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
57 57 ports:
58 58 - "8080"
59   - - "5683:5683/udp"
60 59 logging:
61 60 driver: "json-file"
62 61 options:
... ... @@ -96,6 +95,50 @@ services:
96 95 - tb-mqtt-transport.env
97 96 depends_on:
98 97 - kafka
  98 + tb-http-transport1:
  99 + restart: always
  100 + image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
  101 + ports:
  102 + - "8081"
  103 + environment:
  104 + TB_KAFKA_SERVERS: kafka:9092
  105 + env_file:
  106 + - tb-http-transport.env
  107 + depends_on:
  108 + - kafka
  109 + tb-http-transport2:
  110 + restart: always
  111 + image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
  112 + ports:
  113 + - "8081"
  114 + environment:
  115 + TB_KAFKA_SERVERS: kafka:9092
  116 + env_file:
  117 + - tb-http-transport.env
  118 + depends_on:
  119 + - kafka
  120 + tb-coap-transport1:
  121 + restart: always
  122 + image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
  123 + ports:
  124 + - "5683"
  125 + environment:
  126 + TB_KAFKA_SERVERS: kafka:9092
  127 + env_file:
  128 + - tb-coap-transport.env
  129 + depends_on:
  130 + - kafka
  131 + tb-coap-transport2:
  132 + restart: always
  133 + image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
  134 + ports:
  135 + - "5683"
  136 + environment:
  137 + TB_KAFKA_SERVERS: kafka:9092
  138 + env_file:
  139 + - tb-coap-transport.env
  140 + depends_on:
  141 + - kafka
99 142 tb-web-ui1:
100 143 restart: always
101 144 image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}"
... ... @@ -116,6 +159,16 @@ services:
116 159 TB_PORT: 8080
117 160 env_file:
118 161 - tb-web-ui.env
  162 + coap-lb:
  163 + restart: always
  164 + container_name: coap-loadbalancer
  165 + image: instantlinux/udp-nginx-proxy
  166 + ports:
  167 + - "5683:5683/udp"
  168 + environment:
  169 + BACKENDS: tb-coap-transport1 tb-coap-transport2
  170 + PORT_BACKEND: 5683
  171 + PORT_LISTEN: 5683
119 172 web:
120 173 restart: always
121 174 container_name: haproxy-certbot
... ... @@ -140,3 +193,5 @@ services:
140 193 - tb-web-ui2
141 194 - tb-mqtt-transport1
142 195 - tb-mqtt-transport2
  196 + - tb-http-transport1
  197 + - tb-http-transport2
... ...
... ... @@ -39,6 +39,7 @@ frontend http-in
39 39 acl letsencrypt_http_acl path_beg /.well-known/acme-challenge/
40 40 redirect scheme https if !letsencrypt_http_acl !transport_http_acl
41 41 use_backend letsencrypt_http if letsencrypt_http_acl
  42 + use_backend tb-http-backend if transport_http_acl
42 43
43 44 default_backend tb-web-backend
44 45
... ... @@ -72,3 +73,10 @@ backend tb-mqtt-backend
72 73 option log-health-checks
73 74 server tbMqtt1 tb-mqtt-transport1:1883 check
74 75 server tbMqtt2 tb-mqtt-transport2:1883 check
  76 +
  77 +backend tb-http-backend
  78 + balance leastconn
  79 + option tcp-check
  80 + option log-health-checks
  81 + server tbHttp1 tb-http-transport1:8081 check
  82 + server tbHttp2 tb-http-transport2:8081 check
... ...
  1 +
  2 +COAP_BIND_ADDRESS=0.0.0.0
  3 +COAP_BIND_PORT=5683
  4 +COAP_TIMEOUT=10000
  5 +
  6 +TB_KAFKA_SERVERS=localhost:9092
\ No newline at end of file
... ...
  1 +
  2 +HTTP_BIND_ADDRESS=0.0.0.0
  3 +HTTP_BIND_PORT=8081
  4 +HTTP_REQUEST_TIMEOUT=60000
  5 +
  6 +TB_KAFKA_SERVERS=localhost:9092
\ No newline at end of file
... ...
  1 +#
  2 +# Copyright © 2016-2018 The Thingsboard Authors
  3 +#
  4 +# Licensed under the Apache License, Version 2.0 (the "License");
  5 +# you may not use this file except in compliance with the License.
  6 +# You may obtain a copy of the License at
  7 +#
  8 +# http://www.apache.org/licenses/LICENSE-2.0
  9 +#
  10 +# Unless required by applicable law or agreed to in writing, software
  11 +# distributed under the License is distributed on an "AS IS" BASIS,
  12 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +# See the License for the specific language governing permissions and
  14 +# limitations under the License.
  15 +#
  16 +
  17 +FROM openjdk:8-jre
  18 +
  19 +COPY logback.xml ${pkg.name}.conf start-tb-coap-transport.sh ${pkg.name}.deb /tmp/
  20 +
  21 +RUN chmod a+x /tmp/*.sh \
  22 + && mv /tmp/start-tb-coap-transport.sh /usr/bin
  23 +
  24 +RUN dpkg -i /tmp/${pkg.name}.deb
  25 +
  26 +RUN update-rc.d ${pkg.name} disable
  27 +
  28 +RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \
  29 + && mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf
  30 +
  31 +CMD ["start-tb-coap-transport.sh"]
... ...
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!--
  3 +
  4 + Copyright © 2016-2018 The Thingsboard Authors
  5 +
  6 + Licensed under the Apache License, Version 2.0 (the "License");
  7 + you may not use this file except in compliance with the License.
  8 + You may obtain a copy of the License at
  9 +
  10 + http://www.apache.org/licenses/LICENSE-2.0
  11 +
  12 + Unless required by applicable law or agreed to in writing, software
  13 + distributed under the License is distributed on an "AS IS" BASIS,
  14 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 + See the License for the specific language governing permissions and
  16 + limitations under the License.
  17 +
  18 +-->
  19 +<!DOCTYPE configuration>
  20 +<configuration scan="true" scanPeriod="10 seconds">
  21 +
  22 + <appender name="fileLogAppender"
  23 + class="ch.qos.logback.core.rolling.RollingFileAppender">
  24 + <file>/var/log/${pkg.name}/${pkg.name}.log</file>
  25 + <rollingPolicy
  26 + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  27 + <fileNamePattern>/var/log/${pkg.name}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  28 + <maxFileSize>100MB</maxFileSize>
  29 + <maxHistory>30</maxHistory>
  30 + <totalSizeCap>3GB</totalSizeCap>
  31 + </rollingPolicy>
  32 + <encoder>
  33 + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
  34 + </encoder>
  35 + </appender>
  36 +
  37 + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  38 + <encoder>
  39 + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
  40 + </encoder>
  41 + </appender>
  42 +
  43 + <logger name="org.thingsboard.server" level="INFO" />
  44 +
  45 + <root level="INFO">
  46 + <appender-ref ref="fileLogAppender"/>
  47 + <appender-ref ref="STDOUT"/>
  48 + </root>
  49 +
  50 +</configuration>
\ No newline at end of file
... ...
  1 +#!/bin/bash
  2 +#
  3 +# Copyright © 2016-2018 The Thingsboard Authors
  4 +#
  5 +# Licensed under the Apache License, Version 2.0 (the "License");
  6 +# you may not use this file except in compliance with the License.
  7 +# You may obtain a copy of the License at
  8 +#
  9 +# http://www.apache.org/licenses/LICENSE-2.0
  10 +#
  11 +# Unless required by applicable law or agreed to in writing, software
  12 +# distributed under the License is distributed on an "AS IS" BASIS,
  13 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +# See the License for the specific language governing permissions and
  15 +# limitations under the License.
  16 +#
  17 +
  18 +CONF_FOLDER="${pkg.installFolder}/conf"
  19 +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar
  20 +configfile=${pkg.name}.conf
  21 +
  22 +source "${CONF_FOLDER}/${configfile}"
  23 +
  24 +echo "Starting '${project.name}' ..."
  25 +
  26 +exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.coap.ThingsboardCoapTransportApplication \
  27 + -Dspring.jpa.hibernate.ddl-auto=none \
  28 + -Dlogging.config=${CONF_FOLDER}/logback.xml \
  29 + org.springframework.boot.loader.PropertiesLauncher
... ...
  1 +#
  2 +# Copyright © 2016-2018 The Thingsboard Authors
  3 +#
  4 +# Licensed under the Apache License, Version 2.0 (the "License");
  5 +# you may not use this file except in compliance with the License.
  6 +# You may obtain a copy of the License at
  7 +#
  8 +# http://www.apache.org/licenses/LICENSE-2.0
  9 +#
  10 +# Unless required by applicable law or agreed to in writing, software
  11 +# distributed under the License is distributed on an "AS IS" BASIS,
  12 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +# See the License for the specific language governing permissions and
  14 +# limitations under the License.
  15 +#
  16 +
  17 +export JAVA_OPTS="$JAVA_OPTS -Xloggc:@pkg.logFolder@/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
  18 +export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10"
  19 +export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark"
  20 +export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled"
  21 +export JAVA_OPTS="$JAVA_OPTS -XX:+CMSEdenChunksRecordAlways -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+ExitOnOutOfMemoryError"
  22 +export LOG_FILENAME=${pkg.name}.out
  23 +export LOADER_PATH=${pkg.installFolder}/conf
... ...
  1 +<!--
  2 +
  3 + Copyright © 2016-2018 The Thingsboard Authors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +
  17 +-->
  18 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  20 + <modelVersion>4.0.0</modelVersion>
  21 + <parent>
  22 + <groupId>org.thingsboard.msa</groupId>
  23 + <version>2.2.0-SNAPSHOT</version>
  24 + <artifactId>transport</artifactId>
  25 + </parent>
  26 + <groupId>org.thingsboard.msa.transport</groupId>
  27 + <artifactId>coap</artifactId>
  28 + <packaging>pom</packaging>
  29 +
  30 + <name>ThingsBoard COAP Transport Microservice</name>
  31 + <url>https://thingsboard.io</url>
  32 + <description>ThingsBoard COAP Transport Microservice</description>
  33 +
  34 + <properties>
  35 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  36 + <main.dir>${basedir}/../../..</main.dir>
  37 + <pkg.name>tb-coap-transport</pkg.name>
  38 + <docker.name>tb-coap-transport</docker.name>
  39 + <pkg.user>thingsboard</pkg.user>
  40 + <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>
  41 + <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
  42 + </properties>
  43 +
  44 + <dependencies>
  45 + <dependency>
  46 + <groupId>org.thingsboard.transport</groupId>
  47 + <artifactId>coap</artifactId>
  48 + <version>${project.version}</version>
  49 + <classifier>deb</classifier>
  50 + <type>deb</type>
  51 + <scope>provided</scope>
  52 + </dependency>
  53 + </dependencies>
  54 +
  55 + <build>
  56 + <plugins>
  57 + <plugin>
  58 + <groupId>org.apache.maven.plugins</groupId>
  59 + <artifactId>maven-dependency-plugin</artifactId>
  60 + <executions>
  61 + <execution>
  62 + <id>copy-tb-coap-transport-deb</id>
  63 + <phase>package</phase>
  64 + <goals>
  65 + <goal>copy</goal>
  66 + </goals>
  67 + <configuration>
  68 + <artifactItems>
  69 + <artifactItem>
  70 + <groupId>org.thingsboard.transport</groupId>
  71 + <artifactId>coap</artifactId>
  72 + <classifier>deb</classifier>
  73 + <type>deb</type>
  74 + <destFileName>${pkg.name}.deb</destFileName>
  75 + <outputDirectory>${project.build.directory}</outputDirectory>
  76 + </artifactItem>
  77 + </artifactItems>
  78 + </configuration>
  79 + </execution>
  80 + </executions>
  81 + </plugin>
  82 + <plugin>
  83 + <groupId>org.apache.maven.plugins</groupId>
  84 + <artifactId>maven-resources-plugin</artifactId>
  85 + <executions>
  86 + <execution>
  87 + <id>copy-docker-config</id>
  88 + <phase>process-resources</phase>
  89 + <goals>
  90 + <goal>copy-resources</goal>
  91 + </goals>
  92 + <configuration>
  93 + <outputDirectory>${project.build.directory}</outputDirectory>
  94 + <resources>
  95 + <resource>
  96 + <directory>docker</directory>
  97 + <filtering>true</filtering>
  98 + </resource>
  99 + </resources>
  100 + </configuration>
  101 + </execution>
  102 + </executions>
  103 + </plugin>
  104 + <plugin>
  105 + <groupId>com.spotify</groupId>
  106 + <artifactId>dockerfile-maven-plugin</artifactId>
  107 + <executions>
  108 + <execution>
  109 + <id>build-docker-image</id>
  110 + <phase>pre-integration-test</phase>
  111 + <goals>
  112 + <goal>build</goal>
  113 + </goals>
  114 + </execution>
  115 + </executions>
  116 + <configuration>
  117 + <skip>${dockerfile.skip}</skip>
  118 + <repository>${docker.repo}/${docker.name}</repository>
  119 + <tag>${project.version}</tag>
  120 + <verbose>true</verbose>
  121 + <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
  122 + <contextDirectory>${project.build.directory}</contextDirectory>
  123 + </configuration>
  124 + </plugin>
  125 + </plugins>
  126 + </build>
  127 + <repositories>
  128 + <repository>
  129 + <id>jenkins</id>
  130 + <name>Jenkins Repository</name>
  131 + <url>http://repo.jenkins-ci.org/releases</url>
  132 + <snapshots>
  133 + <enabled>false</enabled>
  134 + </snapshots>
  135 + </repository>
  136 + </repositories>
  137 +</project>
... ...
  1 +#
  2 +# Copyright © 2016-2018 The Thingsboard Authors
  3 +#
  4 +# Licensed under the Apache License, Version 2.0 (the "License");
  5 +# you may not use this file except in compliance with the License.
  6 +# You may obtain a copy of the License at
  7 +#
  8 +# http://www.apache.org/licenses/LICENSE-2.0
  9 +#
  10 +# Unless required by applicable law or agreed to in writing, software
  11 +# distributed under the License is distributed on an "AS IS" BASIS,
  12 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +# See the License for the specific language governing permissions and
  14 +# limitations under the License.
  15 +#
  16 +
  17 +FROM openjdk:8-jre
  18 +
  19 +COPY logback.xml ${pkg.name}.conf start-tb-http-transport.sh ${pkg.name}.deb /tmp/
  20 +
  21 +RUN chmod a+x /tmp/*.sh \
  22 + && mv /tmp/start-tb-http-transport.sh /usr/bin
  23 +
  24 +RUN dpkg -i /tmp/${pkg.name}.deb
  25 +
  26 +RUN update-rc.d ${pkg.name} disable
  27 +
  28 +RUN mv /tmp/logback.xml ${pkg.installFolder}/conf \
  29 + && mv /tmp/${pkg.name}.conf ${pkg.installFolder}/conf
  30 +
  31 +CMD ["start-tb-http-transport.sh"]
... ...
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<!--
  3 +
  4 + Copyright © 2016-2018 The Thingsboard Authors
  5 +
  6 + Licensed under the Apache License, Version 2.0 (the "License");
  7 + you may not use this file except in compliance with the License.
  8 + You may obtain a copy of the License at
  9 +
  10 + http://www.apache.org/licenses/LICENSE-2.0
  11 +
  12 + Unless required by applicable law or agreed to in writing, software
  13 + distributed under the License is distributed on an "AS IS" BASIS,
  14 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 + See the License for the specific language governing permissions and
  16 + limitations under the License.
  17 +
  18 +-->
  19 +<!DOCTYPE configuration>
  20 +<configuration scan="true" scanPeriod="10 seconds">
  21 +
  22 + <appender name="fileLogAppender"
  23 + class="ch.qos.logback.core.rolling.RollingFileAppender">
  24 + <file>/var/log/${pkg.name}/${pkg.name}.log</file>
  25 + <rollingPolicy
  26 + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
  27 + <fileNamePattern>/var/log/${pkg.name}/${pkg.name}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  28 + <maxFileSize>100MB</maxFileSize>
  29 + <maxHistory>30</maxHistory>
  30 + <totalSizeCap>3GB</totalSizeCap>
  31 + </rollingPolicy>
  32 + <encoder>
  33 + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
  34 + </encoder>
  35 + </appender>
  36 +
  37 + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
  38 + <encoder>
  39 + <pattern>%d{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
  40 + </encoder>
  41 + </appender>
  42 +
  43 + <logger name="org.thingsboard.server" level="INFO" />
  44 +
  45 + <root level="INFO">
  46 + <appender-ref ref="fileLogAppender"/>
  47 + <appender-ref ref="STDOUT"/>
  48 + </root>
  49 +
  50 +</configuration>
\ No newline at end of file
... ...
  1 +#!/bin/bash
  2 +#
  3 +# Copyright © 2016-2018 The Thingsboard Authors
  4 +#
  5 +# Licensed under the Apache License, Version 2.0 (the "License");
  6 +# you may not use this file except in compliance with the License.
  7 +# You may obtain a copy of the License at
  8 +#
  9 +# http://www.apache.org/licenses/LICENSE-2.0
  10 +#
  11 +# Unless required by applicable law or agreed to in writing, software
  12 +# distributed under the License is distributed on an "AS IS" BASIS,
  13 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +# See the License for the specific language governing permissions and
  15 +# limitations under the License.
  16 +#
  17 +
  18 +CONF_FOLDER="${pkg.installFolder}/conf"
  19 +jarfile=${pkg.installFolder}/bin/${pkg.name}.jar
  20 +configfile=${pkg.name}.conf
  21 +
  22 +source "${CONF_FOLDER}/${configfile}"
  23 +
  24 +echo "Starting '${project.name}' ..."
  25 +
  26 +exec java -cp ${jarfile} $JAVA_OPTS -Dloader.main=org.thingsboard.server.http.ThingsboardHttpTransportApplication \
  27 + -Dspring.jpa.hibernate.ddl-auto=none \
  28 + -Dlogging.config=${CONF_FOLDER}/logback.xml \
  29 + org.springframework.boot.loader.PropertiesLauncher
... ...
  1 +#
  2 +# Copyright © 2016-2018 The Thingsboard Authors
  3 +#
  4 +# Licensed under the Apache License, Version 2.0 (the "License");
  5 +# you may not use this file except in compliance with the License.
  6 +# You may obtain a copy of the License at
  7 +#
  8 +# http://www.apache.org/licenses/LICENSE-2.0
  9 +#
  10 +# Unless required by applicable law or agreed to in writing, software
  11 +# distributed under the License is distributed on an "AS IS" BASIS,
  12 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +# See the License for the specific language governing permissions and
  14 +# limitations under the License.
  15 +#
  16 +
  17 +export JAVA_OPTS="$JAVA_OPTS -Xloggc:@pkg.logFolder@/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
  18 +export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10"
  19 +export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark"
  20 +export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled"
  21 +export JAVA_OPTS="$JAVA_OPTS -XX:+CMSEdenChunksRecordAlways -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+ExitOnOutOfMemoryError"
  22 +export LOG_FILENAME=${pkg.name}.out
  23 +export LOADER_PATH=${pkg.installFolder}/conf
... ...
  1 +<!--
  2 +
  3 + Copyright © 2016-2018 The Thingsboard Authors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +
  17 +-->
  18 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  19 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  20 + <modelVersion>4.0.0</modelVersion>
  21 + <parent>
  22 + <groupId>org.thingsboard.msa</groupId>
  23 + <version>2.2.0-SNAPSHOT</version>
  24 + <artifactId>transport</artifactId>
  25 + </parent>
  26 + <groupId>org.thingsboard.msa.transport</groupId>
  27 + <artifactId>http</artifactId>
  28 + <packaging>pom</packaging>
  29 +
  30 + <name>ThingsBoard HTTP Transport Microservice</name>
  31 + <url>https://thingsboard.io</url>
  32 + <description>ThingsBoard HTTP Transport Microservice</description>
  33 +
  34 + <properties>
  35 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  36 + <main.dir>${basedir}/../../..</main.dir>
  37 + <pkg.name>tb-http-transport</pkg.name>
  38 + <docker.name>tb-http-transport</docker.name>
  39 + <pkg.user>thingsboard</pkg.user>
  40 + <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>
  41 + <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
  42 + </properties>
  43 +
  44 + <dependencies>
  45 + <dependency>
  46 + <groupId>org.thingsboard.transport</groupId>
  47 + <artifactId>http</artifactId>
  48 + <version>${project.version}</version>
  49 + <classifier>deb</classifier>
  50 + <type>deb</type>
  51 + <scope>provided</scope>
  52 + </dependency>
  53 + </dependencies>
  54 +
  55 + <build>
  56 + <plugins>
  57 + <plugin>
  58 + <groupId>org.apache.maven.plugins</groupId>
  59 + <artifactId>maven-dependency-plugin</artifactId>
  60 + <executions>
  61 + <execution>
  62 + <id>copy-tb-http-transport-deb</id>
  63 + <phase>package</phase>
  64 + <goals>
  65 + <goal>copy</goal>
  66 + </goals>
  67 + <configuration>
  68 + <artifactItems>
  69 + <artifactItem>
  70 + <groupId>org.thingsboard.transport</groupId>
  71 + <artifactId>http</artifactId>
  72 + <classifier>deb</classifier>
  73 + <type>deb</type>
  74 + <destFileName>${pkg.name}.deb</destFileName>
  75 + <outputDirectory>${project.build.directory}</outputDirectory>
  76 + </artifactItem>
  77 + </artifactItems>
  78 + </configuration>
  79 + </execution>
  80 + </executions>
  81 + </plugin>
  82 + <plugin>
  83 + <groupId>org.apache.maven.plugins</groupId>
  84 + <artifactId>maven-resources-plugin</artifactId>
  85 + <executions>
  86 + <execution>
  87 + <id>copy-docker-config</id>
  88 + <phase>process-resources</phase>
  89 + <goals>
  90 + <goal>copy-resources</goal>
  91 + </goals>
  92 + <configuration>
  93 + <outputDirectory>${project.build.directory}</outputDirectory>
  94 + <resources>
  95 + <resource>
  96 + <directory>docker</directory>
  97 + <filtering>true</filtering>
  98 + </resource>
  99 + </resources>
  100 + </configuration>
  101 + </execution>
  102 + </executions>
  103 + </plugin>
  104 + <plugin>
  105 + <groupId>com.spotify</groupId>
  106 + <artifactId>dockerfile-maven-plugin</artifactId>
  107 + <executions>
  108 + <execution>
  109 + <id>build-docker-image</id>
  110 + <phase>pre-integration-test</phase>
  111 + <goals>
  112 + <goal>build</goal>
  113 + </goals>
  114 + </execution>
  115 + </executions>
  116 + <configuration>
  117 + <skip>${dockerfile.skip}</skip>
  118 + <repository>${docker.repo}/${docker.name}</repository>
  119 + <tag>${project.version}</tag>
  120 + <verbose>true</verbose>
  121 + <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
  122 + <contextDirectory>${project.build.directory}</contextDirectory>
  123 + </configuration>
  124 + </plugin>
  125 + </plugins>
  126 + </build>
  127 + <repositories>
  128 + <repository>
  129 + <id>jenkins</id>
  130 + <name>Jenkins Repository</name>
  131 + <url>http://repo.jenkins-ci.org/releases</url>
  132 + <snapshots>
  133 + <enabled>false</enabled>
  134 + </snapshots>
  135 + </repository>
  136 + </repositories>
  137 +</project>
... ...
... ... @@ -36,6 +36,8 @@
36 36
37 37 <modules>
38 38 <module>mqtt</module>
  39 + <module>http</module>
  40 + <module>coap</module>
39 41 </modules>
40 42
41 43 <build>
... ...
transport/http/src/main/java/org/thingsboard/server/http/ThingsboardHttpTransportApplication.java renamed from transport/http/src/main/java/org/thingsboard/server/mqtt/ThingsboardHttpTransportApplication.java
1   -package org.thingsboard.server.mqtt; /**
  1 +/**
2 2 * Copyright © 2016-2018 The Thingsboard Authors
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
... ... @@ -14,13 +14,12 @@ package org.thingsboard.server.mqtt; /**
14 14 * limitations under the License.
15 15 */
16 16
  17 +package org.thingsboard.server.http;
  18 +
17 19 import org.springframework.boot.SpringApplication;
18   -import org.springframework.boot.SpringBootConfiguration;
19   -import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
20 20 import org.springframework.boot.autoconfigure.SpringBootApplication;
21 21 import org.springframework.context.annotation.ComponentScan;
22 22 import org.springframework.scheduling.annotation.EnableAsync;
23   -import org.springframework.scheduling.annotation.EnableScheduling;
24 23
25 24 import java.util.Arrays;
26 25
... ...
1   -package org.thingsboard.server.mqtt; /**
  1 +/**
2 2 * Copyright © 2016-2018 The Thingsboard Authors
3 3 *
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
... ... @@ -14,6 +14,8 @@ package org.thingsboard.server.mqtt; /**
14 14 * limitations under the License.
15 15 */
16 16
  17 +package org.thingsboard.server.mqtt;
  18 +
17 19 import org.springframework.boot.SpringApplication;
18 20 import org.springframework.boot.SpringBootConfiguration;
19 21 import org.springframework.context.annotation.ComponentScan;
... ...