001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.springframework.boot.actuate.autoconfigure.cassandra; 017 018import java.util.Map; 019 020import com.datastax.driver.core.Cluster; 021import reactor.core.publisher.Flux; 022 023import org.springframework.boot.actuate.autoconfigure.health.CompositeReactiveHealthIndicatorConfiguration; 024import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; 025import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; 026import org.springframework.boot.actuate.cassandra.CassandraReactiveHealthIndicator; 027import org.springframework.boot.actuate.health.ReactiveHealthIndicator; 028import org.springframework.boot.autoconfigure.AutoConfigureAfter; 029import org.springframework.boot.autoconfigure.AutoConfigureBefore; 030import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 031import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 032import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 033import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 034import org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration; 035import org.springframework.context.annotation.Bean; 036import org.springframework.context.annotation.Configuration; 037import org.springframework.data.cassandra.core.ReactiveCassandraOperations; 038 039/** 040 * {@link EnableAutoConfiguration Auto-configuration} for 041 * {@link CassandraReactiveHealthIndicator}. 042 * 043 * @author Artsiom Yudovin 044 * @author Stephane Nicoll 045 * @since 2.1.0 046 */ 047@Configuration 048@ConditionalOnClass({ Cluster.class, ReactiveCassandraOperations.class, Flux.class }) 049@ConditionalOnBean(ReactiveCassandraOperations.class) 050@ConditionalOnEnabledHealthIndicator("cassandra") 051@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) 052@AutoConfigureAfter(CassandraReactiveDataAutoConfiguration.class) 053public class CassandraReactiveHealthIndicatorAutoConfiguration extends 054 CompositeReactiveHealthIndicatorConfiguration<CassandraReactiveHealthIndicator, ReactiveCassandraOperations> { 055 056 private final Map<String, ReactiveCassandraOperations> reactiveCassandraOperations; 057 058 public CassandraReactiveHealthIndicatorAutoConfiguration( 059 Map<String, ReactiveCassandraOperations> reactiveCassandraOperations) { 060 this.reactiveCassandraOperations = reactiveCassandraOperations; 061 } 062 063 @Bean 064 @ConditionalOnMissingBean(name = "cassandraReactiveHealthIndicator") 065 public ReactiveHealthIndicator cassandraHealthIndicator() { 066 return createHealthIndicator(this.reactiveCassandraOperations); 067 } 068 069}