public ByteBuffer _readFromCache(final long offset,final int nbytes) throws ChecksumError, InterruptedException {
  if (nbytes > capacity) {
    return null;
  }
  final Long off=Long.valueOf(offset);
  while (true) {
    if (!open.get()) {
      return null;
    }
    final WriteCache cache=serviceMap.get(off);
    if (cache == null) {
      break;
    }
    try {
      final ByteBuffer ret=cache.read(off.longValue(),nbytes);
      if (ret == null && serviceMap.get(off) == cache) {
        throw new IllegalStateException("Inconsistent cache for offset: " + off);
      }
      if (ret == null && log.isDebugEnabled()) {
        log.debug("WriteCache out of sync with WriteCacheService");
      }
      if (ret != null)       return ret;
      continue;
    }
 catch (    IllegalStateException ex) {
      assert !open.get();
      return null;
    }
  }
  return null;
}

public ByteBuffer _readFromCache ( final long offset , final int nbytes ) throws ChecksumError , InterruptedException { if ( nbytes > capacity ) { return null ; } final Long off = Long . valueOf ( offset ) ; while ( true ) { if ( ! open . get ( ) ) { return null ; } final WriteCache cache = serviceMap . get ( off ) ; if ( cache == null ) { break ; } try { final ByteBuffer ret = cache . read ( off . longValue ( ) , nbytes ) ; if ( ret == null && serviceMap . get ( off ) == cache ) { throw new IllegalStateException ( "Inconsistent cache for offset: " + off ) ; } if ( ret == null && log . isDebugEnabled ( ) ) { log . debug ( "WriteCache out of sync with WriteCacheService" ) ; } if ( ret != null ) return ret ; continue ; } catch ( IllegalStateException ex ) { assert ! open . get ( ) ; return null ; } } return null ; }
attempt to read record from cache ( either write cache or read cache depending on the service map state ) .
