Fix issues from code review

This commit is contained in:
thingsboard017 2024-11-29 12:30:56 +02:00
parent 01c45240f1
commit b135975061
3 changed files with 13 additions and 30 deletions

View File

@ -73,32 +73,15 @@ public class DeprecationService {
}
private void checkDatabaseTypeDeprecation() {
String deprecatedDatabaseType = "timescale";
var fieldsWithDeprecatedType = new ArrayList<String>();
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<String> 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
)));
}
}
}

View File

@ -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:

View File

@ -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();