From b1359750610e953b1f68b16cab5309c3c260f167 Mon Sep 17 00:00:00 2001 From: thingsboard017 Date: Fri, 29 Nov 2024 12:30:56 +0200 Subject: [PATCH] Fix issues from code review --- .../service/update/DeprecationService.java | 33 +++++-------------- .../src/main/resources/thingsboard.yml | 4 +-- .../notification/DefaultNotifications.java | 6 ++-- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java b/application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java index 539b5c58bb..ef73848669 100644 --- a/application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java +++ b/application/src/main/java/org/thingsboard/server/service/update/DeprecationService.java @@ -73,32 +73,15 @@ public class DeprecationService { } private void checkDatabaseTypeDeprecation() { - String deprecatedDatabaseType = "timescale"; - var fieldsWithDeprecatedType = new ArrayList(); + if ("timescale".equals(tsType) || "timescale".equals(tsLatestType)) { + String deprecatedDatabaseType = "Timescale"; - addFieldIfValueDeprecated(tsType, "ts", fieldsWithDeprecatedType, deprecatedDatabaseType); - addFieldIfValueDeprecated(tsLatestType, "ts_latest", fieldsWithDeprecatedType, deprecatedDatabaseType); - - if (fieldsWithDeprecatedType.isEmpty()) { - return; - } - - String deprecatedFieldNames = String.join(", ", fieldsWithDeprecatedType); - - log.warn("WARNING: Starting with ThingsBoard 4.0, {} will no longer be supported as a database type for telemetry storage. " + - "Please migrate to Cassandra or SQL-based storage solutions. This change will not impact the telemetry query.", - deprecatedDatabaseType); - - notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(), - DefaultNotifications.databaseTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of( - "databaseType", deprecatedDatabaseType, - "deprecatedFields", deprecatedFieldNames - ))); - } - - private void addFieldIfValueDeprecated(String fieldValue, String fieldName, List fieldsWithDeprecatedType, String deprecatedDatabaseType) { - if (deprecatedDatabaseType.equals(fieldValue)) { - fieldsWithDeprecatedType.add(fieldName); + 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); + notificationCenter.sendGeneralWebNotification(TenantId.SYS_TENANT_ID, new SystemAdministratorsFilter(), + DefaultNotifications.databaseTypeDeprecation.toTemplate(), new GeneralNotificationInfo(Map.of( + "databaseType", deprecatedDatabaseType + ))); } } } diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 09d97b7e88..a4fd737afc 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -212,9 +212,9 @@ ui: 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: - type: "${DATABASE_TS_TYPE:timescale}" # cassandra, sql (timescale is deprecated and no longer supported in ThingsBoard 4.0) + type: "${DATABASE_TS_TYPE:sql}" # cassandra, sql. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0 ts_latest: - type: "${DATABASE_TS_LATEST_TYPE:sql}" # cassandra, sql (timescale is deprecated and no longer supported in ThingsBoard 4.0) + type: "${DATABASE_TS_LATEST_TYPE:sql}" # cassandra, sql. timescale option is deprecated and will no longer be supported in ThingsBoard 4.0 # Cassandra driver configuration parameters cassandra: diff --git a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java b/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java index 6a904b5e64..81af17b75f 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java +++ b/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() .name("Database type deprecation") .type(NotificationType.GENERAL) - .subject("WARNING: Database type '${databaseType}' is deprecated") - .text("Starting with ThingsBoard 4.0, the database type '${databaseType}' (${deprecatedFields}) will no longer be supported. " + - "Please migrate to Cassandra or SQL-based storage solutions") + .subject("WARNING: '${databaseType}' deprecation") + .text("Starting with ThingsBoard 4.0, the database type '${databaseType}' will no longer be supported as a storage provider." + + "Please migrate to Cassandra or Cassandra or PostgreSQL") .icon("warning") .color(RED_COLOR) .build();