Search in sources :

Example 1 with MessagesStats

use of org.thingsboard.server.common.stats.MessagesStats in project thingsboard by thingsboard.

the class TbSqlBlockingQueueWrapper method init.

/**
 * Starts TbSqlBlockingQueues.
 *
 * @param  logExecutor  executor that will be printing logs and statistics
 * @param  saveFunction function to save entities in database
 * @param  batchUpdateComparator comparator to sort entities by primary key to avoid deadlocks in cluster mode
 *                               NOTE: you must use all of primary key parts in your comparator
 */
public void init(ScheduledLogExecutorComponent logExecutor, Consumer<List<E>> saveFunction, Comparator<E> batchUpdateComparator) {
    for (int i = 0; i < maxThreads; i++) {
        MessagesStats stats = statsFactory.createMessagesStats(params.getStatsNamePrefix() + ".queue." + i);
        TbSqlBlockingQueue<E> queue = new TbSqlBlockingQueue<>(params, stats);
        queues.add(queue);
        queue.init(logExecutor, saveFunction, batchUpdateComparator, i);
    }
}
Also used : MessagesStats(org.thingsboard.server.common.stats.MessagesStats)

Example 2 with MessagesStats

use of org.thingsboard.server.common.stats.MessagesStats in project thingsboard by thingsboard.

the class TbCoreTransportApiService method init.

@PostConstruct
public void init() {
    this.transportCallbackExecutor = ThingsBoardExecutors.newWorkStealingPool(maxCallbackThreads, getClass());
    TbQueueProducer<TbProtoQueueMsg<TransportApiResponseMsg>> producer = tbCoreQueueFactory.createTransportApiResponseProducer();
    TbQueueConsumer<TbProtoQueueMsg<TransportApiRequestMsg>> consumer = tbCoreQueueFactory.createTransportApiRequestConsumer();
    String key = StatsType.TRANSPORT.getName();
    MessagesStats queueStats = statsFactory.createMessagesStats(key);
    DefaultTbQueueResponseTemplate.DefaultTbQueueResponseTemplateBuilder<TbProtoQueueMsg<TransportApiRequestMsg>, TbProtoQueueMsg<TransportApiResponseMsg>> builder = DefaultTbQueueResponseTemplate.builder();
    builder.requestTemplate(consumer);
    builder.responseTemplate(producer);
    builder.maxPendingRequests(maxPendingRequests);
    builder.requestTimeout(requestTimeout);
    builder.pollInterval(responsePollDuration);
    builder.executor(transportCallbackExecutor);
    builder.handler(transportApiService);
    builder.stats(queueStats);
    transportApiTemplate = builder.build();
}
Also used : TbProtoQueueMsg(org.thingsboard.server.queue.common.TbProtoQueueMsg) DefaultTbQueueResponseTemplate(org.thingsboard.server.queue.common.DefaultTbQueueResponseTemplate) MessagesStats(org.thingsboard.server.common.stats.MessagesStats) PostConstruct(javax.annotation.PostConstruct)

Aggregations

MessagesStats (org.thingsboard.server.common.stats.MessagesStats)2 PostConstruct (javax.annotation.PostConstruct)1 DefaultTbQueueResponseTemplate (org.thingsboard.server.queue.common.DefaultTbQueueResponseTemplate)1 TbProtoQueueMsg (org.thingsboard.server.queue.common.TbProtoQueueMsg)1