Browse Source

Refactoring for Timescale deprecation

pull/12129/head
ViacheslavKlimov 2 years ago
parent
commit
4e22667fe1
  1. 29
      application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java
  2. 4
      application/src/main/resources/thingsboard.yml
  3. 6
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

29
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;
@ -64,22 +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);
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(), sendNotification(DefaultNotifications.queueTypeDeprecation, Map.of(
DefaultNotifications.queueTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of( "queueType", queueTypeName
"queueType", queueTypeName ));
)));
} }
private void checkDatabaseTypeDeprecation() { private void checkDatabaseTypeDeprecation() {
if ("timescale".equals(tsType) || "timescale".equals(tsLatestType)) { String deprecatedDatabaseType = "Timescale";
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. " +
log.warn("WARNING: Starting with ThingsBoard 4.0, the database type {} will no longer be supported as a storage provider. " +
"Please migrate to Cassandra or PostgreSQL.", deprecatedDatabaseType); "Please migrate to Cassandra or PostgreSQL.", deprecatedDatabaseType);
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(), sendNotification(DefaultNotifications.databaseTypeDeprecation, Map.of(
DefaultNotifications.databaseTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of( "databaseType", deprecatedDatabaseType
"databaseType", deprecatedDatabaseType ));
)));
} }
} }
private void sendNotification(DefaultNotification notification, Map<String, String> info) {
notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(),
notification.toTemplate(), new GeneralNotificationInfo(info));
}
} }

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. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0 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. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0 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:

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

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

Loading…
Cancel
Save