Merge branch 'develop/1.5' of github.com:thingsboard/thingsboard into develop/1.5

This commit is contained in:
Andrew Shvayka 2018-03-23 19:29:58 +02:00
commit 02c4d6b08a
5 changed files with 13 additions and 6 deletions

View File

@ -106,6 +106,7 @@ public class PluginActorMessageProcessor extends ComponentMsgProcessor<PluginId>
try { try {
pluginImpl.process(trustedCtx, msg.getRuleTenantId(), msg.getRuleId(), msg.getMsg()); pluginImpl.process(trustedCtx, msg.getRuleTenantId(), msg.getRuleId(), msg.getMsg());
} catch (Exception ex) { } catch (Exception ex) {
logger.debug("[{}] Failed to process RuleToPlugin msg: [{}] [{}]", tenantId, msg.getMsg(), ex);
RuleToPluginMsg ruleMsg = msg.getMsg(); RuleToPluginMsg ruleMsg = msg.getMsg();
MsgType responceMsgType = MsgType.RULE_ENGINE_ERROR; MsgType responceMsgType = MsgType.RULE_ENGINE_ERROR;
Integer requestId = 0; Integer requestId = 0;

View File

@ -238,7 +238,7 @@ caffeine:
specs: specs:
relations: relations:
timeToLiveInMinutes: 1440 timeToLiveInMinutes: 1440
maxSize: 0 maxSize: 100000
deviceCredentials: deviceCredentials:
timeToLiveInMinutes: 1440 timeToLiveInMinutes: 1440
maxSize: 100000 maxSize: 100000

View File

@ -439,8 +439,6 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
private PreparedStatement getLatestStmt() { private PreparedStatement getLatestStmt() {
if (latestInsertStmt == null) { if (latestInsertStmt == null) {
// latestInsertStmt = new PreparedStatement[DataType.values().length];
// for (DataType type : DataType.values()) {
latestInsertStmt = prepare(INSERT_INTO + ModelConstants.TS_KV_LATEST_CF + latestInsertStmt = prepare(INSERT_INTO + ModelConstants.TS_KV_LATEST_CF +
"(" + ModelConstants.ENTITY_TYPE_COLUMN + "(" + ModelConstants.ENTITY_TYPE_COLUMN +
"," + ModelConstants.ENTITY_ID_COLUMN + "," + ModelConstants.ENTITY_ID_COLUMN +
@ -451,7 +449,6 @@ public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implem
"," + ModelConstants.LONG_VALUE_COLUMN + "," + ModelConstants.LONG_VALUE_COLUMN +
"," + ModelConstants.DOUBLE_VALUE_COLUMN + ")" + "," + ModelConstants.DOUBLE_VALUE_COLUMN + ")" +
" VALUES(?, ?, ?, ?, ?, ?, ?, ?)"); " VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
// }
} }
return latestInsertStmt; return latestInsertStmt;
} }

View File

@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Component @Component
@Slf4j @Slf4j
@NoSqlDao
public class BufferedRateLimiter implements AsyncRateLimiter { public class BufferedRateLimiter implements AsyncRateLimiter {
private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
@ -113,6 +114,9 @@ public class BufferedRateLimiter implements AsyncRateLimiter {
lockedFuture.cancelFuture(); lockedFuture.cancelFuture();
return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Buffer is full. Reject")); return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Buffer is full. Reject"));
} }
if(permits.get() < permitsLimit) {
reprocessQueue();
}
return lockedFuture.future; return lockedFuture.future;
} catch (InterruptedException e) { } catch (InterruptedException e) {
return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Task interrupted. Reject")); return Futures.immediateFailedFuture(new IllegalStateException("Rate Limit Task interrupted. Reject"));
@ -130,8 +134,8 @@ public class BufferedRateLimiter implements AsyncRateLimiter {
expiredCount++; expiredCount++;
} }
} }
log.info("Permits maxBuffer is [{}] max concurrent [{}] expired [{}]", maxQueueSize.getAndSet(0), log.info("Permits maxBuffer is [{}] max concurrent [{}] expired [{}] current granted [{}]", maxQueueSize.getAndSet(0),
maxGrantedPermissions.getAndSet(0), expiredCount); maxGrantedPermissions.getAndSet(0), expiredCount, permits.get());
} }
private class LockedFuture { private class LockedFuture {

View File

@ -47,3 +47,8 @@ cassandra.query.default_fetch_size=2000
cassandra.query.ts_key_value_partitioning=HOURS cassandra.query.ts_key_value_partitioning=HOURS
cassandra.query.max_limit_per_request=1000 cassandra.query.max_limit_per_request=1000
cassandra.query.buffer_size=100000
cassandra.query.concurrent_limit=1000
cassandra.query.permit_max_wait_time=20000
cassandra.query.rate_limit_print_interval_ms=30000