Package org.apache.hadoop.hdfs.AppendTestUtil

Examples of org.apache.hadoop.hdfs.AppendTestUtil.WriterThread


    FSDataOutputStream stm = fs1.create(path);
    byte[] toWrite = AppendTestUtil.randomBytes(0, 5);
   
    CountDownLatch countdown = new CountDownLatch(1);
    AtomicReference<Throwable> thrown = new AtomicReference<Throwable>();
    WriterThread writerThread = new AppendTestUtil.WriterThread(
        stm, toWrite, thrown, countdown, numWrites);
    writerThread.start();
    countdown.countDown();
    while (writerThread.getNumWritten() == 0 &&
        thrown.get() == null &&
        writerThread.isAlive()) {
      System.err.println("Waiting for writer to start");
      Thread.sleep(10);
    }
    assertTrue(writerThread.isAlive());   
    if (thrown.get() != null) {
      throw new RuntimeException(thrown.get());
    }
   
    AppendTestUtil.loseLeases(fs1);   
    AppendTestUtil.recoverFile(cluster, fs2, path);

    while (thrown.get() == null) {
      LOG.info("Waiting for writer thread to get expected exception");
      Thread.sleep(1000);
    }
    assertNotNull(thrown.get());
   
    // Check that we can see all of the synced edits
    int expectedEdits = writerThread.getNumWritten();
    int gotEdits = (int)(fs2.getFileStatus(path).getLen() / toWrite.length);
    assertTrue("Expected at least " + expectedEdits +
        " edits, got " + gotEdits, gotEdits >= expectedEdits);
   
  }
View Full Code Here


    FSDataOutputStream stm = fs1.create(path);
    byte[] toWrite = AppendTestUtil.randomBytes(0, 5);
   
    CountDownLatch countdown = new CountDownLatch(1);
    AtomicReference<Throwable> thrown = new AtomicReference<Throwable>();
    WriterThread writerThread = new AppendTestUtil.WriterThread(
        stm, toWrite, thrown, countdown, numWrites);
    writerThread.start();
    countdown.countDown();
    while (writerThread.getNumWritten() == 0 &&
        thrown.get() == null &&
        writerThread.isAlive()) {
      System.err.println("Waiting for writer to start");
      Thread.sleep(10);
    }
    assertTrue(writerThread.isAlive());   
    if (thrown.get() != null) {
      throw new RuntimeException(thrown.get());
    }
   
    AppendTestUtil.loseLeases(fs1);   
    AppendTestUtil.recoverFile(cluster, fs2, path);

    while (thrown.get() == null) {
      LOG.info("Waiting for writer thread to get expected exception");
      Thread.sleep(1000);
    }
    assertNotNull(thrown.get());
   
    // Check that we can see all of the synced edits
    int expectedEdits = writerThread.getNumWritten();
    int gotEdits = (int)(fs2.getFileStatus(path).getLen() / toWrite.length);
    assertTrue("Expected at least " + expectedEdits +
        " edits, got " + gotEdits, gotEdits >= expectedEdits);
   
  }
View Full Code Here

    FSDataOutputStream stm = fs1.create(path);
    byte[] toWrite = AppendTestUtil.randomBytes(0, 5);
   
    CountDownLatch countdown = new CountDownLatch(1);
    AtomicReference<Throwable> thrown = new AtomicReference<Throwable>();
    WriterThread writerThread = new AppendTestUtil.WriterThread(
        stm, toWrite, thrown, countdown, numWrites);
    writerThread.start();
    countdown.countDown();
    while (writerThread.getNumWritten() == 0 &&
        thrown.get() == null &&
        writerThread.isAlive()) {
      System.err.println("Waiting for writer to start");
      Thread.sleep(10);
    }
    assertTrue(writerThread.isAlive());   
    if (thrown.get() != null) {
      throw new RuntimeException(thrown.get());
    }
   
    AppendTestUtil.loseLeases(fs1);   
    AppendTestUtil.recoverFile(cluster, fs2, path);

    while (thrown.get() == null) {
      LOG.info("Waiting for writer thread to get expected exception");
      Thread.sleep(1000);
    }
    assertNotNull(thrown.get());
   
    // Check that we can see all of the synced edits
    int expectedEdits = writerThread.getNumWritten();
    int gotEdits = (int)(fs2.getFileStatus(path).getLen() / toWrite.length);
    assertTrue("Expected at least " + expectedEdits +
        " edits, got " + gotEdits, gotEdits >= expectedEdits);
   
  }
View Full Code Here

    FSDataOutputStream stm = fs1.create(path);
    byte[] toWrite = AppendTestUtil.randomBytes(0, 5);
   
    CountDownLatch countdown = new CountDownLatch(1);
    AtomicReference<Throwable> thrown = new AtomicReference<Throwable>();
    WriterThread writerThread = new AppendTestUtil.WriterThread(
        stm, toWrite, thrown, countdown, numWrites);
    writerThread.start();
    countdown.countDown();
    while (writerThread.getNumWritten() == 0 &&
        thrown.get() == null &&
        writerThread.isAlive()) {
      System.err.println("Waiting for writer to start");
      Thread.sleep(10);
    }
    assertTrue(writerThread.isAlive());   
    if (thrown.get() != null) {
      throw new RuntimeException(thrown.get());
    }
   
    AppendTestUtil.loseLeases(fs1);   
    AppendTestUtil.recoverFile(cluster, fs2, path);

    while (thrown.get() == null) {
      LOG.info("Waiting for writer thread to get expected exception");
      Thread.sleep(1000);
    }
    assertNotNull(thrown.get());
   
    // Check that we can see all of the synced edits
    int expectedEdits = writerThread.getNumWritten();
    int gotEdits = (int)(fs2.getFileStatus(path).getLen() / toWrite.length);
    assertTrue("Expected at least " + expectedEdits +
        " edits, got " + gotEdits, gotEdits >= expectedEdits);
   
  }
View Full Code Here

    FSDataOutputStream stm = fs1.create(path);
    byte[] toWrite = AppendTestUtil.randomBytes(0, 5);

    CountDownLatch countdown = new CountDownLatch(1);
    AtomicReference<Throwable> thrown = new AtomicReference<Throwable>();
    WriterThread writerThread = new AppendTestUtil.WriterThread(
        stm, toWrite, thrown, countdown, numWrites);
    writerThread.start();
    countdown.countDown();
    while (writerThread.getNumWritten() == 0 &&
        thrown.get() == null &&
        writerThread.isAlive()) {
      System.err.println("Waiting for writer to start");
      Thread.sleep(10);
    }
    assertTrue(writerThread.isAlive());
    if (thrown.get() != null) {
      throw new RuntimeException(thrown.get());
    }

    AppendTestUtil.loseLeases(fs1);
    AppendTestUtil.recoverFile(cluster, fs2, path);

    while (thrown.get() == null) {
      LOG.info("Waiting for writer thread to get expected exception");
      Thread.sleep(1000);
    }
    assertNotNull(thrown.get());

    // Check that we can see all of the synced edits
    int expectedEdits = writerThread.getNumWritten();
    int gotEdits = (int)(fs2.getFileStatus(path).getLen() / toWrite.length);
    assertTrue("Expected at least " + expectedEdits +
        " edits, got " + gotEdits, gotEdits >= expectedEdits);

  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.AppendTestUtil.WriterThread

Copyright © 2018 www.massapicom. 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.