Browse Source

Merge pull request #12129 from artem-barysh-dev/timescale-deprecation

Deprecate Timescale
pull/12157/head
Viacheslav Klimov 2 years ago
committed by GitHub
parent
commit
f168b35c59
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 30
      application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java
  2. 4
      application/src/main/resources/thingsboard.yml
  3. 10
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

30
application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java

@ -17,6 +17,7 @@ package org.thingsboard.server.service.update;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.thingsboard.rule.engine.api.NotificationCenter; import org.thingsboard.rule.engine.api.NotificationCenter;
@ -24,6 +25,7 @@ import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo; import org.thingsboard.server.common.data.notification.info.GeneralNotificationInfo;
import org.thingsboard.server.common.data.notification.targets.platform.SystemAdministratorsFilter; import org.thingsboard.server.common.data.notification.targets.platform.SystemAdministratorsFilter;
import org.thingsboard.server.dao.notification.DefaultNotifications; import org.thingsboard.server.dao.notification.DefaultNotifications;
import org.thingsboard.server.dao.notification.DefaultNotifications.DefaultNotification;
import org.thingsboard.server.queue.util.AfterStartUp; import org.thingsboard.server.queue.util.AfterStartUp;
import java.util.Map; import java.util.Map;
@ -38,9 +40,16 @@ public class DeprecationService {
@Value("${queue.type}") @Value("${queue.type}")
private String queueType; private String queueType;
@Value("${database.ts.type}")
private String tsType;
@Value("${database.ts_latest.type}")
private String tsLatestType;
@AfterStartUp(order = Integer.MAX_VALUE) @AfterStartUp(order = Integer.MAX_VALUE)
public void checkDeprecation() { public void checkDeprecation() {
checkQueueTypeDeprecation(); checkQueueTypeDeprecation();
checkDatabaseTypeDeprecation();
} }
private void checkQueueTypeDeprecation() { private void checkQueueTypeDeprecation() {
@ -57,10 +66,25 @@ public class DeprecationService {
log.warn("WARNING: Starting with ThingsBoard 4.0, {} will no longer be supported as a message queue for microservices. " + log.warn("WARNING: Starting with ThingsBoard 4.0, {} will no longer be supported as a message queue for microservices. " +
"Please migrate to Apache Kafka. This change will not impact any rule nodes", queueTypeName); "Please migrate to Apache Kafka. This change will not impact any rule nodes", queueTypeName);
sendNotification(DefaultNotifications.queueTypeDeprecation, Map.of(
"queueType", queueTypeName
));
}
private void checkDatabaseTypeDeprecation() {
String deprecatedDatabaseType = "Timescale";
if (StringUtils.equalsAnyIgnoreCase(deprecatedDatabaseType, tsType, tsLatestType)) {
log.warn("WARNING: Starting with ThingsBoard 4.0, {} will no longer be supported as a storage provider. " +
"Please migrate to Cassandra or PostgreSQL.", deprecatedDatabaseType);
sendNotification(DefaultNotifications.databaseTypeDeprecation, Map.of(
"databaseType", deprecatedDatabaseType
));
}
}
private void sendNotification(DefaultNotification notification, Map<String, String> info) {
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(), notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(),
DefaultNotifications.queueTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of( notification.toTemplate(), new GeneralNotificationInfo(info));
"queueType", queueTypeName
)));
} }
} }

4
application/src/main/resources/thingsboard.yml

@ -212,9 +212,9 @@ ui:
database: database:
ts_max_intervals: "${DATABASE_TS_MAX_INTERVALS:700}" # Max number of DB queries generated by a single API call to fetch telemetry records ts_max_intervals: "${DATABASE_TS_MAX_INTERVALS:700}" # Max number of DB queries generated by a single API call to fetch telemetry records
ts: ts:
type: "${DATABASE_TS_TYPE:sql}" # cassandra, sql, or timescale (for hybrid mode, DATABASE_TS_TYPE value should be cassandra, or timescale) type: "${DATABASE_TS_TYPE:sql}" # cassandra or sql. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0
ts_latest: ts_latest:
type: "${DATABASE_TS_LATEST_TYPE:sql}" # cassandra, sql, or timescale (for hybrid mode, DATABASE_TS_TYPE value should be cassandra, or timescale) type: "${DATABASE_TS_LATEST_TYPE:sql}" # cassandra or sql. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0
# Cassandra driver configuration parameters # Cassandra driver configuration parameters
cassandra: cassandra:

10
dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

@ -381,6 +381,16 @@ public class DefaultNotifications {
.icon("warning").color(RED_COLOR) .icon("warning").color(RED_COLOR)
.build(); .build();
public static final DefaultNotification databaseTypeDeprecation = DefaultNotification.builder()
.name("Database type deprecation")
.type(NotificationType.GENERAL)
.subject("WARNING: ${databaseType} deprecation")
.text("Starting with ThingsBoard 4.0, ${databaseType} will no longer be supported as a storage provider. " +
"Please migrate to Cassandra or PostgreSQL.")
.icon("warning")
.color(RED_COLOR)
.build();
private final NotificationTemplateService templateService; private final NotificationTemplateService templateService;
private final NotificationRuleService ruleService; private final NotificationRuleService ruleService;

Loading…
Cancel
Save