Skip to content

Commit

Permalink
Merge pull request #122 from Netflix/ignore_alias
Browse files Browse the repository at this point in the history
Adding a config/FP to ignore the set alias.
  • Loading branch information
tharanga authored Apr 29, 2022
2 parents 221c907 + 6a2caf1 commit 13d3a33
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ public EVCacheExecutor getEVCacheExecutor() {

private String getAppName(String _app) {
_app = _app.toUpperCase();
final String app = EVCacheConfig.getInstance().getPropertyRepository().get("EVCacheClientPoolManager." + _app + ".alias", String.class).orElse(_app).get().toUpperCase();
Boolean ignoreAlias = EVCacheConfig.getInstance().getPropertyRepository()
.get("EVCacheClientPoolManager." + _app + ".ignoreAlias", Boolean.class)
.orElseGet("EVCacheClientPoolManager.ignoreAlias")
.orElse(false).get();
final String app = ignoreAlias ? _app :
EVCacheConfig.getInstance().getPropertyRepository()
.get("EVCacheClientPoolManager." + _app + ".alias", String.class)
.orElse(_app).get().toUpperCase();
if (log.isDebugEnabled()) log.debug("Original App Name : " + _app + "; Alias App Name : " + app);
if(app != null && app.length() > 0) return app.toUpperCase();
return _app;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.netflix.evcache.test;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

import java.util.Map;
import java.util.Properties;
import java.util.concurrent.BlockingQueue;
Expand All @@ -29,10 +26,15 @@

import rx.schedulers.Schedulers;

import static org.testng.Assert.*;

@SuppressWarnings({"unused","deprecation"})
public class SimpleEVCacheTest extends Base {
private static final Logger log = LogManager.getLogger(SimpleEVCacheTest.class);

private static final String APP_NAME = "EVCACHE_TEST";
private static final String ALIAS_APP_NAME = "EVCACHE";

private ThreadPoolExecutor pool = null;

public static void main(String args[]) {
Expand All @@ -54,12 +56,18 @@ public void setProps() {
Logger.getLogger(EVCacheClientPool.class).setLevel(Level.DEBUG);

final Properties props = getProps();
props.setProperty("EVCACHE_TEST.use.simple.node.list.provider", "true");
props.setProperty("EVCACHE_TEST.EVCacheClientPool.readTimeout", "1000");
props.setProperty("EVCACHE_TEST.EVCacheClientPool.bulkReadTimeout", "1000");
props.setProperty("EVCACHE_TEST.max.read.queue.length", "100");
props.setProperty("EVCACHE_TEST.operation.timeout", "10000");
props.setProperty("EVCACHE_TEST.throw.exception", "false");
props.setProperty(APP_NAME + ".use.simple.node.list.provider", "true");
props.setProperty(APP_NAME + ".EVCacheClientPool.readTimeout", "1000");
props.setProperty(APP_NAME + ".EVCacheClientPool.bulkReadTimeout", "1000");
props.setProperty(APP_NAME + ".max.read.queue.length", "100");
props.setProperty(APP_NAME + ".operation.timeout", "10000");
props.setProperty(APP_NAME + ".throw.exception", "false");

// Setting properties here for testing how we can disable aliases. If there are test case
// that requires aliases, these properties should go under a special condition.
props.setProperty("EVCacheClientPoolManager." + APP_NAME + ".alias", ALIAS_APP_NAME);
props.setProperty("EVCacheClientPoolManager." + APP_NAME + ".ignoreAlias", "true");
// End alias properties

int maxThreads = 2;
final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(100000);
Expand All @@ -74,10 +82,18 @@ public SimpleEVCacheTest() {
public void setupClusterDetails() {
manager = EVCacheClientPoolManager.getInstance();
}


@Test public void testDisablingAlias()
{
// Ensure alias is disabled, we see "EVCACHE_TEST" instead of "EVCACHE" as we have set above.
EVCacheClientPool pool = EVCacheClientPoolManager.getInstance().getEVCacheClientPool(APP_NAME);
assertEquals(pool.getAppName(), APP_NAME);
}

public void testAll() {
try {
EVCacheClientPoolManager.getInstance().initEVCache("EVCACHE_TEST");
EVCacheClientPoolManager.getInstance().initEVCache(APP_NAME);
testDisablingAlias();
testEVCache();

int i = 1;
Expand Down

0 comments on commit 13d3a33

Please sign in to comment.