Package com.google.enterprise.connector.util

Examples of com.google.enterprise.connector.util.SystemClock


        PusherFactory pusherFactory =
            new DocPusherFactory(new MockFileFeedConnection(out));

        MockInstantiator instantiator =
            new MockInstantiator(new ThreadPool(300, new SystemClock()));

        Traverser traverser = new QueryTraverser(pusherFactory, qtm,
            instantiator.getTraversalStateStore(connectorName),
            connectorName, null, new SystemClock());

        instantiator.setupTraverser(connectorName, traverser);

        System.out.println();
        System.out.println("Running batch test batchsize " + batchHint);
View Full Code Here


    // for a short period, in case that information is needed again.
    // The documents age out of the cache relatively quickly (1 minute), as
    // the information should only be needed for a single servlet request.
    // The cache is configured hold 100 items, as the GSA may open many
    // concurrent content retrieval requests.
    clock = new SystemClock();
    documentCache =
        Collections.synchronizedMap(new AgingDocumentCache(100, 60 * 1000));
  }
View Full Code Here

    final String connectorName = "sharepoint";
    final Session session = this.connector.login();
    GlobalState.forgetState(null);
    final SharepointTraversalManager traversalManager = (SharepointTraversalManager) session.getTraversalManager();
    final MockInstantiator instantiator = new MockInstantiator(new ThreadPool(
        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

      ThreadPool threadPool) {
    this.name = name;
    this.typeName = name;
    this.interfaces = connectorInterfaces;
    this.traverser = traverser;
    this.hostLoadManager = new HostLoadManager(null, null, new SystemClock());
    this.stateStore =
        new MockTraversalStateStore(persistentStore, storeContext);
    this.persistentStore = persistentStore;
    this.storeContext = storeContext;
    this.threadPool = threadPool;
View Full Code Here

import com.google.enterprise.connector.util.SystemClock;

public class MockLoadManagerFactory implements LoadManagerFactory {
  public LoadManager newLoadManager(String ignored) {
    return new HostLoadManager(null, null, new SystemClock());
  }
View Full Code Here

    }
  }

  private Instantiator createMockInstantiator() {
    ThreadPool threadPool = new ThreadPool(5,
        new SystemClock() /* TODO: use mock clock? */);
    MockInstantiator instantiator = new MockInstantiator(threadPool);
    instantiator.setupTestTraversers();
    return instantiator;
  }
View Full Code Here

    testPusherStatus(PusherStatus.LOW_MEMORY, 500L, 2000L, 2, 2 * 500L);
  }

  private void testPusherStatus(PusherStatus status, long shortSleep,
      long longSleep, int retries, long expectedDelay) throws Exception {
    SystemClock clock = new SystemClock();
    String connectorName = getName();
    Document document = ConnectorTestUtils.createSimpleDocument("foo");
    MockPusher pusher = new MockPusher();
    DocumentAcceptorImpl documentAcceptor =
        new DocumentAcceptorImpl(connectorName, pusher);
    documentAcceptor.setSleepIntervals(shortSleep, longSleep, retries);

    // Initial document feed should go unimpeded.
    long startTime = clock.getTimeMillis();
    documentAcceptor.take(document);
    long stopTime = clock.getTimeMillis();
    assertEquals(1, pusher.getTotalDocs());
    assertEquals(PusherStatus.OK, pusher.getPusherStatus());
    assertTrue("Delay too long " + (stopTime - startTime),
               shortSleep > (stopTime - startTime));

    // If pusher returns not-ready status, documentAcceptor should sleep.
    pusher.setPusherStatus(status);
    startTime = clock.getTimeMillis();
    documentAcceptor.take(document);
    stopTime = clock.getTimeMillis();
    assertEquals(2, pusher.getTotalDocs());
    assertTrue("Delay " + (stopTime - startTime),
               expectedDelay <= (stopTime - startTime));

    // Once the Pusher is OK, there should be no delays.
    pusher.setPusherStatus(PusherStatus.OK);
    startTime = clock.getTimeMillis();
    documentAcceptor.take(document);
    stopTime = clock.getTimeMillis();
    assertEquals(3, pusher.getTotalDocs());
    assertTrue("Delay " + (stopTime - startTime),
               shortSleep > (stopTime - startTime));
  }
View Full Code Here

  }

  public void testTimeoutBatch() throws Exception {
    // Override default ThreadPool timeout with much shorter timeout of 1 sec.
    // TODO: Use a mock clock.
    getCoordinatorFactory().setThreadPool(new ThreadPool(1, new SystemClock()));
    createPusherAndCoordinator();
    coordinator.startBatch();
    SyncingConnector.Tracker tracker =
        SyncingConnector.getTracker();
    tracker.blockUntilTraversingInterrupted();
View Full Code Here

    StoreContext storeContext = getStoreContext(connectorName);
    QueryTraverser queryTraverser =
        new QueryTraverser(new MockPusher(), traversalManager,
            new MockTraversalStateStore(persistentStore, storeContext),
            connectorName, traversalContext,
            new SystemClock() /* TODO: use a mock clock */, null);

    ConnectorInterfaces interfaces =
        new ConnectorInterfaces(connectorName, connector);
    ConnectorCoordinator cc =
        new MockConnectorCoordinator(connectorName, interfaces, queryTraverser,
View Full Code Here

  private String connectorName = MockInstantiator.TRAVERSER_NAME1;
  private String docid = "docid";

  private MockInstantiator getMockInstantiator() throws Exception {
    MockInstantiator instantiator =
        new MockInstantiator(new ThreadPool(5, new SystemClock()));
    instantiator.setupTestTraversers();
    instantiator.addConnector(connectorName,
        new MockConnector(null, null, null, new MockRetriever(), null));
    return instantiator;
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.util.SystemClock

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.