in aws-glue-datacatalog-client-common/src/main/java/com/amazonaws/glue/catalog/metastore/AWSGlueMetastoreCacheDecorator.java [52:96]
public AWSGlueMetastoreCacheDecorator(HiveConf conf, AWSGlueMetastore awsGlueMetastore, Ticker ticker) {
super(awsGlueMetastore);
checkNotNull(conf, "conf can not be null");
this.conf = conf;
databaseCacheEnabled = conf.getBoolean(AWS_GLUE_DB_CACHE_ENABLE, false);
if(databaseCacheEnabled) {
int dbCacheSize = conf.getInt(AWS_GLUE_DB_CACHE_SIZE, 0);
int dbCacheTtlMins = conf.getInt(AWS_GLUE_DB_CACHE_TTL_MINS, 0);
//validate config values for size and ttl
validateConfigValueIsGreaterThanZero(AWS_GLUE_DB_CACHE_SIZE, dbCacheSize);
validateConfigValueIsGreaterThanZero(AWS_GLUE_DB_CACHE_TTL_MINS, dbCacheTtlMins);
//initialize database cache
databaseCache = CacheBuilder.newBuilder().maximumSize(dbCacheSize)
.ticker(ticker)
.expireAfterWrite(dbCacheTtlMins, TimeUnit.MINUTES).build();
databasesCache = CacheBuilder.newBuilder().maximumSize(dbCacheSize)
.ticker(ticker)
.expireAfterWrite(dbCacheTtlMins, TimeUnit.MINUTES).build();
} else {
databaseCache = null;
databasesCache = null;
}
tableCacheEnabled = conf.getBoolean(AWS_GLUE_TABLE_CACHE_ENABLE, false);
if(tableCacheEnabled) {
int tableCacheSize = conf.getInt(AWS_GLUE_TABLE_CACHE_SIZE, 0);
int tableCacheTtlMins = conf.getInt(AWS_GLUE_TABLE_CACHE_TTL_MINS, 0);
//validate config values for size and ttl
validateConfigValueIsGreaterThanZero(AWS_GLUE_TABLE_CACHE_SIZE, tableCacheSize);
validateConfigValueIsGreaterThanZero(AWS_GLUE_TABLE_CACHE_TTL_MINS, tableCacheTtlMins);
//initialize table cache
tableCache = CacheBuilder.newBuilder().maximumSize(tableCacheSize)
.ticker(ticker)
.expireAfterWrite(tableCacheTtlMins, TimeUnit.MINUTES).build();
} else {
tableCache = null;
}
logger.info("Constructed");
}