public abstract class BufferedMOTableModel<R extends MOTableRow> extends Object implements MOTableModel<R>
getMaxBufferSize()
rows fetched from the backend.
Rows are removed from the buffer either when they are older than getBufferTimeoutNanoSeconds()
or
if the maximum number of buffered rows is reached.
The MOTableRowFactory
is needed to create table rows from the
backend plain row data.
Modifier and Type | Class and Description |
---|---|
protected class |
BufferedMOTableModel.BufferedMOTableRow<R extends MOTableRow>
The BufferedMOTableRow is a wrapper class that holds additional information for the buffering.
|
protected class |
BufferedMOTableModel.RowBufferIterator
The RowBufferIterator implements the iterator needed by the
MOTableModel to
traverse the model's rows. |
Modifier and Type | Field and Description |
---|---|
protected List<BufferedMOTableModel.BufferedMOTableRow<R>> |
bufferedChunksList |
protected SortedMap<OID,BufferedMOTableModel.BufferedMOTableRow<R>> |
bufferedRows |
protected long |
bufferHits
The number of rows that were read from the buffer without backend access.
|
protected long |
bufferMisses
The number of rows that were read from the backend, because they were not found or not valid in the buffer.
|
protected long |
bufferTimeoutNanoSeconds
The timeout for buffered rows in 10^-9 seconds.
|
protected int |
chunkSize
The number of rows that are fetched with
fetchNextRows(org.snmp4j.smi.OID, int) consecutively to
minimize the number of backend read operations. |
protected int |
columnCount
The number of columns in this table model.
|
protected BufferedMOTableModel.BufferedMOTableRow<R> |
firstRow |
protected BufferedMOTableModel.BufferedMOTableRow<R> |
lastRow |
protected int |
maxBufferSize
The maximum number of rows in the buffer.
|
protected MOTableRowFactory<R> |
rowFactory |
Modifier | Constructor and Description |
---|---|
protected |
BufferedMOTableModel(MOTableRowFactory<R> rowFactory)
Creates a BufferedMOTableModel with the specified
MOTableRowFactory . |
Modifier and Type | Method and Description |
---|---|
protected int |
cleanupBuffer()
Removes any rows from the buffer that exceed the buffer's size limit (FIFO).
|
abstract boolean |
containsRow(OID index) |
protected abstract List<R> |
fetchNextRows(OID lowerBound,
int chunkSize)
Fetches a list of rows from the backend source.
|
protected abstract Variable[] |
fetchRow(OID index)
Fetches the specified row from the backend source.
|
abstract OID |
firstIndex() |
R |
firstRow() |
long |
getBufferHits()
Returns the number of row accesses that were served by the buffer.
|
long |
getBufferMisses()
The number of row accesses that could not be served from the buffer and thus
needed backend processing.
|
long |
getBufferTimeoutNanoSeconds()
Gets the timeout nano-seconds for buffered rows.
|
int |
getChunkSize()
Returns the chunk size for GETNEXT like buffer fetching with the
fetchNextRows(org.snmp4j.smi.OID, int)
operation. |
int |
getColumnCount() |
protected BufferedMOTableModel.BufferedMOTableRow<R> |
getFirstBufferRow()
Gets the first row from the buffer or the backend if not available from the buffer.
|
protected BufferedMOTableModel.BufferedMOTableRow<R> |
getLastBufferRow()
Gets the last row from the buffer or the backend if not available from the buffer.
|
int |
getMaxBufferSize()
Returns the maximum number of rows in the buffer.
|
R |
getRow(OID index) |
protected R |
getRow(OID index,
boolean putRowIntoBuffer)
Gets a row from the internal buffer or the backend and puts it into the buffer if specified.
|
abstract int |
getRowCount() |
<F extends MOTableRowFactory<R>> |
getRowFactory() |
protected BufferedMOTableModel.BufferedMOTableRow<R> |
getRowFromBuffer(OID index)
Gets a row from the buffer.
|
protected boolean |
isRowValid(long lastRefreshNanoTime)
Tests if the given timestamp (in nano seconds as retrieved from
System.nanoTime() ) denotes
a valid row. |
Iterator<R> |
iterator() |
abstract OID |
lastIndex() |
R |
lastRow() |
R |
removeRow(OID index)
Removes a row from the table.
|
void |
resetBuffer()
Removes all rows from the internal buffer.
|
void |
setBufferTimeoutNanoSeconds(long bufferTimeoutNanoSeconds)
Sets the timeout nano-seconds for buffered rows.
|
void |
setChunkSize(int chunkSize)
Sets the chunk size for GETNEXT like buffer fetching with the
fetchNextRows(org.snmp4j.smi.OID, int)
operation. |
void |
setMaxBufferSize(int maxBufferSize)
Sets the maximum number of rows in the buffer.
|
<F extends MOTableRowFactory<R>> |
setRowFactory(F rowFactory)
Sets the factory instance to be used for creating rows for this model.
|
Iterator<R> |
tailIterator(OID lowerBound) |
String |
toString() |
protected BufferedMOTableModel.BufferedMOTableRow<R> |
updateBuffer(List<R> newBufferRows,
BufferedMOTableModel.BufferedMOTableRow<R> predecessor)
Updates the internal buffer with a list of consecutive rows.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isEmpty
protected final SortedMap<OID,BufferedMOTableModel.BufferedMOTableRow<R extends MOTableRow>> bufferedRows
protected final List<BufferedMOTableModel.BufferedMOTableRow<R extends MOTableRow>> bufferedChunksList
protected BufferedMOTableModel.BufferedMOTableRow<R extends MOTableRow> firstRow
protected BufferedMOTableModel.BufferedMOTableRow<R extends MOTableRow> lastRow
protected MOTableRowFactory<R extends MOTableRow> rowFactory
protected int columnCount
protected long bufferTimeoutNanoSeconds
protected int chunkSize
fetchNextRows(org.snmp4j.smi.OID, int)
consecutively to
minimize the number of backend read operations.protected int maxBufferSize
getMaxBufferSize()
and getChunkSize()
.protected long bufferHits
protected long bufferMisses
protected BufferedMOTableModel(MOTableRowFactory<R> rowFactory)
MOTableRowFactory
.rowFactory
- the row factory to be used to create rows from backend data.public <F extends MOTableRowFactory<R>> void setRowFactory(F rowFactory)
F
- the MOTableRowFactory
class creating rows of type R.rowFactory
- a MOTableRowFactory
instance or null
to
disable row creation.public <F extends MOTableRowFactory<R>> F getRowFactory()
public long getBufferTimeoutNanoSeconds()
public void setBufferTimeoutNanoSeconds(long bufferTimeoutNanoSeconds)
bufferTimeoutNanoSeconds
- the number of nano-seconds after which an buffered row is invalidated and removed from the buffer.public int getMaxBufferSize()
public void setMaxBufferSize(int maxBufferSize)
maxBufferSize
- the size of the row buffer.public int getChunkSize()
fetchNextRows(org.snmp4j.smi.OID, int)
operation. The default is 10.public void setChunkSize(int chunkSize)
fetchNextRows(org.snmp4j.smi.OID, int)
operation. The default is 10.chunkSize
- the chunk size for consecutive row fetching from the backend.public int getColumnCount()
getColumnCount
in interface MOTableModel<R extends MOTableRow>
public abstract int getRowCount()
getRowCount
in interface MOTableModel<R extends MOTableRow>
public abstract boolean containsRow(OID index)
containsRow
in interface MOTableModel<R extends MOTableRow>
public R getRow(OID index)
getRow
in interface MOTableModel<R extends MOTableRow>
protected R getRow(OID index, boolean putRowIntoBuffer)
index
- the index of the target row.putRowIntoBuffer
- if true
then the fetched row (not from the buffer) will be put into the buffer.null
if it does not exist.public Iterator<R> iterator()
iterator
in interface MOTableModel<R extends MOTableRow>
public Iterator<R> tailIterator(OID lowerBound)
tailIterator
in interface MOTableModel<R extends MOTableRow>
public abstract OID lastIndex()
lastIndex
in interface MOTableModel<R extends MOTableRow>
public abstract OID firstIndex()
firstIndex
in interface MOTableModel<R extends MOTableRow>
public R firstRow()
firstRow
in interface MOTableModel<R extends MOTableRow>
protected BufferedMOTableModel.BufferedMOTableRow<R> getFirstBufferRow()
public R lastRow()
lastRow
in interface MOTableModel<R extends MOTableRow>
protected BufferedMOTableModel.BufferedMOTableRow<R> getLastBufferRow()
protected boolean isRowValid(long lastRefreshNanoTime)
System.nanoTime()
) denotes
a valid row.lastRefreshNanoTime
- the last refresh timestamp from a buffered row.true
if (System.nanoTime() - lastRefreshNanoTime < bufferTimeoutNanoSeconds)
protected BufferedMOTableModel.BufferedMOTableRow<R> getRowFromBuffer(OID index)
index
- the index of the target row.null
if a row with the given index is not buffered (or no longer valid) and
the buffered row with that index if that row could be found and is still valid.protected abstract Variable[] fetchRow(OID index)
index
- the rows index OID value.null
if the row does not exists.protected abstract List<R> fetchNextRows(OID lowerBound, int chunkSize)
lowerBound
- the lower bound index (inclusive) of the first row to return.chunkSize
- the maximum number of rows to return. Less rows may be returned even if there are more
available.null
, no more rows are available at the source.public R removeRow(OID index)
UnsupportedOperationException
.index
- the index of the target row.null
if such a row does not exist.protected BufferedMOTableModel.BufferedMOTableRow<R> updateBuffer(List<R> newBufferRows, BufferedMOTableModel.BufferedMOTableRow<R> predecessor)
newBufferRows
- a list of rows which must be in lexicographic order (regarding their index values) and
without holes.predecessor
- the preceding row of the buffer area that needs to be updated.BufferedMOTableModel.BufferedMOTableRow.getNextRow()
the buffered rows can be fully traversed by using that first row.protected int cleanupBuffer()
public long getBufferHits()
public long getBufferMisses()
public void resetBuffer()
Copyright © 2016 SNMP4J.org. All rights reserved.