-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from diegopacheco/dev
Support for Rnd k/v and new Redis Validation Tasks.
- Loading branch information
Showing
19 changed files
with
329 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
.../com/github/diegopacheco/dynomite/cluster/checker/cluster/RedisNodeConnectionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.github.diegopacheco.dynomite.cluster.checker.cluster; | ||
|
||
import com.github.diegopacheco.dynomite.cluster.checker.parser.DynomiteNodeInfo; | ||
|
||
import redis.clients.jedis.Jedis; | ||
|
||
/** | ||
* RedisNodeConnectionManager connects to a single redis node. | ||
* | ||
* @author diegopacheco | ||
* @since 27/03/2018 | ||
* | ||
*/ | ||
public class RedisNodeConnectionManager { | ||
|
||
public static Jedis createNodeConnection(DynomiteNodeInfo node) { | ||
Jedis jedisClient = new Jedis(node.getServer(), new Integer(node.getRedisPort())); | ||
jedisClient.connect(); | ||
return jedisClient; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...java/com/github/diegopacheco/dynomite/cluster/checker/cluster/cache/RedisClientCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.github.diegopacheco.dynomite.cluster.checker.cluster.cache; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.apache.log4j.Logger; | ||
|
||
import com.google.common.cache.Cache; | ||
import com.google.common.cache.CacheBuilder; | ||
import com.google.common.cache.RemovalListener; | ||
import com.google.common.cache.RemovalNotification; | ||
|
||
import redis.clients.jedis.Jedis; | ||
|
||
@Singleton | ||
public class RedisClientCache { | ||
|
||
private static Cache<String, Jedis> cache; | ||
private static final Logger logger = Logger.getLogger(RedisClientCache.class); | ||
|
||
static { | ||
cache = CacheBuilder.newBuilder(). | ||
maximumSize(500). | ||
expireAfterAccess(2, TimeUnit.HOURS). | ||
removalListener(new RemovalListener<String, Jedis>() { | ||
@Override | ||
public void onRemoval(RemovalNotification<String, Jedis> notification) { | ||
logger.debug("Removing... " + notification.getKey()); | ||
try { | ||
notification.getValue().disconnect(); | ||
} catch (Exception e) { | ||
logger.error("Error on close evicted client. EX: " + e); | ||
} | ||
} | ||
}).build(); | ||
} | ||
|
||
public static Jedis get(String node) { | ||
try { | ||
return cache.getIfPresent(node); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static void put(String node, Jedis client) { | ||
cache.put(node, client); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.