<commit_before>package org.zalando.nakadi.config;

import com.google.common.base.Charsets;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.zalando.nakadi.domain.storage.DefaultStorage;
import org.zalando.nakadi.domain.storage.KafkaConfiguration;
import org.zalando.nakadi.domain.storage.Storage;
import org.zalando.nakadi.domain.storage.ZookeeperConnection;
import org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException;
import org.zalando.nakadi.exceptions.runtime.InternalNakadiException;
import org.zalando.nakadi.repository.db.StorageDbRepository;
import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder;
import org.zalando.nakadi.service.StorageService;

import java.util.concurrent.Executors;
import java.util.Optional;

@Configuration
@EnableScheduling
public class NakadiConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(NakadiConfig.class);

    @Bean
    public AsyncTaskExecutor asyncTaskExecutor() {
        return new ConcurrentTaskExecutor(Executors.newCachedThreadPool());
    }

    @Bean
    @Qualifier("default_storage")
    public DefaultStorage defaultStorage(final StorageDbRepository storageDbRepository,
                                         final Environment environment,
                                         final ZooKeeperHolder zooKeeperHolder)<commit_msg>Clean NDC and MDC in the async task executor (#1355)<commit_after>package org.zalando.nakadi.config;

import com.google.common.base.Charsets;
import org.apache.curator.framework.CuratorFramework;
import org.apache.log4j.NDC;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.TaskDecorator;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor;
import org.zalando.nakadi.domain.storage.DefaultStorage;
import org.zalando.nakadi.domain.storage.KafkaConfiguration;
import org.zalando.nakadi.domain.storage.Storage;
import org.zalando.nakadi.domain.storage.ZookeeperConnection;
import org.zalando.nakadi.exceptions.runtime.DuplicatedStorageException;
import org.zalando.nakadi.exceptions.runtime.InternalNakadiException;
import org.zalando.nakadi.repository.db.StorageDbRepository;
import org.zalando.nakadi.repository.zookeeper.ZooKeeperHolder;
import org.zalando.nakadi.service.StorageService;

import java.util.concurrent.Executors;
import java.util.Optional;

@Configuration
@EnableScheduling
public class NakadiConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(NakadiConfig.class);

    @Bean
    public AsyncTaskExecutor asyncTaskExecutor() {
        final ConcurrentTaskExecutor taskExecutor = new ConcurrentTaskExecutor(Executors.newCachedThreadPool());
        taskExecutor.setTaskDecorator(new TaskDecorator() {
                @Override
                public Runnable decorate(final Runnable runnable) {
                    return new Runnable() {
                        @Override
                        public void run() {
                            NDC.clear();
                            MDC.clear();

                            runnable.run();
                        }
                    };
                }
            });
        return taskExecutor;
    }

    @Bean
    @Qualifier("default_storage")
    public DefaultStorage defaultStorage(final StorageDbRepository storageDbRepository,
                                         final Environment environment,
                                         final ZooKeeperHolder zooKeeperHolder)
{'fraction_non_alphanumeric': 0.08066696710229833, 'fraction_numerical': 0.002253267237494367, 'mean_word_length': 3.707317073170732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7248175', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1157, 'n_words': 194}