Package org.rrd4j.core
Class ByteBufferBackend
- java.lang.Object
-
- org.rrd4j.core.RrdBackend
-
- org.rrd4j.core.ByteBufferBackend
-
- Direct Known Subclasses:
RrdByteArrayBackend
,RrdMemoryBackend
,RrdNioBackend
public abstract class ByteBufferBackend extends RrdBackend
A backend that store and provides access to data using aByteBuffer
, using java internal methods for long, integer and others types.- Since:
- 3.4
- Author:
- Fabrice Bacchella
-
-
Field Summary
-
Fields inherited from class org.rrd4j.core.RrdBackend
BYTEORDER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ByteBufferBackend(String path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
close()
Closes the underlying backend.protected CharBuffer
getCharBuffer(long offset, int size)
Extract a CharBuffer from the backend, used by readStringprotected boolean
isDirty()
protected void
read(long offset, byte[] b)
Reads a number of bytes from the RRD file on the diskdouble
readDouble(long offset)
double[]
readDouble(long offset, int count)
protected int
readInt(long offset)
protected long
readLong(long offset)
protected short
readShort(long offset)
protected void
rrdClose()
Closes the underlying backend.protected void
setByteBuffer(ByteBuffer byteBuffer)
protected void
write(long offset, byte[] b)
Writes bytes to the underlying RRD file on the diskprotected void
writeDouble(long offset, double value)
protected void
writeDouble(long offset, double[] values)
protected void
writeDouble(long offset, double value, int count)
protected void
writeInt(long offset, int value)
protected void
writeLong(long offset, long value)
protected void
writeShort(long offset, short value)
protected void
writeString(long offset, String value, int length)
-
Methods inherited from class org.rrd4j.core.RrdBackend
done, getFactory, getLength, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readString, setLength, writeString
-
-
-
-
Constructor Detail
-
ByteBufferBackend
protected ByteBufferBackend(String path)
-
-
Method Detail
-
setByteBuffer
protected void setByteBuffer(ByteBuffer byteBuffer)
-
write
protected void write(long offset, byte[] b) throws IOException
Writes bytes to the underlying RRD file on the disk- Specified by:
write
in classRrdBackend
- Parameters:
offset
- Starting file offsetb
- Bytes to be written.- Throws:
IOException
- if any.IllegalArgumentException
- if offset is bigger that the possible mapping position (2GiB).
-
writeShort
protected void writeShort(long offset, short value) throws IOException
- Overrides:
writeShort
in classRrdBackend
- Throws:
IOException
-
writeInt
protected void writeInt(long offset, int value) throws IOException
- Overrides:
writeInt
in classRrdBackend
- Throws:
IOException
-
writeLong
protected void writeLong(long offset, long value) throws IOException
- Overrides:
writeLong
in classRrdBackend
- Throws:
IOException
-
writeDouble
protected void writeDouble(long offset, double value) throws IOException
- Overrides:
writeDouble
in classRrdBackend
- Throws:
IOException
-
writeDouble
protected void writeDouble(long offset, double value, int count) throws IOException
- Overrides:
writeDouble
in classRrdBackend
- Throws:
IOException
-
writeDouble
protected void writeDouble(long offset, double[] values) throws IOException
- Overrides:
writeDouble
in classRrdBackend
- Throws:
IOException
-
writeString
protected void writeString(long offset, String value, int length) throws IOException
- Overrides:
writeString
in classRrdBackend
- Throws:
IOException
-
read
protected void read(long offset, byte[] b) throws IOException
Reads a number of bytes from the RRD file on the disk- Specified by:
read
in classRrdBackend
- Parameters:
offset
- Starting file offsetb
- Buffer which receives bytes read from the file.- Throws:
IOException
- Thrown in case of I/O error.IllegalArgumentException
- if offset is bigger that the possible mapping position (2GiB).
-
readShort
protected short readShort(long offset) throws IOException
- Overrides:
readShort
in classRrdBackend
- Throws:
IOException
-
readInt
protected int readInt(long offset) throws IOException
- Overrides:
readInt
in classRrdBackend
- Throws:
IOException
-
readLong
protected long readLong(long offset) throws IOException
- Overrides:
readLong
in classRrdBackend
- Throws:
IOException
-
readDouble
public double readDouble(long offset) throws IOException
- Overrides:
readDouble
in classRrdBackend
- Throws:
IOException
-
readDouble
public double[] readDouble(long offset, int count) throws IOException
- Overrides:
readDouble
in classRrdBackend
- Throws:
IOException
-
getCharBuffer
protected CharBuffer getCharBuffer(long offset, int size) throws RrdException
Description copied from class:RrdBackend
Extract a CharBuffer from the backend, used by readString- Overrides:
getCharBuffer
in classRrdBackend
- Parameters:
offset
- the offset in the rrdsize
- the size of the buffer, in character- Returns:
- a new CharBuffer
- Throws:
RrdException
-
close
protected void close() throws IOException
Description copied from class:RrdBackend
Closes the underlying backend. Used internally, should not be called from external code.- Specified by:
close
in classRrdBackend
- Throws:
IOException
- Thrown in case of I/O error
-
isDirty
protected boolean isDirty()
-
rrdClose
protected void rrdClose() throws IOException
Description copied from class:RrdBackend
Closes the underlying backend. Call byRrdDb#close()
when it's closed. All subclass must keep calling it.- Overrides:
rrdClose
in classRrdBackend
- Throws:
IOException
- Thrown in case of I/O error
-
-