Search in sources :

Example 1 with StatInfo

use of io.nuls.core.utils.queue.entity.StatInfo in project nuls by nuls-io.

the class QueueManager method initQueue.

/**
 * 将队列加入管理中
 *
 * @param queueName    队列名称
 * @param queue        队列实例
 * @param latelySecond 统计日志时间段
 */
public static void initQueue(String queueName, AbstractNulsQueue queue, int latelySecond) {
    if (!Running) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "The DBModule is not running!");
    }
    if (QUEUES_MAP.containsKey(queueName)) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "queue name is allready exist");
    }
    if (latelySecond == 0) {
        latelySecond = LATELY_SECOND;
    }
    Log.debug("队列初始化,名称:{},单个文件最大大小:{}", queue.getQueueName(), queue.getMaxSize());
    queue.setStatInfo(new StatInfo(queue.getQueueName(), queue.size(), latelySecond));
    QUEUES_MAP.put(queueName, queue);
    LOCK_MAP.put(queueName, new ReentrantLock());
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) StatInfo(io.nuls.core.utils.queue.entity.StatInfo)

Aggregations

NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 StatInfo (io.nuls.core.utils.queue.entity.StatInfo)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1