public class QueueMiddleComponent extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected LevelDBPersistenceAdapter |
adapter |
protected LevelDBPage |
currentPage |
protected LevelDBCursor |
deleteCursor
pop a message wouldn't really delete a data, it just move deleteCursor, data would be deleted by house keeping
|
protected ReentrantLock |
deleteLock
when operating delete, it need to lock
|
protected Long |
headPageNo |
protected org.apache.log4j.Logger |
logger |
protected String |
queueName |
protected LevelDBCursor |
readCursor |
protected ReentrantLock |
readLock
when operating read , it need to lock
|
protected Long |
rearPageNo |
static long |
THRESHOLD_SST_FILE_SIZE_OF_COMPACT
进行compact操作的sst文件大小阈值(100M)
|
protected LevelDBCursor |
writeCursor |
protected ReentrantLock |
writeLock
when operating write, it need to lock
|
| 构造器和说明 |
|---|
QueueMiddleComponent(LevelDBPersistenceAdapter adapter)
create default queue named dq --> defaultQueue
|
QueueMiddleComponent(LevelDBPersistenceAdapter adapter,
String queueName) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected List<EventSourceWrapper> |
_peek(int bulkSize) |
protected void |
batchDelete(long pageNo,
int index,
String... keys) |
protected Long |
calculateTotalCount() |
void |
clear() |
void |
close() |
long |
count() |
<T> T |
get(String key,
Class<T> type) |
protected org.iq80.leveldb.DB |
getDB() |
int |
getPageSize() |
String |
getQueueName() |
void |
houseKeeping() |
boolean |
isOpenTxn() |
void |
load()
load page info, read,write and delete cursor
|
protected void |
loadCursor() |
protected void |
loadPage() |
void |
open() |
EventSourceWrapper |
peek()
return the head data, but not move read cursor
|
List<EventSourceWrapper> |
peek(int bulkSize) |
EventSourceWrapper |
pop()
return the head data, and move read cursor ahead. if read cursor equals write cursor, it would return null.
|
List<EventSourceWrapper> |
pop(int bulkSize) |
List<EventSourceWrapper> |
pop(int bulkSize,
org.iq80.leveldb.WriteBatch wb)
return a batch head data, and move read cursor ahead. if read cursor equals write cursor, it would return min size data.
|
EventSourceWrapper |
pop(org.iq80.leveldb.WriteBatch wb) |
long |
popCount()
获取未被删除,但是已经pop的消息数量
|
protected void |
put(String key,
Serializable ser) |
protected void |
put(String key,
Serializable ser,
org.iq80.leveldb.WriteBatch update) |
protected void |
put(org.iq80.leveldb.WriteBatch wb,
String key,
Serializable ser) |
String |
save(CommonEventSource evt) |
void |
setOpenTxn(boolean openTxn) |
void |
setPageSize(int pageSize) |
protected String |
wrapperKey(String key) |
protected volatile LevelDBCursor readCursor
protected volatile LevelDBCursor writeCursor
protected volatile LevelDBCursor deleteCursor
protected volatile LevelDBPage currentPage
protected volatile Long rearPageNo
protected volatile Long headPageNo
protected final ReentrantLock readLock
protected ReentrantLock writeLock
protected ReentrantLock deleteLock
protected final org.apache.log4j.Logger logger
protected final LevelDBPersistenceAdapter adapter
protected final String queueName
public static final long THRESHOLD_SST_FILE_SIZE_OF_COMPACT
public QueueMiddleComponent(LevelDBPersistenceAdapter adapter)
adapter - public QueueMiddleComponent(LevelDBPersistenceAdapter adapter, String queueName)
protected org.iq80.leveldb.DB getDB()
public String getQueueName()
public int getPageSize()
public void setPageSize(int pageSize)
public void open()
throws IOException
IOExceptionpublic void close()
throws IOException
IOExceptionpublic void load()
throws PersistenceException
public boolean isOpenTxn()
public void setOpenTxn(boolean openTxn)
public <T> T get(String key, Class<T> type) throws PersistenceException
protected void put(String key, Serializable ser) throws PersistenceException
protected void put(org.iq80.leveldb.WriteBatch wb,
String key,
Serializable ser)
throws PersistenceException
protected void put(String key, Serializable ser, org.iq80.leveldb.WriteBatch update) throws PersistenceException
protected void loadPage()
throws PersistenceException
protected void loadCursor()
throws PersistenceException
protected Long calculateTotalCount()
public String save(CommonEventSource evt) throws PersistenceException
public EventSourceWrapper pop() throws PersistenceException
PersistenceExceptionpublic EventSourceWrapper pop(org.iq80.leveldb.WriteBatch wb) throws PersistenceException
public List<EventSourceWrapper> pop(int bulkSize) throws PersistenceException
public List<EventSourceWrapper> pop(int bulkSize, org.iq80.leveldb.WriteBatch wb) throws PersistenceException
bulkSize - PersistenceExceptionpublic EventSourceWrapper peek() throws PersistenceException
PersistenceExceptionprotected List<EventSourceWrapper> _peek(int bulkSize) throws PersistenceException
public List<EventSourceWrapper> peek(int bulkSize) throws PersistenceException
public long count()
public long popCount()
public void houseKeeping()
throws PersistenceException
protected void batchDelete(long pageNo,
int index,
String... keys)
throws PersistenceException
Copyright © 2018 Jue Ming. All rights reserved.