Skip to content

Commit

Permalink
moved ConfigurationManager to DyanamicProperties
Browse files Browse the repository at this point in the history
Loading the property file using a ConfigLoader
  • Loading branch information
smadappa committed May 6, 2017
1 parent aabb8e9 commit d02310d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.netflix.archaius.api.annotations.ConfigurationSource;
import com.netflix.evcache.event.hotkey.HotKeyListener;
import com.netflix.evcache.event.throttle.ThrottleListener;
import com.netflix.evcache.pool.EVCacheClientPoolManager;
Expand All @@ -12,8 +13,15 @@ public class EVCacheModule extends AbstractModule {
public EVCacheModule() {
}

@Singleton
@ConfigurationSource("evcache")
public static class EVCacheModuleConfigLoader {
}


@Override
protected void configure() {
bind(EVCacheModuleConfigLoader.class).asEagerSingleton();
bind(EVCacheClientPoolManager.class).asEagerSingleton();

bind(HotKeyListener.class).asEagerSingleton();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.netflix.evcache;

import com.netflix.config.ConfigurationManager;
import com.netflix.evcache.util.EVCacheConfig;

import net.spy.memcached.CachedData;
import net.spy.memcached.transcoders.SerializingTranscoder;

public class EVCacheTranscoder extends SerializingTranscoder {

public EVCacheTranscoder() {
this(ConfigurationManager.getConfigInstance().getInt("default.evcache.max.data.size", Integer.MAX_VALUE));
this(EVCacheConfig.getInstance().getDynamicIntProperty("default.evcache.max.data.size", Integer.MAX_VALUE).get());
}

public EVCacheTranscoder(int max) {
this(max, ConfigurationManager.getConfigInstance().getInt("default.evcache.compression.threshold", 120));
this(max, EVCacheConfig.getInstance().getDynamicIntProperty("default.evcache.compression.threshold", 120).get());
}

public EVCacheTranscoder(int max, int compressionThreshold) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.netflix.evcache.connection;

import com.netflix.config.ConfigurationManager;
import com.netflix.config.DynamicIntProperty;
import com.netflix.evcache.pool.EVCacheClientPoolManager;
import com.netflix.evcache.pool.ServerGroup;
Expand All @@ -15,9 +14,9 @@ public ConnectionFactoryProvider() {

public ConnectionFactory getConnectionFactory(String appName, int id, ServerGroup serverGroup, EVCacheClientPoolManager poolManager) {

final int maxQueueSize = ConfigurationManager.getConfigInstance().getInt(appName + ".max.queue.length", 16384);
final int maxQueueSize = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".max.queue.length", 16384).get();
final DynamicIntProperty operationTimeout = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".operation.timeout", 2500);
final int opQueueMaxBlockTime = ConfigurationManager.getConfigInstance().getInt(appName + ".operation.QueueMaxBlockTime", 10);
final int opQueueMaxBlockTime = EVCacheConfig.getInstance().getDynamicIntProperty(appName + ".operation.QueueMaxBlockTime", 10).get();

return new BaseConnectionFactory(appName, maxQueueSize, operationTimeout, opQueueMaxBlockTime, id, serverGroup, poolManager);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ private synchronized void refresh(boolean force) throws IOException {
final int poolSize = _poolSize.get();
final List<EVCacheClient> newClients = new ArrayList<EVCacheClient>(poolSize);
for (int i = 0; i < poolSize; i++) {
final int maxQueueSize = ConfigurationManager.getConfigInstance().getInt(_appName
+ ".max.queue.length", 16384);
final int maxQueueSize = EVCacheConfig.getInstance().getDynamicIntProperty(_appName
+ ".max.queue.length", 16384).get();
EVCacheClient client;
try {
client = new EVCacheClient(_appName, zone, i, config, memcachedSAInServerGroup, maxQueueSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ public class EVCacheClientPoolManager {
@Inject
public EVCacheClientPoolManager(ApplicationInfoManager applicationInfoManager, DiscoveryClient discoveryClient, Provider<IConnectionFactoryProvider> connectionFactoryprovider) {
instance = this;

try {
ConfigurationManager.loadCascadedPropertiesFromResources("evcache");
} catch (IOException e) {
log.info("Default evcache configuration not loaded", e);
}

this.applicationInfoManager = applicationInfoManager;
this.discoveryClient = discoveryClient;
this.connectionFactoryprovider = connectionFactoryprovider;
Expand Down Expand Up @@ -267,7 +260,7 @@ public DynamicIntProperty getDefaultRefreshInterval() {

private String getAppName(String _app) {
_app = _app.toUpperCase();
final String app = ConfigurationManager.getConfigInstance().getString("EVCacheClientPoolManager." + _app + ".alias", _app).toUpperCase();
final String app = EVCacheConfig.getInstance().getDynamicStringProperty("EVCacheClientPoolManager." + _app + ".alias", _app).get().toUpperCase();
if (log.isDebugEnabled()) log.debug("Original App Name : " + _app + "; Alias App Name : " + app);
return app;
}
Expand Down

0 comments on commit d02310d

Please sign in to comment.