-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/maven/fixes/9.1' into maven/rele…
…ase/9.1
- Loading branch information
Showing
7 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
tracker/src/main/java/org/edu_sharing/elasticsearch/TrackerAvailabilityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.edu_sharing.elasticsearch; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.actuate.health.Health; | ||
import org.springframework.boot.availability.*; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class TrackerAvailabilityService extends ApplicationAvailabilityBean implements TrackerAvailabilityTickService { | ||
// curl localhost:8081/actuator/health/liveness | ||
private long lastTrackingEvent = System.currentTimeMillis(); | ||
@Value("${management.endpoint.health.trackingTimeoutThreshold}") | ||
private long trackingTimeoutThreshold; | ||
|
||
@Override | ||
public void tick() { | ||
lastTrackingEvent = System.currentTimeMillis(); | ||
} | ||
|
||
@Override | ||
public <S extends AvailabilityState> S getState(Class<S> stateType) { | ||
S state = super.getState(stateType); | ||
if(state instanceof LivenessState && (System.currentTimeMillis() - lastTrackingEvent) > trackingTimeoutThreshold * 1000 * 60) { | ||
return (S) LivenessState.BROKEN; | ||
} | ||
return state; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tracker/src/main/java/org/edu_sharing/elasticsearch/TrackerAvailabilityTickService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.edu_sharing.elasticsearch; | ||
|
||
public interface TrackerAvailabilityTickService { | ||
|
||
/** | ||
* tell the application that the tracker is still alive and has just triggered a new run | ||
* Used for liveness probes | ||
*/ | ||
void tick(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters