InMobi/DistCpV2-0.20.203 — pull request #16 by rajub41 (2013-12-24 11:05:33+00:00)
Title: fix getBytesPerSec: should return correct read rate to avoid idleness

Currently, it is returning the actual read rate.

Ex: Assume, maxBandwidth = 1MBPS and reading 1M messages per second(read rate = 1MBPS)
First it checks whether number of bytes per second is more than maxBandwidth berfore reading a byte/ chunk of bytes from buffer. If read rate exceeds bandwidth then it sleeps for 50ms and resume the process.

It does not sleep till 1 sec as number of bytes read in that elapsed time is lesser than maxBandwidth.
when it reads 1M +1 byte/chunk it checks read rate against maxBandwidth.
when it reads 1M + 2byte /chunk it sleeps for 50ms
when it reads 1M + 3byte/chunk again it sleeps for 50ms...
...
it reads 1.5MB in 1.5 sec but still it goes for sleeping mode as it assumes read rate is 1.5M (bytes read/ time i.e. 1.5/1.. time is 1500ms/1000 =1) instead of 1(i.e. 1.5/1.5).

Current Behavior: it reads for a sec and almost sleeps for a 1sec in an alternate fashion