org.elasticsearch.common.logging.Loggers Java Examples
The following examples show how to use
org.elasticsearch.common.logging.Loggers.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecoveryTarget.java From crate with Apache License 2.0 | 6 votes |
/** * Creates a new recovery target object that represents a recovery to the provided shard. * * @param indexShard local shard where we want to recover to * @param sourceNode source node of the recovery where we recover from * @param listener called when recovery is completed/failed * @param ensureClusterStateVersionCallback callback to ensure that the current node is at least on a cluster state with the provided * version; necessary for primary relocation so that new primary knows about all other ongoing * replica recoveries when replicating documents (see {@link RecoverySourceHandler}) */ public RecoveryTarget(final IndexShard indexShard, final DiscoveryNode sourceNode, final PeerRecoveryTargetService.RecoveryListener listener, final LongConsumer ensureClusterStateVersionCallback) { super("recovery_status"); this.cancellableThreads = new CancellableThreads(); this.recoveryId = ID_GENERATOR.incrementAndGet(); this.listener = listener; this.logger = Loggers.getLogger(getClass(), indexShard.shardId()); this.indexShard = indexShard; this.sourceNode = sourceNode; this.shardId = indexShard.shardId(); this.tempFilePrefix = RECOVERY_PREFIX + UUIDs.randomBase64UUID() + "."; this.store = indexShard.store(); this.ensureClusterStateVersionCallback = ensureClusterStateVersionCallback; // make sure the store is not released until we are done. store.incRef(); indexShard.recoveryStats().incCurrentAsTarget(); }
Example #2
Source File: RecoverySourceHandler.java From crate with Apache License 2.0 | 6 votes |
public RecoverySourceHandler(final IndexShard shard, RecoveryTargetHandler recoveryTarget, final StartRecoveryRequest request, final int fileChunkSizeInBytes, final int maxConcurrentFileChunks) { this.shard = shard; this.recoveryTarget = recoveryTarget; this.request = request; this.shardId = this.request.shardId().id(); this.logger = Loggers.getLogger(getClass(), request.shardId(), "recover to " + request.targetNode().getName()); this.chunkSizeInBytes = fileChunkSizeInBytes; // if the target is on an old version, it won't be able to handle out-of-order file chunks. this.maxConcurrentFileChunks = request.targetNode().getVersion().onOrAfter(Version.V_4_0_0) ? maxConcurrentFileChunks : 1; }
Example #3
Source File: ScriptModule.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override protected void configure() { MapBinder<String, NativeScriptFactory> scriptsBinder = MapBinder.newMapBinder(binder(), String.class, NativeScriptFactory.class); for (Map.Entry<String, Class<? extends NativeScriptFactory>> entry : scripts.entrySet()) { scriptsBinder.addBinding(entry.getKey()).to(entry.getValue()).asEagerSingleton(); } Multibinder<ScriptEngineService> multibinder = Multibinder.newSetBinder(binder(), ScriptEngineService.class); multibinder.addBinding().to(NativeScriptEngineService.class); try { Class.forName("com.github.mustachejava.Mustache"); multibinder.addBinding().to(MustacheScriptEngineService.class).asEagerSingleton(); } catch (Throwable t) { Loggers.getLogger(ScriptService.class, settings).debug("failed to load mustache", t); } for (Class<? extends ScriptEngineService> scriptEngine : scriptEngines) { multibinder.addBinding().to(scriptEngine).asEagerSingleton(); } bind(ScriptContextRegistry.class).toInstance(new ScriptContextRegistry(customScriptContexts)); bind(ScriptService.class).asEagerSingleton(); }
Example #4
Source File: ScriptParameterParser.java From Elasticsearch with Apache License 2.0 | 6 votes |
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)); } } }
Example #5
Source File: SearchSlowLog.java From Elasticsearch with Apache License 2.0 | 6 votes |
SearchSlowLog(Settings indexSettings) { this.reformat = indexSettings.getAsBoolean(INDEX_SEARCH_SLOWLOG_REFORMAT, true); this.queryWarnThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_WARN, TimeValue.timeValueNanos(-1)).nanos(); this.queryInfoThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_INFO, TimeValue.timeValueNanos(-1)).nanos(); this.queryDebugThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_DEBUG, TimeValue.timeValueNanos(-1)).nanos(); this.queryTraceThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_TRACE, TimeValue.timeValueNanos(-1)).nanos(); this.fetchWarnThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_WARN, TimeValue.timeValueNanos(-1)).nanos(); this.fetchInfoThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_INFO, TimeValue.timeValueNanos(-1)).nanos(); this.fetchDebugThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG, TimeValue.timeValueNanos(-1)).nanos(); this.fetchTraceThreshold = indexSettings.getAsTime(INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE, TimeValue.timeValueNanos(-1)).nanos(); this.level = indexSettings.get(INDEX_SEARCH_SLOWLOG_LEVEL, "TRACE").toUpperCase(Locale.ROOT); this.queryLogger = Loggers.getLogger(INDEX_SEARCH_SLOWLOG_PREFIX + ".query"); this.fetchLogger = Loggers.getLogger(INDEX_SEARCH_SLOWLOG_PREFIX + ".fetch"); queryLogger.setLevel(level); fetchLogger.setLevel(level); }
Example #6
Source File: ContextPreparer.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Inject public ContextPreparer(Settings settings, MapSideDataCollectOperation collectOperation, ClusterService clusterService, CrateCircuitBreakerService breakerService, CountOperation countOperation, ThreadPool threadPool, PageDownstreamFactory pageDownstreamFactory, RowDownstreamFactory rowDownstreamFactory) { super(settings); nlContextLogger = Loggers.getLogger(NestedLoopContext.class, settings); pageDownstreamContextLogger = Loggers.getLogger(PageDownstreamContext.class, settings); this.collectOperation = collectOperation; this.clusterService = clusterService; this.countOperation = countOperation; this.threadPool = threadPool; circuitBreaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY); this.pageDownstreamFactory = pageDownstreamFactory; this.rowDownstreamFactory = rowDownstreamFactory; innerPreparer = new InnerPreparer(); }
Example #7
Source File: MockFSIndexStore.java From crate with Apache License 2.0 | 5 votes |
@Override public void afterIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, Settings indexSettings) { if (indexShard != null) { Boolean remove = shardSet.remove(indexShard); if (remove == Boolean.TRUE) { Logger logger = Loggers.getLogger(getClass(), indexShard.shardId()); MockFSDirectoryService.checkIndex(logger, indexShard.store(), indexShard.shardId()); } } }
Example #8
Source File: SettingsFilterTests.java From crate with Apache License 2.0 | 5 votes |
private void assertExpectedLogMessages(Consumer<Logger> consumer, MockLogAppender.LoggingExpectation ... expectations) throws IllegalAccessException { Logger testLogger = LogManager.getLogger("org.elasticsearch.test"); MockLogAppender appender = new MockLogAppender(); Loggers.addAppender(testLogger, appender); try { appender.start(); Arrays.stream(expectations).forEach(appender::addExpectation); consumer.accept(testLogger); appender.assertAllExpectationsMatched(); } finally { Loggers.removeAppender(testLogger, appender); } }
Example #9
Source File: SystemPropsTestLoggingListener.java From crate with Apache License 2.0 | 5 votes |
private Map<String, String> reset(Map<String, String> map) { if (map != null) { for (Map.Entry<String, String> previousLogger : map.entrySet()) { Logger logger = resolveLogger(previousLogger.getKey()); Loggers.setLevel(logger, previousLogger.getValue()); } } return null; }
Example #10
Source File: SystemPropsTestLoggingListener.java From crate with Apache License 2.0 | 5 votes |
private Map<String, String> processTestLogging() { Map<String, String> map = getLoggersAndLevelsFromSystemProperty(); if (map == null) { return null; } Map<String, String> previousValues = new HashMap<>(); for (Map.Entry<String, String> entry : map.entrySet()) { Logger logger = resolveLogger(entry.getKey()); previousValues.put(entry.getKey(), logger.getLevel().toString()); Loggers.setLevel(logger, entry.getValue()); } return previousValues; }
Example #11
Source File: Bootstrap.java From Elasticsearch with Apache License 2.0 | 5 votes |
private static void checkUnsetAndMaybeExit(String confFileSetting, String settingName) { if (confFileSetting != null && confFileSetting.isEmpty() == false) { ESLogger logger = Loggers.getLogger(Bootstrap.class); logger.info("{} is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed.", settingName); exit(1); } }
Example #12
Source File: LoggingListener.java From crate with Apache License 2.0 | 5 votes |
/** * Reset the logging levels to the state provided by the map. * * @param map the logging levels to apply * @return an empty map */ private Map<String, String> reset(final Map<String, String> map) { for (final Map.Entry<String, String> previousLogger : map.entrySet()) { final Logger logger = resolveLogger(previousLogger.getKey()); Loggers.setLevel(logger, previousLogger.getValue()); } return Collections.emptyMap(); }
Example #13
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testFallbackToLoggerLevel() { final Level level = LogManager.getRootLogger().getLevel(); try { ClusterSettings settings = new ClusterSettings(Settings.builder().put("logger.level", "ERROR").build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); assertEquals(level, LogManager.getRootLogger().getLevel()); settings.applySettings(Settings.builder().put("logger._root", "TRACE").build()); assertEquals(Level.TRACE, LogManager.getRootLogger().getLevel()); settings.applySettings(Settings.builder().build()); // here we fall back to 'logger.level' which is our default. assertEquals(Level.ERROR, LogManager.getRootLogger().getLevel()); } finally { Loggers.setLevel(LogManager.getRootLogger(), level); } }
Example #14
Source File: ScopedSettingsTests.java From crate with Apache License 2.0 | 5 votes |
@Test public void testLoggingUpdates() { final Level level = LogManager.getRootLogger().getLevel(); final Level testLevel = LogManager.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(), false)); assertEquals("Unknown level constant [BOOM].", ex.getMessage()); assertEquals(level, LogManager.getRootLogger().getLevel()); settings.applySettings(Settings.builder().put("logger._root", "TRACE").build()); assertEquals(Level.TRACE, LogManager.getRootLogger().getLevel()); settings.applySettings(Settings.builder().build()); assertEquals(property, LogManager.getRootLogger().getLevel()); settings.applySettings(Settings.builder().put("logger.test", "TRACE").build()); assertEquals(Level.TRACE, LogManager.getLogger("test").getLevel()); settings.applySettings(Settings.builder().build()); assertEquals(property, LogManager.getLogger("test").getLevel()); } finally { Loggers.setLevel(LogManager.getRootLogger(), level); Loggers.setLevel(LogManager.getLogger("test"), testLevel); } }
Example #15
Source File: ElasticsearchConcurrentMergeScheduler.java From crate with Apache License 2.0 | 5 votes |
ElasticsearchConcurrentMergeScheduler(ShardId shardId, IndexSettings indexSettings) { this.config = indexSettings.getMergeSchedulerConfig(); this.shardId = shardId; this.indexSettings = indexSettings.getSettings(); this.logger = Loggers.getLogger(getClass(), shardId); refreshConfig(); }
Example #16
Source File: TransportService.java From crate with Apache License 2.0 | 5 votes |
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor, Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings, ConnectionManager connectionManager) { this.transport = transport; this.threadPool = threadPool; this.localNodeFactory = localNodeFactory; this.connectionManager = connectionManager; this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings)); setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings)); tracerLog = Loggers.getLogger(LOGGER, ".tracer"); taskManager = createTaskManager(settings, threadPool); this.interceptor = transportInterceptor; this.asyncSender = interceptor.interceptSender(this::sendRequestInternal); responseHandlers = transport.getResponseHandlers(); if (clusterSettings != null) { clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude); clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude); } registerRequestHandler( HANDSHAKE_ACTION_NAME, HandshakeRequest::new, ThreadPool.Names.SAME, false, false, (request, channel, task) -> channel.sendResponse( new HandshakeResponse(localNode, clusterName, localNode.getVersion()))); }
Example #17
Source File: ClusterSettings.java From crate with Apache License 2.0 | 5 votes |
@Override public Settings getValue(Settings current, Settings previous) { Settings.Builder builder = Settings.builder(); builder.put(current.filter(loggerPredicate)); for (String key : previous.keySet()) { if (loggerPredicate.test(key) && builder.keys().contains(key) == false) { if (Loggers.LOG_LEVEL_SETTING.getConcreteSetting(key).exists(settings) == false) { builder.putNull(key); } else { builder.put(key, Loggers.LOG_LEVEL_SETTING.getConcreteSetting(key).get(settings).toString()); } } } return builder.build(); }
Example #18
Source File: DefaultRequestHandler.java From elasticsearch-taste with Apache License 2.0 | 5 votes |
public DefaultRequestHandler(final Settings settings, final Client client, final ThreadPool pool) { this.settings = settings; this.client = client; this.pool = pool; maxRetryCount = settings.getAsInt("taste.rest.retry", 20); logger = Loggers.getLogger(getClass(), settings); indexCreationLock = new ReentrantLock(); }
Example #19
Source File: ActionHandler.java From elasticsearch-taste with Apache License 2.0 | 5 votes |
public ActionHandler(final Settings settings, final Map<String, Object> sourceMap, final Client client, final ThreadPool pool) { this.client = client; this.settings = settings; rootSettings = sourceMap; this.pool = pool; logger = Loggers.getLogger(getClass(), settings); }
Example #20
Source File: CompositeIndexEventListener.java From crate with Apache License 2.0 | 5 votes |
CompositeIndexEventListener(IndexSettings indexSettings, Collection<IndexEventListener> listeners) { for (IndexEventListener listener : listeners) { if (listener == null) { throw new IllegalArgumentException("listeners must be non-null"); } } this.listeners = Collections.unmodifiableList(new ArrayList<>(listeners)); this.logger = Loggers.getLogger(getClass(), indexSettings.getIndex()); }
Example #21
Source File: JVMCheck.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Checks that the current JVM is "ok". This means it doesn't have severe bugs that cause data corruption. */ static void check() { if (Boolean.parseBoolean(System.getProperty(JVM_BYPASS))) { Loggers.getLogger(JVMCheck.class).warn("bypassing jvm version check for version [{}], this can result in data corruption!", fullVersion()); } else if ("Oracle Corporation".equals(Constants.JVM_VENDOR)) { HotspotBug bug = JVM_BROKEN_HOTSPOT_VERSIONS.get(Constants.JVM_VERSION); if (bug != null) { if (bug.workAround != null && ManagementFactory.getRuntimeMXBean().getInputArguments().contains(bug.workAround)) { Loggers.getLogger(JVMCheck.class).warn(bug.getWarningMessage()); } else { throw new RuntimeException(bug.getErrorMessage()); } } } else if ("IBM Corporation".equals(Constants.JVM_VENDOR)) { // currently some old JVM versions from IBM will easily result in index corruption. // 2.8+ seems ok for ES from testing. float version = Float.POSITIVE_INFINITY; try { version = Float.parseFloat(Constants.JVM_VERSION); } catch (NumberFormatException ignored) { // this is just a simple best-effort to detect old runtimes, // if we cannot parse it, we don't fail. } if (version < 2.8f) { StringBuilder sb = new StringBuilder(); sb.append("IBM J9 runtimes < 2.8 suffer from several bugs which can cause data corruption."); sb.append(System.lineSeparator()); sb.append("Your version: " + fullVersion()); sb.append(System.lineSeparator()); sb.append("Please upgrade the JVM to a recent IBM JDK"); throw new RuntimeException(sb.toString()); } } }
Example #22
Source File: JarHell.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Checks the current classpath for duplicate classes * @throws IllegalStateException if jar hell was found */ public static void checkJarHell() throws Exception { ClassLoader loader = JarHell.class.getClassLoader(); ESLogger logger = Loggers.getLogger(JarHell.class); if (logger.isDebugEnabled()) { logger.debug("java.class.path: {}", System.getProperty("java.class.path")); logger.debug("sun.boot.class.path: {}", System.getProperty("sun.boot.class.path")); if (loader instanceof URLClassLoader ) { logger.debug("classloader urls: {}", Arrays.toString(((URLClassLoader)loader).getURLs())); } } checkJarHell(parseClassPath()); }
Example #23
Source File: Retry.java From Elasticsearch with Apache License 2.0 | 5 votes |
public AbstractRetryHandler(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client, ActionListener<BulkResponse> listener) { this.retryOnThrowable = retryOnThrowable; this.backoff = backoffPolicy.iterator(); this.client = client; this.listener = listener; this.logger = Loggers.getLogger(getClass(), client.settings()); // in contrast to System.currentTimeMillis(), nanoTime() uses a monotonic clock under the hood this.startTimestampNanos = System.nanoTime(); }
Example #24
Source File: Node.java From Elasticsearch with Apache License 2.0 | 5 votes |
private Node stop() { if (!lifecycle.moveToStopped()) { return this; } ESLogger logger = Loggers.getLogger(Node.class, settings.get("name")); logger.info("stopping ..."); injector.getInstance(TribeService.class).stop(); injector.getInstance(ResourceWatcherService.class).stop(); if (settings.getAsBoolean("http.enabled", true)) { injector.getInstance(HttpServer.class).stop(); } injector.getInstance(SnapshotsService.class).stop(); injector.getInstance(SnapshotShardsService.class).stop(); // stop any changes happening as a result of cluster state changes injector.getInstance(IndicesClusterStateService.class).stop(); // we close indices first, so operations won't be allowed on it injector.getInstance(IndexingMemoryController.class).stop(); injector.getInstance(IndicesTTLService.class).stop(); injector.getInstance(RoutingService.class).stop(); injector.getInstance(ClusterService.class).stop(); injector.getInstance(DiscoveryService.class).stop(); injector.getInstance(MonitorService.class).stop(); injector.getInstance(GatewayService.class).stop(); injector.getInstance(SearchService.class).stop(); injector.getInstance(RestController.class).stop(); injector.getInstance(TransportService.class).stop(); for (Class<? extends LifecycleComponent> plugin : pluginsService.nodeServices()) { injector.getInstance(plugin).stop(); } // we should stop this last since it waits for resources to get released // if we had scroll searchers etc or recovery going on we wait for to finish. injector.getInstance(IndicesService.class).stop(); logger.info("stopped"); return this; }
Example #25
Source File: ConsoleAppender.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void write(final int b) throws IOException { if (!Loggers.consoleLoggingEnabled()) { return; } System.out.write(b); }
Example #26
Source File: ConsoleAppender.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (!Loggers.consoleLoggingEnabled()) { return; } System.out.write(b, off, len); }
Example #27
Source File: AuthService.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Inject public AuthService(final ClusterService clusterService, final Settings settings, final RestController restController, final IndexNameExpressionResolver indexNameExpressionResolver) { super(settings); this.clusterService = clusterService; this.restController = restController; this.indexNameExpressionResolver = indexNameExpressionResolver; this.logger = Loggers.getLogger(getClass(), settings); this.whitelistRefreshInterval = settings.getAsInt("auth.whitelist.refresh.interval_sec", DEFAULT_WHITELIST_REFRESH_INTERVAL_SEC); }
Example #28
Source File: ConsoleAppender.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void write(final int b) throws IOException { if (!Loggers.consoleLoggingEnabled()) { return; } System.err.write(b); }
Example #29
Source File: ConsoleAppender.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (!Loggers.consoleLoggingEnabled()) { return; } System.err.write(b, off, len); }
Example #30
Source File: ConsoleAppender.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void write(final byte[] b) throws IOException { if (!Loggers.consoleLoggingEnabled()) { return; } System.err.write(b); }