(Context context)
| 813 | } |
| 814 | |
| 815 | @Override |
| 816 | public void run(Context context) throws IOException, InterruptedException { |
| 817 | Configuration conf = context.getConfiguration(); |
| 818 | this.fetchQueues = new FetchItemQueues(conf); |
| 819 | int threadCount = conf.getInt("fetcher.threads.fetch", 10); |
| 820 | parse = conf.getBoolean(FetcherJob.PARSE_KEY, false); |
| 821 | storingContent = conf.getBoolean("fetcher.store.content", true); |
| 822 | if (parse) { |
| 823 | boolean sitemap = conf.getBoolean(FetcherJob.SITEMAP, false); |
| 824 | |
| 825 | if (sitemap) { |
| 826 | skipTruncated = false; |
| 827 | } else { |
| 828 | skipTruncated = conf.getBoolean(ParserJob.SKIP_TRUNCATED, true); |
| 829 | } |
| 830 | parseUtil = new ParseUtil(conf); |
| 831 | } |
| 832 | LOG.info("Fetcher: threads: " + threadCount); |
| 833 | |
| 834 | int maxFeedPerThread = conf.getInt("fetcher.queue.depth.multiplier", 50); |
| 835 | feeder = new QueueFeeder(context, fetchQueues, threadCount |
| 836 | * maxFeedPerThread); |
| 837 | feeder.start(); |
| 838 | |
| 839 | for (int i = 0; i < threadCount; i++) { // spawn threads |
| 840 | FetcherThread ft = new FetcherThread(context, i); |
| 841 | fetcherThreads.add(ft); |
| 842 | ft.start(); |
| 843 | } |
| 844 | // select a timeout that avoids a task timeout |
| 845 | final long timeout = conf.getInt("mapreduce.task.timeout", 10 * 60 * 1000) / 2; |
| 846 | |
| 847 | // Used for threshold check, holds pages and bytes processed in the last sec |
| 848 | float pagesLastSec; |
| 849 | int bytesLastSec; |
| 850 | |
| 851 | int throughputThresholdCurrentSequence = 0; |
| 852 | |
| 853 | int throughputThresholdPages = conf.getInt( |
| 854 | "fetcher.throughput.threshold.pages", -1); |
| 855 | if (LOG.isInfoEnabled()) { |
| 856 | LOG.info("Fetcher: throughput threshold: " + throughputThresholdPages); |
| 857 | } |
| 858 | int throughputThresholdSequence = conf.getInt( |
| 859 | "fetcher.throughput.threshold.sequence", 5); |
| 860 | if (LOG.isInfoEnabled()) { |
| 861 | LOG.info("Fetcher: throughput threshold sequence: " |
| 862 | + throughputThresholdSequence); |
| 863 | } |
| 864 | long throughputThresholdTimeLimit = System.currentTimeMillis() + (conf.getLong( |
| 865 | "fetcher.throughput.threshold.check.after", 5) * 60 * 1000); |
| 866 | |
| 867 | do { // wait for threads to exit |
| 868 | pagesLastSec = pages.get(); |
| 869 | bytesLastSec = (int) bytes.get(); |
| 870 | final int secondsToSleep = 5; |
| 871 | try { |
| 872 | Thread.sleep(secondsToSleep * 1000); |
nothing calls this directly
no test coverage detected