From b4b71b902493cac1e5b57c70ab53961c26ceb323 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Mon, 29 Jan 2018 20:23:59 -0800 Subject: Adding /ping resource for deep health checks --- .../ccb/ChurchCommunityBuilderIntegrationDriver.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/main/java/com/p4square/grow/ccb') diff --git a/src/main/java/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java b/src/main/java/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java index 3704fdc..dd62401 100644 --- a/src/main/java/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java +++ b/src/main/java/com/p4square/grow/ccb/ChurchCommunityBuilderIntegrationDriver.java @@ -6,9 +6,11 @@ import com.p4square.ccbapi.CCBAPIClient; import com.p4square.grow.config.Config; import com.p4square.grow.frontend.IntegrationDriver; import com.p4square.grow.frontend.ProgressReporter; +import org.apache.log4j.Logger; import org.restlet.Context; import org.restlet.security.Verifier; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -17,6 +19,8 @@ import java.net.URISyntaxException; */ public class ChurchCommunityBuilderIntegrationDriver implements IntegrationDriver { + private static final Logger LOG = Logger.getLogger(ChurchCommunityBuilderIntegrationDriver.class); + private final Context mContext; private final MetricRegistry mMetricRegistry; private final Config mConfig; @@ -65,4 +69,18 @@ public class ChurchCommunityBuilderIntegrationDriver implements IntegrationDrive public ProgressReporter getProgressReporter() { return mProgressReporter; } + + @Override + public boolean doHealthCheck() { + try { + // Try something benign, like getting the custom field labels, + // to verify that we can talk to CCB. + mAPI.getCustomFieldLabels(); + return true; + + } catch (IOException e) { + LOG.warn("CCB Health Check Failed: " + e.getMessage(), e); + return false; + } + } } -- cgit v1.2.3