<commit_before>
package com.eightkdata.mongowp.client.wrapper;

import com.eightkdata.mongowp.MongoVersion;
import com.eightkdata.mongowp.client.core.MongoClient;
import com.eightkdata.mongowp.client.core.MongoConnection;
import com.eightkdata.mongowp.client.core.UnreachableMongoServerException;
import com.google.common.base.Preconditions;
import com.google.common.net.HostAndPort;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import org.bson.BsonDocument;
import org.bson.BsonDouble;
import org.bson.Document;
import org.bson.codecs.DocumentCodec;
import org.bson.codecs.configuration.CodecRegistries;
import org.bson.codecs.configuration.CodecRegistry;

/**
 *
 */
public class MongoClientWrapper implements MongoClient {

    private boolean closed;
    private final HostAndPort address;
    private final MongoVersion version;
    private final com.mongodb.MongoClient driverClient;
    private final CodecRegistry codecRegistry;

    public MongoClientWrapper(HostAndPort address) throws UnreachableMongoServerException {
        testAddress(address);

        this.address = address.withDefaultPort(27017);

        this.driverClient = new com.mongodb.MongoClient(
                this.address.getHostText(),
                this.address.getPort()
        );

        version = calculateVersion();
        codecRegistry = CodecRegistries.fromCodecs(new DocumentCodec());
        closed = false;
    }

    @Override
    public boolean isRemote() {
        return true;
    }

    private void testAddress(HostAndPort address) throws UnreachableMongoServerException {
        SocketAddress sa = new InetSocketAddress(address.getHostText(), address.getPort());
        Socket s = null;
        try {
            s = new Socket();
            s.connect(sa, 3000);<commit_msg>Added mongo client wrapper SSL and authentication configuration<commit_after>
package com.eightkdata.mongowp.client.wrapper;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;

import org.bson.BsonDocument;
import org.bson.BsonDouble;
import org.bson.Document;
import org.bson.codecs.DocumentCodec;
import org.bson.codecs.configuration.CodecRegistries;
import org.bson.codecs.configuration.CodecRegistry;

import com.eightkdata.mongowp.MongoVersion;
import com.eightkdata.mongowp.client.core.MongoClient;
import com.eightkdata.mongowp.client.core.MongoConnection;
import com.eightkdata.mongowp.client.core.UnreachableMongoServerException;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;

/**
 *
 */
public class MongoClientWrapper implements MongoClient {

    private boolean closed;
    private final HostAndPort address;
    private final MongoVersion version;
    private final com.mongodb.MongoClient driverClient;
    private final CodecRegistry codecRegistry;

    public MongoClientWrapper(HostAndPort address, MongoClientOptions mongoClientOptions, MongoCredential credential) throws UnreachableMongoServerException {
        testAddress(address, mongoClientOptions);

        this.address = address.withDefaultPort(27017);

        this.driverClient = new com.mongodb.MongoClient(
            new ServerAddress(
                this.address.getHostText(),
                this.address.getPort()),
            credential != null ? ImmutableList.of(credential) : ImmutableList.of(),
            mongoClientOptions
        );

        version = calculateVersion();
        codecRegistry = CodecRegistries.fromCodecs(new DocumentCodec());
        closed = false;
    }

    @Override
    public boolean isRemote() {
        return true;
    }

    private void testAddress(HostAndPort address, MongoClientOptions mongoClientOptions) throws UnreachableMongoServerException {
        SocketAddress sa = new InetSocketAddress(address.getHostText(), address.getPort());
        Socket s = null;
        try {
            s = mongoClientOptions.getSocketFactory().createSocket();
            s.connect(sa, 3000);
{'fraction_non_alphanumeric': 0.08555896951075397, 'fraction_numerical': 0.004254313401087214, 'mean_word_length': 3.853211009174312, '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': '685079', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1174, 'n_words': 237}