Package java.io

Examples of java.io.RandomAccessFile.seek()


    FlumeEvent get(int offset) throws IOException, InterruptedException {
      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)) {
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

            return n;
        } else if (file != null) {
            try {
                RandomAccessFile random = new RandomAccessFile(file, "r");
                try {
                    random.seek(position);
                    return random.read(b);
                } finally {
                    random.close();
                }
            } catch (FileNotFoundException e) {
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.writeLong(2L);
    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.writeLong(EventQueueBackingStoreFile.CHECKPOINT_INCOMPLETE);
    writer.getFD().sync();
    writer.close();
    channel = createFileChannel(overrides);
View Full Code Here

    forceCheckpoint(channel);
    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

  int id = currentEl % (getInputSize() / files.length);

  RandomAccessFile f = files[currentEl / (getInputSize() / files.length)];

  try {
      f.seek(id * (3072 + labelSize));
      if (labelSize > 1) {
    f.readUnsignedByte();
      }

      Util.fillArray(nextTarget, 0);
View Full Code Here

        reader.close();
        continue;
      }
      long eventPosition2 = reader.getPosition();
      rec = reader.next();
      handle.seek(eventPosition1 + 100);
      handle.writeInt(random.nextInt());
      corrupted++;
      corruptFiles.add(dataFile.getName());
      if (rec == null ||
        rec.getEvent().getClass().getName().
View Full Code Here

          equals("org.apache.flume.channel.file.Commit")) {
        handle.close();
        reader.close();
        continue;
      }
      handle.seek(eventPosition2 + 100);
      handle.writeInt(random.nextInt());
      corrupted++;
      handle.close();
      reader.close();
View Full Code Here

      queue.addWithoutCommit(new FlumeEventPointer(2, 2), txnID2);
      queue.checkpoint(true);
      TimeUnit.SECONDS.sleep(3L);
      inflight = new RandomAccessFile(
              backingStoreSupplier.getInflightPuts(), "rw");
      inflight.seek(0);
      inflight.writeInt(new Random().nextInt());
      queue = new FlumeEventQueue(backingStore,
              backingStoreSupplier.getInflightTakes(),
              backingStoreSupplier.getInflightPuts(),
              backingStoreSupplier.getQueueSetDir());
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.