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


Java ESLoggerFactory类代码示例

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


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

示例1: maybeDie

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
/**
 * If the specified cause is an unrecoverable error, this method will rethrow the cause on a separate thread so that it can not be
 * caught and bubbles up to the uncaught exception handler.
 *
 * @param cause the throwable to test
 */
public static void maybeDie(final Throwable cause) {
    if (cause instanceof Error) {
        /*
         * Here be dragons. We want to rethrow this so that it bubbles up to the uncaught exception handler. Yet, Netty wraps too many
         * invocations of user-code in try/catch blocks that swallow all throwables. This means that a rethrow here will not bubble up
         * to where we want it to. So, we fork a thread and throw the exception from there where Netty can not get to it. We do not wrap
         * the exception so as to not lose the original cause during exit.
         */
        try {
            // try to log the current stack trace
            final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
            final String formatted = Arrays.stream(stackTrace).skip(1).map(e -> "\tat " + e).collect(Collectors.joining("\n"));
            ESLoggerFactory.getLogger(Netty4Utils.class).error("fatal error on the network layer\n{}", formatted);
        } finally {
            new Thread(
                    () -> {
                        throw (Error) cause;
                    })
                    .start();
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:Netty4Utils.java

示例2: testRelationSupport

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
protected static boolean testRelationSupport(SpatialOperation relation) {
    if (relation == SpatialOperation.IsDisjointTo) {
        // disjoint works in terms of intersection
        relation = SpatialOperation.Intersects;
    }
    try {
        GeohashPrefixTree tree = new GeohashPrefixTree(SpatialContext.GEO, 3);
        RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(tree, "area");
        Shape shape = SpatialContext.GEO.makePoint(0, 0);
        SpatialArgs args = new SpatialArgs(relation, shape);
        strategy.makeQuery(args);
        return true;
    } catch (UnsupportedSpatialOperation e) {
        final SpatialOperation finalRelation = relation;
        ESLoggerFactory
            .getLogger(GeoFilterIT.class.getName())
            .info((Supplier<?>) () -> new ParameterizedMessage("Unsupported spatial operation {}", finalRelation), e);
        return false;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:GeoFilterIT.java

示例3: testInvalidLenientBooleanForCurrentIndexVersion

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的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

示例4: testLoggingUpdates

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
public void testLoggingUpdates() {
    final Level level = ESLoggerFactory.getRootLogger().getLevel();
    final Level testLevel = ESLoggerFactory.getLogger("test").getLevel();
    Level property = randomFrom(Level.values());
    Settings.Builder builder = Settings.builder().put("logger.level", property);
    try {
        ClusterSettings settings = new ClusterSettings(builder.build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
        IllegalArgumentException ex =
            expectThrows(
                IllegalArgumentException.class,
                () -> settings.validate(Settings.builder().put("logger._root", "boom").build()));
        assertEquals("Unknown level constant [BOOM].", ex.getMessage());
        assertEquals(level, ESLoggerFactory.getRootLogger().getLevel());
        settings.applySettings(Settings.builder().put("logger._root", "TRACE").build());
        assertEquals(Level.TRACE, ESLoggerFactory.getRootLogger().getLevel());
        settings.applySettings(Settings.builder().build());
        assertEquals(property, ESLoggerFactory.getRootLogger().getLevel());
        settings.applySettings(Settings.builder().put("logger.test", "TRACE").build());
        assertEquals(Level.TRACE, ESLoggerFactory.getLogger("test").getLevel());
        settings.applySettings(Settings.builder().build());
        assertEquals(property, ESLoggerFactory.getLogger("test").getLevel());
    } finally {
        Loggers.setLevel(ESLoggerFactory.getRootLogger(), level);
        Loggers.setLevel(ESLoggerFactory.getLogger("test"), testLevel);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:ScopedSettingsTests.java

示例5: getScore

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
/**
 * Calculates score with a script
 *
 * @param subsetFreq   The frequency of the term in the selected sample
 * @param subsetSize   The size of the selected sample (typically number of docs)
 * @param supersetFreq The frequency of the term in the superset from which the sample was taken
 * @param supersetSize The size of the superset from which the sample was taken  (typically number of docs)
 * @return a "significance" score
 */
@Override
public double getScore(long subsetFreq, long subsetSize, long supersetFreq, long supersetSize) {
    if (searchScript == null) {
        //In tests, wehn calling assertSearchResponse(..) the response is streamed one additional time with an arbitrary version, see assertVersionSerializable(..).
        // Now, for version before 1.5.0 the score is computed after streaming the response but for scripts the script does not exists yet.
        // assertSearchResponse() might therefore fail although there is no problem.
        // This should be replaced by an exception in 2.0.
        ESLoggerFactory.getLogger("script heuristic").warn("cannot compute score - script has not been initialized yet.");
        return 0;
    }
    subsetSizeHolder.value = subsetSize;
    supersetSizeHolder.value = supersetSize;
    subsetDfHolder.value = subsetFreq;
    supersetDfHolder.value = supersetFreq;
    return ((Number) searchScript.run()).doubleValue();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:26,代码来源:ScriptHeuristic.java

示例6: EventHookService

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
@Inject
public EventHookService(final Settings settings,
        final DynamicSettings dynamicSettings,
        final ClusterService clusterService, final Client client,
        final ScriptService scriptService, final ThreadPool threadPool) {
    super(settings);
    this.clusterService = clusterService;
    this.client = client;
    this.scriptService = scriptService;
    this.threadPool = threadPool;

    logger.info("Creating EventHookService");

    index = settings.get(CLUSTER_EVENTHOOK_INDEX, DEFAULT_EVENTHOOK_INDEX);
    eventSize = settings.getAsInt(CLUSTER_EVENTHOOK_SIZE,
            DEFAULT_EVENTHOOK_SIZE);

    final String loggerName = settings.get(CLUSTER_EVENTHOOK_LOGGER,
            DEFAULT_EVENTHOOK_LOGGER);
    scriptLogger = ESLoggerFactory.getLogger(loggerName);
}
 
开发者ID:codelibs,项目名称:elasticsearch-eventhook,代码行数:22,代码来源:EventHookService.java

示例7: resolveLogger

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
/**
 * Obtain the logger with the given name.
 *
 * @param loggerName the logger to obtain
 * @return the logger
 */
private static Logger resolveLogger(String loggerName) {
    if (loggerName.equalsIgnoreCase("_root")) {
        return ESLoggerFactory.getRootLogger();
    }
    return Loggers.getLogger(loggerName);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:LoggingListener.java

示例8: testCustomLevelPerMethod

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
public void testCustomLevelPerMethod() throws Exception {
    LoggingListener loggingListener = new LoggingListener();

    Description suiteDescription = Description.createSuiteDescription(TestClass.class);

    Logger xyzLogger = Loggers.getLogger("xyz");
    Logger abcLogger = Loggers.getLogger("abc");

    final Level level = ESLoggerFactory.getRootLogger().getLevel();

    assertThat(xyzLogger.getLevel(), equalTo(level));
    assertThat(abcLogger.getLevel(), equalTo(level));
    loggingListener.testRunStarted(suiteDescription);
    assertThat(xyzLogger.getLevel(), equalTo(level));
    assertThat(abcLogger.getLevel(), equalTo(level));

    Method method = TestClass.class.getMethod("annotatedTestMethod");
    TestLogging annotation = method.getAnnotation(TestLogging.class);
    Description testDescription = Description.createTestDescription(LoggingListenerTests.class, "annotatedTestMethod", annotation);
    loggingListener.testStarted(testDescription);
    assertThat(xyzLogger.getLevel(), equalTo(Level.TRACE));
    assertThat(abcLogger.getLevel(), equalTo(level));

    loggingListener.testFinished(testDescription);
    assertThat(xyzLogger.getLevel(), equalTo(level));
    assertThat(abcLogger.getLevel(), equalTo(level));

    loggingListener.testRunFinished(new Result());
    assertThat(xyzLogger.getLevel(), equalTo(level));
    assertThat(abcLogger.getLevel(), equalTo(level));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:LoggingListenerTests.java

示例9: BM25SimilarityProvider

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的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

示例10: DFISimilarityProvider

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的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

示例11: getValue

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
@Override
public Settings getValue(Settings current, Settings previous) {
    Settings.Builder builder = Settings.builder();
    builder.put(current.filter(loggerPredicate).getAsMap());
    for (String key : previous.getAsMap().keySet()) {
        if (loggerPredicate.test(key) && builder.internalMap().containsKey(key) == false) {
            if (ESLoggerFactory.LOG_LEVEL_SETTING.getConcreteSetting(key).exists(settings) == false) {
                builder.putNull(key);
            } else {
                builder.put(key, ESLoggerFactory.LOG_LEVEL_SETTING.getConcreteSetting(key).get(settings));
            }
        }
    }
    return builder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ClusterSettings.java

示例12: createCodecService

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
private CodecService createCodecService() throws IOException {
    Settings nodeSettings = Settings.builder()
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
            .build();
    IndexSettings settings = IndexSettingsModule.newIndexSettings("_na", nodeSettings);
    SimilarityService similarityService = new SimilarityService(settings, Collections.emptyMap());
    IndexAnalyzers indexAnalyzers = createTestAnalysis(settings, nodeSettings).indexAnalyzers;
    MapperRegistry mapperRegistry = new MapperRegistry(Collections.emptyMap(), Collections.emptyMap());
    MapperService service = new MapperService(settings, indexAnalyzers, xContentRegistry(), similarityService, mapperRegistry,
            () -> null);
    return new CodecService(service, ESLoggerFactory.getLogger("test"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:CodecTests.java

示例13: testLenientBooleanForPreEs6Index

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的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

示例14: testValidLenientBooleanForCurrentIndexVersion

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
@SuppressWarnings("deprecation") //#getAsBooleanLenientForPreEs6Indices is the test subject
public void testValidLenientBooleanForCurrentIndexVersion() {
    Settings settings = Settings.builder()
        .put("foo", "false")
        .put("bar", "true").build();

    final DeprecationLogger deprecationLogger =
        new DeprecationLogger(ESLoggerFactory.getLogger("testValidLenientBooleanForCurrentIndexVersion"));
    assertFalse(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "foo", null, deprecationLogger));
    assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "bar", null, deprecationLogger));
    assertTrue(settings.getAsBooleanLenientForPreEs6Indices(Version.CURRENT, "baz", true, deprecationLogger));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:SettingsTests.java

示例15: testFallbackToLoggerLevel

import org.elasticsearch.common.logging.ESLoggerFactory; //导入依赖的package包/类
public void testFallbackToLoggerLevel() {
    final Level level = ESLoggerFactory.getRootLogger().getLevel();
    try {
        ClusterSettings settings =
            new ClusterSettings(Settings.builder().put("logger.level", "ERROR").build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
        assertEquals(level, ESLoggerFactory.getRootLogger().getLevel());
        settings.applySettings(Settings.builder().put("logger._root", "TRACE").build());
        assertEquals(Level.TRACE, ESLoggerFactory.getRootLogger().getLevel());
        settings.applySettings(Settings.builder().build()); // here we fall back to 'logger.level' which is our default.
        assertEquals(Level.ERROR, ESLoggerFactory.getRootLogger().getLevel());
    } finally {
        Loggers.setLevel(ESLoggerFactory.getRootLogger(), level);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:ScopedSettingsTests.java


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