Fix EntityDaoRegistry init
This commit is contained in:
parent
40d9789035
commit
881a8048ce
@ -1643,7 +1643,7 @@ queue:
|
||||
# DELETE_LATEST_TS, DELETE_TS_HISTORY, DELETE_EVENTS, DELETE_ALARMS, UNASSIGN_ALARMS
|
||||
disabled-task-types: "${TB_HOUSEKEEPER_DISABLED_TASK_TYPES:}"
|
||||
# Delay in milliseconds between tasks reprocessing
|
||||
task-reprocessing-delay-ms: "${TB_HOUSEKEEPER_TASK_REPROCESSING_DELAY_MS:5000}"
|
||||
task-reprocessing-delay-ms: "${TB_HOUSEKEEPER_TASK_REPROCESSING_DELAY_MS:3000}"
|
||||
# Maximum amount of task reprocessing attempts. After exceeding, the task will be dropped
|
||||
max-reprocessing-attempts: "${TB_HOUSEKEEPER_MAX_REPROCESSING_ATTEMPTS:10}"
|
||||
stats:
|
||||
|
||||
@ -32,7 +32,7 @@ public class HousekeeperConfig {
|
||||
private int taskProcessingTimeout;
|
||||
@Value("${queue.core.housekeeper.poll-interval-ms:500}")
|
||||
private int pollInterval;
|
||||
@Value("${queue.core.housekeeper.task-reprocessing-delay-ms:5000}")
|
||||
@Value("${queue.core.housekeeper.task-reprocessing-delay-ms:3000}")
|
||||
private int taskReprocessingDelay;
|
||||
@Value("${queue.core.housekeeper.max-reprocessing-attempts:10}")
|
||||
private int maxReprocessingAttempts;
|
||||
|
||||
@ -20,19 +20,23 @@ import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.dao.Dao;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EntityDaoRegistry {
|
||||
|
||||
private final Map<EntityType, Dao<?>> daos;
|
||||
private final Map<EntityType, Dao<?>> daos = new EnumMap<>(EntityType.class);
|
||||
|
||||
private EntityDaoRegistry(List<Dao<?>> daos) {
|
||||
this.daos = daos.stream().filter(dao -> dao.getEntityType() != null)
|
||||
.collect(Collectors.toMap(Dao::getEntityType, dao -> dao));
|
||||
daos.forEach(dao -> {
|
||||
EntityType entityType = dao.getEntityType();
|
||||
if (entityType != null) {
|
||||
this.daos.put(entityType, dao);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user