This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.21.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.21.x by this push: new 313593502ac CAMEL-19491: use ScheduledPollConsumerHealthCheck 313593502ac is described below commit 313593502acc3099fdab2f59008663ac97b28ac9 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Jul 28 07:44:10 2023 +0200 CAMEL-19491: use ScheduledPollConsumerHealthCheck --- .../google/storage/GoogleCloudStorageConsumer.java | 16 ------ .../GoogleCloudStorageConsumerHealthCheck.java | 67 ---------------------- 2 files changed, 83 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 6f839702b55..03b6c9d20c6 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 @@ -37,8 +37,6 @@ import org.apache.camel.ExtendedExchange; 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; @@ -55,9 +53,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"); @@ -67,21 +62,10 @@ 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()); - healthCheckRepository.addHealthCheck(consumerHealthCheck); - } - if (getConfiguration().isMoveAfterRead()) { Bucket bucket = getStorageClient().get(getConfiguration().getDestinationBucket()); if (bucket != null) { LOG.trace("Bucket [{}] already exists", bucket.getName()); - return; } else { LOG.trace("Destination Bucket [{}] doesn't exist yet", getConfiguration().getDestinationBucket()); if (getConfiguration().isAutoCreateBucket()) { 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(); - - } -}