Package com.google.enterprise.connector.util.diffing

Examples of com.google.enterprise.connector.util.diffing.CheckpointAndChangeQueue$MonitorRestartState


    assertTrue(deleteDir(persistDirAux));
  }

  public void testRecoveryFromOneIncompleteFileOnly() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    File persistFile = new File(persistDir, "recovery.1234");
    FileWriter writer = new FileWriter(persistFile);
    writer.write("omonee-harmony");
    writer.close();
    q.setMaximumQueueSize(2);
    try {
      q.start(DiffingConnectorCheckpoint.newFirst().toString());
      fail("Should have failed on sole faulty recovery file.");
    } catch(IOException e) {
      assertTrue(-1 != e.getMessage().indexOf("Found incomplete recovery file: "));
    }
  }
View Full Code Here


    }
  }

  public void testReStart() throws IOException {
    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(null);
    List<CheckpointAndChange> firstBatch = q.resume(null);
    String checkpoint = firstBatch.get(1).getCheckpoint().toString();
    List<CheckpointAndChange> secondBatch = q.resume(checkpoint);
    q.start(null);
    assertTrue(0 == persistDir.listFiles().length);
    List<CheckpointAndChange> firstBatchAgain = q.resume(null);
    assertEquals(firstBatch, firstBatchAgain);
  }
View Full Code Here

  }

  public void testWithMoreResumeCallsThanFileDescriptors() throws IOException {
    final int NUM_RESUME_CALLS = 1000;
    ChangeSource changeSource = new MockChangeSource(NUM_RESUME_CALLS * 3);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    String checkpoint = null;
    q.start(checkpoint);
    for (int i = 0; i < NUM_RESUME_CALLS; i++) {
       List<CheckpointAndChange> batch = q.resume(checkpoint);
       checkpoint = batch.get(1).getCheckpoint().toString();
       assertTrue(1 >= persistDir.listFiles().length);
    }
    assertTrue(1 == persistDir.listFiles().length);
  }
View Full Code Here

    final String MON_B = "I am mon B";
    ChangeSource changeSource = new MockChangeSource(Arrays.asList(new Change[] {
        newChange(0, MON_A), newChange(0, MON_B), newChange(1, MON_A),
        newChange(1, MON_B), newChange(2, MON_B), newChange(2, MON_A)
    }));
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    String checkpoint = null;
    q.start(checkpoint);

    List<CheckpointAndChange> batch = q.resume(checkpoint);
    Map<String, MonitorCheckpoint> monPoints = q.getMonitorRestartPoints();
    assertEquals(2, monPoints.size());
    assertTrue(monPoints.containsKey(MON_A));
    assertTrue(monPoints.containsKey(MON_B));
    assertEquals(0, monPoints.get(MON_A).getOffset1());
    assertEquals(0, monPoints.get(MON_B).getOffset1());
    assertEquals(0, monPoints.get(MON_A).getOffset2());
    assertEquals(0, monPoints.get(MON_B).getOffset2());
    checkpoint = batch.get(0).getCheckpoint().toString();
    batch = q.resume(checkpoint);
    monPoints = q.getMonitorRestartPoints();
    assertEquals(2, monPoints.size());
    assertTrue(monPoints.containsKey(MON_A));
    assertTrue(monPoints.containsKey(MON_B));
    assertEquals(1, monPoints.get(MON_A).getOffset1());
    assertEquals(0, monPoints.get(MON_B).getOffset1());
    assertEquals(1, monPoints.get(MON_A).getOffset2());
    assertEquals(0, monPoints.get(MON_B).getOffset2());
    // Can do it again.
    batch = q.resume(checkpoint);
    monPoints = q.getMonitorRestartPoints();
    assertEquals(2, monPoints.size());
    assertTrue(monPoints.containsKey(MON_A));
    assertTrue(monPoints.containsKey(MON_B));
    assertEquals(1, monPoints.get(MON_A).getOffset1());
    assertEquals(0, monPoints.get(MON_B).getOffset1());
View Full Code Here

        newChange(0, MON_C), newChange(0, MON_D), newChange(0, MON_E),
        newChange(1, MON_C), newChange(1, MON_D), newChange(1, MON_E),
        newChange(1, MON_B), newChange(2, MON_B), newChange(2, MON_A),
        newChange(2, MON_E), newChange(2, MON_C), newChange(2, MON_D),
    }));
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(15);
    String checkpoint = null;
    q.start(checkpoint);
    List<CheckpointAndChange> batch = q.resume(checkpoint);
    Map<String, MonitorCheckpoint> monPoints = q.getMonitorRestartPoints();
    assertEquals(5, monPoints.size());
    assertTrue(monPoints.containsKey(MON_A));
    assertTrue(monPoints.containsKey(MON_B));
    assertTrue(monPoints.containsKey(MON_C));
    assertTrue(monPoints.containsKey(MON_D));
View Full Code Here

    Map<String, MonitorCheckpoint> monPoints = null;

    String checkpoint = null;
    { /* Make recovery file that finishes 2nd batch. */
      ChangeSource changeSource = new MockChangeSource(6);
      CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
          persistDirSeed, internalFactory, clientFactory);
      q.setMaximumQueueSize(2);
      q.start(checkpoint);
      List<CheckpointAndChange> firstBatch = q.resume(checkpoint);
      checkpoint = firstBatch.get(1).getCheckpoint().toString();
      List<CheckpointAndChange> secondBatch = q.resume(checkpoint);
      checkpoint = secondBatch.get(1).getCheckpoint().toString();
      q.resume(checkpoint);
      monPoints = q.getMonitorRestartPoints();
      File recoveryFiles[] = persistDirSeed.listFiles();
      assertEquals(1, recoveryFiles.length);
      File recoveryFile = recoveryFiles[0];
      recoveryFile.renameTo(new File(persistDir, recoveryFile.getName()));
    }

    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(checkpoint);
    // Note: It's important that q.resume(checkpoint) is not called.
    // That is start(checkpoint) loads the persisted monitor state.
    assertEquals(monPoints, q.getMonitorRestartPoints());
  }
View Full Code Here

    Map<String, MonitorCheckpoint> monPoints = null;

    String checkpoint = null;
    { /* Make recovery file that finishes 2nd batch. */
      ChangeSource changeSource = new MockChangeSource(6);
      CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
          persistDirSeed, internalFactory, clientFactory);
      q.setMaximumQueueSize(2);
      q.start(checkpoint);
      List<CheckpointAndChange> firstBatch = q.resume(checkpoint);
      checkpoint = firstBatch.get(1).getCheckpoint().toString();
      List<CheckpointAndChange> secondBatch = q.resume(checkpoint);
      checkpoint = secondBatch.get(0).getCheckpoint().toString();
      q.resume(checkpoint);
      monPoints = q.getMonitorRestartPoints();
      File recoveryFiles[] = persistDirSeed.listFiles();
      assertEquals(1, recoveryFiles.length);
      File recoveryFile = recoveryFiles[0];
      recoveryFile.renameTo(new File(persistDir, recoveryFile.getName()));
    }

    ChangeSource changeSource = new MockChangeSource(6);
    CheckpointAndChangeQueue q = new CheckpointAndChangeQueue(changeSource,
        persistDir, internalFactory, clientFactory);
    q.setMaximumQueueSize(2);
    q.start(checkpoint);
    // Note: It's important that q.resume(checkpoint) is not called.
    // That is start(checkpoint) loads the persisted monitor state.
    assertEquals(monPoints, q.getMonitorRestartPoints());
  }
View Full Code Here

  public FakeDocumentSnapshotRepositoryMonitorManager(ChangeSource changeSource,
      TestCase testCase, DocumentHandleFactory internalFactory,
      DocumentHandleFactory clientFactory) throws IOException {
    File persistDir = new TestDirectoryManager(testCase).makeDirectory("queue");
    checkpointAndChangeQueue = (changeSource == null) ? null :
        new CheckpointAndChangeQueue(changeSource, persistDir, internalFactory,
            clientFactory);
    try {
      this.checkpointAndChangeQueue.start(null);
    } catch (IOException e) {
      throw new IllegalStateException(
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.util.diffing.CheckpointAndChangeQueue$MonitorRestartState

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.