Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
cafeabed
Commit
cafeabed
authored
May 25, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分布式锁
parent
de2b0b9b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
DaemonScanThreadRunHelperRedisLock.java
.../com/byit/factory/DaemonScanThreadRunHelperRedisLock.java
+2
-2
RunRecordingAndJobTaskServiceImpl.java
...ce/mapservice/impl/RunRecordingAndJobTaskServiceImpl.java
+2
-0
RedissonDistributedLocker.java
...in/java/com/byit/util/lock/RedissonDistributedLocker.java
+5
-0
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/factory/DaemonScanThreadRunHelperRedisLock.java
View file @
cafeabed
...
@@ -42,7 +42,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH
...
@@ -42,7 +42,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH
Long
sleepTime
=
0L
;
Long
sleepTime
=
0L
;
try
{
try
{
//加锁 60秒后超时
//加锁 60秒后超时
if
(
RedissLockUtil
.
trlock
(
lockName
,
TimeUnit
.
SECONDS
,
1
))
{
if
(
RedissLockUtil
.
trlock
(
lockName
,
TimeUnit
.
SECONDS
,
30
))
{
log
.
debug
(
"------------{},加锁成功,锁名称为{}----------"
,
threadName
,
lockName
);
log
.
debug
(
"------------{},加锁成功,锁名称为{}----------"
,
threadName
,
lockName
);
dateAligned
(
CYCLE_INTERVAL
,
threadName
);
dateAligned
(
CYCLE_INTERVAL
,
threadName
);
//调用业务操作
//调用业务操作
...
@@ -52,7 +52,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH
...
@@ -52,7 +52,7 @@ public class DaemonScanThreadRunHelperRedisLock extends BaseDaemonScanThreadRunH
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(!
THREAD_GROUP_STOP
){
if
(!
THREAD_GROUP_STOP
){
e
.
printStackTrace
(
);
log
.
error
(
"---------{}---------"
,
e
.
getMessage
()
);
}
}
}
finally
{
}
finally
{
RedissLockUtil
.
unlock
(
lockName
);
RedissLockUtil
.
unlock
(
lockName
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/mapservice/impl/RunRecordingAndJobTaskServiceImpl.java
View file @
cafeabed
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
...
@@ -226,6 +227,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
...
@@ -226,6 +227,7 @@ public class RunRecordingAndJobTaskServiceImpl implements RunRecordingAndJobTask
}
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
,
propagation
=
Propagation
.
REQUIRED
)
public
void
updateRunRecordingAndTask
(
WaitingRecord
waitingRecord
)
{
public
void
updateRunRecordingAndTask
(
WaitingRecord
waitingRecord
)
{
log
.
debug
(
"---------开始查询等待工作流{}对应的数据-------------"
,
waitingRecord
);
log
.
debug
(
"---------开始查询等待工作流{}对应的数据-------------"
,
waitingRecord
);
RunRecording
runRecording
=
runRecordingService
.
findAllByRunID
(
waitingRecord
.
getRunId
());
RunRecording
runRecording
=
runRecordingService
.
findAllByRunID
(
waitingRecord
.
getRunId
());
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/util/lock/RedissonDistributedLocker.java
View file @
cafeabed
...
@@ -18,7 +18,12 @@ public class RedissonDistributedLocker implements DistributedLocker {
...
@@ -18,7 +18,12 @@ public class RedissonDistributedLocker implements DistributedLocker {
@Override
@Override
public
void
unlock
(
String
lockKey
)
{
public
void
unlock
(
String
lockKey
)
{
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
try
{
lock
.
unlock
();
lock
.
unlock
();
}
catch
(
IllegalMonitorStateException
sta
)
{
log
.
warn
(
"--------解锁错误{}---------"
,
sta
.
getMessage
());
}
}
}
@Override
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment