@SuppressWarnings("deprecation") public void testSimpleRWWriterReader() throws FileNotFoundException, IOException {
  final ChecksumUtility checker=ChecksumUtility.getCHK();
  final HALogManager manager=new HALogManager(m_logdir);
  final IRootBlockView rbv=openRBV(StoreTypeEnum.RW);
  assertTrue(rbv.getStoreType() == StoreTypeEnum.RW);
  final HALogFile logfile=manager.createLog(rbv);
  final IHALogWriter writer=logfile.getWriter();
  int sequence=0;
  final ByteBuffer data=randomData(2000);
  final UUID storeUUID=UUID.randomUUID();
  final IHAWriteMessage msg=new HAWriteMessage(storeUUID,rbv.getCommitCounter(),rbv.getFirstCommitTime(),sequence,data.limit(),checker.checksum(data),rbv.getStoreType(),rbv.getQuorumToken(),1000,0);
  writer.write(msg,data);
  final IHALogReader reader=logfile.getReader();
  assertTrue(reader.hasMoreBuffers());
  ByteBuffer rbuf=ByteBuffer.allocate(1 * 1024 * 1024);
  IHAWriteMessage rmsg=reader.processNextBuffer(rbuf);
  assertTrue(rmsg.getSize() == msg.getSize());
  writer.close(closeRBV(rbv));
  assertFalse(reader.hasMoreBuffers());
  assertTrue(logfile.isOpen());
  reader.close();
  assertFalse(logfile.isOpen());
  try {
    HALogManager.main(new String[]{m_logdir.getAbsolutePath()});
  }
 catch (  InterruptedException e) {
  }
}

@ SuppressWarnings ( "deprecation" ) public void testSimpleRWWriterReader ( ) throws FileNotFoundException , IOException { final ChecksumUtility checker = ChecksumUtility . getCHK ( ) ; final HALogManager manager = new HALogManager ( m_logdir ) ; final IRootBlockView rbv = openRBV ( StoreTypeEnum . RW ) ; assertTrue ( rbv . getStoreType ( ) == StoreTypeEnum . RW ) ; final HALogFile logfile = manager . createLog ( rbv ) ; final IHALogWriter writer = logfile . getWriter ( ) ; int sequence = 0 ; final ByteBuffer data = randomData ( 2000 ) ; final UUID storeUUID = UUID . randomUUID ( ) ; final IHAWriteMessage msg = new HAWriteMessage ( storeUUID , rbv . getCommitCounter ( ) , rbv . getFirstCommitTime ( ) , sequence , data . limit ( ) , checker . checksum ( data ) , rbv . getStoreType ( ) , rbv . getQuorumToken ( ) , 1000 , 0 ) ; writer . write ( msg , data ) ; final IHALogReader reader = logfile . getReader ( ) ; assertTrue ( reader . hasMoreBuffers ( ) ) ; ByteBuffer rbuf = ByteBuffer . allocate ( 1 * 1024 * 1024 ) ; IHAWriteMessage rmsg = reader . processNextBuffer ( rbuf ) ; assertTrue ( rmsg . getSize ( ) == msg . getSize ( ) ) ; writer . close ( closeRBV ( rbv ) ) ; assertFalse ( reader . hasMoreBuffers ( ) ) ; assertTrue ( logfile . isOpen ( ) ) ; reader . close ( ) ; assertFalse ( logfile . isOpen ( ) ) ; try { HALogManager . main ( new String [ ] { m_logdir . getAbsolutePath ( ) } ) ; } catch ( InterruptedException e ) { } }
simple writereader , no concurrency , confirms non - delayed responses .
