-
Notifications
You must be signed in to change notification settings - Fork 129
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 #1 from TaXueWWL/dev
Dev
- Loading branch information
Showing
11 changed files
with
181 additions
and
64 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
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 @@ | ||
# 开分支到dev |
74 changes: 37 additions & 37 deletions
74
...ibuted-lock-starter-demo/src/main/java/com/snowalker/executor/ExecutorRedissonNormal.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 |
---|---|---|
@@ -1,37 +1,37 @@ | ||
package com.snowalker.executor; | ||
|
||
import com.snowalker.lock.redisson.RedissonLock; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @author wuwl@19pay.com.cn | ||
* @date 2018-7-9 | ||
* @desc 纯java调用 | ||
*/ | ||
@Component | ||
public class ExecutorRedissonNormal { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ExecutorRedissonNormal.class); | ||
|
||
@Autowired | ||
RedissonLock redissonLock; | ||
|
||
@Scheduled(cron = "${redis.lock.cron}") | ||
public void execute() throws InterruptedException { | ||
if (redissonLock.lock("redisson", 10)) { | ||
LOGGER.info("[ExecutorRedisson]--执行定时任务开始,休眠三秒"); | ||
Thread.sleep(3000); | ||
System.out.println("=======================业务逻辑============================="); | ||
LOGGER.info("[ExecutorRedisson]--执行定时任务结束,休眠三秒"); | ||
redissonLock.release("redisson"); | ||
} else { | ||
LOGGER.info("[ExecutorRedisson]获取锁失败"); | ||
} | ||
|
||
} | ||
|
||
} | ||
//package com.snowalker.executor; | ||
// | ||
//import com.snowalker.lock.redisson.RedissonLock; | ||
//import org.slf4j.Logger; | ||
//import org.slf4j.LoggerFactory; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.scheduling.annotation.Scheduled; | ||
//import org.springframework.stereotype.Component; | ||
// | ||
///** | ||
// * @author wuwl@19pay.com.cn | ||
// * @date 2018-7-9 | ||
// * @desc 纯java调用 | ||
// */ | ||
//@Component | ||
//public class ExecutorRedissonNormal { | ||
// | ||
// private static final Logger LOGGER = LoggerFactory.getLogger(ExecutorRedissonNormal.class); | ||
// | ||
// @Autowired | ||
// RedissonLock redissonLock; | ||
// | ||
// @Scheduled(cron = "${redis.lock.cron}") | ||
// public void execute() throws InterruptedException { | ||
// if (redissonLock.lock("redisson", 10)) { | ||
// LOGGER.info("[ExecutorRedisson]--执行定时任务开始,休眠三秒"); | ||
// Thread.sleep(3000); | ||
// System.out.println("=======================业务逻辑============================="); | ||
// LOGGER.info("[ExecutorRedisson]--执行定时任务结束,休眠三秒"); | ||
// redissonLock.release("redisson"); | ||
// } else { | ||
// LOGGER.info("[ExecutorRedisson]获取锁失败"); | ||
// } | ||
// | ||
// } | ||
// | ||
//} |
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
16 changes: 14 additions & 2 deletions
16
redis-distributed-lock-starter/conf/application.properties
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 |
---|---|---|
@@ -1,2 +1,14 @@ | ||
redisson.server.host=127.0.0.1 | ||
redisson.server.ip=6379 | ||
######################################################################## | ||
# | ||
# redisson分布式锁配置--单机 | ||
# | ||
######################################################################### | ||
redisson.lock.server.address=127.0.0.1:6379 | ||
redisson.lock.server.type=standalone | ||
######################################################################## | ||
# | ||
# redisson分布式锁配置--哨兵 | ||
# | ||
######################################################################### | ||
#redisson.server.address=127.0.0.1:6379 | ||
#redisson.server.type=sentinel |
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
34 changes: 34 additions & 0 deletions
34
...-lock-starter/src/main/java/com/snowalker/lock/redisson/constant/RedisConnectionType.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,34 @@ | ||
package com.snowalker.lock.redisson.constant; | ||
|
||
/** | ||
* @author snowalker | ||
* @date 2018/7/11 | ||
* @desc Redis连接方式 | ||
* 包含:standalone-单节点部署方式 | ||
* sentinel-哨兵部署方式 | ||
* cluster-集群方式 | ||
* masterslave-主从部署方式 | ||
*/ | ||
public enum RedisConnectionType { | ||
|
||
STANDALONE("standalone", "单节点部署方式"), | ||
SENTINEL("sentinel", "哨兵部署方式"), | ||
CLUSTER("cluster", "集群方式"), | ||
MASTERSLAVE("masterslave", "主从部署方式"); | ||
|
||
private final String connection_type; | ||
private final String connection_desc; | ||
|
||
private RedisConnectionType(String connection_type, String connection_desc) { | ||
this.connection_type = connection_type; | ||
this.connection_desc = connection_desc; | ||
} | ||
|
||
public String getConnection_type() { | ||
return connection_type; | ||
} | ||
|
||
public String getConnection_desc() { | ||
return connection_desc; | ||
} | ||
} |