Example usage for io.vertx.core.dns AddressResolverOptions setCacheMaxTimeToLive

List of usage examples for io.vertx.core.dns AddressResolverOptions setCacheMaxTimeToLive

Introduction

In this page you can find the example usage for io.vertx.core.dns AddressResolverOptions setCacheMaxTimeToLive.

Prototype

public AddressResolverOptions setCacheMaxTimeToLive(int cacheMaxTimeToLive) 

Source Link

Document

Set the cache maximum TTL value in seconds.

Usage

From source file:org.apache.servicecomb.foundation.vertx.AddressResolverConfig.java

License:Apache License

/**
 * get the target endpoints with custom address resolve config
 * @param tag config tag, such as sc.consumer or cc.consumer
 * @param configSource get config from special config source
 * @return AddressResolverOptions/*  w  ww .j  av a2  s  .  c o  m*/
 */
public static AddressResolverOptions getAddressResover(String tag, Configuration configSource) {
    AddressResolverOptions addressResolverOptions = new AddressResolverOptions();
    addressResolverOptions
            .setServers(getStringListProperty(configSource, AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
                    "addressResolver." + tag + ".servers", "addressResolver.servers"));
    addressResolverOptions.setOptResourceEnabled(
            getBooleanProperty(configSource, AddressResolverOptions.DEFAULT_OPT_RESOURCE_ENABLED,
                    "addressResolver." + tag + ".optResourceEnabled", "addressResolver.optResourceEnabled"));
    addressResolverOptions.setCacheMinTimeToLive(
            getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
                    "addressResolver." + tag + ".cacheMinTimeToLive", "addressResolver.cacheMinTimeToLive"));
    addressResolverOptions.setCacheMaxTimeToLive(
            getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_CACHE_MAX_TIME_TO_LIVE,
                    "addressResolver." + tag + ".cacheMaxTimeToLive", "addressResolver.cacheMaxTimeToLive"));
    addressResolverOptions.setCacheNegativeTimeToLive(getPositiveIntProperty(configSource,
            AddressResolverOptions.DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE,
            "addressResolver." + tag + ".cacheNegativeTimeToLive", "addressResolver.cacheNegativeTimeToLive"));
    addressResolverOptions
            .setQueryTimeout(getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_QUERY_TIMEOUT,
                    "addressResolver." + tag + ".queryTimeout", "addressResolver.queryTimeout"));
    addressResolverOptions
            .setMaxQueries(getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_MAX_QUERIES,
                    "addressResolver." + tag + ".maxQueries", "addressResolver.maxQueries"));
    addressResolverOptions.setRdFlag(getBooleanProperty(configSource, AddressResolverOptions.DEFAULT_RD_FLAG,
            "addressResolver." + tag + ".rdFlag", "addressResolver.rdFlag"));
    addressResolverOptions
            .setSearchDomains(getStringListProperty(configSource, AddressResolverOptions.DEFAULT_SEACH_DOMAINS,
                    "addressResolver." + tag + ".searchDomains", "addressResolver.searchDomains"));
    addressResolverOptions.setNdots(
            getPositiveIntProperty(configSource, AddressResolverOptions.DEFAULT_CACHE_MIN_TIME_TO_LIVE,
                    "addressResolver." + tag + ".ndots", "addressResolver.ndots"));
    addressResolverOptions
            .setRotateServers(getBooleanProperty(configSource, AddressResolverOptions.DEFAULT_ROTATE_SERVERS,
                    "addressResolver." + tag + ".rotateServers", "addressResolver.rotateServers"));
    return addressResolverOptions;
}