All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.aerospike.jdbc.model.DriverPolicy Maven / Gradle / Ivy

The newest version!
package com.aerospike.jdbc.model;

import java.util.Properties;

public class DriverPolicy {

    private static final int DEFAULT_RECORD_SET_QUEUE_CAPACITY = 256;
    private static final int DEFAULT_RECORD_SET_TIMEOUT_MS = 1000;
    private static final int DEFAULT_METADATA_CACHE_TTL_SECONDS = 3600;
    private static final int DEFAULT_SCHEMA_BUILDER_MAX_RECORDS = 1000;

    private final int recordSetQueueCapacity;
    private final int recordSetTimeoutMs;
    private final int metadataCacheTtlSeconds;
    private final int schemaBuilderMaxRecords;
    private final boolean showRecordMetadata;

    public DriverPolicy(Properties properties) {
        recordSetQueueCapacity = parseInt(properties.getProperty("recordSetQueueCapacity"),
                DEFAULT_RECORD_SET_QUEUE_CAPACITY);
        recordSetTimeoutMs = parseInt(properties.getProperty("recordSetTimeoutMs"),
                DEFAULT_RECORD_SET_TIMEOUT_MS);
        metadataCacheTtlSeconds = parseInt(properties.getProperty("metadataCacheTtlSeconds"),
                DEFAULT_METADATA_CACHE_TTL_SECONDS);
        schemaBuilderMaxRecords = parseInt(properties.getProperty("schemaBuilderMaxRecords"),
                DEFAULT_SCHEMA_BUILDER_MAX_RECORDS);
        showRecordMetadata = Boolean.parseBoolean(properties.getProperty("showRecordMetadata"));
    }

    public int getRecordSetQueueCapacity() {
        return recordSetQueueCapacity;
    }

    public int getRecordSetTimeoutMs() {
        return recordSetTimeoutMs;
    }

    public int getMetadataCacheTtlSeconds() {
        return metadataCacheTtlSeconds;
    }

    public int getSchemaBuilderMaxRecords() {
        return schemaBuilderMaxRecords;
    }

    public boolean getShowRecordMetadata() {
        return showRecordMetadata;
    }

    private int parseInt(String value, int defaultValue) {
        if (value != null) {
            return Integer.parseInt(value);
        }
        return defaultValue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy