Package java.io

Examples of java.io.RandomAccessFile.seek()


     RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    try {
    EventQueueBackingStore backingStore = EventQueueBackingStoreFactory.
            get(checkpoint, 10, "test");
    backingStore.close();
    writer.seek(
            EventQueueBackingStoreFile.INDEX_VERSION * Serialization.SIZE_OF_LONG);
    writer.writeLong(94L);
    writer.getFD().sync();

    backingStore = EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
View Full Code Here


    try {
    EventQueueBackingStore backingStore = EventQueueBackingStoreFactory.
            get(checkpoint, 10, "test");
    backingStore.close();
    writer.seek(
            EventQueueBackingStoreFile.INDEX_CHECKPOINT_MARKER *
            Serialization.SIZE_OF_LONG);
    writer.writeLong(EventQueueBackingStoreFile.CHECKPOINT_INCOMPLETE);
    writer.getFD().sync();
    backingStore = EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
View Full Code Here

    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    try {
      EventQueueBackingStore backingStore = EventQueueBackingStoreFactory.
              get(checkpoint, 10, "test");
      backingStore.close();
      writer.seek(
              EventQueueBackingStoreFile.INDEX_VERSION
              * Serialization.SIZE_OF_LONG);
      writer.writeLong(2L);
      writer.getFD().sync();
      backingStore = EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
View Full Code Here

    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    try {
      EventQueueBackingStore backingStore = EventQueueBackingStoreFactory.
              get(checkpoint, 10, "test");
      backingStore.close();
      writer.seek(
              EventQueueBackingStoreFile.INDEX_WRITE_ORDER_ID
              * Serialization.SIZE_OF_LONG);
      writer.writeLong(2L);
      writer.getFD().sync();
      backingStore = EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
View Full Code Here

    backingStore.close();
    Assert.assertTrue(checkpoint.exists());
    File metaFile = Serialization.getMetaDataFile(checkpoint);
    Assert.assertTrue(metaFile.length() != 0);
    RandomAccessFile writer = new RandomAccessFile(metaFile, "rw");
    writer.seek(10);
    writer.writeLong(new Random().nextLong());
    writer.getFD().sync();
    writer.close();
    try {
      backingStore = EventQueueBackingStoreFactory.get(checkpoint, 10, "test");
View Full Code Here

    logFileWriter.commit(TransactionEventRecord.toByteBuffer(new Commit
      (transactionID, WriteOrderOracle.next())));
    logFileWriter.sync();
    final int offset = ptr.getOffset();
    RandomAccessFile writer = new RandomAccessFile(dataFile, "rw");
    writer.seek(offset + 1500);
    writer.write((byte) 45);
    writer.write((byte) 12);
    writer.getFD().sync();
    logFileReader.get(offset);
View Full Code Here

    File temp = new File(tempDir, "temp");
    final RandomAccessFile tempFile = new RandomAccessFile(temp, "rw");
    for(int i = 0; i < 5000; i++) {
      tempFile.write(LogFile.OP_RECORD);
    }
    tempFile.seek(0);
    LogFile.OperationRecordUpdater recordUpdater = new LogFile
      .OperationRecordUpdater(temp);
    //Convert every 10th byte into a noop byte
    for(int i = 0; i < 5000; i+=10) {
      recordUpdater.markRecordAsNoop(i);
View Full Code Here

    for(int i = 0; i < 5000; i+=10) {
      recordUpdater.markRecordAsNoop(i);
    }
    recordUpdater.close();

    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());
    }
View Full Code Here

    recordUpdater.close();

    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());
    }

  }
View Full Code Here

      CorruptEventException, NoopRecordException {
      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");
        }
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.