Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8806639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:10:27+00:00 2026-06-14T02:10:27+00:00

I am working on an application that retrieves files from different URL’s. There is

  • 0

I am working on an application that retrieves files from different URL’s.

There is a TreeSet that contains the target to download. This is processed in a loop with each item being called with an ExecutorService. Here’s some code:

private void retrieveDataFiles() {
    if (this.urlsToRetrieve.size() > 0) {
        System.out.println("Target URLs to retrieve: " + this.urlsToRetrieve.size());
        ExecutorService executorProcessUrls = Executors.newFixedThreadPool(this.urlsToRetrieve.size());//could use fixed pool based on size of urls to retrieve
        for (Entry target : this.urlsToRetrieve.entrySet()) {
            final String fileName = (String) target.getKey();
            final String url = (String) target.getValue();

            String localFile = localDirectory + File.separator + fileName;
            System.out.println(localFile);
            executorProcessUrls.submit(new WikiDumpRetriever(url, localFile));
            dumpFiles.add(localFile); 
            //TODO: figure out why only 2 files download
        }
        executorProcessUrls.shutdown();
        try {
            executorProcessUrls.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
        } catch (InterruptedException ex) {
            System.out.println("retrieveDataFiles InterruptedException: " + ex.getMessage());
        }
    } else {
        System.out.println("No target URL's were retrieved");
    }
}

Then the WikiDumpRetriever:

private static class WikiDumpRetriever implements Runnable {

    private String wikiUrl;
    private String downloadTo;

    public WikiDumpRetriever(String targetUrl, String localDirectory) {
        this.downloadTo = localDirectory;
        this.wikiUrl = targetUrl;
    }

    public void downloadFile() throws FileNotFoundException, IOException, URISyntaxException {
        HTTPCommunicationGet httpGet = new HTTPCommunicationGet(wikiUrl, "");
        httpGet.downloadFiles(downloadTo);
    }

    @Override
    public void run() {
        try {
            downloadFile();
        } catch (FileNotFoundException ex) {
            System.out.println("WDR: FileNotFound " + ex.getMessage());
        } catch (IOException ex) {
            System.out.println("WDR: IOException " + ex.getMessage());
        } catch (URISyntaxException ex) {
            System.out.println("WDR: URISyntaxException " + ex.getMessage());
        }
    }
}

As you can see this is an inner class. The TreeSet contains:

Key : Value

enwiki-latest-pages-articles.xml.bz2 : http://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles.xml.bz2

elwiki-latest-pages-articles.xml.bz2 : http://dumps.wikimedia.org/enwiki/latest/elwiki-latest-pages-articles.xml.bz2

zhwiki-latest-pages-articles.xml.bz2 : http://dumps.wikimedia.org/enwiki/latest/zhwiki-latest-pages-articles.xml.bz2

hewiki-latest-pages-articles.xml.bz2 : http://dumps.wikimedia.org/enwiki/latest/hewiki-latest-pages-articles.xml.bz2

The problem is that this process downloads 2 of the four files. I know that all four are available and I know that they can be downloaded. However, only 2 of them process at any time.

Can anyone shed any light on this for me please – what am I missing or what am I getting wrong?

Thanks
nathj07

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:10:28+00:00Added an answer on June 14, 2026 at 2:10 am

    Thanks to ppeterka – it was a limit from the source. So, to overcome this I set the fixed thread pool size to 2. This means that only 2 files are downloaded simultaneously.

    The answer then was to find the vendor imposed limit and set the thread pool:

    ExecutorService executorProcessUrls = Executors.newFixedThreadPool(2);
    

    I wanted to accept an answer but couldn’t seem to do it with the comments. Sorry if this was the wrong way to do it.

    Thanks for all the pointers – the ‘group think’ really helped solve this for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an application that contains some buttons defined via layout.xml like this
I have an applicaton written in PHP that retrieves files from mongoDB Grid collection,
I'm working on an application which retrieves some HTML code from a record in
I am working in an application development. On that application i am performing files
I am currently working on an application that will retrieve other users' locations based
I am working on splitting out an existing, working application that I currently have
Im working on an application that needs to talk to a database. The application
I'm working on an application that needs to convert an HTML workspace (fixed size
I'm working on an application that integrates w/ Facebook to publish videos that are
I am working on an application that imports an unmanaged dll into C#. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.