<commit_before>/**
 * Copyright 2015 <NAME>
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.cassandra;

import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.util.Set;

import org.immutables.value.Value;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.palantir.atlasdb.spi.KeyValueServiceConfig;

@JsonDeserialize(as = ImmutableCassandraKeyValueServiceConfig.class)
@JsonSerialize(as = ImmutableCassandraKeyValueServiceConfig.class)
@JsonTypeName(CassandraKeyValueServiceConfig.TYPE)
@Value.Immutable
public abstract class CassandraKeyValueServiceConfig implements KeyValueServiceConfig {

    public static final String TYPE = "cassandra";

    public abstract Set<InetSocketAddress> servers();

    @Value.Default
    public int poolSize() {
        return 20;
    }

    @Value.Default
    public String keyspace() {
        return "atlasdb";
    }

    public abstract boolean ssl();

    public abstract int replicationFactor();

    @Value.Default
    public int mutationBatchCount() {
        return 5000;
    }

    @Value.Default
    public int mutationBatchSizeBytes() {
        return 4 * 1024 * 1024;
    }

    @Value.Default
    public int fetchBatchCount() { return 5000; }

    @Value.Default
    public boolean safetyDisabled() {
        return false;
    }

    @Value.Default
    public boolean autoRefreshNodes() {
        return true;
    }

    /**
     * This is how long we will wait when we first open a socket to the cassandra server.
     * This should be long enough to enough to handle cross data center latency, but short enough
     * that it will fail out quickly if it is clear we can't reach that server.
     */
    @Value.Default
    public int socketTimeoutMillis() {
        return 2 * 1000;
    }

    /**
     * Socket timeout is a java side concept.  This the maximum time we will block on a network
     * read without the server sending us any bytes.  After this time a {@link SocketTimeoutException}
     * will be thrown.  All cassandra reads time out at less than this value so we shouldn't see
     * it very much (10s by default).
     */
    @Value.Default
    public int socketQueryTimeoutMillis() {
        return 62 * 1000;
    }

    @Value.Default
    public int cqlPoolTimeoutMillis() {
        return 5 * 1000;
    }

    @Value.Default
    public int schemaMutationTimeoutMillis() { return 60 * 1000; }

    @Value.Default
    public int rangesConcurrency() {
        return 64;
    }

    public abstract Optional<CassandraJmxCompactionConfig> jmx();

    @Override
    public final String type() {
        return TYPE;
    }

    @Value.Check
    protected final void check() {
        Preconditions.checkState(!servers().isEmpty(), "'servers' must have at least one entry");
        for (InetSocketAddress addr : servers()) {
            Preconditions.checkState(addr.getPort() != 0, "each server must specify a port ([host]:[port])");
        }
    }
}
<commit_msg>nit fix on cassandra config validator<commit_after>/**
 * Copyright 2015 <NAME>
 *
 * Licensed under the BSD-3 License (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://opensource.org/licenses/BSD-3-Clause
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.palantir.atlasdb.cassandra;

import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
import java.util.Set;

import org.immutables.value.Value;

import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.palantir.atlasdb.spi.KeyValueServiceConfig;

@JsonDeserialize(as = ImmutableCassandraKeyValueServiceConfig.class)
@JsonSerialize(as = ImmutableCassandraKeyValueServiceConfig.class)
@JsonTypeName(CassandraKeyValueServiceConfig.TYPE)
@Value.Immutable
public abstract class CassandraKeyValueServiceConfig implements KeyValueServiceConfig {

    public static final String TYPE = "cassandra";

    public abstract Set<InetSocketAddress> servers();

    @Value.Default
    public int poolSize() {
        return 20;
    }

    @Value.Default
    public String keyspace() {
        return "atlasdb";
    }

    public abstract boolean ssl();

    public abstract int replicationFactor();

    @Value.Default
    public int mutationBatchCount() {
        return 5000;
    }

    @Value.Default
    public int mutationBatchSizeBytes() {
        return 4 * 1024 * 1024;
    }

    @Value.Default
    public int fetchBatchCount() { return 5000; }

    @Value.Default
    public boolean safetyDisabled() {
        return false;
    }

    @Value.Default
    public boolean autoRefreshNodes() {
        return true;
    }

    /**
     * This is how long we will wait when we first open a socket to the cassandra server.
     * This should be long enough to enough to handle cross data center latency, but short enough
     * that it will fail out quickly if it is clear we can't reach that server.
     */
    @Value.Default
    public int socketTimeoutMillis() {
        return 2 * 1000;
    }

    /**
     * Socket timeout is a java side concept.  This the maximum time we will block on a network
     * read without the server sending us any bytes.  After this time a {@link SocketTimeoutException}
     * will be thrown.  All cassandra reads time out at less than this value so we shouldn't see
     * it very much (10s by default).
     */
    @Value.Default
    public int socketQueryTimeoutMillis() {
        return 62 * 1000;
    }

    @Value.Default
    public int cqlPoolTimeoutMillis() {
        return 5 * 1000;
    }

    @Value.Default
    public int schemaMutationTimeoutMillis() { return 60 * 1000; }

    @Value.Default
    public int rangesConcurrency() {
        return 64;
    }

    public abstract Optional<CassandraJmxCompactionConfig> jmx();

    @Override
    public final String type() {
        return TYPE;
    }

    @Value.Check
    protected final void check() {
        Preconditions.checkState(!servers().isEmpty(), "'servers' must have at least one entry");
        for (InetSocketAddress addr : servers()) {
            Preconditions.checkState(addr.getPort() > 0, "each server must specify a port ([host]:[port])");
        }
    }
}

{'fraction_non_alphanumeric': 0.0824507306609465, 'fraction_numerical': 0.013942887786566565, 'mean_word_length': 3.149054505005562, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '5568475', 'n_tokens_mistral': 2155, 'n_tokens_neox': 1981, 'n_words': 703}