001package com.thed.zblast.util;
002
003import com.thed.model.AutomationJobDetail;
004import com.thed.model.QueueProcessor;
005import com.thed.util.Utils;
006
007import java.util.Queue;
008import java.util.concurrent.ExecutorService;
009import java.util.concurrent.Executors;
010import java.util.logging.Logger;
011
012public class ResultParser {
013        private static Logger logger = Logger.getLogger(ResultParser.class.getName());
014        private ExecutorService threads;
015        static int threadPoolSize=Utils.getZbotProperties().getInt("ThreadPoolSize");
016
017        public ResultParser() {
018                threads= Executors.newFixedThreadPool((threadPoolSize == 0) ? 10 : threadPoolSize);
019        }
020        
021                public  void postInParallel(Queue<Queue<AutomationJobDetail>> queue, Long userId) throws Exception {
022                while(queue.peek()!=null) {
023                        Queue<AutomationJobDetail> jobQueue=queue.poll();
024                        
025                        for(AutomationJobDetail ajd: jobQueue)
026                        {
027                                System.out.println(">>>>>ajd :::"+ajd);
028                                /*INFO: no failed execution implemented after maven dependency removed
029                                 *   ---remove from queue if its re executed the failed testcases only */
030                                if(ajd.getStatus()!=null && ajd.getStatus().equalsIgnoreCase("failed_execute_new")) {
031                                        System.out.println("inside failed_execute_new.... ..");
032                                        jobQueue.remove(ajd);
033                                        System.out.println("inside if after remove jobQueue :::: "+jobQueue.size());
034                                }
035                        }
036                        threads.submit(new QueueProcessor(jobQueue, userId));
037                }
038        }
039
040        public void shutDownThreadPool() {
041                if(threads!=null) {
042                        threads.shutdownNow();
043                }
044        }
045        
046        
047}