Browse Source

Minor refactoring

pull/7371/head
ViacheslavKlimov 4 years ago
parent
commit
7eea5a6cda
  1. 3
      application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java
  2. 4
      application/src/main/java/org/thingsboard/server/service/ttl/AuditLogsCleanUpService.java
  3. 2
      application/src/main/resources/thingsboard.yml
  4. 1
      dao/src/main/java/org/thingsboard/server/dao/sqlts/insert/sql/SqlPartitioningRepository.java

3
application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java

@ -184,7 +184,10 @@ public class DefaultDataUpdateService implements DataUpdateService {
boolean skipAuditLogsMigration = getEnv("TB_SKIP_AUDIT_LOGS_MIGRATION", false);
if (!skipAuditLogsMigration) {
log.info("Updating data from version 3.4.1 to 3.4.2 ...");
log.info("Starting audit logs migration. Can be skipped with TB_SKIP_AUDIT_LOGS_MIGRATION env variable set to true");
auditLogDao.migrateAuditLogs();
} else {
log.info("Skipping audit logs migration");
}
break;
default:

4
application/src/main/java/org/thingsboard/server/service/ttl/AuditLogsCleanUpService.java

@ -49,8 +49,8 @@ public class AuditLogsCleanUpService extends AbstractCleanUpService {
this.partitioningRepository = partitioningRepository;
}
@Scheduled(initialDelayString = "#{T(org.apache.commons.lang3.RandomUtils).nextLong(0, ${sql.ttl.audit_logs.execution_interval_ms})}",
fixedDelayString = "${sql.ttl.audit_logs.execution_interval_ms}")
@Scheduled(initialDelayString = "#{T(org.apache.commons.lang3.RandomUtils).nextLong(0, ${sql.ttl.audit_logs.checking_interval_ms})}",
fixedDelayString = "${sql.ttl.audit_logs.checking_interval_ms}")
public void cleanUp() {
long auditLogsExpTime = System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(ttlInSec);
if (isSystemTenantPartitionMine()) {

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

@ -308,7 +308,7 @@ sql:
audit_logs:
enabled: "${SQL_TTL_AUDIT_LOGS_ENABLED:true}"
ttl: "${SQL_TTL_AUDIT_LOGS_SECS:0}" # Disabled by default. Accuracy of the cleanup depends on the sql.audit_logs.partition_size
execution_interval_ms: "${SQL_TTL_AUDIT_LOGS_EXECUTION_INTERVAL_MS:86400000}" # Default value - 1 day
checking_interval_ms: "${SQL_TTL_AUDIT_LOGS_CHECKING_INTERVAL_MS:86400000}" # Default value - 1 day
relations:
max_level: "${SQL_RELATIONS_MAX_LEVEL:50}" # //This value has to be reasonable small to prevent infinite recursion as early as possible

1
dao/src/main/java/org/thingsboard/server/dao/sqlts/insert/sql/SqlPartitioningRepository.java

@ -63,6 +63,7 @@ public class SqlPartitioningRepository {
SqlPartition partition = new SqlPartition(table, partitionStartTs, partitionStartTs + partitionDurationMs, Long.toString(partitionStartTs));
partitionCreationLock.lock();
try {
if (partitions.containsKey(partitionStartTs)) return;
log.trace("Saving partition: {}", partition);
save(partition);
log.trace("Adding partition to map: {}", partition);

Loading…
Cancel
Save