Package java.io

Examples of java.io.RandomAccessFile.readByte()


      Preconditions.checkState(open, "File closed");
      RandomAccessFile fileHandle = checkOut();
      boolean error = true;
      try {
        fileHandle.seek(offset);
        byte operation = fileHandle.readByte();
        Preconditions.checkState(operation == OP_RECORD,
            Integer.toHexString(operation));
        TransactionEventRecord record = doGet(fileHandle);
        if(!(record instanceof Put)) {
          Preconditions.checkState(false, "Record is " +
View Full Code Here


    tempFile.seek(0);
    // Verify every 10th byte is actually a NOOP
    for(int i = 0; i < 5000; i+=10) {
      tempFile.seek(i);
      Assert.assertEquals(LogFile.OP_NOOP, tempFile.readByte());
    }

  }

  @Test
View Full Code Here

    final int offset = ptr.getOffset();
    LogFile.OperationRecordUpdater updater = new LogFile
      .OperationRecordUpdater(dataFile);
    updater.markRecordAsNoop(offset);
    RandomAccessFile fileReader = new RandomAccessFile(dataFile, "rw");
    Assert.assertEquals(LogFile.OP_NOOP, fileReader.readByte());
  }

  @Test
  public void testGroupCommit() throws Exception {
    final FlumeEvent eventIn = TestUtils.newPersistableEvent(250);
View Full Code Here

      Preconditions.checkState(open, "File closed");
      RandomAccessFile fileHandle = checkOut();
      boolean error = true;
      try {
        fileHandle.seek(offset);
        byte operation = fileHandle.readByte();
        if(operation == OP_NOOP) {
          throw new NoopRecordException("No op record found. Corrupt record " +
            "may have been repaired by File Channel Integrity tool");
        }
        if (operation != OP_RECORD) {
View Full Code Here

        assertThat(buf.getPosition(), is(1L));
        buf.write(2);
        buf.flush();

        file.seek(0);
        assertThat(file.readByte(), is((byte) 1));
        assertThat(file.readByte(), is((byte) 2));

        eof(file);
    }
View Full Code Here

        buf.write(2);
        buf.flush();

        file.seek(0);
        assertThat(file.readByte(), is((byte) 1));
        assertThat(file.readByte(), is((byte) 2));

        eof(file);
    }

    /**
 
View Full Code Here

        buf.write(-1);
        buf.seek(2);
        buf.flush();

        file.seek(0);
        assertThat(file.readByte(), is((byte) 0));
        assertThat(file.readByte(), is((byte) -1));
        for (int i = 2; i < 100; i++) {
            assertThat(file.readByte(), is((byte) i));
        }
    }
View Full Code Here

        buf.seek(2);
        buf.flush();

        file.seek(0);
        assertThat(file.readByte(), is((byte) 0));
        assertThat(file.readByte(), is((byte) -1));
        for (int i = 2; i < 100; i++) {
            assertThat(file.readByte(), is((byte) i));
        }
    }
}
View Full Code Here

        file.seek(0);
        assertThat(file.readByte(), is((byte) 0));
        assertThat(file.readByte(), is((byte) -1));
        for (int i = 2; i < 100; i++) {
            assertThat(file.readByte(), is((byte) i));
        }
    }
}
View Full Code Here

        }
        buf.flush();

        file.seek(0);
        for (int i = 0; i < 256; i++) {
            assertThat(file.readByte(), is((byte) i));
        }

        eof(file);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.