@Test
 public void testHugeFile() throws Exception {
   setupPartition(PARTITION_ID_2, 2);
   int numMsgs = 1000;
   int msgsPerLine = 10;
   RecoveryManager rm = (RecoveryManager) ManagementContainer.getInstance().getRecoveryManager();
   rm.setMsgIdPerLine(msgsPerLine);
   String archiveName = "activerecovery.multilinetest.archive";
   createActiveRecoveryTestFile(archiveName, msgsPerLine, numMsgs, PARTITION_ID_2);
   MutableInt chunkPartition = new MutableInt(-1);
   MutableLong chunkSeekChar = new MutableLong(-1);
   TimeQueryArchiveBuilder builder;
   do {
     resetPipeline();
     builder =
         new TimeQueryArchiveBuilder(
             1,
             1,
             m_pipeline,
             m_quota,
             archiveName,
             chunkPartition.intValue(),
             chunkSeekChar.longValue());
     builder.processTimeQuery(1L, 2L);
     parseChunkHint(builder.getChunkHint(), chunkPartition, chunkSeekChar);
     builder.finish();
   } while (builder.hasMoreChunks());
   assertEquals(numMsgs, m_processedIds.size());
 }
  @Test
  public void testMultiPartitionFiles() throws Exception {
    setupPartition(PARTITION_ID_1, 1);
    setupPartition(PARTITION_ID_2, 2);
    int numMsgs1 = 8;
    int numMsgs2 = 15;
    int msgsPerLine = 10;
    RecoveryManager rm = (RecoveryManager) ManagementContainer.getInstance().getRecoveryManager();
    rm.setMsgIdPerLine(msgsPerLine);
    String archiveName = "activerecovery.multilinetest.archive";
    createActiveRecoveryTestFile(archiveName, msgsPerLine, numMsgs1, PARTITION_ID_1);
    createActiveRecoveryTestFile(archiveName, msgsPerLine, numMsgs2, PARTITION_ID_2);

    TimeQueryArchiveBuilder builder =
        new TimeQueryArchiveBuilder(1, 1, m_pipeline, m_quota, archiveName, -1, -1);
    builder.processTimeQuery(1L, 2L);
    builder.finish();
    assertTrue(builder.hasMoreChunks());
    String chunkHint = builder.getChunkHint();
    assertEquals(PARTITION_ID_2 + "_22", chunkHint);
    assertEquals(numMsgs1 + msgsPerLine, m_processedIds.size());

    resetPipeline();
    builder =
        new TimeQueryArchiveBuilder(1, 1, m_pipeline, m_quota, archiveName, PARTITION_ID_2, 22);
    builder.processTimeQuery(1L, 2L);
    builder.finish();
    assertFalse(builder.hasMoreChunks());
    assertEquals(numMsgs1 + numMsgs2, m_processedIds.size());
  }
 @Test
 public void testFullLineFile() throws Exception {
   setupPartition(PARTITION_ID_2, 2);
   int numMsgs = 10;
   int msgsPerLine = 10;
   RecoveryManager rm = (RecoveryManager) ManagementContainer.getInstance().getRecoveryManager();
   rm.setMsgIdPerLine(msgsPerLine);
   String archiveName = "activerecovery.fulllinetest.archive";
   createActiveRecoveryTestFile(archiveName, msgsPerLine, numMsgs, PARTITION_ID_2);
   TimeQueryArchiveBuilder builder =
       new TimeQueryArchiveBuilder(1, 1, m_pipeline, m_quota, archiveName, -1, -1);
   builder.processTimeQuery(1L, 2L);
   builder.finish();
   assertFalse(builder.hasMoreChunks());
   assertEquals(numMsgs, m_processedIds.size());
 }
  @Test
  public void testLineLengthChangeSmallerFile() throws Exception {
    setupPartition(PARTITION_ID_2, 2);
    int numMsgs = 1000;
    int msgsPerLineStart = 100;
    int msgsPerLineEnd = 10;
    RecoveryManager rm = (RecoveryManager) ManagementContainer.getInstance().getRecoveryManager();
    rm.setMsgIdPerLine(msgsPerLineStart);
    String archiveName = "activerecovery.multilinetest.archive";
    createActiveRecoveryTestFile(archiveName, msgsPerLineStart, numMsgs, PARTITION_ID_2);

    // set to smaller line length after file was created
    rm.setMsgIdPerLine(msgsPerLineEnd);
    MutableInt chunkPartition = new MutableInt(-1);
    MutableLong chunkSeekChar = new MutableLong(-1);
    TimeQueryArchiveBuilder builder;
    int iterations = 0;
    do {
      resetPipeline();
      builder =
          new TimeQueryArchiveBuilder(
              1,
              1,
              m_pipeline,
              m_quota,
              archiveName,
              chunkPartition.intValue(),
              chunkSeekChar.longValue());
      builder.processTimeQuery(1L, 2L);
      parseChunkHint(builder.getChunkHint(), chunkPartition, chunkSeekChar);
      builder.finish();
      iterations++;
    } while (builder.hasMoreChunks());
    assertEquals(
        numMsgs / msgsPerLineStart,
        iterations); // we'll ask for 10, but we'll get 100 in each batch
    assertEquals(numMsgs, m_processedIds.size());
  }