<commit_before>package work.hoodie.exchange.monitor.data.config;

import com.mongodb.MongoClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import work.hoodie.exchange.monitor.data.validator.MongoConnectionValidator;

import javax.annotation.PostConstruct;

@Slf4j
@Configuration("Database")
@ComponentScan("work.hoodie.exchange.monitor.data")
@EnableMongoRepositories("work.hoodie.exchange.monitor.data.repository")
public class DataConfig {

    public static final String EXCHANGE_MONITOR_DB = "exchangeMonitorDb";

    @Value("${mongo.database.host:mongo}")
    private String mongoHost;

    @Value("${mongo.database.port:27017}")
    private Integer mongoPort;

    public MongoTemplate mongoTemplate;

    @PostConstruct
    public void init() {
        boolean connected = MongoConnectionValidator.isConnected(mongoTemplate);
        if (connected) {
            log.info("---------- Mongo Configuration -----------");
            log.info("Mongo Host: " + mongoHost);
            log.info("Mongo Port: " + mongoPort);
            log.info("Mongo Connected: " + connected);
            log.info("------------------------------------------");
        } else {
            log.info("No Database Connected...");
        }
    }

    @Bean
    public MongoDbFactory mongoDbFactory() throws Exception {
        log.info("Mongo Client Info - Host: {} Port: {}", mongoHost, mongoPort);
        return new SimpleMongoDbFactory(new MongoClient(mongoHost, mongoPort), EXCHANGE_MONITOR_DB);
    }

    @Bean
    public MongoTemplate mongoTemplate() throws Exception {
        MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory());
        this.mongoTemplate = mongoTemplate;
        log.info("Mongo Template: {}", mongoTemplate);
        return mongoTemplate;
    }

}<commit_msg>updated mongo problems<commit_after>package work.hoodie.exchange.monitor.data.config;

import com.mongodb.MongoClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import work.hoodie.exchange.monitor.data.validator.MongoConnectionValidator;

import javax.annotation.PostConstruct;
import java.net.UnknownHostException;

@Slf4j
@Configuration("Database")
@ComponentScan("work.hoodie.exchange.monitor.data")
@EnableMongoRepositories("work.hoodie.exchange.monitor.data.repository")
public class DataConfig {

    public static final String EXCHANGE_MONITOR_DB = "exchangeMonitorDb";

    @Value("${mongo.database.host:mongo}")
    private String mongoHost;

    @Value("${mongo.database.port:27017}")
    private Integer mongoPort;

    public MongoTemplate mongoTemplate;
    private MongoClient mongoClient;
    private SimpleMongoDbFactory simpleMongoDbFactory;

    public MongoDbFactory mongoDbFactory() throws UnknownHostException {
        log.info("Mongo Client Info - Host: {} Port: {}", mongoHost, mongoPort);
        if (mongoClient == null) {
            mongoClient = new MongoClient(mongoHost, mongoPort);
        }
        if (simpleMongoDbFactory == null) {
            simpleMongoDbFactory = new SimpleMongoDbFactory(mongoClient, EXCHANGE_MONITOR_DB);
        }
        return simpleMongoDbFactory;
    }

    @Bean
    public MongoTemplate mongoTemplate() throws UnknownHostException {
        if (this.mongoTemplate == null) {
            mongoTemplate = new MongoTemplate(mongoDbFactory());
        }
        return mongoTemplate;
    }

    @PostConstruct
    public void init() throws UnknownHostException {
        boolean connected = MongoConnectionValidator.isConnected(mongoTemplate());
        if (connected) {
            log.info("---------- Mongo Configuration -----------");
            log.info("Mongo Host: " + mongoHost);
            log.info("Mongo Port: " + mongoPort);
            log.info("Mongo Connected: " + connected);
            log.info("------------------------------------------");
        } else {
            log.info("No Database Connected...");
        }
    }

}
{'fraction_non_alphanumeric': 0.12748514039762246, 'fraction_numerical': 0.003279360524697684, 'mean_word_length': 3.416289592760181, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6277180', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1326, 'n_words': 242}