Search in sources :

Example 6 with AbstractNulsQueue

use of io.nuls.core.utils.queue.intf.AbstractNulsQueue in project nuls by nuls-io.

the class QueueManager method remove.

public static <T> void remove(String queueName, T item) {
    if (!Running) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "The DBModule is not running!");
    }
    AbstractNulsQueue queue = QUEUES_MAP.get(queueName);
    if (null == queue) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "queue not exist");
    }
    queue.remove(item);
    queue.getStatInfo().putOne();
    Log.debug("从队列中删除数据,名称:{},当前长度:{}。", queueName, queue.size());
}
Also used : AbstractNulsQueue(io.nuls.core.utils.queue.intf.AbstractNulsQueue) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException)

Example 7 with AbstractNulsQueue

use of io.nuls.core.utils.queue.intf.AbstractNulsQueue in project nuls by nuls-io.

the class QueueManager method destroyQueue.

public static void destroyQueue(String queueName) throws IOException, FileFormatException {
    if (!Running) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "The DBModule is not running!");
    }
    AbstractNulsQueue queue = QUEUES_MAP.get(queueName);
    if (null == queue) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "queue not exist");
    }
    queue.distroy();
    QUEUES_MAP.remove(queueName);
    Log.debug("队列销毁,名称:{}。", queueName);
}
Also used : AbstractNulsQueue(io.nuls.core.utils.queue.intf.AbstractNulsQueue) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException)

Example 8 with AbstractNulsQueue

use of io.nuls.core.utils.queue.intf.AbstractNulsQueue in project nuls by nuls-io.

the class QueueManager method offer.

public static void offer(String queueName, Object item) {
    if (!Running) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "The DBModule is not running!");
    }
    AbstractNulsQueue queue = QUEUES_MAP.get(queueName);
    if (null == queue) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "queue not exist");
    }
    queue.offer(item);
    queue.getStatInfo().putOne();
    Log.debug("向队列中加入数据,名称:{},当前长度:{}。", queueName, queue.size());
}
Also used : AbstractNulsQueue(io.nuls.core.utils.queue.intf.AbstractNulsQueue) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException)

Example 9 with AbstractNulsQueue

use of io.nuls.core.utils.queue.intf.AbstractNulsQueue in project nuls by nuls-io.

the class QueueManager method close.

public static void close(String queueName) throws NulsRuntimeException {
    if (!Running) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "The DBModule is not running!");
    }
    AbstractNulsQueue queue = QUEUES_MAP.get(queueName);
    if (null == queue) {
        throw new NulsRuntimeException(ErrorCode.FAILED, "queue not exist");
    }
    try {
        queue.close();
    } catch (Exception e) {
        throw new NulsRuntimeException(e);
    }
    Log.debug("关闭队列实例,名称:{},当前长度:{}。", queueName, queue.size());
}
Also used : AbstractNulsQueue(io.nuls.core.utils.queue.intf.AbstractNulsQueue) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException) IOException(java.io.IOException) FileFormatException(io.nuls.core.utils.queue.fqueue.exception.FileFormatException) NulsRuntimeException(io.nuls.core.exception.NulsRuntimeException)

Aggregations

AbstractNulsQueue (io.nuls.core.utils.queue.intf.AbstractNulsQueue)9 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)8 FileFormatException (io.nuls.core.utils.queue.fqueue.exception.FileFormatException)2 IOException (java.io.IOException)2 BlockingQueueImpl (io.nuls.core.utils.queue.entity.BlockingQueueImpl)1 PersistentQueue (io.nuls.core.utils.queue.entity.PersistentQueue)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1