Browse Source

Implemented timescale deprecated notification

pull/12129/head
thingsboard017 2 years ago
parent
commit
01c45240f1
  1. 38
      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

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

@ -26,6 +26,8 @@ import org.thingsboard.server.common.data.notification.targets.platform.SystemAd
import org.thingsboard.server.dao.notification.DefaultNotifications;
import org.thingsboard.server.queue.util.AfterStartUp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service
@ -38,9 +40,16 @@ public class DeprecationService {
@Value("${queue.type}")
private String queueType;
@Value("${database.ts.type}")
private String tsType;
@Value("${database.ts_latest.type}")
private String tsLatestType;
@AfterStartUp(order = Integer.MAX_VALUE)
public void checkDeprecation() {
checkQueueTypeDeprecation();
checkDatabaseTypeDeprecation();
}
private void checkQueueTypeDeprecation() {
@ -63,4 +72,33 @@ public class DeprecationService {
)));
}
private void checkDatabaseTypeDeprecation() {
String deprecatedDatabaseType = "timescale";
var fieldsWithDeprecatedType = new ArrayList<String>();
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<String> fieldsWithDeprecatedType, String deprecatedDatabaseType) {
if (deprecatedDatabaseType.equals(fieldValue)) {
fieldsWithDeprecatedType.add(fieldName);
}
}
}

4
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:sql}" # cassandra, sql, or timescale (for hybrid mode, DATABASE_TS_TYPE value should be cassandra, or timescale)
type: "${DATABASE_TS_TYPE:timescale}" # cassandra, sql (timescale is deprecated and no longer supported in ThingsBoard 4.0)
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, sql (timescale is deprecated and no longer supported in ThingsBoard 4.0)
# Cassandra driver configuration parameters
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)
.build();
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")
.icon("warning")
.color(RED_COLOR)
.build();
private final NotificationTemplateService templateService;
private final NotificationRuleService ruleService;

Loading…
Cancel
Save