Refactoring of Docker Compose
This commit is contained in:
parent
a91a69c57f
commit
b5bedbfdf6
@ -3,7 +3,7 @@
|
||||
"additionalInfo": null,
|
||||
"name": "Root Rule Chain",
|
||||
"firstRuleNodeId": null,
|
||||
"root": false,
|
||||
"root": true,
|
||||
"debugMode": false,
|
||||
"configuration": null
|
||||
},
|
||||
|
||||
@ -161,15 +161,15 @@ public class RuleChainController extends BaseController {
|
||||
TenantId tenantId = getCurrentUser().getTenantId();
|
||||
RuleChain previousRootRuleChain = ruleChainService.getRootTenantRuleChain(tenantId);
|
||||
if (ruleChainService.setRootRuleChain(getTenantId(), ruleChainId)) {
|
||||
if (previousRootRuleChain != null) {
|
||||
previousRootRuleChain = ruleChainService.findRuleChainById(getTenantId(), previousRootRuleChain.getId());
|
||||
|
||||
previousRootRuleChain = ruleChainService.findRuleChainById(getTenantId(), previousRootRuleChain.getId());
|
||||
|
||||
tbClusterService.onEntityStateChange(previousRootRuleChain.getTenantId(), previousRootRuleChain.getId(),
|
||||
ComponentLifecycleEvent.UPDATED);
|
||||
|
||||
logEntityAction(previousRootRuleChain.getId(), previousRootRuleChain,
|
||||
null, ActionType.UPDATED, null);
|
||||
tbClusterService.onEntityStateChange(previousRootRuleChain.getTenantId(), previousRootRuleChain.getId(),
|
||||
ComponentLifecycleEvent.UPDATED);
|
||||
|
||||
logEntityAction(previousRootRuleChain.getId(), previousRootRuleChain,
|
||||
null, ActionType.UPDATED, null);
|
||||
}
|
||||
ruleChain = ruleChainService.findRuleChainById(getTenantId(), ruleChainId);
|
||||
|
||||
tbClusterService.onEntityStateChange(ruleChain.getTenantId(), ruleChain.getId(),
|
||||
|
||||
@ -88,26 +88,33 @@ public class BaseRuleChainService extends AbstractEntityService implements RuleC
|
||||
RuleChain ruleChain = ruleChainDao.findById(tenantId, ruleChainId.getId());
|
||||
if (!ruleChain.isRoot()) {
|
||||
RuleChain previousRootRuleChain = getRootTenantRuleChain(ruleChain.getTenantId());
|
||||
if (!previousRootRuleChain.getId().equals(ruleChain.getId())) {
|
||||
try {
|
||||
try {
|
||||
if (previousRootRuleChain == null) {
|
||||
setRootAndSave(tenantId, ruleChain);
|
||||
return true;
|
||||
} else if (!previousRootRuleChain.getId().equals(ruleChain.getId())) {
|
||||
deleteRelation(tenantId, new EntityRelation(previousRootRuleChain.getTenantId(), previousRootRuleChain.getId(),
|
||||
EntityRelation.CONTAINS_TYPE, RelationTypeGroup.RULE_CHAIN));
|
||||
previousRootRuleChain.setRoot(false);
|
||||
ruleChainDao.save(tenantId, previousRootRuleChain);
|
||||
createRelation(tenantId, new EntityRelation(ruleChain.getTenantId(), ruleChain.getId(),
|
||||
EntityRelation.CONTAINS_TYPE, RelationTypeGroup.RULE_CHAIN));
|
||||
ruleChain.setRoot(true);
|
||||
ruleChainDao.save(tenantId, ruleChain);
|
||||
setRootAndSave(tenantId, ruleChain);
|
||||
return true;
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.warn("[{}] Failed to set root rule chain, ruleChainId: [{}]", ruleChainId);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.warn("[{}] Failed to set root rule chain, ruleChainId: [{}]", ruleChainId);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setRootAndSave(TenantId tenantId, RuleChain ruleChain) throws ExecutionException, InterruptedException {
|
||||
createRelation(tenantId, new EntityRelation(ruleChain.getTenantId(), ruleChain.getId(),
|
||||
EntityRelation.CONTAINS_TYPE, RelationTypeGroup.RULE_CHAIN));
|
||||
ruleChain.setRoot(true);
|
||||
ruleChainDao.save(tenantId, ruleChain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleChainMetaData saveRuleChainMetaData(TenantId tenantId, RuleChainMetaData ruleChainMetaData) {
|
||||
Validator.validateId(ruleChainMetaData.getRuleChainId(), "Incorrect rule chain id.");
|
||||
|
||||
@ -58,7 +58,7 @@ In case of any issues you can examine service logs for errors.
|
||||
For example to see ThingsBoard node logs execute the following command:
|
||||
|
||||
`
|
||||
$ docker-compose logs -f tb1
|
||||
$ docker-compose logs -f tb-core1 tb-rule-engine1
|
||||
`
|
||||
|
||||
Or use `docker-compose ps` to see the state of all the containers.
|
||||
|
||||
@ -24,14 +24,28 @@ services:
|
||||
- "9042"
|
||||
volumes:
|
||||
- ./tb-node/cassandra:/var/lib/cassandra
|
||||
tb1:
|
||||
tb-core1:
|
||||
env_file:
|
||||
- tb-node.cassandra.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- cassandra
|
||||
tb2:
|
||||
tb-core2:
|
||||
env_file:
|
||||
- tb-node.cassandra.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- cassandra
|
||||
tb-rule-engine1:
|
||||
env_file:
|
||||
- tb-node.cassandra.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- cassandra
|
||||
tb-rule-engine2:
|
||||
env_file:
|
||||
- tb-node.cassandra.env
|
||||
depends_on:
|
||||
|
||||
@ -20,10 +20,16 @@ services:
|
||||
postgres:
|
||||
volumes:
|
||||
- postgres-db-volume:/var/lib/postgresql/data
|
||||
tb1:
|
||||
tb-core1:
|
||||
volumes:
|
||||
- tb-log-volume:/var/log/thingsboard
|
||||
tb2:
|
||||
tb-core2:
|
||||
volumes:
|
||||
- tb-log-volume:/var/log/thingsboard
|
||||
tb-rule-engine1:
|
||||
volumes:
|
||||
- tb-log-volume:/var/log/thingsboard
|
||||
tb-rule-engine2:
|
||||
volumes:
|
||||
- tb-log-volume:/var/log/thingsboard
|
||||
tb-coap-transport:
|
||||
|
||||
@ -27,14 +27,28 @@ services:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
volumes:
|
||||
- ./tb-node/postgres:/var/lib/postgresql/data
|
||||
tb1:
|
||||
tb-core1:
|
||||
env_file:
|
||||
- tb-node.postgres.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- postgres
|
||||
tb2:
|
||||
tb-core2:
|
||||
env_file:
|
||||
- tb-node.postgres.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- postgres
|
||||
tb-rule-engine1:
|
||||
env_file:
|
||||
- tb-node.postgres.env
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- postgres
|
||||
tb-rule-engine2:
|
||||
env_file:
|
||||
- tb-node.postgres.env
|
||||
depends_on:
|
||||
|
||||
@ -48,7 +48,7 @@ services:
|
||||
- tb-js-executor.env
|
||||
depends_on:
|
||||
- kafka
|
||||
tb1:
|
||||
tb-core1:
|
||||
restart: always
|
||||
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
|
||||
ports:
|
||||
@ -59,7 +59,8 @@ services:
|
||||
max-size: "200m"
|
||||
max-file: "30"
|
||||
environment:
|
||||
TB_SERVICE_ID: tb1
|
||||
TB_SERVICE_ID: tb-core1
|
||||
TB_SERVICE_TYPE: tb-core
|
||||
env_file:
|
||||
- tb-node.env
|
||||
volumes:
|
||||
@ -69,7 +70,7 @@ services:
|
||||
- kafka
|
||||
- redis
|
||||
- tb-js-executor
|
||||
tb2:
|
||||
tb-core2:
|
||||
restart: always
|
||||
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
|
||||
ports:
|
||||
@ -80,7 +81,52 @@ services:
|
||||
max-size: "200m"
|
||||
max-file: "30"
|
||||
environment:
|
||||
TB_SERVICE_ID: tb2
|
||||
TB_SERVICE_ID: tb-core2
|
||||
TB_SERVICE_TYPE: tb-core
|
||||
env_file:
|
||||
- tb-node.env
|
||||
volumes:
|
||||
- ./tb-node/conf:/config
|
||||
- ./tb-node/log:/var/log/thingsboard
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- tb-js-executor
|
||||
tb-rule-engine1:
|
||||
restart: always
|
||||
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
|
||||
ports:
|
||||
- "8080"
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "200m"
|
||||
max-file: "30"
|
||||
environment:
|
||||
TB_SERVICE_ID: tb-rule-engine1
|
||||
TB_SERVICE_TYPE: tb-rule-engine
|
||||
env_file:
|
||||
- tb-node.env
|
||||
volumes:
|
||||
- ./tb-node/conf:/config
|
||||
- ./tb-node/log:/var/log/thingsboard
|
||||
depends_on:
|
||||
- kafka
|
||||
- redis
|
||||
- tb-js-executor
|
||||
tb-rule-engine2:
|
||||
restart: always
|
||||
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
|
||||
ports:
|
||||
- "8080"
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "200m"
|
||||
max-file: "30"
|
||||
environment:
|
||||
TB_SERVICE_ID: tb-rule-engine2
|
||||
TB_SERVICE_TYPE: tb-rule-engine
|
||||
env_file:
|
||||
- tb-node.env
|
||||
volumes:
|
||||
@ -195,8 +241,8 @@ services:
|
||||
MQTT_PORT: 1883
|
||||
FORCE_HTTPS_REDIRECT: "false"
|
||||
links:
|
||||
- tb1
|
||||
- tb2
|
||||
- tb-core1
|
||||
- tb-core2
|
||||
- tb-web-ui1
|
||||
- tb-web-ui2
|
||||
- tb-mqtt-transport1
|
||||
|
||||
@ -49,6 +49,6 @@ if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
|
||||
fi
|
||||
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb1
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb-core1
|
||||
|
||||
|
||||
|
||||
@ -44,8 +44,8 @@ ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
|
||||
|
||||
ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $?
|
||||
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull tb1
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull tb-core1
|
||||
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
|
||||
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb1
|
||||
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb-core1
|
||||
|
||||
@ -111,6 +111,6 @@ backend tb-api-backend
|
||||
balance leastconn
|
||||
option tcp-check
|
||||
option log-health-checks
|
||||
server tbApi1 tb1:8080 check inter 5s resolvers docker_resolver resolve-prefer ipv4
|
||||
server tbApi2 tb2:8080 check inter 5s resolvers docker_resolver resolve-prefer ipv4
|
||||
server tbApi1 tb-core1:8080 check inter 5s resolvers docker_resolver resolve-prefer ipv4
|
||||
server tbApi2 tb-core2:8080 check inter 5s resolvers docker_resolver resolve-prefer ipv4
|
||||
http-request set-header X-Forwarded-Port %[dst_port]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
REMOTE_JS_EVAL_REQUEST_TOPIC=js.eval.requests
|
||||
REMOTE_JS_EVAL_REQUEST_TOPIC=js_eval.requests
|
||||
TB_KAFKA_SERVERS=kafka:9092
|
||||
LOGGER_LEVEL=info
|
||||
LOG_FOLDER=logs
|
||||
|
||||
@ -4,7 +4,7 @@ ZOOKEEPER_ENABLED=true
|
||||
ZOOKEEPER_URL=zookeeper:2181
|
||||
TB_QUEUE_TYPE=kafka
|
||||
TB_KAFKA_SERVERS=kafka:9092
|
||||
JS_EVALUATOR=local
|
||||
JS_EVALUATOR=remote
|
||||
TRANSPORT_TYPE=remote
|
||||
CACHE_TYPE=redis
|
||||
REDIS_HOST=redis
|
||||
|
||||
@ -92,7 +92,7 @@ public class ThingsBoardDbInstaller extends ExternalResource {
|
||||
dockerCompose.withCommand("up -d redis postgres");
|
||||
dockerCompose.invokeCompose();
|
||||
|
||||
dockerCompose.withCommand("run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=true tb1");
|
||||
dockerCompose.withCommand("run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=true tb-core1");
|
||||
dockerCompose.invokeCompose();
|
||||
|
||||
} finally {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user