Subversion Repositories SmartDukaan

Rev

Rev 37472 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37472 Rev 37673
Line 19... Line 19...
19
import org.openqa.selenium.support.ui.WebDriverWait;
19
import org.openqa.selenium.support.ui.WebDriverWait;
20
import com.smartdukaan.cron.monitored.ImeiActivationGauges;
20
import com.smartdukaan.cron.monitored.ImeiActivationGauges;
21
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.beans.factory.annotation.Autowired;
22
import org.springframework.stereotype.Component;
22
import org.springframework.stereotype.Component;
23
 
23
 
-
 
24
import com.spice.profitmandi.common.util.BrowserLane;
-
 
25
 
24
import javax.imageio.ImageIO;
26
import javax.imageio.ImageIO;
25
import java.awt.image.BufferedImage;
27
import java.awt.image.BufferedImage;
26
import java.io.File;
28
import java.io.File;
27
import java.time.LocalDate;
29
import java.time.LocalDate;
28
import java.time.format.DateTimeFormatter;
30
import java.time.format.DateTimeFormatter;
Line 85... Line 87...
85
        options.addArguments("--disable-dev-shm-usage");
87
        options.addArguments("--disable-dev-shm-usage");
86
        options.addArguments("--disable-software-rasterizer");
88
        options.addArguments("--disable-software-rasterizer");
87
 
89
 
88
        WebDriver driver = null;
90
        WebDriver driver = null;
89
 
91
 
-
 
92
        // One driver tree on this box at a time -- see BrowserLane for the 850MB/96%-duty-cycle
-
 
93
        // arithmetic. Five minutes is a whole chunk's worth of waiting: the only thing that can
-
 
94
        // hold the lane that long is the other brand mid-chunk or the knowlarity scrape, and
-
 
95
        // giving up costs nothing because these imeis stay pending for the next tick.
-
 
96
        BrowserLane lane = BrowserLane.acquire(BRAND, 5, TimeUnit.MINUTES);
-
 
97
        if (lane == null) {
-
 
98
            return dateMap;
-
 
99
        }
-
 
100
 
90
        try {
101
        try {
91
            driver = new ChromeDriver(options);
102
            driver = new ChromeDriver(options);
92
            driver.manage().timeouts().setScriptTimeout(6, TimeUnit.SECONDS);
103
            driver.manage().timeouts().setScriptTimeout(6, TimeUnit.SECONDS);
93
            driver.manage().window().setSize(new Dimension(1600, 900));
104
            driver.manage().window().setSize(new Dimension(1600, 900));
94
            driver.manage().window().maximize();
105
            driver.manage().window().maximize();
Line 290... Line 301...
290
                    driver.quit(); //Ensures cleanup even on return or error
301
                    driver.quit(); //Ensures cleanup even on return or error
291
                } catch (Exception e) {
302
                } catch (Exception e) {
292
                    LOGGER.warn("Error closing driver: " + e.getMessage());
303
                    LOGGER.warn("Error closing driver: " + e.getMessage());
293
                }
304
                }
294
            }
305
            }
-
 
306
            // After quit(), not before: the 850MB is resident for the whole chunk.
-
 
307
            lane.close();
295
        }
308
        }
296
 
309
 
297
        return dateMap;
310
        return dateMap;
298
    }
311
    }
299
 
312