Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
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
youjj
cloud-platform
Commits
01fbac34
Commit
01fbac34
authored
Aug 01, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改代码
parent
61e9b976
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
77 deletions
+77
-77
pom.xml
ace-control/ace-monitor/pom.xml
+2
-2
NacosWatch.java
...om/github/wxiaoqi/security/monitor/config/NacosWatch.java
+61
-61
NacosWatchAutoConfiguration.java
.../security/monitor/config/NacosWatchAutoConfiguration.java
+7
-7
application.yml
ace-control/ace-monitor/src/main/resources/application.yml
+7
-7
No files found.
ace-control/ace-monitor/pom.xml
View file @
01fbac34
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
</dependency>
</dependency>
<!--<dependency>-->
<!--<dependency>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<groupId>org.springframework.cloud</groupId>-->
<!--<artifactId>spring-cloud-starter-consul-all</artifactId>-->
<!--<artifactId>spring-cloud-starter-consul-all</artifactId>-->
<!--</dependency>-->
<!--</dependency>-->
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
...
...
ace-control/ace-monitor/src/main/java/com/github/wxiaoqi/security/monitor/config/NacosWatch.java
View file @
01fbac34
...
@@ -39,85 +39,85 @@ import java.util.concurrent.atomic.AtomicLong;
...
@@ -39,85 +39,85 @@ import java.util.concurrent.atomic.AtomicLong;
*/
*/
public
class
NacosWatch
implements
ApplicationEventPublisherAware
,
SmartLifecycle
{
public
class
NacosWatch
implements
ApplicationEventPublisherAware
,
SmartLifecycle
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
NacosWatch
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
NacosWatch
.
class
);
private
final
NacosDiscoveryProperties
properties
;
private
final
NacosDiscoveryProperties
properties
;
private
long
watchDelay
=
30000
;
private
long
watchDelay
=
30000
;
private
final
TaskScheduler
taskScheduler
;
private
final
TaskScheduler
taskScheduler
;
private
final
AtomicLong
nacosWatchIndex
=
new
AtomicLong
(
0
);
private
final
AtomicLong
nacosWatchIndex
=
new
AtomicLong
(
0
);
private
final
AtomicBoolean
running
=
new
AtomicBoolean
(
false
);
private
final
AtomicBoolean
running
=
new
AtomicBoolean
(
false
);
private
ApplicationEventPublisher
publisher
;
private
ApplicationEventPublisher
publisher
;
private
ScheduledFuture
<?>
watchFuture
;
private
ScheduledFuture
<?>
watchFuture
;
private
Set
<
String
>
cacheServices
=
new
HashSet
<>();
private
Set
<
String
>
cacheServices
=
new
HashSet
<>();
private
HashMap
<
String
,
EventListener
>
subscribeListeners
=
new
HashMap
<>();
private
HashMap
<
String
,
EventListener
>
subscribeListeners
=
new
HashMap
<>();
public
NacosWatch
(
NacosDiscoveryProperties
properties
)
{
public
NacosWatch
(
NacosDiscoveryProperties
properties
)
{
this
(
properties
,
getTaskScheduler
());
this
(
properties
,
getTaskScheduler
());
}
}
public
NacosWatch
(
NacosDiscoveryProperties
properties
,
TaskScheduler
taskScheduler
)
{
public
NacosWatch
(
NacosDiscoveryProperties
properties
,
TaskScheduler
taskScheduler
)
{
this
.
properties
=
properties
;
this
.
properties
=
properties
;
this
.
taskScheduler
=
taskScheduler
;
this
.
taskScheduler
=
taskScheduler
;
}
}
private
static
ThreadPoolTaskScheduler
getTaskScheduler
()
{
private
static
ThreadPoolTaskScheduler
getTaskScheduler
()
{
ThreadPoolTaskScheduler
taskScheduler
=
new
ThreadPoolTaskScheduler
();
ThreadPoolTaskScheduler
taskScheduler
=
new
ThreadPoolTaskScheduler
();
taskScheduler
.
initialize
();
taskScheduler
.
initialize
();
return
taskScheduler
;
return
taskScheduler
;
}
}
@Override
@Override
public
void
setApplicationEventPublisher
(
ApplicationEventPublisher
publisher
)
{
public
void
setApplicationEventPublisher
(
ApplicationEventPublisher
publisher
)
{
this
.
publisher
=
publisher
;
this
.
publisher
=
publisher
;
}
}
@Override
@Override
public
boolean
isAutoStartup
()
{
public
boolean
isAutoStartup
()
{
return
true
;
return
true
;
}
}
@Override
@Override
public
void
stop
(
Runnable
callback
)
{
public
void
stop
(
Runnable
callback
)
{
this
.
stop
();
this
.
stop
();
callback
.
run
();
callback
.
run
();
}
}
@Override
@Override
public
void
start
()
{
public
void
start
()
{
if
(
this
.
running
.
compareAndSet
(
false
,
true
))
{
if
(
this
.
running
.
compareAndSet
(
false
,
true
))
{
this
.
watchFuture
=
this
.
taskScheduler
.
scheduleWithFixedDelay
(
this
.
watchFuture
=
this
.
taskScheduler
.
scheduleWithFixedDelay
(
this
::
nacosServicesWatch
,
watchDelay
);
this
::
nacosServicesWatch
,
watchDelay
);
}
}
}
}
@Override
@Override
public
void
stop
()
{
public
void
stop
()
{
if
(
this
.
running
.
compareAndSet
(
true
,
false
)
&&
this
.
watchFuture
!=
null
)
{
if
(
this
.
running
.
compareAndSet
(
true
,
false
)
&&
this
.
watchFuture
!=
null
)
{
this
.
watchFuture
.
cancel
(
true
);
this
.
watchFuture
.
cancel
(
true
);
}
}
}
}
@Override
@Override
public
boolean
isRunning
()
{
public
boolean
isRunning
()
{
return
false
;
return
false
;
}
}
@Override
@Override
public
int
getPhase
()
{
public
int
getPhase
()
{
return
0
;
return
0
;
}
}
public
void
nacosServicesWatch
()
{
public
void
nacosServicesWatch
()
{
// nacos doesn't support watch now , publish an event every 30 seconds.
// nacos doesn't support watch now , publish an event every 30 seconds.
this
.
publisher
.
publishEvent
(
this
.
publisher
.
publishEvent
(
new
HeartbeatEvent
(
this
,
nacosWatchIndex
.
getAndIncrement
()));
new
HeartbeatEvent
(
this
,
nacosWatchIndex
.
getAndIncrement
()));
}
}
}
}
ace-control/ace-monitor/src/main/java/com/github/wxiaoqi/security/monitor/config/NacosWatchAutoConfiguration.java
View file @
01fbac34
...
@@ -8,11 +8,11 @@ import org.springframework.context.annotation.Configuration;
...
@@ -8,11 +8,11 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@Configuration
public
class
NacosWatchAutoConfiguration
{
public
class
NacosWatchAutoConfiguration
{
@Bean
@Bean
@ConditionalOnMissingBean
@ConditionalOnMissingBean
@ConditionalOnProperty
(
value
=
"spring.cloud.nacos.discovery.watch.enabled"
,
matchIfMissing
=
true
)
@ConditionalOnProperty
(
value
=
"spring.cloud.nacos.discovery.watch.enabled"
,
matchIfMissing
=
true
)
public
NacosWatch
nacosWatch
(
NacosDiscoveryProperties
nacosDiscoveryProperties
)
{
public
NacosWatch
nacosWatch
(
NacosDiscoveryProperties
nacosDiscoveryProperties
)
{
return
new
NacosWatch
(
nacosDiscoveryProperties
);
return
new
NacosWatch
(
nacosDiscoveryProperties
);
}
}
}
}
\ No newline at end of file
ace-control/ace-monitor/src/main/resources/application.yml
View file @
01fbac34
spring
:
spring
:
application
:
application
:
name
:
ace-monitor
name
:
ace-monitor
cloud
:
cloud
:
nacos
:
nacos
:
discovery
:
discovery
:
server-addr
:
127.0.0.1:8848
server-addr
:
127.0.0.1:8848
server
:
server
:
port
:
8764
#启动端口
port
:
8764
#启动端口
#
#
#eureka:
#eureka:
# instance:
# instance:
...
...
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