Subversion Repositories SmartDukaan

Rev

Rev 37449 | Rev 37482 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37449 Rev 37472
Line 16... Line 16...
16
import java.time.LocalDate;
16
import java.time.LocalDate;
17
import java.time.LocalDateTime;
17
import java.time.LocalDateTime;
18
import java.time.LocalTime;
18
import java.time.LocalTime;
19
import java.time.YearMonth;
19
import java.time.YearMonth;
20
import java.util.Date;
20
import java.util.Date;
21
import java.util.LinkedHashMap;
-
 
22
 
21
 
23
@Component
22
@Component
24
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
23
//@ConditionalOnProperty(name = "scheduled", havingValue = "true", matchIfMissing = true)
25
public class ScheduledSkeleton {
24
public class ScheduledSkeleton {
26
 
25
 
Line 293... Line 292...
293
        scheduledTasks.partnerProblemAlert();
292
        scheduledTasks.partnerProblemAlert();
294
 
293
 
295
        log.info("endTime" + LocalDateTime.now());
294
        log.info("endTime" + LocalDateTime.now());
296
    }
295
    }
297
 
296
 
298
    /*
-
 
299
     * @Scheduled(cron = "0 30 10 * * MON-SAT") public void
-
 
300
     * sendMorningAttendanceAlert() throws Throwable { log.info("startTime" +
-
 
301
     * LocalDateTime.now()); LinkedHashMap<String, String> propertiesDetails = new
-
 
302
     * LinkedHashMap<>(); propertiesDetails.put("sendMorningAttendanceAlert", "0");
-
 
303
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
-
 
304
     * nagiosCronPropertiesFile);
-
 
305
     *
-
 
306
     * scheduledTasks.sendAttendanceMorningAlert();
-
 
307
     * propertiesDetails.put("sendMorningAttendanceAlert", "1");
-
 
308
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
-
 
309
     * nagiosCronPropertiesFile);
-
 
310
     *
-
 
311
     * log.info("endTime" + LocalDateTime.now()); }
-
 
312
     *
-
 
313
     * @Scheduled(cron = "0 30 20 * * MON-SAT") public void
-
 
314
     * sendEveningAttendanceAlert() throws Throwable { log.info("startTime" +
-
 
315
     * LocalDateTime.now()); LinkedHashMap<String, String> propertiesDetails = new
-
 
316
     * LinkedHashMap<>(); propertiesDetails.put("sendEveningAttendanceAlert", "0");
-
 
317
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
-
 
318
     * nagiosCronPropertiesFile);
-
 
319
     *
-
 
320
     * scheduledTasks.sendAttendanceEveningAlert();
-
 
321
     * propertiesDetails.put("sendEveningAttendanceAlert", "1");
-
 
322
     * writeToPropertiesFile.saveParamChanges(propertiesDetails,
-
 
323
     * nagiosCronPropertiesFile);
-
 
324
     *
-
 
325
     * log.info("endTime" + LocalDateTime.now()); }
-
 
326
     */
-
 
327
 
-
 
328
    @Scheduled(cron = "0 0 10 * * *")
297
    @Scheduled(cron = "0 0 10 * * *")
329
    public void onboardingEventDelays() throws Throwable {
298
    public void onboardingEventDelays() throws Throwable {
330
        log.info("startTime" + LocalDateTime.now());
299
        log.info("startTime" + LocalDateTime.now());
331
 
300
 
332
        onBoardingRelatedSchelduleTask.onboardingEventDelays();
301
        onBoardingRelatedSchelduleTask.onboardingEventDelays();
Line 355... Line 324...
355
        onBoardingRelatedSchelduleTask.brandingAlert();
324
        onBoardingRelatedSchelduleTask.brandingAlert();
356
 
325
 
357
        log.info("endTime" + LocalDateTime.now());
326
        log.info("endTime" + LocalDateTime.now());
358
    }
327
    }
359
 
328
 
360
//    @Scheduled(cron = "0 0 8 * * *")
-
 
361
//    public void advancePaymentPendingAlert() throws Throwable {
-
 
362
//        log.info("startTime" + LocalDateTime.now());
-
 
363
//
-
 
364
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
-
 
365
//        propertiesDetails.put("advancePaymentPendingAlert", "0");
-
 
366
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
367
//
-
 
368
//        onBoardingRelatedSchelduleTask.advancePaymentPendingAlert();
-
 
369
//        propertiesDetails.put("advancePaymentPendingAlert", "1");
-
 
370
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
371
//
-
 
372
//        log.info("endTime" + LocalDateTime.now());
-
 
373
//    }
-
 
374
 
-
 
375
    @Scheduled(cron = "0 0 8 * * *")
329
    @Scheduled(cron = "0 0 8 * * *")
376
    public void fullPaymentPendingAlert() throws Throwable {
330
    public void fullPaymentPendingAlert() throws Throwable {
377
        log.info("startTime" + LocalDateTime.now());
331
        log.info("startTime" + LocalDateTime.now());
378
 
332
 
379
        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();
333
        onBoardingRelatedSchelduleTask.fullPaymentPendingAlert();
380
 
334
 
381
        log.info("endTime" + LocalDateTime.now());
335
        log.info("endTime" + LocalDateTime.now());
382
    }
336
    }
383
 
337
 
384
//    @Scheduled(cron = "0 0 9 * * *")
-
 
385
//    public void advancePaymentPendinglegalAlert() throws Throwable {
-
 
386
//        log.info("startTime" + LocalDateTime.now());
-
 
387
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
-
 
388
//        propertiesDetails.put("advancePaymentPendinglegalAlert", "0");
-
 
389
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
390
//
-
 
391
////        onBoardingRelatedSchelduleTask.advancePaymentPendinglegalAlert();
-
 
392
//
-
 
393
//        propertiesDetails.put("advancePaymentPendinglegalAlert", "1");
-
 
394
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
395
//
-
 
396
//        log.info("endTime" + LocalDateTime.now());
-
 
397
//    }
-
 
398
 
-
 
399
    @Scheduled(cron = "0 */5 * * * *")
338
    @Scheduled(cron = "0 */5 * * * *")
400
    public void onBoardingCompleteEventEmail() throws Throwable {
339
    public void onBoardingCompleteEventEmail() throws Throwable {
401
        log.info("startTime" + LocalDateTime.now());
340
        log.info("startTime" + LocalDateTime.now());
402
 
341
 
403
        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();
342
        onBoardingRelatedSchelduleTask.onBoardingCompleteEventEmail();
Line 425... Line 364...
425
    @Scheduled(fixedDelay = 5 * 60 * 1000)
364
    @Scheduled(fixedDelay = 5 * 60 * 1000)
426
    public void fetchPartnerStat() throws Throwable {
365
    public void fetchPartnerStat() throws Throwable {
427
        scheduledTasks.fetchParnterStats();
366
        scheduledTasks.fetchParnterStats();
428
    }
367
    }
429
 
368
 
430
//    @Scheduled(cron = "0 0 9 * * *")
-
 
431
//    public void storeTimelinePromoterPending() throws Throwable {
-
 
432
//        log.info("startTime" + LocalDateTime.now());
-
 
433
//
-
 
434
//        LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
-
 
435
//        propertiesDetails.put("storeTimelinePromoterPending", "0");
-
 
436
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
437
//
-
 
438
////        onBoardingRelatedSchelduleTask.storeTimelinePromoterPending();
-
 
439
//        propertiesDetails.put("storeTimelinePromoterPending", "1");
-
 
440
//        writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
-
 
441
//
-
 
442
//        log.info("endTime" + LocalDateTime.now());
-
 
443
//    }
-
 
444
 
-
 
445
    //@Scheduled(cron = "0 0 23 * * *")
369
    @Scheduled(cron = "0 0 23 * * *")
446
    public void checkItelImeiActivationNew() throws Throwable {
370
    public void checkItelImeiActivationNew() throws Throwable {
447
        log.info("startTime" + LocalDate.now());
371
        log.info("startTime" + LocalDate.now());
448
 
372
 
449
        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
373
        log.info("startTimecheckItelImeiActivation" + LocalDate.now());
450
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
374
        scheduledTasks.checkItelImeiActivationNew(LocalDate.now(), 90);
451
        long secs = (new Date().getTime()) / 1000;
375
        long secs = (new Date().getTime()) / 1000;
452
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());
376
        log.info("endTimecheckItelImeiActivation" + LocalDate.now());
453
 
377
 
454
    }
378
    }
455
 
379
 
-
 
380
    /**
-
 
381
     * Vivo: one full pass a day, then nothing until tomorrow.
-
 
382
     *
-
 
383
     * Was two parallel jobs every 5 minutes capped at 50 and 10 imeis, which never
-
 
384
     * finished a pass over a 9,510-row pool and retried a failed lookup five minutes
-
 
385
     * later instead of the next day. Vivo stays on its own schedule and its own thread:
-
 
386
     * it is direct HTTP plus the captcha solver, no ChromeDriver, so it does not
-
 
387
     * contend for the resource the oppo/realme pass is rationing.
-
 
388
     *
-
 
389
     * ~9,510 imeis at roughly 2.5s each is about 6.6 hours.
-
 
390
     */
456
    @Scheduled(fixedDelay = 5 * 60 * 1000)
391
    @Scheduled(cron = "0 15 0 * * *")
457
    public void vivoImeiActivation() throws Throwable {
392
    public void vivoImeiActivation() throws Throwable {
458
        log.info("startTimevivoImeiActivation" + LocalDateTime.now());
393
        log.info("startTimevivoImeiActivation" + LocalDateTime.now());
459
 
394
 
460
        scheduledTasks.checkImeiActivation();
395
        scheduledTasks.checkImeiActivation();
461
        long secs = (new Date().getTime()) / 1000;
-
 
462
        log.info("endTimevivoImeiActivation" + LocalDateTime.now());
-
 
463
 
-
 
464
    }
-
 
465
 
396
 
466
    @Scheduled(fixedDelay = 5 * 60 * 1000)
-
 
467
    public void vivoImeiActivationTertiary() throws Throwable {
-
 
468
        log.info("startTimevivoImeiActivationTertiary" + LocalDateTime.now());
397
        log.info("endTimevivoImeiActivation" + LocalDateTime.now());
469
 
-
 
470
        scheduledTasks.checkImeiActivationTertiary();
-
 
471
 
398
 
472
        log.info("endTimevivoImeiActivationTertiary" + LocalDateTime.now());
-
 
473
    }
399
    }
474
 
400
 
475
    @Scheduled(cron = "0 0 8 * * *")
401
    @Scheduled(cron = "0 0 8 * * *")
476
    public void reviewUncontactablePartner() throws Throwable {
402
    public void reviewUncontactablePartner() throws Throwable {
477
        log.info("startTime" + LocalDateTime.now());
403
        log.info("startTime" + LocalDateTime.now());
Line 508... Line 434...
508
    private StandAlone standAlone;
434
    private StandAlone standAlone;
509
 
435
 
510
    @Autowired
436
    @Autowired
511
    OrderTrackingService orderTrackingService;
437
    OrderTrackingService orderTrackingService;
512
 
438
 
-
 
439
    // ONE thread, ONE full pass a day, for oppo and realme together.
-
 
440
    //
-
 
441
    // This replaces four @Scheduled jobs (oppo and realme x secondary and tertiary,
513
    // Oppo runs its two pools in PARALLEL again (r37447 merged them; measured cost was
442
    // every 5 minutes), and it supersedes the r37447 / r37448 / r37449 argument about
-
 
443
    // how many ChromeDrivers to run. That argument was about the wrong variable.
-
 
444
    //
514
    // 5,280 -> 3,456/day because merging serialises the work, and at ~21s/imei merged
445
    // The revert in r37449 was sized on lookups ATTEMPTED per day, and the re-merge that
-
 
446
    // followed blamed the resulting collapse on CPU contention pushing the captcha
515
    // there is no batch size or delay that reaches its target). Two drivers for oppo is
447
    // render past the element waits. The logs do not support contention:
-
 
448
    //
516
    // the price of its throughput; realme stays merged since it has headroom.
449
    //   29 Aug        imeis   canvas timeouts   captcha ok   distinct imeis   asks each
-
 
450
    //   oppo          4,350                 0       ~100%            4,238        1.03
-
 
451
    //   realme        4,524             3,390         19%            1,004        4.50
-
 
452
    //
-
 
453
    // Same box, same six cores, same driver count, same captcha vendor, load average
-
 
454
    // 0.9 -- and oppo took ZERO timeouts in all 24 hours, including the 15:00-23:00
-
 
455
    // window in which realme solved nothing at all. Realme's own canvas wait is 15s
517
    @Scheduled(fixedDelay = 5 * 60 * 1000)
456
    // against oppo's 8s, so the LONGER wait is the one expiring.
-
 
457
    //
-
 
458
    // What realme's timeout rate actually tracks is its own daily request volume, and
-
 
459
    // it resets at midnight: 920/day -> 0.3%, 3,467/day -> 28%, 4,524/day -> 75%. That
518
    public void oppo() throws Throwable {
460
    // is realme.com declining to serve the widget, not a busy box.
-
 
461
    //
-
 
462
    // The 4.5 asks per imei is why it ran away. A failed lookup never reaches
-
 
463
    // dateMap.put, so no row is written, so createTimestamp is not bumped, so the same
-
 
464
    // imei was eligible again five minutes later -- more requests hardened the block,
-
 
465
    // which caused more failures, which caused more requests. A snapshotted daily pass
-
 
466
    // bounds that by construction: a failure costs one retry tomorrow, never one in
519
        standAlone.checkOppoImeiStatus();
467
    // five minutes, however the far end behaves.
520
    }
468
    //
-
 
469
    // Judge this change on dates written, not on timeout count.
-
 
470
    @Scheduled(cron = "0 30 0 * * *")
-
 
471
    public void oppoRealmeImeiActivation() throws Throwable {
-
 
472
        log.info("startTimeOppoRealmeImeiActivation {}", LocalDateTime.now());
521
 
473
 
522
    @Scheduled(fixedDelay = 5 * 60 * 1000)
-
 
523
    public void oppoTertiary() throws Throwable {
-
 
524
        standAlone.checkOppoImeiStatusTertiary();
474
        standAlone.checkBrowserImeiActivation();
525
    }
-
 
526
 
475
 
527
    // Realme unmerged too. Merging it saved a driver, but once oppo went back to two
-
 
528
    // browsers realme's per-imei went 14.2s -> 29s purely from CPU contention, and at 29s
-
 
529
    // its merged ceiling (86400/29 = 2,979/day) sits just under the 3,054/day the daily
-
 
530
    // re-check needs -- so no batch size could close it. Two parallel pools restore the
-
 
531
    // ~3,900/day it managed historically at this driver count.
-
 
532
    @Scheduled(fixedDelay = 5 * 60 * 1000)
-
 
533
    public void realme() throws Throwable {
-
 
534
        standAlone.checkRealmeImeiStatus();
-
 
535
    }
-
 
536
 
-
 
537
    @Scheduled(fixedDelay = 5 * 60 * 1000)
-
 
538
    public void realmeTertiary() throws Throwable {
-
 
539
        standAlone.checkRealmeImeiStatusTertiary();
476
        log.info("endTimeOppoRealmeImeiActivation {}", LocalDateTime.now());
540
    }
477
    }
541
 
478
 
542
    @Scheduled(cron = "0 0 * * * *")
479
    @Scheduled(cron = "0 0 * * * *")
543
    public void markBlueDartOrderDelivered() throws Throwable {
480
    public void markBlueDartOrderDelivered() throws Throwable {
544
        log.info("startTime" + LocalDateTime.now());
481
        log.info("startTime" + LocalDateTime.now());