Java 类org.apache.hadoop.hdfs.server.namenode.JournalSet.JournalAndStream 实例源码

项目:hadoop    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:big-c    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hadoop-EAR    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private EditLogOutputStream invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  FSImage fsimage = cluster.getNameNode().getFSImage();
  FSEditLog editLog = fsimage.getEditLog();

  JournalAndStream jas = editLog.getJournals().get(index);
  EditLogFileOutputStream elos =
    (EditLogFileOutputStream) jas.getCurrentStream();
  EditLogFileOutputStream spyElos = spy(elos);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else { 
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
  doNothing().when(spyElos).abort();

  jas.setCurrentStreamForTests(spyElos);

  return elos;
}
项目:hadoop-EAR    文件:TestPreFailoverCheck.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 */
private EditLogOutputStream invalidateEditsDirAtIndex(int index)
    throws IOException {
  FSImage fsimage = cluster.getNameNode(0).avatars.get(0).avatar.getFSImage();
  FSEditLog editLog = fsimage.getEditLog();

  JournalAndStream jas = editLog.getJournals().get(index);
  EditLogFileOutputStream elos = (EditLogFileOutputStream) jas
      .getCurrentStream();
  EditLogFileOutputStream spyElos = spy(elos);

  doThrow(new IOException("fail on write()")).when(spyElos).write(
      (FSEditLogOp) any());
  doThrow(new IOException("fail on write()")).when(spyElos).writeRaw(
      (byte[]) any(), anyInt(), anyInt());
  doThrow(new IOException("fail on write()")).when(spyElos).writeRawOp(
      (byte[]) any(), anyInt(), anyInt(), anyLong());
  doNothing().when(spyElos).abort();
  jas.setCurrentStreamForTests(spyElos);

  return elos;
}
项目:hadoop-plus    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:FlexMap    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hadoop-TCP    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hardfs    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hadoop-on-lustre2    文件:TestEditLogJournalFailures.java   
/**
 * Replace the journal at index <code>index</code> with one that throws an
 * exception on flush.
 * 
 * @param index the index of the journal to take offline.
 * @return the original <code>EditLogOutputStream</code> of the journal.
 */
private void invalidateEditsDirAtIndex(int index,
    boolean failOnFlush, boolean failOnWrite) throws IOException {
  JournalAndStream jas = getJournalAndStream(index);
  EditLogFileOutputStream spyElos = spyOnStream(jas);
  if (failOnWrite) {
    doThrow(new IOException("fail on write()")).when(spyElos).write(
        (FSEditLogOp) any());
  }
  if (failOnFlush) {
    doThrow(new IOException("fail on flush()")).when(spyElos).flush();
  } else {
    doThrow(new IOException("fail on setReadyToFlush()")).when(spyElos)
      .setReadyToFlush();
  }
}
项目:hadoop    文件:FSNamesystem.java   
@Override  // NameNodeMXBean
public String getNameJournalStatus() {
  List<Map<String, String>> jasList = new ArrayList<Map<String, String>>();
  FSEditLog log = getFSImage().getEditLog();
  if (log != null) {
    boolean openForWrite = log.isOpenForWrite();
    for (JournalAndStream jas : log.getJournals()) {
      final Map<String, String> jasMap = new HashMap<String, String>();
      String manager = jas.getManager().toString();

      jasMap.put("required", String.valueOf(jas.isRequired()));
      jasMap.put("disabled", String.valueOf(jas.isDisabled()));
      jasMap.put("manager", manager);

      if (jas.isDisabled()) {
        jasMap.put("stream", "Failed");
      } else if (openForWrite) {
        EditLogOutputStream elos = jas.getCurrentStream();
        if (elos != null) {
          jasMap.put("stream", elos.generateReport());
        } else {
          jasMap.put("stream", "not currently writing");
        }
      } else {
        jasMap.put("stream", "open for read");
      }
      jasList.add(jasMap);
    }
  }
  return JSON.toString(jasList);
}
项目:hadoop    文件:FSEditLog.java   
public long getSharedLogCTime() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().getJournalCTime();
    }
  }
  throw new IOException("No shared log found.");
}
项目:hadoop    文件:FSEditLog.java   
public synchronized void doPreUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doPreUpgrade();
    }
  }
}
项目:hadoop    文件:FSEditLog.java   
public synchronized void doUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doUpgrade(storage);
    }
  }
}
项目:hadoop    文件:FSEditLog.java   
public synchronized void doFinalizeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doFinalize();
    }
  }
}
项目:hadoop    文件:FSEditLog.java   
public synchronized boolean canRollBackSharedLog(StorageInfo prevStorage,
    int targetLayoutVersion) throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().canRollBack(storage, prevStorage,
          targetLayoutVersion);
    }
  }
  throw new IOException("No shared log found.");
}
项目:hadoop    文件:FSEditLog.java   
public synchronized void doRollback() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doRollback();
    }
  }
}
项目:hadoop    文件:TestEditLogJournalFailures.java   
private EditLogFileOutputStream spyOnStream(JournalAndStream jas) {
  EditLogFileOutputStream elos =
    (EditLogFileOutputStream) jas.getCurrentStream();
  EditLogFileOutputStream spyElos = spy(elos);
  jas.setCurrentStreamForTests(spyElos);
  return spyElos;
}
项目:hadoop    文件:TestEditLogJournalFailures.java   
/**
 * Pull out one of the JournalAndStream objects from the edit log.
 */
private JournalAndStream getJournalAndStream(int index) {
  FSImage fsimage = cluster.getNamesystem().getFSImage();
  FSEditLog editLog = fsimage.getEditLog();

  return editLog.getJournals().get(index);
}
项目:hadoop    文件:TestStorageRestore.java   
/**
 * invalidate storage by removing the second and third storage directories
 */
public void invalidateStorage(FSImage fi, Set<File> filesToInvalidate) throws IOException {
  ArrayList<StorageDirectory> al = new ArrayList<StorageDirectory>(2);
  Iterator<StorageDirectory> it = fi.getStorage().dirIterator();
  while(it.hasNext()) {
    StorageDirectory sd = it.next();
    if(filesToInvalidate.contains(sd.getRoot())) {
      LOG.info("causing IO error on " + sd.getRoot());
      al.add(sd);
    }
  }
  // simulate an error
  fi.getStorage().reportErrorsOnDirectories(al);

  for (JournalAndStream j : fi.getEditLog().getJournals()) {
    if (j.getManager() instanceof FileJournalManager) {
      FileJournalManager fm = (FileJournalManager)j.getManager();
      if (fm.getStorageDirectory().getRoot().equals(path2)
          || fm.getStorageDirectory().getRoot().equals(path3)) {
        EditLogOutputStream mockStream = spy(j.getCurrentStream());
        j.setCurrentStreamForTests(mockStream);
        doThrow(new IOException("Injected fault: write")).
          when(mockStream).write(Mockito.<FSEditLogOp>anyObject());
      }
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:FSNamesystem.java   
@Override  // NameNodeMXBean
public String getNameJournalStatus() {
  List<Map<String, String>> jasList = new ArrayList<Map<String, String>>();
  FSEditLog log = getFSImage().getEditLog();
  if (log != null) {
    boolean openForWrite = log.isOpenForWrite();
    for (JournalAndStream jas : log.getJournals()) {
      final Map<String, String> jasMap = new HashMap<String, String>();
      String manager = jas.getManager().toString();

      jasMap.put("required", String.valueOf(jas.isRequired()));
      jasMap.put("disabled", String.valueOf(jas.isDisabled()));
      jasMap.put("manager", manager);

      if (jas.isDisabled()) {
        jasMap.put("stream", "Failed");
      } else if (openForWrite) {
        EditLogOutputStream elos = jas.getCurrentStream();
        if (elos != null) {
          jasMap.put("stream", elos.generateReport());
        } else {
          jasMap.put("stream", "not currently writing");
        }
      } else {
        jasMap.put("stream", "open for read");
      }
      jasList.add(jasMap);
    }
  }
  return JSON.toString(jasList);
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public long getSharedLogCTime() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().getJournalCTime();
    }
  }
  throw new IOException("No shared log found.");
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public synchronized void doPreUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doPreUpgrade();
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public synchronized void doUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doUpgrade(storage);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public synchronized void doFinalizeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doFinalize();
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public synchronized boolean canRollBackSharedLog(StorageInfo prevStorage,
    int targetLayoutVersion) throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().canRollBack(storage, prevStorage,
          targetLayoutVersion);
    }
  }
  throw new IOException("No shared log found.");
}
项目:aliyun-oss-hadoop-fs    文件:FSEditLog.java   
public synchronized void doRollback() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doRollback();
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestEditLogJournalFailures.java   
private EditLogFileOutputStream spyOnStream(JournalAndStream jas) {
  EditLogFileOutputStream elos =
    (EditLogFileOutputStream) jas.getCurrentStream();
  EditLogFileOutputStream spyElos = spy(elos);
  jas.setCurrentStreamForTests(spyElos);
  return spyElos;
}
项目:aliyun-oss-hadoop-fs    文件:TestEditLogJournalFailures.java   
/**
 * Pull out one of the JournalAndStream objects from the edit log.
 */
private JournalAndStream getJournalAndStream(int index) {
  FSImage fsimage = cluster.getNamesystem().getFSImage();
  FSEditLog editLog = fsimage.getEditLog();

  return editLog.getJournals().get(index);
}
项目:aliyun-oss-hadoop-fs    文件:TestStorageRestore.java   
/**
 * invalidate storage by removing the second and third storage directories
 */
public void invalidateStorage(FSImage fi, Set<File> filesToInvalidate) throws IOException {
  ArrayList<StorageDirectory> al = new ArrayList<StorageDirectory>(2);
  Iterator<StorageDirectory> it = fi.getStorage().dirIterator();
  while(it.hasNext()) {
    StorageDirectory sd = it.next();
    if(filesToInvalidate.contains(sd.getRoot())) {
      LOG.info("causing IO error on " + sd.getRoot());
      al.add(sd);
    }
  }
  // simulate an error
  fi.getStorage().reportErrorsOnDirectories(al);

  for (JournalAndStream j : fi.getEditLog().getJournals()) {
    if (j.getManager() instanceof FileJournalManager) {
      FileJournalManager fm = (FileJournalManager)j.getManager();
      if (fm.getStorageDirectory().getRoot().equals(path2)
          || fm.getStorageDirectory().getRoot().equals(path3)) {
        EditLogOutputStream mockStream = spy(j.getCurrentStream());
        j.setCurrentStreamForTests(mockStream);
        doThrow(new IOException("Injected fault: write")).
          when(mockStream).write(Mockito.<FSEditLogOp>anyObject());
      }
    }
  }
}
项目:big-c    文件:FSNamesystem.java   
@Override  // NameNodeMXBean
public String getNameJournalStatus() {
  List<Map<String, String>> jasList = new ArrayList<Map<String, String>>();
  FSEditLog log = getFSImage().getEditLog();
  if (log != null) {
    boolean openForWrite = log.isOpenForWrite();
    for (JournalAndStream jas : log.getJournals()) {
      final Map<String, String> jasMap = new HashMap<String, String>();
      String manager = jas.getManager().toString();

      jasMap.put("required", String.valueOf(jas.isRequired()));
      jasMap.put("disabled", String.valueOf(jas.isDisabled()));
      jasMap.put("manager", manager);

      if (jas.isDisabled()) {
        jasMap.put("stream", "Failed");
      } else if (openForWrite) {
        EditLogOutputStream elos = jas.getCurrentStream();
        if (elos != null) {
          jasMap.put("stream", elos.generateReport());
        } else {
          jasMap.put("stream", "not currently writing");
        }
      } else {
        jasMap.put("stream", "open for read");
      }
      jasList.add(jasMap);
    }
  }
  return JSON.toString(jasList);
}
项目:big-c    文件:FSEditLog.java   
public long getSharedLogCTime() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().getJournalCTime();
    }
  }
  throw new IOException("No shared log found.");
}
项目:big-c    文件:FSEditLog.java   
public synchronized void doPreUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doPreUpgrade();
    }
  }
}
项目:big-c    文件:FSEditLog.java   
public synchronized void doUpgradeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doUpgrade(storage);
    }
  }
}
项目:big-c    文件:FSEditLog.java   
public synchronized void doFinalizeOfSharedLog() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doFinalize();
    }
  }
}
项目:big-c    文件:FSEditLog.java   
public synchronized boolean canRollBackSharedLog(StorageInfo prevStorage,
    int targetLayoutVersion) throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      return jas.getManager().canRollBack(storage, prevStorage,
          targetLayoutVersion);
    }
  }
  throw new IOException("No shared log found.");
}
项目:big-c    文件:FSEditLog.java   
public synchronized void doRollback() throws IOException {
  for (JournalAndStream jas : journalSet.getAllJournalStreams()) {
    if (jas.isShared()) {
      jas.getManager().doRollback();
    }
  }
}
项目:big-c    文件:TestEditLogJournalFailures.java   
private EditLogFileOutputStream spyOnStream(JournalAndStream jas) {
  EditLogFileOutputStream elos =
    (EditLogFileOutputStream) jas.getCurrentStream();
  EditLogFileOutputStream spyElos = spy(elos);
  jas.setCurrentStreamForTests(spyElos);
  return spyElos;
}
项目:big-c    文件:TestEditLogJournalFailures.java   
/**
 * Pull out one of the JournalAndStream objects from the edit log.
 */
private JournalAndStream getJournalAndStream(int index) {
  FSImage fsimage = cluster.getNamesystem().getFSImage();
  FSEditLog editLog = fsimage.getEditLog();

  return editLog.getJournals().get(index);
}