This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new c451f092cbc CAMEL-19491: use ScheduledPollConsumerHealthCheck c451f092cbc is described below commit c451f092cbc361ad4066d679718e607b716390dd Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Jul 28 07:41:56 2023 +0200 CAMEL-19491: use ScheduledPollConsumerHealthCheck --- .../google/storage/GoogleCloudStorageConsumer.java | 17 ------ .../GoogleCloudStorageConsumerHealthCheck.java | 67 ---------------------- 2 files changed, 84 deletions(-) diff --git a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumer.java b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumer.java index 0f140b1b4ab..ca308e15056 100644 --- a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumer.java +++ b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumer.java @@ -36,8 +36,6 @@ import org.apache.camel.Expression; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.RuntimeCamelException; -import org.apache.camel.health.HealthCheckHelper; -import org.apache.camel.health.WritableHealthCheckRepository; import org.apache.camel.spi.Language; import org.apache.camel.spi.Synchronization; import org.apache.camel.support.EmptyAsyncCallback; @@ -54,9 +52,6 @@ public class GoogleCloudStorageConsumer extends ScheduledBatchPollingConsumer { private final Language language; - private WritableHealthCheckRepository healthCheckRepository; - private GoogleCloudStorageConsumerHealthCheck consumerHealthCheck; - public GoogleCloudStorageConsumer(GoogleCloudStorageEndpoint endpoint, Processor processor) { super(endpoint, processor); this.language = getEndpoint().getCamelContext().resolveLanguage("file"); @@ -66,18 +61,6 @@ public class GoogleCloudStorageConsumer extends ScheduledBatchPollingConsumer { protected void doStart() throws Exception { super.doStart(); - healthCheckRepository = HealthCheckHelper.getHealthCheckRepository( - getEndpoint().getCamelContext(), - "components", - WritableHealthCheckRepository.class); - - if (healthCheckRepository != null) { - consumerHealthCheck = new GoogleCloudStorageConsumerHealthCheck(this, getRouteId()); - consumerHealthCheck.setEnabled(getEndpoint().getComponent().isHealthCheckEnabled() - && getEndpoint().getComponent().isHealthCheckConsumerEnabled()); - healthCheckRepository.addHealthCheck(consumerHealthCheck); - } - if (getConfiguration().isMoveAfterRead()) { Bucket bucket = getStorageClient().get(getConfiguration().getDestinationBucket()); if (bucket != null) { diff --git a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumerHealthCheck.java b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumerHealthCheck.java deleted file mode 100644 index 3e5bf8e33c0..00000000000 --- a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageConsumerHealthCheck.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.component.google.storage; - -import java.util.Map; - -import com.google.api.gax.rpc.ApiException; -import com.google.cloud.storage.Storage; -import org.apache.camel.health.HealthCheckResultBuilder; -import org.apache.camel.impl.health.AbstractHealthCheck; -import org.apache.camel.util.ObjectHelper; - -public class GoogleCloudStorageConsumerHealthCheck extends AbstractHealthCheck { - - private final GoogleCloudStorageConsumer googleCloudStorageConsumer; - - public GoogleCloudStorageConsumerHealthCheck(GoogleCloudStorageConsumer googleCloudStorageConsumer, String routeId) { - super("camel", "google-cloud-storage-consumer-" + routeId); - this.googleCloudStorageConsumer = googleCloudStorageConsumer; - } - - @Override - protected void doCall(HealthCheckResultBuilder builder, Map<String, Object> options) { - Storage client; - try { - GoogleCloudStorageConfiguration configuration = googleCloudStorageConsumer.getConfiguration(); - if (ObjectHelper.isNotEmpty(configuration.getStorageClient())) { - client = configuration.getStorageClient(); - } else { - client = googleCloudStorageConsumer.getStorageClient(); - } - client.list(); - } catch (ApiException e) { - builder.message(e.getMessage()); - builder.error(e); - if (ObjectHelper.isNotEmpty(e.getStatusCode())) { - builder.detail(SERVICE_STATUS_CODE, e.getStatusCode()); - } - if (ObjectHelper.isNotEmpty(e.getStatusCode().getCode())) { - builder.detail(SERVICE_ERROR_CODE, e.getStatusCode().getCode()); - } - builder.down(); - return; - - } catch (Exception e) { - builder.error(e); - builder.down(); - return; - } - builder.up(); - - } -}