<commit_before>package org.m2mp.es;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gson.JsonObject;
import io.searchbox.Action;
import io.searchbox.Parameters;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.JestResult;
import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.ClientConstants;
import io.searchbox.core.Delete;
import io.searchbox.core.Index;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 *
 * @author <NAME>
 */
public class ESClientWrapper {

	private static final JestClientFactory clientFactory = new JestClientFactory();
	private static final ClientConfig clientConfig = new ClientConfig();
	private static final Logger log = LogManager.getLogger(ESClientWrapper.class);
	private static final ExecutorService executor = Executors.newFixedThreadPool(2);

	static {
		clientConfig.getProperties().put(ClientConstants.SERVER_LIST, new LinkedHashSet<>(Arrays.asList("http://localhost:9200")));
		clientFactory.setClientConfig(clientConfig);
	}
	private static final LoadingCache<Long, ESClientWrapper> clients = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).maximumSize(20).build(new CacheLoader<Long, ESClientWrapper>() {
		@Override
		public ESClientWrapper load(Long k) throws Exception {
			return new ESClientWrapper();
		}
	});

	static ESClientWrapper get() {
		ESClientWrapper client;
		try {
			client = clients.get(Thread.currentThread().getId());
		} catch (ExecutionException ex) {
			log.catching(ex);
			return null;
		}
		return client;
	}
<commit_msg>ESClientWrapper: Adding thread name to the ESClient threads.<commit_after>package org.m2mp.es;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gson.JsonObject;
import io.searchbox.Action;
import io.searchbox.Parameters;
import io.searchbox.client.JestClient;
import io.searchbox.client.JestClientFactory;
import io.searchbox.client.JestResult;
import io.searchbox.client.config.ClientConfig;
import io.searchbox.client.config.ClientConstants;
import io.searchbox.core.Delete;
import io.searchbox.core.Index;
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class ESClientWrapper {

	private static final JestClientFactory clientFactory = new JestClientFactory();
	private static final ClientConfig clientConfig = new ClientConfig();
	private static final Logger log = LogManager.getLogger(ESClientWrapper.class);
	private static final ExecutorService executor = Executors.newFixedThreadPool(2, new ThreadFactory() {
		@Override
		public Thread newThread(Runnable r) {
			Thread t = new Thread(r, "ESClientWrapper_Thread");
			t.setPriority(Thread.MIN_PRIORITY);
			return t;
		}
	});

	static {
		clientConfig.getProperties().put(ClientConstants.SERVER_LIST, new LinkedHashSet<>(Arrays.asList("http://localhost:9200")));
		clientFactory.setClientConfig(clientConfig);
	}
	private static final LoadingCache<Long, ESClientWrapper> clients = CacheBuilder.newBuilder().expireAfterWrite(5, TimeUnit.MINUTES).maximumSize(20).build(new CacheLoader<Long, ESClientWrapper>() {
		@Override
		public ESClientWrapper load(Long k) throws Exception {
			return new ESClientWrapper();
		}
	});

	static ESClientWrapper get() {
		ESClientWrapper client;
		try {
			client = clients.get(Thread.currentThread().getId());
		} catch (ExecutionException ex) {
			log.catching(ex);
			return null;
		}
		return client;
	}

{'fraction_non_alphanumeric': 0.10631777463460632, 'fraction_numerical': 0.005186232909005186, 'mean_word_length': 6.013223140495867, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2557987', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1243, 'n_words': 258}