Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
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
谢捷峰
discovery
Commits
44b040f0
Commit
44b040f0
authored
Jun 22, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交discovery-plugin-actuator模块
parent
b9698a8f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
0 deletions
+154
-0
discovery-plugin-actuator/pom.xml
+29
-0
discovery-plugin-actuator/src/main/java/com/nepxion/discovery/plugin/actuator/cache/ActuatorCache.java
+66
-0
discovery-plugin-core/src/main/java/com/nepxion/discovery/plugin/core/cache/PluginCache.java
+59
-0
No files found.
discovery-plugin-actuator/pom.xml
0 → 100644
View file @
44b040f0
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<artifactId>
discovery-plugin-actuator
</artifactId>
<name>
Nepxion Discovery Plugin Actuator
</name>
<packaging>
jar
</packaging>
<modelVersion>
4.0.0
</modelVersion>
<description>
Nepxion Discovery is an enhancement for Spring Cloud Discovery
</description>
<url>
http://www.nepxion.com
</url>
<parent>
<groupId>
com.nepxion
</groupId>
<artifactId>
discovery
</artifactId>
<version>
1.0.0
</version>
</parent>
<dependencies>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
discovery-plugin-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
discovery-plugin-actuator/src/main/java/com/nepxion/discovery/plugin/actuator/cache/ActuatorCache.java
0 → 100644
View file @
44b040f0
package
com
.
nepxion
.
discovery
.
plugin
.
actuator
.
cache
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.CacheLoader
;
import
com.google.common.cache.LoadingCache
;
public
class
ActuatorCache
{
private
static
class
LazyHolder
{
private
static
final
ActuatorCache
INSTANCE
=
new
ActuatorCache
();
}
private
static
final
LoadingCache
<
String
,
String
>
EUREKA_RULE_CACHE
=
CacheBuilder
.
newBuilder
()
.
concurrencyLevel
(
8
)
.
expireAfterWrite
(
1
,
TimeUnit
.
DAYS
)
.
initialCapacity
(
10
)
.
maximumSize
(
100
)
.
recordStats
()
.
build
(
new
CacheLoader
<
String
,
String
>()
{
@Override
public
String
load
(
String
key
)
throws
Exception
{
return
StringUtils
.
EMPTY
;
}
});
private
ActuatorCache
()
{
}
public
static
final
ActuatorCache
getInstance
()
{
return
LazyHolder
.
INSTANCE
;
}
public
boolean
put
(
String
serviceId
,
String
rule
)
{
EUREKA_RULE_CACHE
.
put
(
serviceId
,
rule
);
return
Boolean
.
TRUE
;
}
public
String
get
(
String
serviceId
)
{
try
{
return
EUREKA_RULE_CACHE
.
get
(
serviceId
);
}
catch
(
ExecutionException
e
)
{
return
StringUtils
.
EMPTY
;
}
}
public
boolean
clear
(
String
serviceId
)
{
EUREKA_RULE_CACHE
.
invalidate
(
serviceId
);
return
Boolean
.
TRUE
;
}
}
\ No newline at end of file
discovery-plugin-core/src/main/java/com/nepxion/discovery/plugin/core/cache/PluginCache.java
0 → 100644
View file @
44b040f0
package
com
.
nepxion
.
discovery
.
plugin
.
core
.
cache
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.CacheLoader
;
import
com.google.common.cache.LoadingCache
;
public
class
PluginCache
{
private
LoadingCache
<
String
,
String
>
loadingCache
;
public
PluginCache
()
{
loadingCache
=
CacheBuilder
.
newBuilder
()
.
concurrencyLevel
(
8
)
.
expireAfterWrite
(
1
,
TimeUnit
.
DAYS
)
.
initialCapacity
(
10
)
.
maximumSize
(
100
)
.
recordStats
()
.
build
(
new
CacheLoader
<
String
,
String
>()
{
@Override
public
String
load
(
String
key
)
throws
Exception
{
return
StringUtils
.
EMPTY
;
}
});
}
public
boolean
put
(
String
key
,
String
value
)
{
loadingCache
.
put
(
key
,
value
);
return
Boolean
.
TRUE
;
}
public
String
get
(
String
key
)
{
try
{
return
loadingCache
.
get
(
key
);
}
catch
(
ExecutionException
e
)
{
return
StringUtils
.
EMPTY
;
}
}
public
boolean
remove
(
String
key
)
{
loadingCache
.
invalidate
(
key
);
return
Boolean
.
TRUE
;
}
}
\ No newline at end of file
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