當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。