public CrawlRuleTester(int crawlDepth, long crawlDelay, String baseUrl, ArchivalUnit au) { super("crawlrule tester"); m_crawlDepth = crawlDepth; long minFetchDelay = CurrentConfig.getLongParam( BaseArchivalUnit.PARAM_MIN_FETCH_DELAY, BaseArchivalUnit.DEFAULT_MIN_FETCH_DELAY); m_crawlDelay = Math.max(crawlDelay, minFetchDelay); m_baseUrl = baseUrl; m_au = au; }
private void initTestMsg() throws Exception { testV1msg = new V1LcapMessage[3]; int[] pollType = { Poll.V1_NAME_POLL, Poll.V1_CONTENT_POLL, Poll.V1_VERIFY_POLL, }; PollFactory ppf = pollmanager.getPollFactory(1); assertNotNull("PollFactory should not be null", ppf); // XXX V1 support mandatory assertTrue(ppf instanceof V1PollFactory); V1PollFactory pf = (V1PollFactory) ppf; for (int i = 0; i < testV1msg.length; i++) { PollSpec spec = new MockPollSpec(testau, rootV1urls[i], lwrbnd, uprbnd, pollType[i]); log.debug("Created poll spec: " + spec); ((MockCachedUrlSet) spec.getCachedUrlSet()).setHasContent(false); int opcode = V1LcapMessage.NAME_POLL_REQ + (i * 2); long duration = -1; // NB calcDuration is not applied to Verify polls. switch (opcode) { case V1LcapMessage.NAME_POLL_REQ: case V1LcapMessage.CONTENT_POLL_REQ: // this will attempt to schedule and can return -1 duration = Math.max(pf.calcDuration(spec, pollmanager), 1000); break; case V1LcapMessage.VERIFY_POLL_REQ: case V1LcapMessage.VERIFY_POLL_REP: duration = 100000; // Arbitrary break; default: fail("Bad opcode " + opcode); break; } testV1msg[i] = V1LcapMessage.makeRequestMsg( spec, agree_entries, pf.makeVerifier(100000), pf.makeVerifier(100000), opcode, duration, testID); assertNotNull(testV1msg[i]); } }
long sleepTimeToAchieveLoad(long runDuration, float maxLoad) { return Math.round(((double) runDuration / maxLoad) - runDuration); }