@@ -593,14 +593,32 @@ public DomainStatus withStartTime(OffsetDateTime startTime) {
593
593
* Returns the time that the current domain started automatic retries in response to a severe failure.
594
594
*/
595
595
public OffsetDateTime getInitialFailureTime () {
596
- return initialFailureTime ;
596
+ OffsetDateTime minConditionTime = Optional .ofNullable (getConditions ()).orElse (Collections .emptyList ()).stream ()
597
+ .filter (DomainCondition ::isRetriableFailure ).map (DomainCondition ::getLastTransitionTime )
598
+ .min (OffsetDateTime ::compareTo ).orElse (null );
599
+ if (minConditionTime == null ) {
600
+ return initialFailureTime ;
601
+ } else if (initialFailureTime == null ) {
602
+ return minConditionTime ;
603
+ }
604
+
605
+ return initialFailureTime .isBefore (minConditionTime ) ? initialFailureTime : minConditionTime ;
597
606
}
598
607
599
608
/**
600
609
* Returns the time that the last severe failure was reported.
601
610
*/
602
611
public OffsetDateTime getLastFailureTime () {
603
- return lastFailureTime ;
612
+ OffsetDateTime maxConditionTime = Optional .ofNullable (getConditions ()).orElse (Collections .emptyList ()).stream ()
613
+ .filter (DomainCondition ::isRetriableFailure ).map (DomainCondition ::getLastTransitionTime )
614
+ .max (OffsetDateTime ::compareTo ).orElse (null );
615
+ if (maxConditionTime == null ) {
616
+ return lastFailureTime ;
617
+ } else if (lastFailureTime == null ) {
618
+ return maxConditionTime ;
619
+ }
620
+
621
+ return lastFailureTime .isAfter (maxConditionTime ) ? lastFailureTime : maxConditionTime ;
604
622
}
605
623
606
624
/**
@@ -609,10 +627,13 @@ public OffsetDateTime getLastFailureTime() {
609
627
* @param retrySeconds the number of seconds between retries.
610
628
*/
611
629
public int getNumDeadlineIncreases (long retrySeconds ) {
612
- if (initialFailureTime == null || lastFailureTime == null ) {
630
+ OffsetDateTime initial = getInitialFailureTime ();
631
+ OffsetDateTime last = getLastFailureTime ();
632
+ if (initial == null || last == null ) {
613
633
return 0 ;
614
634
} else {
615
- return (int ) (1 + divideRoundingUp (getSecondsFromInitialToLastFailure (), retrySeconds ));
635
+ long duration = Duration .between (initial , last ).getSeconds ();
636
+ return (int ) (1 + divideRoundingUp (duration , retrySeconds ));
616
637
}
617
638
}
618
639
@@ -623,8 +644,14 @@ private long divideRoundingUp(Long dividend, long divisor) {
623
644
/**
624
645
* Returns the number of seconds between the first failure reported and the most recent one.
625
646
*/
626
- public Long getSecondsFromInitialToLastFailure () {
627
- return Duration .between (initialFailureTime , lastFailureTime ).getSeconds ();
647
+ public long getSecondsFromInitialToLastFailure () {
648
+ OffsetDateTime initial = getInitialFailureTime ();
649
+ OffsetDateTime last = getLastFailureTime ();
650
+ if (initial == null || last == null ) {
651
+ return 0 ;
652
+ } else {
653
+ return Duration .between (initial , last ).getSeconds ();
654
+ }
628
655
}
629
656
630
657
public long getMinutesFromInitialToLastFailure () {
0 commit comments