当前位置: 首页>>代码示例>>Java>>正文


Java DeprecationLogger类代码示例

本文整理汇总了Java中org.elasticsearch.common.logging.DeprecationLogger的典型用法代码示例。如果您正苦于以下问题:Java DeprecationLogger类的具体用法?Java DeprecationLogger怎么用?Java DeprecationLogger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeprecationLogger类属于org.elasticsearch.common.logging包,在下文中一共展示了DeprecationLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCredentials

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public static AWSCredentialsProvider buildCredentials(Logger logger, DeprecationLogger deprecationLogger,
                                                      Settings settings, Settings repositorySettings, String clientName) {
    try (SecureString key = getConfigValue(repositorySettings, settings, clientName, S3Repository.ACCESS_KEY_SETTING,
                                           S3Repository.Repository.KEY_SETTING, S3Repository.Repositories.KEY_SETTING);
         SecureString secret = getConfigValue(repositorySettings, settings, clientName, S3Repository.SECRET_KEY_SETTING,
                                              S3Repository.Repository.SECRET_SETTING, S3Repository.Repositories.SECRET_SETTING)) {

        if (key.length() == 0 && secret.length() == 0) {
            logger.debug("Using instance profile credentials");
            return new PrivilegedInstanceProfileCredentialsProvider();
        } else {
            logger.debug("Using basic key/secret credentials");
            return new StaticCredentialsProvider(new BasicAWSCredentials(key.toString(), secret.toString()));
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:InternalAwsS3Service.java

示例2: assertWarnings

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
protected final void assertWarnings(String... expectedWarnings) {
    if (enableWarningsCheck() == false) {
        throw new IllegalStateException("unable to check warning headers if the test is not set to do so");
    }
    try {
        final List<String> actualWarnings = threadContext.getResponseHeaders().get("Warning");
        final Set<String> actualWarningValues =
                actualWarnings.stream().map(DeprecationLogger::extractWarningValueFromWarningHeader).collect(Collectors.toSet());
        for (String msg : expectedWarnings) {
            assertTrue(actualWarningValues.contains(DeprecationLogger.escape(msg)));
        }
        assertEquals("Expected " + expectedWarnings.length + " warnings but found " + actualWarnings.size() + "\nExpected: "
                + Arrays.asList(expectedWarnings) + "\nActual: " + actualWarnings,
            expectedWarnings.length, actualWarnings.size());
    } finally {
        resetDeprecationLogger(true);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:ESTestCase.java

示例3: resetDeprecationLogger

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
/**
 * Reset the deprecation logger by removing the current thread context, and setting a new thread context if {@code setNewThreadContext}
 * is set to {@code true} and otherwise clearing the current thread context.
 *
 * @param setNewThreadContext whether or not to attach a new thread context to the deprecation logger
 */
private void resetDeprecationLogger(final boolean setNewThreadContext) {
    // "clear" current warning headers by setting a new ThreadContext
    DeprecationLogger.removeThreadContext(this.threadContext);
    try {
        this.threadContext.close();
        // catch IOException to avoid that call sites have to deal with it. It is only declared because this class implements Closeable
        // but it is impossible that this implementation will ever throw an IOException.
    } catch (IOException ex) {
        throw new AssertionError("IOException thrown while closing deprecation logger's thread context", ex);
    }
    if (setNewThreadContext) {
        this.threadContext = new ThreadContext(Settings.EMPTY);
        DeprecationLogger.setThreadContext(this.threadContext);
    } else {
        this.threadContext = null;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:ESTestCase.java

示例4: processNormalizerFactory

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
private void processNormalizerFactory(DeprecationLogger deprecationLogger,
        IndexSettings indexSettings,
        String name,
        AnalyzerProvider<?> normalizerFactory,
        Map<String, NamedAnalyzer> normalizers,
        Map<String, TokenFilterFactory> tokenFilters,
        Map<String, CharFilterFactory> charFilters) {
    if (normalizerFactory instanceof CustomNormalizerProvider) {
        ((CustomNormalizerProvider) normalizerFactory).build(charFilters, tokenFilters);
    }
    Analyzer normalizerF = normalizerFactory.get();
    if (normalizerF == null) {
        throw new IllegalArgumentException("normalizer [" + normalizerFactory.name() + "] created null normalizer");
    }
    NamedAnalyzer normalizer = new NamedAnalyzer(name, normalizerFactory.scope(), normalizerF);
    if (normalizers.containsKey(name)) {
        throw new IllegalStateException("already registered analyzer with name: " + name);
    }
    normalizers.put(name, normalizer);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:AnalysisRegistry.java

示例5: getAsBooleanLenientForPreEs6Indices

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
/**
 * Returns the setting value (as boolean) associated with the setting key. If it does not exist, returns the default value provided.
 * If the index was created on Elasticsearch below 6.0, booleans will be parsed leniently otherwise they are parsed strictly.
 *
 * See {@link Booleans#isBooleanLenient(char[], int, int)} for the definition of a "lenient boolean"
 * and {@link Booleans#isBoolean(char[], int, int)} for the definition of a "strict boolean".
 *
 * @deprecated Only used to provide automatic upgrades for pre 6.0 indices.
 */
@Deprecated
public Boolean getAsBooleanLenientForPreEs6Indices(
    final Version indexVersion,
    final String setting,
    final Boolean defaultValue,
    final DeprecationLogger deprecationLogger) {
    if (indexVersion.before(Version.V_6_0_0_alpha1_UNRELEASED)) {
        //Only emit a warning if the setting's value is not a proper boolean
        final String value = get(setting, "false");
        if (Booleans.isBoolean(value) == false) {
            @SuppressWarnings("deprecation")
            boolean convertedValue = Booleans.parseBooleanLenient(get(setting), defaultValue);
            deprecationLogger.deprecated("The value [{}] of setting [{}] is not coerced into boolean anymore. Please change " +
                "this value to [{}].", value, setting, String.valueOf(convertedValue));
            return convertedValue;
        }
    }
    return getAsBoolean(setting, defaultValue);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:Settings.java

示例6: testRegisterAsDeprecatedHandler

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public void testRegisterAsDeprecatedHandler() {
    RestController controller = mock(RestController.class);

    RestRequest.Method method = randomFrom(RestRequest.Method.values());
    String path = "/_" + randomAsciiOfLengthBetween(1, 6);
    RestHandler handler = mock(RestHandler.class);
    String deprecationMessage = randomAsciiOfLengthBetween(1, 10);
    DeprecationLogger logger = mock(DeprecationLogger.class);

    // don't want to test everything -- just that it actually wraps the handler
    doCallRealMethod().when(controller).registerAsDeprecatedHandler(method, path, handler, deprecationMessage, logger);

    controller.registerAsDeprecatedHandler(method, path, handler, deprecationMessage, logger);

    verify(controller).registerHandler(eq(method), eq(path), any(DeprecationRestHandler.class));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestControllerTests.java

示例7: testRegisterWithDeprecatedHandler

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public void testRegisterWithDeprecatedHandler() {
    final RestController controller = mock(RestController.class);

    final RestRequest.Method method = randomFrom(RestRequest.Method.values());
    final String path = "/_" + randomAsciiOfLengthBetween(1, 6);
    final RestHandler handler = mock(RestHandler.class);
    final RestRequest.Method deprecatedMethod = randomFrom(RestRequest.Method.values());
    final String deprecatedPath = "/_" + randomAsciiOfLengthBetween(1, 6);
    final DeprecationLogger logger = mock(DeprecationLogger.class);

    final String deprecationMessage = "[" + deprecatedMethod.name() + " " + deprecatedPath + "] is deprecated! Use [" +
        method.name() + " " + path + "] instead.";

    // don't want to test everything -- just that it actually wraps the handlers
    doCallRealMethod().when(controller).registerWithDeprecatedHandler(method, path, handler, deprecatedMethod, deprecatedPath, logger);

    controller.registerWithDeprecatedHandler(method, path, handler, deprecatedMethod, deprecatedPath, logger);

    verify(controller).registerHandler(method, path, handler);
    verify(controller).registerAsDeprecatedHandler(deprecatedMethod, deprecatedPath, handler, deprecationMessage, logger);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestControllerTests.java

示例8: testInvalidLenientBooleanForCurrentIndexVersion

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
@SuppressWarnings("deprecation") //#getAsBooleanLenientForPreEs6Indices is the test subject
public void testInvalidLenientBooleanForCurrentIndexVersion() {
    String falsy = randomFrom("off", "no", "0");
    String truthy = randomFrom("on", "yes", "1");

    Settings settings = Settings.builder()
        .put("foo", falsy)
        .put("bar", truthy).build();

    final DeprecationLogger deprecationLogger =
        new DeprecationLogger(ESLoggerFactory.getLogger("testInvalidLenientBooleanForCurrentIndexVersion"));
    expectThrows(IllegalArgumentException.class,
        () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null, deprecationLogger));
    expectThrows(IllegalArgumentException.class,
        () -> settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null, deprecationLogger));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SettingsTests.java

示例9: ScriptParameterParser

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public ScriptParameterParser(Set<String> parameterNames) {
    ESLogger logger = Loggers.getLogger(getClass());
    deprecationLogger = new DeprecationLogger(logger);
    if (parameterNames == null || parameterNames.isEmpty()) {
        inlineParameters = Collections.singleton(ScriptService.SCRIPT_INLINE);
        fileParameters = Collections.singleton(ScriptService.SCRIPT_FILE);
        indexedParameters = Collections.singleton(ScriptService.SCRIPT_ID);
    } else {
        inlineParameters = new HashSet<>();
        fileParameters = new HashSet<>();
        indexedParameters = new HashSet<>();
        for (String parameterName : parameterNames) {
            if (ParseFieldMatcher.EMPTY.match(parameterName, ScriptService.SCRIPT_LANG)) {
                throw new IllegalArgumentException("lang is reserved and cannot be used as a parameter name");
            }
            inlineParameters.add(new ParseField(parameterName));
            fileParameters.add(new ParseField(parameterName + FILE_SUFFIX));
            indexedParameters.add(new ParseField(parameterName + INDEXED_SUFFIX));
        }
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:ScriptParameterParser.java

示例10: before

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
@Before
public final void before()  {
    logger.info("[{}]: before test", getTestName());
    assertNull("Thread context initialized twice", threadContext);
    if (enableWarningsCheck()) {
        this.threadContext = new ThreadContext(Settings.EMPTY);
        DeprecationLogger.setThreadContext(threadContext);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ESTestCase.java

示例11: BM25SimilarityProvider

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public BM25SimilarityProvider(String name, Settings settings, Settings indexSettings) {
    super(name);
    float k1 = settings.getAsFloat("k1", 1.2f);
    float b = settings.getAsFloat("b", 0.75f);
    final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger(getClass()));
    boolean discountOverlaps =
        settings.getAsBooleanLenientForPreEs6Indices(Version.indexCreated(indexSettings), "discount_overlaps", true, deprecationLogger);

    this.similarity = new BM25Similarity(k1, b);
    this.similarity.setDiscountOverlaps(discountOverlaps);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:BM25SimilarityProvider.java

示例12: DFISimilarityProvider

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
public DFISimilarityProvider(String name, Settings settings, Settings indexSettings) {
    super(name);
    boolean discountOverlaps = settings.getAsBooleanLenientForPreEs6Indices(
        Version.indexCreated(indexSettings), "discount_overlaps", true, new DeprecationLogger(ESLoggerFactory.getLogger(getClass())));
    Independence measure = parseIndependence(settings);
    this.similarity = new DFISimilarity(measure);
    this.similarity.setDiscountOverlaps(discountOverlaps);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:DFISimilarityProvider.java

示例13: MergePolicyConfig

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
MergePolicyConfig(Logger logger, IndexSettings indexSettings) {
    this.logger = logger;
    double forceMergeDeletesPctAllowed = indexSettings.getValue(INDEX_MERGE_POLICY_EXPUNGE_DELETES_ALLOWED_SETTING); // percentage
    ByteSizeValue floorSegment = indexSettings.getValue(INDEX_MERGE_POLICY_FLOOR_SEGMENT_SETTING);
    int maxMergeAtOnce = indexSettings.getValue(INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_SETTING);
    int maxMergeAtOnceExplicit = indexSettings.getValue(INDEX_MERGE_POLICY_MAX_MERGE_AT_ONCE_EXPLICIT_SETTING);
    // TODO is this really a good default number for max_merge_segment, what happens for large indices, won't they end up with many segments?
    ByteSizeValue maxMergedSegment = indexSettings.getValue(INDEX_MERGE_POLICY_MAX_MERGED_SEGMENT_SETTING);
    double segmentsPerTier = indexSettings.getValue(INDEX_MERGE_POLICY_SEGMENTS_PER_TIER_SETTING);
    double reclaimDeletesWeight = indexSettings.getValue(INDEX_MERGE_POLICY_RECLAIM_DELETES_WEIGHT_SETTING);
    this.mergesEnabled = indexSettings.getSettings()
        .getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), INDEX_MERGE_ENABLED, true, new DeprecationLogger(logger));
    if (mergesEnabled == false) {
        logger.warn("[{}] is set to false, this should only be used in tests and can cause serious problems in production environments", INDEX_MERGE_ENABLED);
    }
    maxMergeAtOnce = adjustMaxMergeAtOnceIfNeeded(maxMergeAtOnce, segmentsPerTier);
    mergePolicy.setNoCFSRatio(indexSettings.getValue(INDEX_COMPOUND_FORMAT_SETTING));
    mergePolicy.setForceMergeDeletesPctAllowed(forceMergeDeletesPctAllowed);
    mergePolicy.setFloorSegmentMB(floorSegment.getMbFrac());
    mergePolicy.setMaxMergeAtOnce(maxMergeAtOnce);
    mergePolicy.setMaxMergeAtOnceExplicit(maxMergeAtOnceExplicit);
    mergePolicy.setMaxMergedSegmentMB(maxMergedSegment.getMbFrac());
    mergePolicy.setSegmentsPerTier(segmentsPerTier);
    mergePolicy.setReclaimDeletesWeight(reclaimDeletesWeight);
    if (logger.isTraceEnabled()) {
        logger.trace("using [tiered] merge mergePolicy with expunge_deletes_allowed[{}], floor_segment[{}], max_merge_at_once[{}], max_merge_at_once_explicit[{}], max_merged_segment[{}], segments_per_tier[{}], reclaim_deletes_weight[{}]",
            forceMergeDeletesPctAllowed, floorSegment, maxMergeAtOnce, maxMergeAtOnceExplicit, maxMergedSegment, segmentsPerTier, reclaimDeletesWeight);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:30,代码来源:MergePolicyConfig.java

示例14: checkDeprecation

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
/** Logs a deprecation warning if the setting is deprecated and used. */
protected void checkDeprecation(Settings settings) {
    // They're using the setting, so we need to tell them to stop
    if (this.isDeprecated() && this.exists(settings)) {
        // It would be convenient to show its replacement key, but replacement is often not so simple
        final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(getClass()));
        deprecationLogger.deprecated("[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " +
            "See the breaking changes documentation for the next major version.", getKey());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Setting.java

示例15: testLenientBooleanForPreEs6Index

import org.elasticsearch.common.logging.DeprecationLogger; //导入依赖的package包/类
@SuppressWarnings("deprecation") //#getAsBooleanLenientForPreEs6Indices is the test subject
public void testLenientBooleanForPreEs6Index() throws IOException {
    // time to say goodbye?
    assertTrue(
        "It's time to implement #22298. Please delete this test and Settings#getAsBooleanLenientForPreEs6Indices().",
        Version.CURRENT.minimumCompatibilityVersion().before(Version.V_6_0_0_alpha1_UNRELEASED));


    String falsy = randomFrom("false", "off", "no", "0");
    String truthy = randomFrom("true", "on", "yes", "1");

    Settings settings = Settings.builder()
        .put("foo", falsy)
        .put("bar", truthy).build();

    final DeprecationLogger deprecationLogger = new DeprecationLogger(ESLoggerFactory.getLogger("testLenientBooleanForPreEs6Index"));

    assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "foo", null, deprecationLogger));
    assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "bar", null, deprecationLogger));
    assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.V_5_0_0, "baz", true, deprecationLogger));

    List<String> expectedDeprecationWarnings = new ArrayList<>();
    if (Booleans.isBoolean(falsy) == false) {
        expectedDeprecationWarnings.add(
            "The value [" + falsy + "] of setting [foo] is not coerced into boolean anymore. Please change this value to [false].");
    }
    if (Booleans.isBoolean(truthy) == false) {
        expectedDeprecationWarnings.add(
            "The value [" + truthy + "] of setting [bar] is not coerced into boolean anymore. Please change this value to [true].");
    }

    if (expectedDeprecationWarnings.isEmpty() == false) {
        assertWarnings(expectedDeprecationWarnings.toArray(new String[1]));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:SettingsTests.java


注:本文中的org.elasticsearch.common.logging.DeprecationLogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。