Package java.io

Examples of java.io.RandomAccessFile.seek()


      queue.addWithoutCommit(new FlumeEventPointer(2, 2), txnID2);
      queue.checkpoint(true);
      TimeUnit.SECONDS.sleep(3L);
      inflight = new RandomAccessFile(
              backingStoreSupplier.getInflightTakes(), "rw");
      inflight.seek(0);
      inflight.writeInt(new Random().nextInt());
      queue = new FlumeEventQueue(backingStore,
              backingStoreSupplier.getInflightTakes(),
              backingStoreSupplier.getInflightPuts(),
              backingStoreSupplier.getQueueSetDir());
View Full Code Here


      Thread.sleep(2000);
    }
    channel.stop();
    File checkpoint = new File(checkpointDir, "checkpoint");
    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    writer.seek(EventQueueBackingStoreFile.INDEX_VERSION *
            Serialization.SIZE_OF_LONG);
    writer.writeLong(2L);
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
View Full Code Here

      Thread.sleep(2000);
    }
    channel.stop();
    File checkpoint = new File(checkpointDir, "checkpoint");
    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    writer.seek(EventQueueBackingStoreFile.INDEX_CHECKPOINT_MARKER
      * Serialization.SIZE_OF_LONG);
    writer.writeLong(EventQueueBackingStoreFile.CHECKPOINT_INCOMPLETE);
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
View Full Code Here

      }
    }
    RandomAccessFile checkpointFileHandle =
        new RandomAccessFile(checkpointFile, "rw");
    try {
      checkpointFileHandle.seek(INDEX_VERSION * Serialization.SIZE_OF_LONG);
      checkpointFileHandle.writeLong(Serialization.VERSION_3);
      checkpointFileHandle.getChannel().force(true);
    } finally {
      try {
        checkpointFileHandle.close();
View Full Code Here

    channel.stop();
    if (shouldCorruptCheckpoint) {
      File checkpoint = new File(checkpointDir, "checkpoint");
      RandomAccessFile writer = new RandomAccessFile(
        Serialization.getMetaDataFile(checkpoint), "rw");
      writer.seek(10);
      writer.writeLong(new Random().nextLong());
      writer.getFD().sync();
      writer.close();
    }
    channel = createFileChannel(overrides);
View Full Code Here

    }
    channel.stop();
    File checkpoint = new File(checkpointDir, "checkpoint");
    RandomAccessFile writer = new RandomAccessFile(
            Serialization.getMetaDataFile(checkpoint), "rw");
    writer.seek(10);
    writer.writeLong(new Random().nextLong());
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
    channel.start();
View Full Code Here

    Assert.assertEquals(100, in.size());
    forceCheckpoint(channel);
    channel.stop();
    File checkpoint = new File(checkpointDir, "checkpoint");
    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    writer.seek(EventQueueBackingStoreFile.INDEX_VERSION *
      Serialization.SIZE_OF_LONG);
    writer.write(new byte[]{(byte)1, (byte)5});
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
View Full Code Here

    Assert.assertEquals(100, in.size());
    forceCheckpoint(channel);
    channel.stop();
    File checkpoint = new File(checkpointDir, "checkpoint");
    RandomAccessFile writer = new RandomAccessFile(checkpoint, "rw");
    writer.seek(EventQueueBackingStoreFile.INDEX_CHECKPOINT_MARKER *
      Serialization.SIZE_OF_LONG);
    writer.write(new byte[]{(byte) 1, (byte) 5});
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
View Full Code Here

        }
      });
      if (files != null && files.length > 0) {
        for (int j = 0; j < files.length; j++) {
          RandomAccessFile fileToCorrupt = new RandomAccessFile(files[0], "rw");
          fileToCorrupt.seek(50);
          fileToCorrupt.writeByte(234);
          fileToCorrupt.close();
        }
      }
    }
View Full Code Here

     */
    public void close() throws IOException {
        writer.close();
        //FileOutputStream fos = new FileOutputStream(outputFile);
        RandomAccessFile raf = new RandomAccessFile(outputFile, "rw");
        raf.seek(4); // skip over the header;
        // Then fill in the sspace information
        switch (format) {
        case TEXT:
        case SPARSE_TEXT:
            //PrintWriter pw = new PrintWriter(fos);
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.