Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
springcloud-sentinel
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
senthink-project-origin
springcloud-sentinel
Commits
2d6c2bb6
You need to sign in or sign up before continuing.
Commit
2d6c2bb6
authored
Apr 03, 2020
by
李根
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改控制台重启导致的异常现象
parent
d0bbf8ad
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java
+39
-2
No files found.
sentinel-dashboard/src/main/java/com/alibaba/csp/sentinel/dashboard/repository/rule/InMemoryRuleRepositoryAdapter.java
View file @
2d6c2bb6
...
...
@@ -39,18 +39,34 @@ public abstract class InMemoryRuleRepositoryAdapter<T extends RuleEntity> implem
private
static
final
int
MAX_RULES_SIZE
=
10000
;
private
static
long
MAX_ID
=
0
l
;
@Override
public
T
save
(
T
entity
)
{
if
(
entity
.
getId
()
==
null
)
{
long
nextId
=
nextId
();
if
(
nextId
<=
MAX_ID
)
{
setId
(
MAX_ID
);
entity
.
setId
(
nextId
());
}
else
{
entity
.
setId
(
nextId
);
}
}
else
{
nextId
();
MAX_ID
=
entity
.
getId
();
}
T
processedEntity
=
preProcess
(
entity
);
if
(
processedEntity
!=
null
)
{
allRules
.
put
(
processedEntity
.
getId
(),
processedEntity
);
machineRules
.
computeIfAbsent
(
MachineInfo
.
of
(
processedEntity
.
getApp
(),
processedEntity
.
getIp
(),
processedEntity
.
getPort
()),
e
->
new
ConcurrentHashMap
<>(
32
))
processedEntity
.
getPort
()),
e
->
{
return
new
ConcurrentHashMap
<>(
32
);
})
.
put
(
processedEntity
.
getId
(),
processedEntity
);
appRules
.
computeIfAbsent
(
processedEntity
.
getApp
(),
v
->
new
ConcurrentHashMap
<>(
32
))
appRules
.
computeIfAbsent
(
processedEntity
.
getApp
(),
v
->
{
return
new
ConcurrentHashMap
<>(
32
);
})
.
put
(
processedEntity
.
getId
(),
processedEntity
);
}
...
...
@@ -60,6 +76,7 @@ public abstract class InMemoryRuleRepositoryAdapter<T extends RuleEntity> implem
@Override
public
List
<
T
>
saveAll
(
List
<
T
>
rules
)
{
// TODO: check here.
clearId
();
allRules
.
clear
();
machineRules
.
clear
();
appRules
.
clear
();
...
...
@@ -111,6 +128,7 @@ public abstract class InMemoryRuleRepositoryAdapter<T extends RuleEntity> implem
}
public
void
clearAll
()
{
clearId
();
allRules
.
clear
();
machineRules
.
clear
();
appRules
.
clear
();
...
...
@@ -126,4 +144,23 @@ public abstract class InMemoryRuleRepositoryAdapter<T extends RuleEntity> implem
* @return next unused id
*/
abstract
protected
long
nextId
();
/**
* @ desc : clearId
* @ params
* @ return
* @ date 2020/4/3
* @ author ligen
*/
abstract
protected
void
clearId
();
/**
* @ desc : setId
* @ params
* @ return
* @ date 2020/4/3
* @ author ligen
*/
abstract
protected
void
setId
(
long
id
);
}
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