当前位置: 首页>>代码示例>>Java>>正文


Java QJMTestUtil类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.qjournal.QJMTestUtil的典型用法代码示例。如果您正苦于以下问题:Java QJMTestUtil类的具体用法?Java QJMTestUtil怎么用?Java QJMTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


QJMTestUtil类属于org.apache.hadoop.hdfs.qjournal包,在下文中一共展示了QJMTestUtil类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeSegmentUntilCrash

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
private long writeSegmentUntilCrash(MiniJournalCluster cluster,
    QuorumJournalManager qjm, long txid, int numTxns, Holder<Throwable> thrown) {
  
  long firstTxId = txid;
  long lastAcked = txid - 1;
  try {
    EditLogOutputStream stm = qjm.startLogSegment(txid,
        NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
    
    for (int i = 0; i < numTxns; i++) {
      QJMTestUtil.writeTxns(stm, txid++, 1);
      lastAcked++;
    }
    
    stm.close();
    qjm.finalizeLogSegment(firstTxId, lastAcked);
  } catch (Throwable t) {
    thrown.held = t;
  }
  return lastAcked;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestQJMWithFaults.java

示例2: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  conf = new Configuration();
  // Don't retry connections - it just slows down the tests.
  conf.setInt(CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, 0);
  
  cluster = new MiniJournalCluster.Builder(conf)
    .build();
  
  qjm = createSpyingQJM();
  spies = qjm.getLoggerSetForTests().getLoggersForTests();

  qjm.format(QJMTestUtil.FAKE_NSINFO);
  qjm.recoverUnfinalizedSegments();
  assertEquals(1, qjm.getLoggerSetForTests().getEpoch());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestQuorumJournalManager.java

示例3: doOutOfSyncTest

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
private void doOutOfSyncTest(int missingOnRecoveryIdx,
    long expectedRecoveryTxnId) throws Exception {
  setupLoggers345();
  
  QJMTestUtil.assertExistsInQuorum(cluster,
      NNStorage.getInProgressEditsFileName(1));

  // Shut down the specified JN, so it's not present during recovery.
  cluster.getJournalNode(missingOnRecoveryIdx).stopAndJoin(0);

  // Make a new QJM
  qjm = createSpyingQJM();
  
  qjm.recoverUnfinalizedSegments();
  checkRecovery(cluster, 1, expectedRecoveryTxnId);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestQuorumJournalManager.java

示例4: testScanEditLog

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
/**
 * Test whether JNs can correctly handle editlog that cannot be decoded.
 */
@Test
public void testScanEditLog() throws Exception {
  // use a future layout version
  journal.startLogSegment(makeRI(1), 1,
      NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION - 1);

  // in the segment we write garbage editlog, which can be scanned but
  // cannot be decoded
  final int numTxns = 5;
  byte[] ops = QJMTestUtil.createGabageTxns(1, 5);
  journal.journal(makeRI(2), 1, 1, numTxns, ops);

  // verify the in-progress editlog segment
  SegmentStateProto segmentState = journal.getSegmentInfo(1);
  assertTrue(segmentState.getIsInProgress());
  Assert.assertEquals(numTxns, segmentState.getEndTxId());
  Assert.assertEquals(1, segmentState.getStartTxId());
  
  // finalize the segment and verify it again
  journal.finalizeLogSegment(makeRI(3), 1, numTxns);
  segmentState = journal.getSegmentInfo(1);
  assertFalse(segmentState.getIsInProgress());
  Assert.assertEquals(numTxns, segmentState.getEndTxId());
  Assert.assertEquals(1, segmentState.getStartTxId());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestJournal.java

示例5: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  conf = new Configuration();
  // Don't retry connections - it just slows down the tests.
  conf.setInt(CommonConfigurationKeysPublic.IPC_CLIENT_CONNECT_MAX_RETRIES_KEY, 0);
  
  cluster = new MiniJournalCluster.Builder(conf)
    .build();
  cluster.waitActive();
  
  qjm = createSpyingQJM();
  spies = qjm.getLoggerSetForTests().getLoggersForTests();

  qjm.format(QJMTestUtil.FAKE_NSINFO);
  qjm.recoverUnfinalizedSegments();
  assertEquals(1, qjm.getLoggerSetForTests().getEpoch());
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:18,代码来源:TestQuorumJournalManager.java

示例6: writeSegmentUntilCrash

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
private long writeSegmentUntilCrash(MiniJournalCluster cluster,
    QuorumJournalManager qjm, long txid, int numTxns, Holder<Throwable> thrown) {
  
  long firstTxId = txid;
  long lastAcked = txid - 1;
  try {
    EditLogOutputStream stm = qjm.startLogSegment(txid);
    
    for (int i = 0; i < numTxns; i++) {
      QJMTestUtil.writeTxns(stm, txid++, 1);
      lastAcked++;
    }
    
    stm.close();
    qjm.finalizeLogSegment(firstTxId, lastAcked);
  } catch (Throwable t) {
    thrown.held = t;
  }
  return lastAcked;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:21,代码来源:TestQJMWithFaults.java

示例7: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  conf = new Configuration();
  // Don't retry connections - it just slows down the tests.
  conf.setInt("ipc.client.connect.max.retries", 0);
  conf.setLong(JournalConfigKeys.DFS_QJOURNAL_CONNECT_TIMEOUT_KEY, 100);
  
  cluster = new MiniJournalCluster.Builder(conf)
    .build();
  
  qjm = createSpyingQJM();
  spies = qjm.getLoggerSetForTests().getLoggersForTests();

  qjm.transitionJournal(QJMTestUtil.FAKE_NSINFO, Transition.FORMAT, null);
  qjm.recoverUnfinalizedSegments();
  assertEquals(1, qjm.getLoggerSetForTests().getEpoch());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:18,代码来源:TestQuorumJournalManager.java

示例8: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  conf = new Configuration();
  // Don't retry connections - it just slows down the tests.
  conf.setInt("ipc.client.connect.max.retries", 0);
  conf.setLong(JournalConfigKeys.DFS_QJOURNAL_CONNECT_TIMEOUT_KEY, 100);
  
  cluster = new MiniJournalCluster.Builder(conf)
    .build();
  
  qjm = TestQuorumJournalManager.createSpyingQJM(conf, cluster, JID, FAKE_NSINFO);

  qjm.transitionJournal(QJMTestUtil.FAKE_NSINFO, Transition.FORMAT, null);
  qjm.recoverUnfinalizedSegments();
  assertEquals(1, qjm.getLoggerSetForTests().getEpoch());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:17,代码来源:TestQuorumJournalManagerInputStream.java

示例9: testRefreshOnlyForInprogress

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
/**
 * Ensure that refresh functionality does not work for finalized streams (at
 * startup)
 */
@Test
public void testRefreshOnlyForInprogress() throws Exception {
  // start new segment
  EditLogOutputStream stm = qjm.startLogSegment(0);
  // write a bunch of transactions
  QJMTestUtil.writeTxns(stm, 0, 10);
  qjm.finalizeLogSegment(0, 9);
  
  // get input stream
  List<EditLogInputStream> streams = Lists.newArrayList();
  // get only finalized streams
  qjm.selectInputStreams(streams, 0, false, false);
  
  try {
    // try refreshing the stream (this is startup mode
    // inprogress segments not allowed -> refresh should fail
    streams.get(0).refresh(10, 0);
    fail("The shream should not allow refreshing");
  } catch (IOException e) { 
    LOG.info("Expected exception: ", e);
  } 
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:27,代码来源:TestQuorumJournalManagerInputStream.java

示例10: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  File editsDir = new File(MiniDFSCluster.getBaseDirectory(null)
      + File.separator + "TestJournalNode");
  FileUtil.fullyDelete(editsDir);

  conf.set(JournalConfigKeys.DFS_JOURNALNODE_DIR_KEY,
      editsDir.getAbsolutePath());
  conf.set(JournalConfigKeys.DFS_JOURNALNODE_RPC_ADDRESS_KEY, "0.0.0.0:0");
  int port = MiniJournalCluster.getFreeHttpPortAndUpdateConf(conf, true);
  httpAddress = "http://localhost:" + port;

  jn = new JournalNode();
  jn.setConf(conf);
  jn.start();
  journalId = "test-journalid-" + QJMTestUtil.uniqueSequenceId();
  journal = jn.getOrCreateJournal(QuorumJournalManager
      .journalIdStringToBytes(journalId));
  journal.transitionJournal(FAKE_NSINFO, Transition.FORMAT, null);
  journal.transitionImage(FAKE_NSINFO, Transition.FORMAT, null);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:22,代码来源:TestHttpImageUploadChannel.java

示例11: setup

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  File editsDir = new File(MiniDFSCluster.getBaseDirectory(null) +
      File.separator + "TestJournalNode");
  FileUtil.fullyDelete(editsDir);
  
  conf.set(JournalConfigKeys.DFS_JOURNALNODE_DIR_KEY,
      editsDir.getAbsolutePath());
  conf.set(JournalConfigKeys.DFS_JOURNALNODE_RPC_ADDRESS_KEY,
      "0.0.0.0:0");    
  MiniJournalCluster.getFreeHttpPortAndUpdateConf(conf, true);
  
  jn = new JournalNode();
  jn.setConf(conf);
  jn.start();
  journalId = "test-journalid-" + QJMTestUtil.uniqueSequenceId();
  journal = jn.getOrCreateJournal(QuorumJournalManager
      .journalIdStringToBytes(journalId));
  journal.transitionJournal(FAKE_NSINFO, Transition.FORMAT, null);
  
  ch = new IPCLoggerChannel(conf, FAKE_NSINFO, journalId, jn.getBoundIpcAddress());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:23,代码来源:TestJournalNode.java

示例12: testAbortOldSegmentIfFinalizeIsMissed

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
/**
 * Assume that a client is writing to a journal, but loses its connection in
 * the middle of a segment. Thus, any future journal() calls in that segment
 * may fail, because some txns were missed while the connection was down.
 * 
 * Eventually, the connection comes back, and the NN tries to start a new
 * segment at a higher txid. This should abort the old one and succeed.
 */
@Test
public void testAbortOldSegmentIfFinalizeIsMissed() throws Exception {
  journal.newEpoch(FAKE_NSINFO, 1);

  // Start a segment at txid 1, and write a batch of 3 txns.
  journal.startLogSegment(makeRI(1), 1);
  journal.journal(makeRI(2), 1, 1, 3, QJMTestUtil.createTxnData(1, 3));

  GenericTestUtils.assertExists(journal.getJournalStorage().getInProgressEditLog(1));

  // Try to start new segment at txid 6, this should abort old segment and
  // then succeed, allowing us to write txid 6-9.
  journal.startLogSegment(makeRI(3), 6);
  journal.journal(makeRI(4), 6, 6, 3, QJMTestUtil.createTxnData(6, 3));

  // The old segment should *not* be finalized.
  GenericTestUtils.assertExists(journal.getJournalStorage().getInProgressEditLog(1));
  GenericTestUtils.assertExists(journal.getJournalStorage().getInProgressEditLog(6));
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:28,代码来源:TestJournal.java

示例13: testAbortOldSegmentIfFinalizeIsMissed

import org.apache.hadoop.hdfs.qjournal.QJMTestUtil; //导入依赖的package包/类
/**
 * Assume that a client is writing to a journal, but loses its connection
 * in the middle of a segment. Thus, any future journal() calls in that
 * segment may fail, because some txns were missed while the connection was
 * down.
 *
 * Eventually, the connection comes back, and the NN tries to start a new
 * segment at a higher txid. This should abort the old one and succeed.
 */
@Test (timeout = 10000)
public void testAbortOldSegmentIfFinalizeIsMissed() throws Exception {
  journal.newEpoch(FAKE_NSINFO, 1);
  
  // Start a segment at txid 1, and write a batch of 3 txns.
  journal.startLogSegment(makeRI(1), 1);
  journal.journal(makeRI(2), 1, 1, 3,
      QJMTestUtil.createTxnData(1, 3));

  GenericTestUtils.assertExists(
      journal.getStorage().getInProgressEditLog(1));
  
  // Try to start new segment at txid 6, this should abort old segment and
  // then succeed, allowing us to write txid 6-9.
  journal.startLogSegment(makeRI(3), 6);
  journal.journal(makeRI(4), 6, 6, 3,
      QJMTestUtil.createTxnData(6, 3));

  // The old segment should *not* be finalized.
  GenericTestUtils.assertExists(
      journal.getStorage().getInProgressEditLog(1));
  GenericTestUtils.assertExists(
      journal.getStorage().getInProgressEditLog(6));
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:34,代码来源:TestJournal.java


注:本文中的org.apache.hadoop.hdfs.qjournal.QJMTestUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。