cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Doubleday <>
Subject Monitoring bytes read per cf
Date Thu, 12 May 2011 17:06:09 GMT
Hi all

got a question for folks with some code insight again.

To be able to better understand where our IO load is coming from we want to monitor the number
of bytes read from disc per cf. (we love stats)

What I have done is wrapping the FileDataInput in SSTableReader to sum the bytes read in CFS.
This will only record data file access but that would be good enough for us.

It seems to work fine but maybe someone here knows that this is not a good idea ....


Some code:

    private static final boolean KEEP_IO_STATISICS = Boolean.getBoolean("cassandra.keepIOStats");
    public FileDataInput getFileDataInput(DecoratedKey decoratedKey, int bufferSize)
        long position = getPosition(decoratedKey, Operator.EQ);
        if (position < 0)
            return null;

        FileDataInput segment = dfile.getSegment(position, bufferSize);
        return (KEEP_IO_STATISICS) ? new MonitoringFileDataIInput(metadata, segment) : segment;


with MonitoringFileDataIInput

public class MonitoringFileDataIInput implements FileDataInput, Closeable

    private final FileDataInput fileDataInput;
    private final ColumnFamilyStore columnFamilyStore;

    public MonitoringFileDataIInput(CFMetaData cfMetaData, FileDataInput fileDataInput)
        columnFamilyStore =;
        this.fileDataInput = fileDataInput;

    public boolean readBoolean() throws IOException
        return fileDataInput.readBoolean();        

    // ... etc

and ColumnFamilyStore
    private final AtomicLong bytesRead = new AtomicLong(0L);
    @Override // ColumnFamilyStoreMBean
    public long getBytesRead()
        return bytesRead.get();
    public void addBytesRead(int num) 

View raw message