Package me.mabra.hellonzb.parser

Examples of me.mabra.hellonzb.parser.DownloadFileSegment


    {
      // more segments to go?
      while(segQueue.hasMoreSegments() && runningThreads < maxThreads && !pause && nioClient.hasFreeSlot())
      {
        // get next download segment of the download file
        DownloadFileSegment seg = segQueue.nextSegment();
        if(seg == null)
          break;
        String filename = seg.getDlFile().getFilename();
        logger.msg("Downloading next segment of file: " + filename, MyLogger.SEV_DEBUG);

        // create new response handler
        RspHandler newHandler = new RspHandler(seg, false);
        synchronized(activeRspHandlers)
        {
          activeRspHandlers.add(newHandler);
        }

        // map the new response handler to the download file
        mapHandlerToFile(newHandler, seg);

        // start data download and increase thread counter
        nioClient.fetchArticleData(seg.getGroups().firstElement(), seg.getArticleId(), newHandler);
        runningThreads++;
      }

      // Add finished response handlers from backup downloader to this.activeRspHandlers
      if(backupFileDownloader != null && backupFileDownloader.hasFinishedHandlers())
      {
        for(RspHandler handler : backupFileDownloader.getFinishedHandlers())
        {
          activeRspHandlers.add(handler);
          DownloadFileSegment seg = handler.dlFileSeg();
          dlFileRspHandlerMap.get(seg.getDlFile()).put(seg.getIndex(), handler);
        }
      }

      // check if the next element of the result set is already finished
      int actRspHdlsSize;
View Full Code Here


    while(!shutdown)
    {
      while(segQueue.hasSegments() && runningThreads < maxThreads && !pause && nioClient.hasFreeSlot())
      {
        // get next segment in queue
        DownloadFileSegment nextSeg = segQueue.nextSegment();
        if(nextSeg == null)
          break;
        String filename = nextSeg.getDlFile().getFilename();
        logger.msg("Downloading from backup server next segment of file: " + filename, MyLogger.SEV_DEBUG);

        // create new response handler
        RspHandler newHandler = new RspHandler(nextSeg, true);
        synchronized(activeRspHandlers)
        {
          activeRspHandlers.add(newHandler);
        }

        // start data download and increase thread counter
        nioClient.fetchArticleData(nextSeg.getGroups().firstElement(), nextSeg.getArticleId(), newHandler);
        runningThreads++;
      }

      // check if the next element of the result set is already finished
      int actRspHdlsSize;
View Full Code Here

TOP

Related Classes of me.mabra.hellonzb.parser.DownloadFileSegment

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.