mirror of
				https://github.com/spring-projects/spring-data-elasticsearch.git
				synced 2025-10-30 22:28:47 +00:00 
			
		
		
		
	Migrate to Spring JCL logging.
Original Pull Request #2001 Closes #2000
This commit is contained in:
		
							parent
							
								
									45b4c99e95
								
							
						
					
					
						commit
						0c7c686cb1
					
				
							
								
								
									
										22
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								pom.xml
									
									
									
									
									
								
							| @ -147,21 +147,6 @@ | ||||
| 			</exclusions> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- Logging --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.slf4j</groupId> | ||||
| 			<artifactId>log4j-over-slf4j</artifactId> | ||||
| 			<version>${slf4j}</version> | ||||
| 			<scope>test</scope> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<dependency> | ||||
| 			<groupId>org.apache.logging.log4j</groupId> | ||||
| 			<artifactId>log4j-core</artifactId> | ||||
| 			<version>${log4j}</version> | ||||
| 			<scope>test</scope> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- Jackson JSON Mapper --> | ||||
| 		<dependency> | ||||
| 			<groupId>com.fasterxml.jackson.core</groupId> | ||||
| @ -223,13 +208,6 @@ | ||||
| 			</exclusions> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<dependency> | ||||
| 			<groupId>org.apache.logging.log4j</groupId> | ||||
| 			<artifactId>log4j-to-slf4j</artifactId> | ||||
| 			<version>${log4j}</version> | ||||
| 			<scope>test</scope> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<dependency> | ||||
| 			<groupId>io.projectreactor.tools</groupId> | ||||
| 			<artifactId>blockhound-junit-platform</artifactId> | ||||
|  | ||||
| @ -24,6 +24,8 @@ import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
| import java.util.stream.Stream; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.elasticsearch.Version; | ||||
| import org.elasticsearch.action.DocWriteResponse; | ||||
| import org.elasticsearch.action.bulk.BulkItemResponse; | ||||
| @ -54,8 +56,6 @@ import org.elasticsearch.index.reindex.DeleteByQueryRequest; | ||||
| import org.elasticsearch.index.reindex.UpdateByQueryRequest; | ||||
| import org.elasticsearch.search.fetch.subphase.FetchSourceContext; | ||||
| import org.elasticsearch.search.suggest.SuggestBuilder; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.data.elasticsearch.BulkFailureException; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.cluster.ElasticsearchClusterOperations; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.document.DocumentAdapters; | ||||
| @ -116,7 +116,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchRestTemplate.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(ElasticsearchRestTemplate.class); | ||||
| 
 | ||||
| 	private final RestHighLevelClient client; | ||||
| 	private final ElasticsearchExceptionTranslator exceptionTranslator = new ElasticsearchExceptionTranslator(); | ||||
| @ -419,7 +419,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate { | ||||
| 			request.scrollIds(scrollIds); | ||||
| 			execute(client -> client.clearScroll(request, RequestOptions.DEFAULT)); | ||||
| 		} catch (Exception e) { | ||||
| 			LOGGER.warn("Could not clear scroll: {}", e.getMessage()); | ||||
| 			LOGGER.warn(String.format("Could not clear scroll: %s", e.getMessage())); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -26,6 +26,8 @@ import java.util.Map; | ||||
| import java.util.function.Function; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.elasticsearch.Version; | ||||
| import org.elasticsearch.action.DocWriteResponse; | ||||
| import org.elasticsearch.action.bulk.BulkItemResponse; | ||||
| @ -47,8 +49,6 @@ import org.elasticsearch.index.reindex.DeleteByQueryRequest; | ||||
| import org.elasticsearch.index.reindex.UpdateByQueryRequest; | ||||
| import org.elasticsearch.search.suggest.SuggestBuilder; | ||||
| import org.reactivestreams.Publisher; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.BeansException; | ||||
| import org.springframework.context.ApplicationContext; | ||||
| import org.springframework.context.ApplicationContextAware; | ||||
| @ -109,8 +109,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOperations, ApplicationContextAware { | ||||
| 
 | ||||
| 	private static final Logger QUERY_LOGGER = LoggerFactory | ||||
| 			.getLogger("org.springframework.data.elasticsearch.core.QUERY"); | ||||
| 	private static final Log QUERY_LOGGER = LogFactory.getLog("org.springframework.data.elasticsearch.core.QUERY"); | ||||
| 
 | ||||
| 	private final ReactiveElasticsearchClient client; | ||||
| 	private final ElasticsearchConverter converter; | ||||
| @ -811,7 +810,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera | ||||
| 	protected Flux<AggregationContainer<?>> doAggregate(SearchRequest request) { | ||||
| 
 | ||||
| 		if (QUERY_LOGGER.isDebugEnabled()) { | ||||
| 			QUERY_LOGGER.debug("Executing doCount: {}", request); | ||||
| 			QUERY_LOGGER.debug(String.format("Executing doCount: %s", request)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Flux.from(execute(client -> client.aggregate(request))) // | ||||
| @ -885,7 +884,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera | ||||
| 	protected Flux<SearchDocument> doFind(SearchRequest request) { | ||||
| 
 | ||||
| 		if (QUERY_LOGGER.isDebugEnabled()) { | ||||
| 			QUERY_LOGGER.debug("Executing doFind: {}", request); | ||||
| 			QUERY_LOGGER.debug(String.format("Executing doFind: %s", request)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Flux.from(execute(client -> client.search(request))).map(DocumentAdapters::from) // | ||||
| @ -903,7 +902,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera | ||||
| 			Function<SearchDocument, ? extends Object> suggestEntityCreator) { | ||||
| 
 | ||||
| 		if (QUERY_LOGGER.isDebugEnabled()) { | ||||
| 			QUERY_LOGGER.debug("Executing doFindForResponse: {}", request); | ||||
| 			QUERY_LOGGER.debug(String.format("Executing doFindForResponse: %s", request)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Mono.from(execute(client1 -> client1.searchForResponse(request))).map(searchResponse -> { | ||||
| @ -920,7 +919,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera | ||||
| 	protected Mono<Long> doCount(SearchRequest request) { | ||||
| 
 | ||||
| 		if (QUERY_LOGGER.isDebugEnabled()) { | ||||
| 			QUERY_LOGGER.debug("Executing doCount: {}", request); | ||||
| 			QUERY_LOGGER.debug(String.format("Executing doCount: %s", request)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Mono.from(execute(client -> client.count(request))) // | ||||
| @ -936,7 +935,7 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera | ||||
| 	protected Flux<SearchDocument> doScroll(SearchRequest request) { | ||||
| 
 | ||||
| 		if (QUERY_LOGGER.isDebugEnabled()) { | ||||
| 			QUERY_LOGGER.debug("Executing doScroll: {}", request); | ||||
| 			QUERY_LOGGER.debug(String.format("Executing doScroll: %s", request)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Flux.from(execute(client -> client.scroll(request))) // | ||||
|  | ||||
| @ -24,6 +24,8 @@ import reactor.core.publisher.Mono; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; | ||||
| import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; | ||||
| import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; | ||||
| @ -36,8 +38,6 @@ import org.elasticsearch.client.indices.GetIndexTemplatesRequest; | ||||
| import org.elasticsearch.client.indices.GetMappingsRequest; | ||||
| import org.elasticsearch.client.indices.IndexTemplatesExistRequest; | ||||
| import org.elasticsearch.client.indices.PutIndexTemplateRequest; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.core.annotation.AnnotatedElementUtils; | ||||
| import org.springframework.dao.InvalidDataAccessApiUsageException; | ||||
| import org.springframework.data.elasticsearch.NoSuchIndexException; | ||||
| @ -69,7 +69,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| class ReactiveIndexTemplate implements ReactiveIndexOperations { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveIndexTemplate.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(ReactiveIndexTemplate.class); | ||||
| 
 | ||||
| 	@Nullable private final Class<?> boundClass; | ||||
| 	private final IndexCoordinates boundIndex; | ||||
| @ -366,7 +366,7 @@ class ReactiveIndexTemplate implements ReactiveIndexOperations { | ||||
| 				} | ||||
| 			}); | ||||
| 		} else { | ||||
| 			LOGGER.info("path in {} has to be defined. Using default instead.", annotation); | ||||
| 			LOGGER.info(String.format("path in %s has to be defined. Using default empty Document instead.", annotation)); | ||||
| 		} | ||||
| 
 | ||||
| 		return Mono.just(Document.create()); | ||||
|  | ||||
| @ -20,6 +20,8 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; | ||||
| import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; | ||||
| import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; | ||||
| @ -38,8 +40,6 @@ import org.elasticsearch.client.indices.IndexTemplatesExistRequest; | ||||
| import org.elasticsearch.client.indices.PutIndexTemplateRequest; | ||||
| import org.elasticsearch.client.indices.PutMappingRequest; | ||||
| import org.elasticsearch.cluster.metadata.MappingMetadata; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.data.elasticsearch.core.AbstractIndexTemplate; | ||||
| import org.springframework.data.elasticsearch.core.IndexInformation; | ||||
| import org.springframework.data.elasticsearch.core.IndexOperations; | ||||
| @ -66,7 +66,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| class RestIndexTemplate extends AbstractIndexTemplate implements IndexOperations { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(RestIndexTemplate.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(RestIndexTemplate.class); | ||||
| 
 | ||||
| 	private final ElasticsearchRestTemplate restTemplate; | ||||
| 
 | ||||
|  | ||||
| @ -18,11 +18,11 @@ package org.springframework.data.elasticsearch.backend.elasticsearch7.client; | ||||
| import java.net.URL; | ||||
| import java.util.ArrayList; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.apache.http.HttpHost; | ||||
| import org.elasticsearch.client.RestClient; | ||||
| import org.elasticsearch.client.RestHighLevelClient; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.DisposableBean; | ||||
| import org.springframework.beans.factory.FactoryBean; | ||||
| import org.springframework.beans.factory.FactoryBeanNotInitializedException; | ||||
| @ -38,7 +38,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>, InitializingBean, DisposableBean { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(RestClientFactoryBean.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(RestClientFactoryBean.class); | ||||
| 
 | ||||
| 	private @Nullable RestHighLevelClient client; | ||||
| 	private String hosts = "http://localhost:9200"; | ||||
|  | ||||
| @ -17,16 +17,15 @@ package org.springframework.data.elasticsearch.client; | ||||
| 
 | ||||
| import java.util.function.Supplier; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.lang.Nullable; | ||||
| import org.springframework.util.ObjectUtils; | ||||
| 
 | ||||
| /** | ||||
|  * Logging Utility to log client requests and responses. Logs client requests and responses to Elasticsearch to a | ||||
|  * dedicated logger: {@code org.springframework.data.elasticsearch.client.WIRE} on {@link org.slf4j.event.Level#TRACE} | ||||
|  * level. | ||||
|  * dedicated logger: {@code org.springframework.data.elasticsearch.client.WIRE} on trace level. | ||||
|  * | ||||
|  * @author Mark Paluch | ||||
|  * @author Christoph Strobl | ||||
| @ -35,8 +34,7 @@ import org.springframework.util.ObjectUtils; | ||||
| public abstract class ClientLogger { | ||||
| 
 | ||||
| 	private static final String lineSeparator = System.getProperty("line.separator"); | ||||
| 	private static final Logger WIRE_LOGGER = LoggerFactory | ||||
| 			.getLogger("org.springframework.data.elasticsearch.client.WIRE"); | ||||
| 	private static final Log WIRE_LOGGER = LogFactory.getLog("org.springframework.data.elasticsearch.client.WIRE"); | ||||
| 
 | ||||
| 	private ClientLogger() {} | ||||
| 
 | ||||
| @ -52,7 +50,7 @@ public abstract class ClientLogger { | ||||
| 	/** | ||||
| 	 * Log an outgoing HTTP request. | ||||
| 	 * | ||||
| 	 * @param logId the correlation Id, see {@link #newLogId()}. | ||||
| 	 * @param logId the correlation id, see {@link #newLogId()}. | ||||
| 	 * @param method HTTP method | ||||
| 	 * @param endpoint URI | ||||
| 	 * @param parameters optional parameters. | ||||
| @ -60,16 +58,15 @@ public abstract class ClientLogger { | ||||
| 	public static void logRequest(String logId, String method, String endpoint, Object parameters) { | ||||
| 
 | ||||
| 		if (isEnabled()) { | ||||
| 
 | ||||
| 			WIRE_LOGGER.trace("[{}] Sending request {} {} with parameters: {}", logId, method.toUpperCase(), endpoint, | ||||
| 					parameters); | ||||
| 			WIRE_LOGGER.trace(String.format("[%s] Sending request %s %s with parameters: %s", logId, method.toUpperCase(), | ||||
| 					endpoint, parameters)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Log an outgoing HTTP request with a request body. | ||||
| 	 * | ||||
| 	 * @param logId the correlation Id, see {@link #newLogId()}. | ||||
| 	 * @param logId the correlation id, see {@link #newLogId()}. | ||||
| 	 * @param method HTTP method | ||||
| 	 * @param endpoint URI | ||||
| 	 * @param parameters optional parameters. | ||||
| @ -79,43 +76,43 @@ public abstract class ClientLogger { | ||||
| 			Supplier<Object> body) { | ||||
| 
 | ||||
| 		if (isEnabled()) { | ||||
| 
 | ||||
| 			WIRE_LOGGER.trace("[{}] Sending request {} {} with parameters: {}{}Request body: {}", logId, method.toUpperCase(), | ||||
| 					endpoint, parameters, lineSeparator, body.get()); | ||||
| 			WIRE_LOGGER.trace(String.format("[%s] Sending request %s %s with parameters: %s%sRequest body: %s", logId, | ||||
| 					method.toUpperCase(), endpoint, parameters, lineSeparator, body.get())); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Log a raw HTTP response without logging the body. | ||||
| 	 * | ||||
| 	 * @param logId the correlation Id, see {@link #newLogId()}. | ||||
| 	 * @param logId the correlation id, see {@link #newLogId()}. | ||||
| 	 * @param statusCode the HTTP status code. | ||||
| 	 */ | ||||
| 	public static void logRawResponse(String logId, @Nullable HttpStatus statusCode) { | ||||
| 
 | ||||
| 		if (isEnabled()) { | ||||
| 			WIRE_LOGGER.trace("[{}] Received raw response: {}", logId, statusCode); | ||||
| 			WIRE_LOGGER.trace(String.format("[%s] Received raw response: %s", logId, statusCode)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Log a raw HTTP response along with the body. | ||||
| 	 * | ||||
| 	 * @param logId the correlation Id, see {@link #newLogId()}. | ||||
| 	 * @param logId the correlation id, see {@link #newLogId()}. | ||||
| 	 * @param statusCode the HTTP status code. | ||||
| 	 * @param body body content. | ||||
| 	 */ | ||||
| 	public static void logResponse(String logId, HttpStatus statusCode, String body) { | ||||
| 
 | ||||
| 		if (isEnabled()) { | ||||
| 			WIRE_LOGGER.trace("[{}] Received response: {}{}Response body: {}", logId, statusCode, lineSeparator, body); | ||||
| 			WIRE_LOGGER.trace( | ||||
| 					String.format("[%s] Received response: %s%sResponse body: %s", logId, statusCode, lineSeparator, body)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * Creates a new, unique correlation Id to improve tracing across log events. | ||||
| 	 * Creates a new, unique correlation id to improve tracing across log events. | ||||
| 	 * | ||||
| 	 * @return a new, unique correlation Id. | ||||
| 	 * @return a new, unique correlation id. | ||||
| 	 */ | ||||
| 	public static String newLogId() { | ||||
| 
 | ||||
|  | ||||
| @ -29,8 +29,8 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.elasticsearch.client.ElasticsearchHost; | ||||
| import org.springframework.data.elasticsearch.client.ElasticsearchHost.State; | ||||
| import org.springframework.data.elasticsearch.client.NoReachableHostException; | ||||
| @ -48,7 +48,7 @@ import org.springframework.web.reactive.function.client.WebClient; | ||||
|  */ | ||||
| class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 
 | ||||
| 	private final static Logger LOG = LoggerFactory.getLogger(MultiNodeHostProvider.class); | ||||
| 	private final static Log LOGGER = LogFactory.getLog(MultiNodeHostProvider.class); | ||||
| 
 | ||||
| 	private final WebClientProvider clientProvider; | ||||
| 	private final Map<InetSocketAddress, ElasticsearchHost> hosts; | ||||
| @ -61,7 +61,9 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 			this.hosts.put(endpoint, new ElasticsearchHost(endpoint, State.UNKNOWN)); | ||||
| 		} | ||||
| 
 | ||||
| 		LOG.debug("initialized with " + hosts); | ||||
| 		if (LOGGER.isDebugEnabled()) { | ||||
| 			LOGGER.debug("initialized with " + hosts); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/* | ||||
| @ -90,19 +92,27 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 	@Override | ||||
| 	public Mono<InetSocketAddress> lookupActiveHost(Verification verification) { | ||||
| 
 | ||||
| 		LOG.trace("lookupActiveHost " + verification + " from " + hosts()); | ||||
| 		if (LOGGER.isTraceEnabled()) { | ||||
| 			LOGGER.trace("lookupActiveHost " + verification + " from " + hosts()); | ||||
| 		} | ||||
| 
 | ||||
| 		if (Verification.LAZY.equals(verification)) { | ||||
| 			for (ElasticsearchHost entry : hosts()) { | ||||
| 				if (entry.isOnline()) { | ||||
| 					LOG.trace("lookupActiveHost returning " + entry); | ||||
| 					if (LOGGER.isTraceEnabled()) { | ||||
| 						LOGGER.trace("lookupActiveHost returning " + entry); | ||||
| 					} | ||||
| 					return Mono.just(entry.getEndpoint()); | ||||
| 				} | ||||
| 			} | ||||
| 			LOG.trace("no online host found with LAZY"); | ||||
| 			if (LOGGER.isTraceEnabled()) { | ||||
| 				LOGGER.trace("no online host found with LAZY"); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		LOG.trace("searching for active host"); | ||||
| 		if (LOGGER.isTraceEnabled()) { | ||||
| 			LOGGER.trace("searching for active host"); | ||||
| 		} | ||||
| 		return findActiveHostInKnownActives() // | ||||
| 				.switchIfEmpty(findActiveHostInUnresolved()) // | ||||
| 				.switchIfEmpty(findActiveHostInDead()) // | ||||
| @ -127,13 +137,17 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 
 | ||||
| 	private Mono<InetSocketAddress> findActiveForState(State state) { | ||||
| 
 | ||||
| 		LOG.trace("findActiveForState state " + state + ", current hosts: " + hosts); | ||||
| 		if (LOGGER.isTraceEnabled()) { | ||||
| 			LOGGER.trace("findActiveForState state " + state + ", current hosts: " + hosts); | ||||
| 		} | ||||
| 
 | ||||
| 		return checkNodes(state) // | ||||
| 				.map(this::updateNodeState) // | ||||
| 				.filter(ElasticsearchHost::isOnline) // | ||||
| 				.map(elasticsearchHost -> { | ||||
| 					LOG.trace("findActiveForState returning host " + elasticsearchHost); | ||||
| 					if (LOGGER.isTraceEnabled()) { | ||||
| 						LOGGER.trace("findActiveForState returning host " + elasticsearchHost); | ||||
| 					} | ||||
| 					return elasticsearchHost; | ||||
| 				}).map(ElasticsearchHost::getEndpoint) // | ||||
| 				.takeLast(1) // | ||||
| @ -150,21 +164,27 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 
 | ||||
| 	private Flux<Tuple2<InetSocketAddress, State>> checkNodes(@Nullable State state) { | ||||
| 
 | ||||
| 		LOG.trace("checkNodes() with state " + state); | ||||
| 		if (LOGGER.isTraceEnabled()) { | ||||
| 			LOGGER.trace("checkNodes() with state " + state); | ||||
| 		} | ||||
| 
 | ||||
| 		return Flux.fromIterable(hosts()) // | ||||
| 				.filter(entry -> state == null || entry.getState().equals(state)) // | ||||
| 				.map(ElasticsearchHost::getEndpoint) // | ||||
| 				.concatMap(host -> { | ||||
| 
 | ||||
| 					LOG.trace("checking host " + host); | ||||
| 					if (LOGGER.isTraceEnabled()) { | ||||
| 						LOGGER.trace("checking host " + host); | ||||
| 					} | ||||
| 
 | ||||
| 					Mono<ClientResponse> clientResponseMono = createWebClient(host) // | ||||
| 							.head().uri("/") // | ||||
| 							.exchangeToMono(Mono::just) // | ||||
| 							.timeout(Duration.ofSeconds(1)) // | ||||
| 							.doOnError(throwable -> { | ||||
| 								LOG.trace("error checking host " + host + ", " + throwable.getMessage()); | ||||
| 								if (LOGGER.isTraceEnabled()) { | ||||
| 									LOGGER.trace("error checking host " + host + ", " + throwable.getMessage()); | ||||
| 								} | ||||
| 								hosts.put(host, new ElasticsearchHost(host, State.OFFLINE)); | ||||
| 								clientProvider.getErrorListener().accept(throwable); | ||||
| 							}); | ||||
| @ -174,7 +194,9 @@ class MultiNodeHostProvider implements HostProvider<MultiNodeHostProvider> { | ||||
| 									.thenReturn(it.statusCode().isError() ? State.OFFLINE : State.ONLINE))); | ||||
| 				}) // | ||||
| 				.map(tuple -> { | ||||
| 					LOG.trace("check result " + tuple); | ||||
| 					if (LOGGER.isTraceEnabled()) { | ||||
| 						LOGGER.trace("check result " + tuple); | ||||
| 					} | ||||
| 					return tuple; | ||||
| 				}).onErrorContinue((throwable, o) -> clientProvider.getErrorListener().accept(throwable)); | ||||
| 	} | ||||
|  | ||||
| @ -22,8 +22,6 @@ import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | ||||
| import java.nio.charset.Charset; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.core.io.ClassPathResource; | ||||
| import org.springframework.core.io.buffer.DataBufferUtils; | ||||
| import org.springframework.core.io.buffer.DefaultDataBufferFactory; | ||||
| @ -38,7 +36,6 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public abstract class ReactiveResourceUtil { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(ReactiveResourceUtil.class); | ||||
| 	private static final int BUFFER_SIZE = 8_192; | ||||
| 
 | ||||
| 	/** | ||||
|  | ||||
| @ -22,8 +22,8 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.document.SearchDocumentResponse; | ||||
| import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter; | ||||
| import org.springframework.data.elasticsearch.core.document.Document; | ||||
| @ -49,7 +49,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class SearchHitMapping<T> { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(SearchHitMapping.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(SearchHitMapping.class); | ||||
| 
 | ||||
| 	private final Class<T> type; | ||||
| 	private final ElasticsearchConverter converter; | ||||
|  | ||||
| @ -18,8 +18,8 @@ package org.springframework.data.elasticsearch.core.convert; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.mapping.PersistentProperty; | ||||
| 
 | ||||
| /** | ||||
| @ -28,7 +28,7 @@ import org.springframework.data.mapping.PersistentProperty; | ||||
|  */ | ||||
| public class DatePropertyValueConverter extends AbstractPropertyValueConverter { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(DatePropertyValueConverter.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(DatePropertyValueConverter.class); | ||||
| 
 | ||||
| 	private final List<ElasticsearchDateConverter> dateConverters; | ||||
| 
 | ||||
| @ -47,7 +47,9 @@ public class DatePropertyValueConverter extends AbstractPropertyValueConverter { | ||||
| 			try { | ||||
| 				return dateConverter.parse(s); | ||||
| 			} catch (Exception e) { | ||||
| 				LOGGER.trace(e.getMessage(), e); | ||||
| 				if (LOGGER.isTraceEnabled()) { | ||||
| 					LOGGER.trace(e.getMessage(), e); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | ||||
| @ -18,8 +18,8 @@ package org.springframework.data.elasticsearch.core.convert; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.mapping.PersistentProperty; | ||||
| 
 | ||||
| /** | ||||
| @ -28,7 +28,7 @@ import org.springframework.data.mapping.PersistentProperty; | ||||
|  */ | ||||
| public class DateRangePropertyValueConverter extends AbstractRangePropertyValueConverter<Date> { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(DateRangePropertyValueConverter.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(DateRangePropertyValueConverter.class); | ||||
| 
 | ||||
| 	private final List<ElasticsearchDateConverter> dateConverters; | ||||
| 
 | ||||
| @ -51,7 +51,9 @@ public class DateRangePropertyValueConverter extends AbstractRangePropertyValueC | ||||
| 			try { | ||||
| 				return converters.parse(value); | ||||
| 			} catch (Exception e) { | ||||
| 				LOGGER.trace(e.getMessage(), e); | ||||
| 				if (LOGGER.isTraceEnabled()) { | ||||
| 					LOGGER.trace(e.getMessage(), e); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | ||||
| @ -21,8 +21,8 @@ import java.util.Map.Entry; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.beans.BeansException; | ||||
| import org.springframework.beans.factory.InitializingBean; | ||||
| import org.springframework.context.ApplicationContext; | ||||
| @ -91,7 +91,7 @@ public class MappingElasticsearchConverter | ||||
| 	private static final String INCOMPATIBLE_TYPES = "Cannot convert %1$s of type %2$s into an instance of %3$s! Implement a custom Converter<%2$s, %3$s> and register it with the CustomConversions."; | ||||
| 	private static final String INVALID_TYPE_TO_READ = "Expected to read Document %s into type %s but didn't find a PersistentEntity for the latter!"; | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(MappingElasticsearchConverter.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(MappingElasticsearchConverter.class); | ||||
| 
 | ||||
| 	private final MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext; | ||||
| 	private final GenericConversionService conversionService; | ||||
| @ -436,10 +436,10 @@ public class MappingElasticsearchConverter | ||||
| 				String key = propertyName + "-read"; | ||||
| 				int count = propertyWarnings.computeIfAbsent(key, k -> 0); | ||||
| 				if (count < 5) { | ||||
| 					LOGGER.warn( | ||||
| 							"Type {} of property {} is a TemporalAccessor class but has neither a @Field annotation defining the date type nor a registered converter for reading!" | ||||
| 					LOGGER.warn(String.format( | ||||
| 							"Type %s of property %s is a TemporalAccessor class but has neither a @Field annotation defining the date type nor a registered converter for reading!" | ||||
| 									+ " It cannot be mapped from a complex object in Elasticsearch!", | ||||
| 							property.getType().getSimpleName(), propertyName); | ||||
| 							property.getType().getSimpleName(), propertyName)); | ||||
| 					propertyWarnings.put(key, count + 1); | ||||
| 				} | ||||
| 			} | ||||
| @ -909,10 +909,10 @@ public class MappingElasticsearchConverter | ||||
| 					String key = propertyName + "-write"; | ||||
| 					int count = propertyWarnings.computeIfAbsent(key, k -> 0); | ||||
| 					if (count < 5) { | ||||
| 						LOGGER.warn( | ||||
| 								"Type {} of property {} is a TemporalAccessor class but has neither a @Field annotation defining the date type nor a registered converter for writing!" | ||||
| 						LOGGER.warn(String.format( | ||||
| 								"Type %s of property %s is a TemporalAccessor class but has neither a @Field annotation defining the date type nor a registered converter for writing!" | ||||
| 										+ " It will be mapped to a complex object in Elasticsearch!", | ||||
| 								property.getType().getSimpleName(), propertyName); | ||||
| 								property.getType().getSimpleName(), propertyName)); | ||||
| 						propertyWarnings.put(key, count + 1); | ||||
| 					} | ||||
| 				} else if (!isSimpleType(value)) { | ||||
|  | ||||
| @ -18,8 +18,8 @@ package org.springframework.data.elasticsearch.core.convert; | ||||
| import java.time.temporal.TemporalAccessor; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.mapping.PersistentProperty; | ||||
| 
 | ||||
| /** | ||||
| @ -28,7 +28,7 @@ import org.springframework.data.mapping.PersistentProperty; | ||||
|  */ | ||||
| public class TemporalPropertyValueConverter extends AbstractPropertyValueConverter { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(TemporalPropertyValueConverter.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(TemporalPropertyValueConverter.class); | ||||
| 
 | ||||
| 	private final List<ElasticsearchDateConverter> dateConverters; | ||||
| 
 | ||||
| @ -50,7 +50,10 @@ public class TemporalPropertyValueConverter extends AbstractPropertyValueConvert | ||||
| 			try { | ||||
| 				return dateConverter.parse(s, (Class<? extends TemporalAccessor>) actualType); | ||||
| 			} catch (Exception e) { | ||||
| 				LOGGER.trace(e.getMessage(), e); | ||||
| 				if (LOGGER.isTraceEnabled()) { | ||||
| 					LOGGER.trace(e.getMessage(), e); | ||||
| 
 | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | ||||
| @ -18,8 +18,8 @@ package org.springframework.data.elasticsearch.core.convert; | ||||
| import java.time.temporal.TemporalAccessor; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.data.mapping.PersistentProperty; | ||||
| import org.springframework.util.Assert; | ||||
| 
 | ||||
| @ -29,7 +29,7 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class TemporalRangePropertyValueConverter extends AbstractRangePropertyValueConverter<TemporalAccessor> { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(TemporalRangePropertyValueConverter.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(TemporalRangePropertyValueConverter.class); | ||||
| 
 | ||||
| 	private final List<ElasticsearchDateConverter> dateConverters; | ||||
| 
 | ||||
| @ -55,7 +55,9 @@ public class TemporalRangePropertyValueConverter extends AbstractRangePropertyVa | ||||
| 			try { | ||||
| 				return converters.parse(value, (Class<? extends TemporalAccessor>) type); | ||||
| 			} catch (Exception e) { | ||||
| 				LOGGER.trace(e.getMessage(), e); | ||||
| 				if (LOGGER.isTraceEnabled()) { | ||||
| 					LOGGER.trace(e.getMessage(), e); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
|  | ||||
| @ -27,8 +27,8 @@ import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.core.io.ClassPathResource; | ||||
| import org.springframework.data.annotation.Transient; | ||||
| import org.springframework.data.elasticsearch.annotations.*; | ||||
| @ -71,7 +71,7 @@ import com.fasterxml.jackson.databind.util.RawValue; | ||||
|  */ | ||||
| public class MappingBuilder { | ||||
| 
 | ||||
| 	private static final Logger logger = LoggerFactory.getLogger(ElasticsearchRestTemplate.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(ElasticsearchRestTemplate.class); | ||||
| 
 | ||||
| 	private static final String FIELD_INDEX = "index"; | ||||
| 	private static final String FIELD_PROPERTIES = "properties"; | ||||
| @ -265,16 +265,16 @@ public class MappingBuilder { | ||||
| 
 | ||||
| 						if (property.isSeqNoPrimaryTermProperty()) { | ||||
| 							if (property.isAnnotationPresent(Field.class)) { | ||||
| 								logger.warn("Property {} of {} is annotated for inclusion in mapping, but its type is " + // | ||||
| 								LOGGER.warn(String.format("Property %s of %s is annotated for inclusion in mapping, but its type is " + // | ||||
| 								"SeqNoPrimaryTerm that is never mapped, so it is skipped", // | ||||
| 										property.getFieldName(), entity.getType()); | ||||
| 										property.getFieldName(), entity.getType())); | ||||
| 							} | ||||
| 							return; | ||||
| 						} | ||||
| 
 | ||||
| 						buildPropertyMapping(propertiesNode, isRootObject, property); | ||||
| 					} catch (IOException e) { | ||||
| 						logger.warn("error mapping property with name {}", property.getName(), e); | ||||
| 						LOGGER.warn(String.format("error mapping property with name %s", property.getName()), e); | ||||
| 					} | ||||
| 				}); | ||||
| 			} | ||||
| @ -491,9 +491,9 @@ public class MappingBuilder { | ||||
| 			JoinTypeRelation[] joinTypeRelations = property.getRequiredAnnotation(JoinTypeRelations.class).relations(); | ||||
| 
 | ||||
| 			if (joinTypeRelations.length == 0) { | ||||
| 				logger.warn("Property {}s type is JoinField but its annotation JoinTypeRelation is " + // | ||||
| 				LOGGER.warn(String.format("Property %s's type is JoinField but its annotation JoinTypeRelation is " + // | ||||
| 						"not properly maintained", // | ||||
| 						property.getFieldName()); | ||||
| 						property.getFieldName())); | ||||
| 				return; | ||||
| 			} | ||||
| 
 | ||||
|  | ||||
| @ -19,8 +19,8 @@ import java.util.Map; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.atomic.AtomicReference; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.core.annotation.AnnotatedElementUtils; | ||||
| import org.springframework.dao.InvalidDataAccessApiUsageException; | ||||
| import org.springframework.data.elasticsearch.annotations.Document; | ||||
| @ -63,7 +63,7 @@ import org.springframework.util.Assert; | ||||
| public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntity<T, ElasticsearchPersistentProperty> | ||||
| 		implements ElasticsearchPersistentEntity<T> { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(SimpleElasticsearchPersistentEntity.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(SimpleElasticsearchPersistentEntity.class); | ||||
| 	private static final SpelExpressionParser PARSER = new SpelExpressionParser(); | ||||
| 
 | ||||
| 	private @Nullable final Document document; | ||||
| @ -235,9 +235,9 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit | ||||
| 	} | ||||
| 
 | ||||
| 	private void warnAboutBothSeqNoPrimaryTermAndVersionProperties() { | ||||
| 		LOGGER.warn( | ||||
| 				"Both SeqNoPrimaryTerm and @Version properties are defined on {}. Version will not be sent in index requests when seq_no is sent!", | ||||
| 				getType()); | ||||
| 		LOGGER.warn(String.format( | ||||
| 				"Both SeqNoPrimaryTerm and @Version properties are defined on %s. Version will not be sent in index requests when seq_no is sent!", | ||||
| 				getType())); | ||||
| 	} | ||||
| 
 | ||||
| 	@Nullable | ||||
|  | ||||
| @ -21,8 +21,8 @@ import java.util.Arrays; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| import org.springframework.data.elasticsearch.annotations.DateFormat; | ||||
| import org.springframework.data.elasticsearch.annotations.Field; | ||||
| @ -69,7 +69,7 @@ import org.springframework.util.StringUtils; | ||||
| public class SimpleElasticsearchPersistentProperty extends | ||||
| 		AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements ElasticsearchPersistentProperty { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(SimpleElasticsearchPersistentProperty.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(SimpleElasticsearchPersistentProperty.class); | ||||
| 
 | ||||
| 	private static final List<String> SUPPORTED_ID_PROPERTY_NAMES = Arrays.asList("id", "document"); | ||||
| 	private static final PropertyNameFieldNamingStrategy DEFAULT_FIELD_NAMING_STRATEGY = PropertyNameFieldNamingStrategy.INSTANCE; | ||||
| @ -161,7 +161,7 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 			case Date_Nanos: { | ||||
| 				List<ElasticsearchDateConverter> dateConverters = getDateConverters(field, actualType); | ||||
| 				if (dateConverters.isEmpty()) { | ||||
| 					LOGGER.warn("No date formatters configured for property '{}'.", getName()); | ||||
| 					LOGGER.warn(String.format("No date formatters configured for property '%s'.", getName())); | ||||
| 					return; | ||||
| 				} | ||||
| 
 | ||||
| @ -170,7 +170,7 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 				} else if (Date.class.isAssignableFrom(actualType)) { | ||||
| 					propertyValueConverter = new DatePropertyValueConverter(this, dateConverters); | ||||
| 				} else { | ||||
| 					LOGGER.warn("Unsupported type '{}' for date property '{}'.", actualType, getName()); | ||||
| 					LOGGER.warn(String.format("Unsupported type '%s' for date property '%s'.", actualType, getName())); | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| @ -181,7 +181,7 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 
 | ||||
| 				List<ElasticsearchDateConverter> dateConverters = getDateConverters(field, actualType); | ||||
| 				if (dateConverters.isEmpty()) { | ||||
| 					LOGGER.warn("No date formatters configured for property '{}'.", getName()); | ||||
| 					LOGGER.warn(String.format("No date formatters configured for property '%s'.", getName())); | ||||
| 					return; | ||||
| 				} | ||||
| 
 | ||||
| @ -191,7 +191,8 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 				} else if (Date.class.isAssignableFrom(genericType)) { | ||||
| 					propertyValueConverter = new DateRangePropertyValueConverter(this, dateConverters); | ||||
| 				} else { | ||||
| 					LOGGER.warn("Unsupported generic type '{}' for date range property '{}'.", genericType, getName()); | ||||
| 					LOGGER.warn( | ||||
| 							String.format("Unsupported generic type '{%s' for date range property '%s'.", genericType, getName())); | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| @ -208,8 +209,8 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 						|| (field.type() == FieldType.Float_Range && !Float.class.isAssignableFrom(genericType)) | ||||
| 						|| (field.type() == FieldType.Long_Range && !Long.class.isAssignableFrom(genericType)) | ||||
| 						|| (field.type() == FieldType.Double_Range && !Double.class.isAssignableFrom(genericType))) { | ||||
| 					LOGGER.warn("Unsupported generic type '{}' for range field type '{}' of property '{}'.", genericType, | ||||
| 							field.type(), getName()); | ||||
| 					LOGGER.warn(String.format("Unsupported generic type '%s' for range field type '%s' of property '%s'.", | ||||
| 							genericType, field.type(), getName())); | ||||
| 					return; | ||||
| 				} | ||||
| 
 | ||||
| @ -251,9 +252,9 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 		List<ElasticsearchDateConverter> converters = new ArrayList<>(); | ||||
| 
 | ||||
| 		if (dateFormats.length == 0 && dateFormatPatterns.length == 0) { | ||||
| 			LOGGER.warn( | ||||
| 					"Property '{}' has @Field type '{}' but has no built-in format or custom date pattern defined. Make sure you have a converter registered for type {}.", | ||||
| 					getName(), field.type().name(), actualType.getSimpleName()); | ||||
| 			LOGGER.warn(String.format( | ||||
| 					"Property '%s' has @Field type '%s' but has no built-in format or custom date pattern defined. Make sure you have a converter registered for type %s.", | ||||
| 					getName(), field.type().name(), actualType.getSimpleName())); | ||||
| 			return converters; | ||||
| 		} | ||||
| 
 | ||||
| @ -266,8 +267,9 @@ public class SimpleElasticsearchPersistentProperty extends | ||||
| 				case weekyear: | ||||
| 				case weekyear_week: | ||||
| 				case weekyear_week_day: | ||||
| 					LOGGER.warn("No default converter available for '{}' and date format '{}'. Use a custom converter instead.", | ||||
| 							actualType.getName(), dateFormat.name()); | ||||
| 					LOGGER.warn(String.format( | ||||
| 							"No default converter available for '%s' and date format '%s'. Use a custom converter instead.", | ||||
| 							actualType.getName(), dateFormat.name())); | ||||
| 					break; | ||||
| 				default: | ||||
| 					converters.add(ElasticsearchDateConverter.of(dateFormat)); | ||||
|  | ||||
| @ -24,13 +24,13 @@ import java.util.List; | ||||
| import java.util.Optional; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageImpl; | ||||
| import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.data.domain.Pageable; | ||||
| import org.springframework.data.domain.Sort; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQuery; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQueryBuilder; | ||||
| import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate; | ||||
| import org.springframework.data.elasticsearch.core.ElasticsearchOperations; | ||||
| import org.springframework.data.elasticsearch.core.IndexOperations; | ||||
| @ -43,8 +43,6 @@ import org.springframework.data.elasticsearch.core.SearchPage; | ||||
| import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity; | ||||
| import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; | ||||
| import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQuery; | ||||
| import org.springframework.data.elasticsearch.backend.elasticsearch7.query.NativeSearchQueryBuilder; | ||||
| import org.springframework.data.elasticsearch.core.query.Query; | ||||
| import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||||
| import org.springframework.data.util.StreamUtils; | ||||
| @ -71,8 +69,6 @@ import org.springframework.util.Assert; | ||||
|  */ | ||||
| public class SimpleElasticsearchRepository<T, ID> implements ElasticsearchRepository<T, ID> { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(SimpleElasticsearchRepository.class); | ||||
| 
 | ||||
| 	protected ElasticsearchOperations operations; | ||||
| 	protected IndexOperations indexOperations; | ||||
| 
 | ||||
|  | ||||
| @ -19,8 +19,8 @@ import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.util.Properties; | ||||
| 
 | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.springframework.lang.Nullable; | ||||
| 
 | ||||
| /** | ||||
| @ -33,7 +33,7 @@ import org.springframework.lang.Nullable; | ||||
|  */ | ||||
| public final class VersionInfo { | ||||
| 
 | ||||
| 	private static final Logger LOG = LoggerFactory.getLogger(VersionInfo.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(VersionInfo.class); | ||||
| 
 | ||||
| 	private static final String VERSION_PROPERTIES = "versions.properties"; | ||||
| 
 | ||||
| @ -50,7 +50,7 @@ public final class VersionInfo { | ||||
| 		try { | ||||
| 			versionProperties = loadVersionProperties(); | ||||
| 		} catch (IOException e) { | ||||
| 			LOG.error("Could not load {}", VERSION_PROPERTIES, e); | ||||
| 			LOGGER.error("Could not load " + VERSION_PROPERTIES, e); | ||||
| 			versionProperties = new Properties(); | ||||
| 			versionProperties.put(VERSION_SPRING_DATA_ELASTICSEARCH, "0.0.0"); | ||||
| 			versionProperties.put(VERSION_ELASTICSEARCH_CLIENT, "0.0.0"); | ||||
| @ -70,25 +70,25 @@ public final class VersionInfo { | ||||
| 			Version versionRuntimeLibrary = Version.fromString(runtimeLibraryVersion); | ||||
| 			Version versionCluster = clusterVersion != null ? Version.fromString(clusterVersion) : null; | ||||
| 
 | ||||
| 			LOG.info("Version Spring Data Elasticsearch: {}", versionSpringDataElasticsearch.toString()); | ||||
| 			LOG.info("Version Elasticsearch client in build: {}", versionBuiltLibraryES.toString()); | ||||
| 			LOG.info("Version runtime client used: {} - {}", vendor, versionRuntimeLibrary.toString()); | ||||
| 			LOGGER.info(String.format("Version Spring Data Elasticsearch: %s", versionSpringDataElasticsearch)); | ||||
| 			LOGGER.info(String.format("Version Elasticsearch client in build: %s", versionBuiltLibraryES)); | ||||
| 			LOGGER.info(String.format("Version runtime client used: %s - %s", vendor, versionRuntimeLibrary)); | ||||
| 
 | ||||
| 			if (differInMajorOrMinor(versionBuiltLibraryES, versionRuntimeLibrary)) { | ||||
| 				LOG.warn("Version mismatch in between Elasticsearch Clients build/use: {} - {}", versionBuiltLibraryES, | ||||
| 						versionRuntimeLibrary); | ||||
| 				LOGGER.warn(String.format("Version mismatch in between Elasticsearch Clients build/use: %s - %s", | ||||
| 						versionBuiltLibraryES, versionRuntimeLibrary)); | ||||
| 			} | ||||
| 
 | ||||
| 			if (versionCluster != null) { | ||||
| 				LOG.info("Version cluster: {} - {}", vendor, versionCluster.toString()); | ||||
| 				LOGGER.info(String.format("Version cluster: %s - %s", vendor, versionCluster)); | ||||
| 
 | ||||
| 				if (differInMajorOrMinor(versionRuntimeLibrary, versionCluster)) { | ||||
| 					LOG.warn("Version mismatch in between  Client and Cluster: {} - {} - {}", vendor, versionRuntimeLibrary, | ||||
| 							versionCluster); | ||||
| 					LOGGER.warn(String.format("Version mismatch in between  Client and Cluster: %s - %s - %s", vendor, | ||||
| 							versionRuntimeLibrary, versionCluster)); | ||||
| 				} | ||||
| 			} | ||||
| 		} catch (Exception e) { | ||||
| 			LOG.warn("Could not log version info: {} - {}", e.getClass().getSimpleName(), e.getMessage()); | ||||
| 			LOGGER.warn(String.format("Could not log version info: %s - %s", e.getClass().getSimpleName(), e.getMessage())); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -4,8 +4,6 @@ import static org.assertj.core.api.Assertions.*; | ||||
| 
 | ||||
| import org.junit.jupiter.api.DisplayName; | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; | ||||
| 
 | ||||
| /** | ||||
| @ -15,8 +13,6 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTes | ||||
| @Foobar | ||||
| public abstract class FoobarIntegrationTest { | ||||
| 
 | ||||
| 	private final Logger LOGGER = LoggerFactory.getLogger(getClass()); | ||||
| 
 | ||||
| 	@Test | ||||
| 	@DisplayName("should run test") | ||||
| 	void shouldRunTest() { | ||||
|  | ||||
| @ -21,9 +21,9 @@ import java.util.LinkedHashMap; | ||||
| import java.util.Map; | ||||
| import java.util.Properties; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.junit.jupiter.api.extension.ExtensionContext; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.lang.Nullable; | ||||
| import org.testcontainers.elasticsearch.ElasticsearchContainer; | ||||
| import org.testcontainers.utility.DockerImageName; | ||||
| @ -38,7 +38,7 @@ import org.testcontainers.utility.DockerImageName; | ||||
|  */ | ||||
| public class ClusterConnection implements ExtensionContext.Store.CloseableResource { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(ClusterConnection.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(ClusterConnection.class); | ||||
| 
 | ||||
| 	private static final String SDE_TESTCONTAINER_IMAGE_NAME = "sde.testcontainers.image-name"; | ||||
| 	private static final String SDE_TESTCONTAINER_IMAGE_VERSION = "sde.testcontainers.image-version"; | ||||
| @ -55,10 +55,14 @@ public class ClusterConnection implements ExtensionContext.Store.CloseableResour | ||||
| 		clusterConnectionInfo = startElasticsearchContainer(); | ||||
| 
 | ||||
| 		if (clusterConnectionInfo != null) { | ||||
| 			LOGGER.debug(clusterConnectionInfo.toString()); | ||||
| 			if (LOGGER.isDebugEnabled()) { | ||||
| 				LOGGER.debug(clusterConnectionInfo.toString()); | ||||
| 			} | ||||
| 			clusterConnectionInfoThreadLocal.set(clusterConnectionInfo); | ||||
| 		} else { | ||||
| 			LOGGER.error("could not create ClusterConnectionInfo"); | ||||
| 			if (LOGGER.isDebugEnabled()) { | ||||
| 				LOGGER.error("could not create ClusterConnectionInfo"); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| @ -82,7 +86,7 @@ public class ClusterConnection implements ExtensionContext.Store.CloseableResour | ||||
| 
 | ||||
| 		try { | ||||
| 			IntegrationtestEnvironment integrationtestEnvironment = IntegrationtestEnvironment.get(); | ||||
| 			LOGGER.info("Integration test environment: {}", integrationtestEnvironment); | ||||
| 			LOGGER.info("Integration test environment: " + integrationtestEnvironment); | ||||
| 			if (integrationtestEnvironment == IntegrationtestEnvironment.UNDEFINED) { | ||||
| 				throw new IllegalArgumentException(IntegrationtestEnvironment.SYSTEM_PROPERTY + " property not set"); | ||||
| 			} | ||||
| @ -128,13 +132,13 @@ public class ClusterConnection implements ExtensionContext.Store.CloseableResour | ||||
| 		String configuredImageName = imageName + ':' + imageVersion; | ||||
| 		DockerImageName dockerImageName = DockerImageName.parse(configuredImageName) | ||||
| 				.asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"); | ||||
| 		LOGGER.info("Docker image: {}", dockerImageName); | ||||
| 		LOGGER.info("Docker image: " + dockerImageName); | ||||
| 		return dockerImageName; | ||||
| 	} | ||||
| 
 | ||||
| 	private Map<String, String> testcontainersProperties(String propertiesFile) { | ||||
| 
 | ||||
| 		LOGGER.info("load configuration from {}", propertiesFile); | ||||
| 		LOGGER.info("load configuration from " + propertiesFile); | ||||
| 
 | ||||
| 		try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propertiesFile)) { | ||||
| 			Properties props = new Properties(); | ||||
| @ -155,10 +159,14 @@ public class ClusterConnection implements ExtensionContext.Store.CloseableResour | ||||
| 	public void close() { | ||||
| 
 | ||||
| 		if (clusterConnectionInfo != null && clusterConnectionInfo.getElasticsearchContainer() != null) { | ||||
| 			LOGGER.debug("Stopping container"); | ||||
| 			if (LOGGER.isDebugEnabled()) { | ||||
| 				LOGGER.debug("Stopping container"); | ||||
| 			} | ||||
| 			clusterConnectionInfo.getElasticsearchContainer().stop(); | ||||
| 		} | ||||
| 
 | ||||
| 		LOGGER.debug("closed"); | ||||
| 		if (LOGGER.isDebugEnabled()) { | ||||
| 			LOGGER.debug("closed"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -19,13 +19,13 @@ import java.util.List; | ||||
| import java.util.concurrent.locks.Lock; | ||||
| import java.util.concurrent.locks.ReentrantLock; | ||||
| 
 | ||||
| import org.apache.commons.logging.Log; | ||||
| import org.apache.commons.logging.LogFactory; | ||||
| import org.junit.jupiter.api.extension.BeforeAllCallback; | ||||
| import org.junit.jupiter.api.extension.ExtensionContext; | ||||
| import org.junit.jupiter.api.extension.ParameterContext; | ||||
| import org.junit.jupiter.api.extension.ParameterResolutionException; | ||||
| import org.junit.jupiter.api.extension.ParameterResolver; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
| import org.springframework.context.ConfigurableApplicationContext; | ||||
| import org.springframework.test.context.ContextConfigurationAttributes; | ||||
| import org.springframework.test.context.ContextCustomizer; | ||||
| @ -46,7 +46,7 @@ import org.springframework.test.context.MergedContextConfiguration; | ||||
| public class SpringDataElasticsearchExtension | ||||
| 		implements BeforeAllCallback, ParameterResolver, ContextCustomizerFactory { | ||||
| 
 | ||||
| 	private static final Logger LOGGER = LoggerFactory.getLogger(SpringDataElasticsearchExtension.class); | ||||
| 	private static final Log LOGGER = LogFactory.getLog(SpringDataElasticsearchExtension.class); | ||||
| 
 | ||||
| 	private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace | ||||
| 			.create(SpringDataElasticsearchExtension.class.getName()); | ||||
| @ -61,7 +61,9 @@ public class SpringDataElasticsearchExtension | ||||
| 		try { | ||||
| 			ExtensionContext.Store store = getStore(extensionContext); | ||||
| 			ClusterConnection clusterConnection = store.getOrComputeIfAbsent(STORE_KEY_CLUSTER_CONNECTION, key -> { | ||||
| 				LOGGER.debug("creating ClusterConnection"); | ||||
| 				if (LOGGER.isDebugEnabled()) { | ||||
| 					LOGGER.debug("creating ClusterConnection"); | ||||
| 				} | ||||
| 				return createClusterConnection(); | ||||
| 			}, ClusterConnection.class); | ||||
| 			store.getOrComputeIfAbsent(STORE_KEY_CLUSTER_CONNECTION_INFO, | ||||
|  | ||||
| @ -1,4 +1,20 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!-- | ||||
|   ~ Copyright 2021 the original author or authors. | ||||
|   ~ | ||||
|   ~ Licensed 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 | ||||
|   ~ | ||||
|   ~      https://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. | ||||
|   --> | ||||
| 
 | ||||
| <configuration> | ||||
| 
 | ||||
| 	<appender name="console" class="ch.qos.logback.core.ConsoleAppender"> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user