New system parameters: default cassandra ts key/val ttl; allow system mail service for rules.
This commit is contained in:
parent
55127ae61c
commit
94db399367
@ -235,6 +235,10 @@ public class ActorSystemContext {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean tenantComponentsInitEnabled;
|
private boolean tenantComponentsInitEnabled;
|
||||||
|
|
||||||
|
@Value("${actors.rule.allow_system_mail_service}")
|
||||||
|
@Getter
|
||||||
|
private boolean allowSystemMailService;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private ActorSystem actorSystem;
|
private ActorSystem actorSystem;
|
||||||
|
|||||||
@ -209,7 +209,11 @@ class DefaultTbContext implements TbContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MailService getMailService() {
|
public MailService getMailService() {
|
||||||
return mainCtx.getMailService();
|
if (mainCtx.isAllowSystemMailService()) {
|
||||||
|
return mainCtx.getMailService();
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Access to System Mail Service is forbidden!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -40,10 +40,10 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class DefaultMsgQueueService implements MsgQueueService {
|
public class DefaultMsgQueueService implements MsgQueueService {
|
||||||
|
|
||||||
@Value("${rule.queue.max_size}")
|
@Value("${actors.rule.queue.max_size}")
|
||||||
private long queueMaxSize;
|
private long queueMaxSize;
|
||||||
|
|
||||||
@Value("${rule.queue.cleanup_period}")
|
@Value("${actors.rule.queue.cleanup_period}")
|
||||||
private long queueCleanUpPeriod;
|
private long queueCleanUpPeriod;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@ -203,6 +203,7 @@ cassandra:
|
|||||||
default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}"
|
default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}"
|
||||||
# Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS
|
# Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS
|
||||||
ts_key_value_partitioning: "${TS_KV_PARTITIONING:MONTHS}"
|
ts_key_value_partitioning: "${TS_KV_PARTITIONING:MONTHS}"
|
||||||
|
ts_key_value_ttl: "${TS_KV_TTL:0}"
|
||||||
buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}"
|
buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}"
|
||||||
concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}"
|
concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}"
|
||||||
permit_max_wait_time: "${PERMIT_MAX_WAIT_TIME:120000}"
|
permit_max_wait_time: "${PERMIT_MAX_WAIT_TIME:120000}"
|
||||||
@ -236,6 +237,8 @@ actors:
|
|||||||
js_thread_pool_size: "${ACTORS_RULE_JS_THREAD_POOL_SIZE:10}"
|
js_thread_pool_size: "${ACTORS_RULE_JS_THREAD_POOL_SIZE:10}"
|
||||||
# Specify thread pool size for mail sender executor service
|
# Specify thread pool size for mail sender executor service
|
||||||
mail_thread_pool_size: "${ACTORS_RULE_MAIL_THREAD_POOL_SIZE:10}"
|
mail_thread_pool_size: "${ACTORS_RULE_MAIL_THREAD_POOL_SIZE:10}"
|
||||||
|
# Whether to allow usage of system mail service for rules
|
||||||
|
allow_system_mail_service: "${ACTORS_RULE_ALLOW_SYSTEM_MAIL_SERVICE:true}"
|
||||||
# Specify thread pool size for external call service
|
# Specify thread pool size for external call service
|
||||||
external_call_thread_pool_size: "${ACTORS_RULE_EXTERNAL_CALL_THREAD_POOL_SIZE:10}"
|
external_call_thread_pool_size: "${ACTORS_RULE_EXTERNAL_CALL_THREAD_POOL_SIZE:10}"
|
||||||
js_sandbox:
|
js_sandbox:
|
||||||
@ -253,6 +256,13 @@ actors:
|
|||||||
node:
|
node:
|
||||||
# Errors for particular actor are persisted once per specified amount of milliseconds
|
# Errors for particular actor are persisted once per specified amount of milliseconds
|
||||||
error_persist_frequency: "${ACTORS_RULE_NODE_ERROR_FREQUENCY:3000}"
|
error_persist_frequency: "${ACTORS_RULE_NODE_ERROR_FREQUENCY:3000}"
|
||||||
|
queue:
|
||||||
|
# Message queue type (memory or db)
|
||||||
|
type: "${ACTORS_RULE_QUEUE_TYPE:memory}"
|
||||||
|
# Message queue maximum size (per tenant)
|
||||||
|
max_size: "${ACTORS_RULE_QUEUE_MAX_SIZE:100}"
|
||||||
|
# Message queue cleanup period in seconds
|
||||||
|
cleanup_period: "${ACTORS_RULE_QUEUE_CLEANUP_PERIOD:3600}"
|
||||||
statistics:
|
statistics:
|
||||||
# Enable/disable actor statistics
|
# Enable/disable actor statistics
|
||||||
enabled: "${ACTORS_STATISTICS_ENABLED:true}"
|
enabled: "${ACTORS_STATISTICS_ENABLED:true}"
|
||||||
@ -333,16 +343,6 @@ spring:
|
|||||||
username: "${SPRING_DATASOURCE_USERNAME:sa}"
|
username: "${SPRING_DATASOURCE_USERNAME:sa}"
|
||||||
password: "${SPRING_DATASOURCE_PASSWORD:}"
|
password: "${SPRING_DATASOURCE_PASSWORD:}"
|
||||||
|
|
||||||
rule:
|
|
||||||
queue:
|
|
||||||
#Message queue type (memory or db)
|
|
||||||
type: "${RULE_QUEUE_TYPE:memory}"
|
|
||||||
#Message queue maximum size (per tenant)
|
|
||||||
max_size: "${RULE_QUEUE_MAX_SIZE:100}"
|
|
||||||
#Message queue cleanup period in seconds
|
|
||||||
cleanup_period: "${RULE_QUEUE_CLEANUP_PERIOD:3600}"
|
|
||||||
|
|
||||||
|
|
||||||
# PostgreSQL DAO Configuration
|
# PostgreSQL DAO Configuration
|
||||||
#spring:
|
#spring:
|
||||||
# data:
|
# data:
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ConditionalOnProperty(prefix = "rule.queue", value = "type", havingValue = "db")
|
@ConditionalOnProperty(prefix = "actors.rule.queue", value = "type", havingValue = "db")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@NoSqlDao
|
@NoSqlDao
|
||||||
public class CassandraMsgQueue implements MsgQueue {
|
public class CassandraMsgQueue implements MsgQueue {
|
||||||
|
|||||||
@ -40,7 +40,7 @@ import java.util.concurrent.Executors;
|
|||||||
* Created by ashvayka on 27.04.18.
|
* Created by ashvayka on 27.04.18.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@ConditionalOnProperty(prefix = "rule.queue", value = "type", havingValue = "memory", matchIfMissing = true)
|
@ConditionalOnProperty(prefix = "actors.rule.queue", value = "type", havingValue = "memory", matchIfMissing = true)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class InMemoryMsgQueue implements MsgQueue {
|
public class InMemoryMsgQueue implements MsgQueue {
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,9 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
|
|||||||
@Value("${cassandra.query.ts_key_value_partitioning}")
|
@Value("${cassandra.query.ts_key_value_partitioning}")
|
||||||
private String partitioning;
|
private String partitioning;
|
||||||
|
|
||||||
|
@Value("${cassandra.query.ts_key_value_ttl}")
|
||||||
|
private long systemTtl;
|
||||||
|
|
||||||
private TsPartitionDate tsFormat;
|
private TsPartitionDate tsFormat;
|
||||||
|
|
||||||
private PreparedStatement partitionInsertStmt;
|
private PreparedStatement partitionInsertStmt;
|
||||||
@ -287,6 +290,7 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Void> save(EntityId entityId, TsKvEntry tsKvEntry, long ttl) {
|
public ListenableFuture<Void> save(EntityId entityId, TsKvEntry tsKvEntry, long ttl) {
|
||||||
|
ttl = computeTtl(ttl);
|
||||||
long partition = toPartitionTs(tsKvEntry.getTs());
|
long partition = toPartitionTs(tsKvEntry.getTs());
|
||||||
DataType type = tsKvEntry.getDataType();
|
DataType type = tsKvEntry.getDataType();
|
||||||
BoundStatement stmt = (ttl == 0 ? getSaveStmt(type) : getSaveTtlStmt(type)).bind();
|
BoundStatement stmt = (ttl == 0 ? getSaveStmt(type) : getSaveTtlStmt(type)).bind();
|
||||||
@ -304,6 +308,7 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Void> savePartition(EntityId entityId, long tsKvEntryTs, String key, long ttl) {
|
public ListenableFuture<Void> savePartition(EntityId entityId, long tsKvEntryTs, String key, long ttl) {
|
||||||
|
ttl = computeTtl(ttl);
|
||||||
long partition = toPartitionTs(tsKvEntryTs);
|
long partition = toPartitionTs(tsKvEntryTs);
|
||||||
log.debug("Saving partition {} for the entity [{}-{}] and key {}", partition, entityId.getEntityType(), entityId.getId(), key);
|
log.debug("Saving partition {} for the entity [{}-{}] and key {}", partition, entityId.getEntityType(), entityId.getId(), key);
|
||||||
BoundStatement stmt = (ttl == 0 ? getPartitionInsertStmt() : getPartitionInsertTtlStmt()).bind();
|
BoundStatement stmt = (ttl == 0 ? getPartitionInsertStmt() : getPartitionInsertTtlStmt()).bind();
|
||||||
@ -317,6 +322,17 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
|
|||||||
return getFuture(executeAsyncWrite(stmt), rs -> null);
|
return getFuture(executeAsyncWrite(stmt), rs -> null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long computeTtl(long ttl) {
|
||||||
|
if (systemTtl > 0) {
|
||||||
|
if (ttl == 0) {
|
||||||
|
ttl = systemTtl;
|
||||||
|
} else {
|
||||||
|
ttl = Math.min(systemTtl, ttl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ttl;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListenableFuture<Void> saveLatest(EntityId entityId, TsKvEntry tsKvEntry) {
|
public ListenableFuture<Void> saveLatest(EntityId entityId, TsKvEntry tsKvEntry) {
|
||||||
BoundStatement stmt = getLatestStmt().bind()
|
BoundStatement stmt = getLatestStmt().bind()
|
||||||
|
|||||||
@ -46,6 +46,8 @@ cassandra.query.default_fetch_size=2000
|
|||||||
|
|
||||||
cassandra.query.ts_key_value_partitioning=HOURS
|
cassandra.query.ts_key_value_partitioning=HOURS
|
||||||
|
|
||||||
|
cassandra.query.ts_key_value_ttl=0
|
||||||
|
|
||||||
cassandra.query.max_limit_per_request=1000
|
cassandra.query.max_limit_per_request=1000
|
||||||
cassandra.query.buffer_size=100000
|
cassandra.query.buffer_size=100000
|
||||||
cassandra.query.concurrent_limit=1000
|
cassandra.query.concurrent_limit=1000
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user