public abstract class BufferedMOTableModel<R extends org.snmp4j.agent.mo.MOTableRow> extends Object implements org.snmp4j.agent.mo.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 org.snmp4j.agent.mo.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<org.snmp4j.smi.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 org.snmp4j.agent.mo.MOTableRowFactory<R> |
rowFactory |
| Modifier | Constructor and Description |
|---|---|
protected |
BufferedMOTableModel(org.snmp4j.agent.mo.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(org.snmp4j.smi.OID index) |
protected abstract List<R> |
fetchNextRows(org.snmp4j.smi.OID lowerBound,
int chunkSize)
Fetches a list of rows from the backend source.
|
protected abstract org.snmp4j.smi.Variable[] |
fetchRow(org.snmp4j.smi.OID index)
Fetches the specified row from the backend source.
|
abstract org.snmp4j.smi.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(org.snmp4j.smi.OID index) |
protected R |
getRow(org.snmp4j.smi.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 org.snmp4j.agent.mo.MOTableRowFactory<R>> |
getRowFactory() |
protected BufferedMOTableModel.BufferedMOTableRow<R> |
getRowFromBuffer(org.snmp4j.smi.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 org.snmp4j.smi.OID |
lastIndex() |
R |
lastRow() |
R |
removeRow(org.snmp4j.smi.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 org.snmp4j.agent.mo.MOTableRowFactory<R>> |
setRowFactory(F rowFactory)
Sets the factory instance to be used for creating rows for this model.
|
Iterator<R> |
tailIterator(org.snmp4j.smi.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.
|
protected final SortedMap<org.snmp4j.smi.OID,BufferedMOTableModel.BufferedMOTableRow<R extends org.snmp4j.agent.mo.MOTableRow>> bufferedRows
protected final List<BufferedMOTableModel.BufferedMOTableRow<R extends org.snmp4j.agent.mo.MOTableRow>> bufferedChunksList
protected BufferedMOTableModel.BufferedMOTableRow<R extends org.snmp4j.agent.mo.MOTableRow> firstRow
protected BufferedMOTableModel.BufferedMOTableRow<R extends org.snmp4j.agent.mo.MOTableRow> lastRow
protected org.snmp4j.agent.mo.MOTableRowFactory<R extends org.snmp4j.agent.mo.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(org.snmp4j.agent.mo.MOTableRowFactory<R> rowFactory)
MOTableRowFactory.rowFactory - the row factory to be used to create rows from backend data.public <F extends org.snmp4j.agent.mo.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 org.snmp4j.agent.mo.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 org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public abstract int getRowCount()
getRowCount in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public abstract boolean containsRow(org.snmp4j.smi.OID index)
containsRow in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public R getRow(org.snmp4j.smi.OID index)
getRow in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>protected R getRow(org.snmp4j.smi.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 org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public Iterator<R> tailIterator(org.snmp4j.smi.OID lowerBound)
tailIterator in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public abstract org.snmp4j.smi.OID lastIndex()
lastIndex in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public abstract org.snmp4j.smi.OID firstIndex()
firstIndex in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>public R firstRow()
firstRow in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.MOTableRow>protected BufferedMOTableModel.BufferedMOTableRow<R> getFirstBufferRow()
public R lastRow()
lastRow in interface org.snmp4j.agent.mo.MOTableModel<R extends org.snmp4j.agent.mo.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(org.snmp4j.smi.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 org.snmp4j.smi.Variable[] fetchRow(org.snmp4j.smi.OID index)
index - the rows index OID value.null if the row does not exists.protected abstract List<R> fetchNextRows(org.snmp4j.smi.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(org.snmp4j.smi.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 © 2020 SNMP4J.org. All rights reserved.