/** * Logs a deprecated message to the deprecation log, as well as to the local {@link ThreadContext}. * * @param threadContexts The node's {@link ThreadContext} (outside of concurrent tests, this should only ever have one context). * @param message The deprecation message. * @param params The parameters used to fill in the message, if any exist. */ void deprecated(final Set<ThreadContext> threadContexts, final String message, final Object... params) { deprecated(threadContexts, message, true, params); }
/** * Logs a deprecation message, adding a formatted warning message as a response header on the thread context. */ public void deprecated(String msg, Object... params) { deprecated(THREAD_CONTEXT, msg, params); }
@Override public void usedDeprecatedField(String usedName, String replacedWith) { DEPRECATION_LOGGER.deprecated("Deprecated field [{}] used, replaced by [{}]", usedName, replacedWith); }
@Override public void usedDeprecatedName(String usedName, String modernName) { DEPRECATION_LOGGER.deprecated("Deprecated field [{}] used, expected [{}] instead", usedName, modernName); }
@Override public void deprecated(final String message, final Object... params) { DEPRECATION_LOGGER.deprecated(message, params); }
/** * Adds a formatted warning message as a response header on the thread context, and logs a deprecation message if the associated key has * not recently been seen. * * @param key the key used to determine if this deprecation should be logged * @param msg the message to log * @param params parameters to the message */ public void deprecatedAndMaybeLog(final String key, final String msg, final Object... params) { deprecated(THREAD_CONTEXT, msg, keys.add(key), params); }
private Float checkWeight(Float weight) { if (weight != null && Float.compare(weight, 0) < 0) { DEPRECATION_LOGGER.deprecated("Setting a negative [weight] in Function Score Query is deprecated " + "and will throw an error in the next major version"); } return weight; }
@Override public Object get(final Object key) { String deprecationMessage = deprecations.get(key); if (deprecationMessage != null) { DEPRECATION_LOGGER.deprecated(deprecationMessage); } return params.get(key); }
public static ExecutionMode fromString(String value, final DeprecationLogger deprecationLogger) { if ("global_ordinals".equals(value)) { return GLOBAL_ORDINALS; } else if ("global_ordinals_hash".equals(value)) { deprecationLogger.deprecated("global_ordinals_hash is deprecated. Please use [global_ordinals] instead."); return GLOBAL_ORDINALS; } else if ("map".equals(value)) { return MAP; } throw new IllegalArgumentException("Unknown `execution_hint`: [" + value + "], expected any of [map, global_ordinals]"); }
/** * Sets the value to use when the source finds a missing value in a * document. * * @deprecated Use {@link #missingBucket(boolean)} instead. */ @SuppressWarnings("unchecked") @Deprecated public AB missing(Object missing) { if (missing == null) { throw new IllegalArgumentException("[missing] must not be null"); } DEPRECATION_LOGGER.deprecated("[missing] is deprecated. Please use [missing_bucket] instead."); this.missing = missing; return (AB) this; }
/** * Explicitly specify the fields that will be returned. By default, nothing is returned. * @deprecated Use {@link UpdateRequestBuilder#setFetchSource(String[], String[])} instead */ @Deprecated public UpdateRequestBuilder setFields(String... fields) { DEPRECATION_LOGGER.deprecated("Deprecated field [fields] used, expected [_source] instead"); request.fields(fields); return this; }
/** * {@inheritDoc} * <p> * Usage is logged via the {@link DeprecationLogger} so that the actual response can be notified of deprecation as well. */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { deprecationLogger.deprecated(deprecationMessage); handler.handleRequest(request, channel, client); }
static void assertSettingsIsSubsetOf(String type, Version version, Settings settings, String... supportedSettings) { Set<String> unknownSettings = new HashSet<>(settings.keySet()); unknownSettings.removeAll(Arrays.asList(supportedSettings)); unknownSettings.remove("type"); // used to figure out which sim this is if (unknownSettings.isEmpty() == false) { DEPRECATION_LOGGER.deprecated("Unknown settings for similarity of type [" + type + "]: " + unknownSettings); } }
private static void checkPrefixTreeSupport(String fieldName) { if (ShapesAvailability.JTS_AVAILABLE == false || ShapesAvailability.SPATIAL4J_AVAILABLE == false) { throw new ElasticsearchParseException("Field parameter [{}] is not supported for [{}] field type", fieldName, CONTENT_TYPE); } DEPRECATION_LOGGER.deprecated("Field parameter [{}] is deprecated and will be removed in a future version.", fieldName); } }
private List<String> getHostsList() { if (Files.exists(unicastHostsFilePath)) { return readFileContents(unicastHostsFilePath); } if (Files.exists(legacyUnicastHostsFilePath)) { deprecationLogger.deprecated("Found dynamic hosts list at [{}] but this path is deprecated. This list should be at [{}] " + "instead. Support for the deprecated path will be removed in future.", legacyUnicastHostsFilePath, unicastHostsFilePath); return readFileContents(legacyUnicastHostsFilePath); } logger.warn("expected, but did not find, a dynamic hosts list at [{}]", unicastHostsFilePath); return Collections.emptyList(); }
public static boolean nodeBooleanValueLenient(String fieldName, String propertyName, Object node) { if (Booleans.isBoolean(node.toString()) == false) { DEPRECATION_LOGGER.deprecated("Expected a boolean for property [{}] for field [{}] but got [{}]", propertyName, fieldName, node); } if (node instanceof Boolean) { return (Boolean) node; } if (node instanceof Number) { return ((Number) node).intValue() != 0; } @SuppressWarnings("deprecated") boolean value = Booleans.parseBooleanLenient(node.toString(), false); return value; }
@Override public Query termQuery(Object value, QueryShardContext context) { if (isEnabled() == false) { throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled"); } DEPRECATION_LOGGER.deprecated( "terms query on the _field_names field is deprecated and will be removed, use exists query instead"); return super.termQuery(value, context); } }
public ByteSizeValue(long size, ByteSizeUnit unit) { if (size < -1 || (size == -1 && unit != ByteSizeUnit.BYTES)) { DEPRECATION_LOGGER.deprecated( "Values less than -1 bytes are deprecated and will not be supported in the next major version: [{}]", size + unit.getSuffix()); } if (size > Long.MAX_VALUE / unit.toBytes(1)) { throw new IllegalArgumentException( "Values greater than " + Long.MAX_VALUE + " bytes are not supported: " + size + unit.getSuffix()); } this.size = size; this.unit = unit; }
@Override public IndexFieldData<?> build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { DEPRECATION_LOGGER.deprecated("Fielddata access on the _uid field is deprecated, use _id instead"); MappedFieldType idFieldType = mapperService.fullName(IdFieldMapper.NAME); IndexFieldData<?> idFieldData = idFieldType.fielddataBuilder(fullyQualifiedIndexName) .build(indexSettings, idFieldType, cache, breakerService, mapperService); final String type = mapperService.types().iterator().next(); return new UidIndexFieldData(indexSettings.getIndex(), type, idFieldData); } };
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index"))); putMappingRequest.type(request.param("type")); putMappingRequest.source(request.requiredContent(), request.getXContentType()); if (request.hasParam("update_all_types")) { DEPRECATION_LOGGER.deprecated("[update_all_types] is deprecated since indices may not have more than one type anymore"); } putMappingRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false)); putMappingRequest.timeout(request.paramAsTime("timeout", putMappingRequest.timeout())); putMappingRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putMappingRequest.masterNodeTimeout())); putMappingRequest.indicesOptions(IndicesOptions.fromRequest(request, putMappingRequest.indicesOptions())); return channel -> client.admin().indices().putMapping(putMappingRequest, new RestToXContentListener<>(channel)); } }