You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by GitBox <gi...@apache.org> on 2021/08/09 19:52:30 UTC
[GitHub] [sling-org-apache-sling-distribution-journal] tmaret commented on a change in pull request #88: SLING-10709 : Migrate SubscriberIdleCheck from Systemready to HC
tmaret commented on a change in pull request #88:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal/pull/88#discussion_r685476567
##########
File path: src/main/java/org/apache/sling/distribution/journal/impl/subscriber/SubscriberIdleCheck.java
##########
@@ -19,34 +19,30 @@
package org.apache.sling.distribution.journal.impl.subscriber;
import java.io.Closeable;
+import java.util.Dictionary;
import java.util.Hashtable;
-import org.apache.felix.systemready.CheckStatus;
-import org.apache.felix.systemready.StateType;
-import org.apache.felix.systemready.SystemReadyCheck;
-import org.apache.felix.systemready.CheckStatus.State;
+import org.apache.felix.hc.api.HealthCheck;
+import org.apache.felix.hc.api.Result;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-public class SubscriberIdleCheck implements SystemReadyCheck, Closeable {
+public class SubscriberIdleCheck implements HealthCheck, Closeable {
static final String CHECK_NAME = "DistributionSubscriber idle";
- private final ServiceRegistration<SystemReadyCheck> reg;
+ private final ServiceRegistration<HealthCheck> reg;
private final IdleCheck idleCheck;
-
+
public SubscriberIdleCheck(BundleContext context, IdleCheck idleCheck) {
this.idleCheck = idleCheck;
- this.reg = context.registerService(SystemReadyCheck.class, this, new Hashtable<>());
+ final Dictionary<String, Object> props = new Hashtable<>();
+ props.put(HealthCheck.NAME, CHECK_NAME);
+ this.reg = context.registerService(HealthCheck.class, this, props);
}
@Override
- public String getName() {
- return CHECK_NAME;
- }
-
- @Override
- public CheckStatus getStatus() {
- State state = idleCheck.isIdle() ? State.GREEN : State.RED;
- return new CheckStatus(getName(), StateType.READY, state, CHECK_NAME);
+ public Result execute() {
+ Result.Status status = idleCheck.isIdle() ? Result.Status.OK : Result.Status.CRITICAL;
Review comment:
We should return `TEMPORARILY_UNAVAILABLE` instead of `CRITICAL`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org