diff --git a/README.md b/README.md index cbf7602..9ab5be7 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ org.quartz.jobStore.class = net.joelinn.quartz.jobstore.RedisJobStore # set the Redis host (required) org.quartz.jobStore.host = +# set the redis password (optional, defaults null) +org.quartz.jobStore.password = + # set the redis port (optional, defaults to 6379) org.quartz.jobStore.port = diff --git a/src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java b/src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java index 76eabfe..e884caf 100644 --- a/src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java +++ b/src/main/java/net/joelinn/quartz/jobstore/RedisJobStore.java @@ -45,6 +45,11 @@ public class RedisJobStore implements JobStore { */ protected int port = 6379; + /** + * Redis password + */ + protected String password; + /** * Redis database */ @@ -127,12 +132,12 @@ public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) t if (logger.isDebugEnabled()) { logger.debug("Instantiating JedisSentinelPool using master " + masterGroupName + " and hosts " + host); } - jedisPool = new JedisSentinelPool(masterGroupName, nodesAsStrings, jedisPoolConfig, Protocol.DEFAULT_TIMEOUT, null, database); + jedisPool = new JedisSentinelPool(masterGroupName, nodesAsStrings, jedisPoolConfig, Protocol.DEFAULT_TIMEOUT, password, database); } else { if (logger.isDebugEnabled()) { logger.debug("Instantiating JedisPool using host " + host + " and port " + port); } - jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, null, database); + jedisPool = new JedisPool(jedisPoolConfig, host, port, Protocol.DEFAULT_TIMEOUT, password, database); } storage = new RedisStorage(redisSchema, mapper, signaler, instanceId, lockTimeout); } @@ -1187,6 +1192,14 @@ public void setMasterGroupName(String masterGroupName) { this.masterGroupName = masterGroupName; } + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + /** * Inform the JobStore of the Scheduler instance's Id, * prior to initialize being invoked. diff --git a/src/main/java/net/joelinn/quartz/jobstore/RedisJobStoreSchema.java b/src/main/java/net/joelinn/quartz/jobstore/RedisJobStoreSchema.java index b2ca185..9cf7142 100644 --- a/src/main/java/net/joelinn/quartz/jobstore/RedisJobStoreSchema.java +++ b/src/main/java/net/joelinn/quartz/jobstore/RedisJobStoreSchema.java @@ -267,6 +267,12 @@ protected String addPrefix(String key){ * @return a list comprised of the split parts of the given string */ protected List split(final String string){ - return Arrays.asList(string.split(delimiter)); + if (null!=prefix){ + //remove prefix before split + return Arrays.asList(string.substring(prefix.length()).split(delimiter)); + }else{ + return Arrays.asList(string.split(delimiter)); + } + } }