Package com.google.enterprise.connector.traversal

Examples of com.google.enterprise.connector.traversal.BatchSize


        System.out.println("Running batch test batchsize " + batchHint);

        int docsProcessed = 0;
        int totalDocsProcessed = 0;
        int batchNumber = 0;
        BatchSize batchSize = new BatchSize(batchHint);
        do {
            BatchResult result = traverser.runBatch(batchSize);
            docsProcessed = result.getCountProcessed();
            if (docsProcessed > 0) {
                totalDocsProcessed += docsProcessed;
View Full Code Here


        5, new SystemClock()));
    final Traverser traverser = new QueryTraverser(new MockPusher(System.out),
        traversalManager, instantiator.getTraversalStateStore(connectorName),
        connectorName, Context.getInstance().getTraversalContext(),
        new SystemClock());
    BatchResult result = traverser.runBatch(new BatchSize(10));
    int totalDocsProcessed = result.getCountProcessed();
    assertTrue(totalDocsProcessed > 0);
  }
View Full Code Here

   * Test minimum batchSize.
   */
  public void testMinimumBatchSize() {
    HostLoadManager hostLoadManager = newHostLoadManager(60);
    hostLoadManager.setBatchSize(10);
    BatchSize batchSize = hostLoadManager.determineBatchSize();
    assertEquals(10, batchSize.getHint());

    hostLoadManager.setBatchSize(20);
    batchSize = hostLoadManager.determineBatchSize();
    assertEquals(20, batchSize.getHint());

    hostLoadManager.setBatchSize(100);
    batchSize = hostLoadManager.determineBatchSize();
    assertEquals(60, batchSize.getHint());
  }
View Full Code Here

    // Advance time more than 1 second, the LoadManager period, so that
    // this connector should be allowed to run again without delay.
    clock.adjustTime(1250); // 1.25 second

    // At that throughput, a batch size of 1 or 2 would be calculated.
    BatchSize batchSize = hostLoadManager.determineBatchSize();
    assertEquals(200, hostLoadManager.determineBatchSize().getHint());
    assertFalse(hostLoadManager.shouldDelay());
  }
View Full Code Here

   * to work more efficiently without expending a great deal of effort
   * trying to hit the batch size exactly.
   */
  public void testDetermineBatchSize() {
    HostLoadManager hostLoadManager = newHostLoadManager(60);
    BatchSize batchSize = hostLoadManager.determineBatchSize();
    assertEquals(60, batchSize.getHint());
    hostLoadManager.setBatchSize(40);
    batchSize = hostLoadManager.determineBatchSize();
    assertEquals(40, batchSize.getHint());
  }
View Full Code Here

    hostLoadManager.recordResult(newBatchResult(200, 4000));
    assertFalse(hostLoadManager.shouldDelay());

    // The host load manager will try to suggest larger batches,
    // trying to pull the low throughput up towards the load.
    BatchSize batchSize = hostLoadManager.determineBatchSize();
    assertEquals(800, batchSize.getHint());

    // Another slow-running batch should produce a similar result, but
    // the returned batch hint should be capped at the maximum batch size.
    hostLoadManager.recordResult(newBatchResult(800, 8000));
    assertFalse(hostLoadManager.shouldDelay());
    batchSize = hostLoadManager.determineBatchSize();
    assertEquals(1000, batchSize.getHint());

    // A gross overage should put the brakes on.
    hostLoadManager.recordResult(newBatchResult(4000, 200));
    assertTrue(hostLoadManager.shouldDelay());
    batchSize = hostLoadManager.determineBatchSize();
    assertEquals(0, batchSize.getHint());
  }
View Full Code Here

    if (taskHandle != null && !taskHandle.isDone()) {
      return false;
    }
    taskHandle = null;

    BatchSize batchSize = hostLoadManager.determineBatchSize();
    if (batchSize.getHint() == 0) {
      return false;
    }

    MockBatchCoordinator batchResultProcessor =
        new MockBatchCoordinator(stateStore, hostLoadManager);
View Full Code Here

      this.batchSize = batchSize;
    }

    @Override
    public BatchSize determineBatchSize() {
      return new BatchSize(Math.min(load, batchSize));
    }
View Full Code Here

  public synchronized boolean startBatch() {
    if (!shouldRun()) {
      return false;
    }

    BatchSize batchSize = loadManager.determineBatchSize();
    if (batchSize.getHint() == 0) {
      return false;
    }

    try {
      TraversalManager traversalManager = getTraversalManager();
View Full Code Here

    runBatch(0, 4, TraversalDelayPolicy.POLL);
  }

  private void runBatch(final int expectCount, final int batchHint,
      final TraversalDelayPolicy expectDelayPolicy) throws Exception {
    BatchSize batchSize = new BatchSize(batchHint);
    BatchResult expectResult = new BatchResult(expectDelayPolicy, expectCount);
    MockTraverser traverser = new MockTraverser(batchSize, expectResult);
    MockBatchResultRecorder recorder = new MockBatchResultRecorder();
    MockBatchTimeout batchTimeout = new MockBatchTimeout();
    CancelableBatch batch =
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.traversal.BatchSize

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.