Package org.gcube.common.health.api
Interface ContextPreparation
public interface ContextPreparation
How an application prepares itself in one of its Contexts (e.g. reads or creates its configuration
there and reaches what it needs) and reports its state there. It is optional: an application
without it is active in every Context. The class is annotated
ContextPreparer.
Both methods work in the Context of the token of the caller, which SmartGears sets before calling
them. An exception thrown by either makes the Context unavailable, with a generic reason.
-
Method Summary
Modifier and TypeMethodDescriptionprepare()Prepares the application in the Context of the caller.default Durationrefresh()Returns how often SmartGears prepares the application again in the Contexts where it is already active, e.g. to notice a configuration changed in the Context.default voidTells the application that the node has left a Context, so that it drops what it keeps for it.state()Returns the state of the application in the Context of the caller, without preparing it.
-
Method Details
-
prepare
ContextState prepare()Prepares the application in the Context of the caller. It does nothing when the application is already active there. It may be called at the same time in the same Context (the start-up thread, a request, the check of the health), so it must be safe under concurrent calls.- Returns:
- the state of the application in the Context after the attempt
-
state
ContextState state()Returns the state of the application in the Context of the caller, without preparing it.- Returns:
- the state
-
refresh
Returns how often SmartGears prepares the application again in the Contexts where it is already active, e.g. to notice a configuration changed in the Context. The Contexts where it is not active are prepared again every 20 minutes in any case.- Returns:
- the interval, or
null(unless the application says otherwise) to prepare an active Context only once
-
removed
Tells the application that the node has left a Context, so that it drops what it keeps for it. It is called with no secret: the token of the Context is gone.- Parameters:
context- the Context the node has left
-