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
a05f1803
Commit
a05f1803
authored
Jul 15, 2019
by
周健威
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/base-modify' into base-modify
parents
f5dd9a36
fbee8634
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
150 additions
and
2 deletions
+150
-2
pom.xml
ace-auth/ace-auth-server/pom.xml
+4
-0
pom.xml
ace-control/ace-monitor/pom.xml
+1
-1
NacosWatch.java
...om/github/wxiaoqi/security/monitor/config/NacosWatch.java
+123
-0
NacosWatchAutoConfiguration.java
.../security/monitor/config/NacosWatchAutoConfiguration.java
+18
-0
pom.xml
xx-common/xx-common-platform-web/pom.xml
+4
-1
No files found.
ace-auth/ace-auth-server/pom.xml
View file @
a05f1803
...
@@ -138,6 +138,10 @@
...
@@ -138,6 +138,10 @@
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
<artifactId>
spring-cloud-starter-alibaba-sentinel
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-alibaba-nacos-config
</artifactId>
<artifactId>
spring-cloud-starter-alibaba-nacos-config
</artifactId>
...
...
ace-control/ace-monitor/pom.xml
View file @
a05f1803
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<artifactId>
ace-monitor
</artifactId>
<artifactId>
ace-monitor
</artifactId>
<properties>
<properties>
<boot.admin.version>
2.1.
2
</boot.admin.version>
<boot.admin.version>
2.1.
6
</boot.admin.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
...
ace-control/ace-monitor/src/main/java/com/github/wxiaoqi/security/monitor/config/NacosWatch.java
0 → 100644
View file @
a05f1803
/*
* Copyright (C) 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
github
.
wxiaoqi
.
security
.
monitor
.
config
;
import
com.alibaba.nacos.api.naming.listener.EventListener
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties
;
import
org.springframework.cloud.client.discovery.event.HeartbeatEvent
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisherAware
;
import
org.springframework.context.SmartLifecycle
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicLong
;
/**
* @author xiaojing
*/
public
class
NacosWatch
implements
ApplicationEventPublisherAware
,
SmartLifecycle
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
NacosWatch
.
class
);
private
final
NacosDiscoveryProperties
properties
;
private
long
watchDelay
=
30000
;
private
final
TaskScheduler
taskScheduler
;
private
final
AtomicLong
nacosWatchIndex
=
new
AtomicLong
(
0
);
private
final
AtomicBoolean
running
=
new
AtomicBoolean
(
false
);
private
ApplicationEventPublisher
publisher
;
private
ScheduledFuture
<?>
watchFuture
;
private
Set
<
String
>
cacheServices
=
new
HashSet
<>();
private
HashMap
<
String
,
EventListener
>
subscribeListeners
=
new
HashMap
<>();
public
NacosWatch
(
NacosDiscoveryProperties
properties
)
{
this
(
properties
,
getTaskScheduler
());
}
public
NacosWatch
(
NacosDiscoveryProperties
properties
,
TaskScheduler
taskScheduler
)
{
this
.
properties
=
properties
;
this
.
taskScheduler
=
taskScheduler
;
}
private
static
ThreadPoolTaskScheduler
getTaskScheduler
()
{
ThreadPoolTaskScheduler
taskScheduler
=
new
ThreadPoolTaskScheduler
();
taskScheduler
.
initialize
();
return
taskScheduler
;
}
@Override
public
void
setApplicationEventPublisher
(
ApplicationEventPublisher
publisher
)
{
this
.
publisher
=
publisher
;
}
@Override
public
boolean
isAutoStartup
()
{
return
true
;
}
@Override
public
void
stop
(
Runnable
callback
)
{
this
.
stop
();
callback
.
run
();
}
@Override
public
void
start
()
{
if
(
this
.
running
.
compareAndSet
(
false
,
true
))
{
this
.
watchFuture
=
this
.
taskScheduler
.
scheduleWithFixedDelay
(
this
::
nacosServicesWatch
,
watchDelay
);
}
}
@Override
public
void
stop
()
{
if
(
this
.
running
.
compareAndSet
(
true
,
false
)
&&
this
.
watchFuture
!=
null
)
{
this
.
watchFuture
.
cancel
(
true
);
}
}
@Override
public
boolean
isRunning
()
{
return
false
;
}
@Override
public
int
getPhase
()
{
return
0
;
}
public
void
nacosServicesWatch
()
{
// nacos doesn't support watch now , publish an event every 30 seconds.
this
.
publisher
.
publishEvent
(
new
HeartbeatEvent
(
this
,
nacosWatchIndex
.
getAndIncrement
()));
}
}
ace-control/ace-monitor/src/main/java/com/github/wxiaoqi/security/monitor/config/NacosWatchAutoConfiguration.java
0 → 100644
View file @
a05f1803
package
com
.
github
.
wxiaoqi
.
security
.
monitor
.
config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
NacosWatchAutoConfiguration
{
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty
(
value
=
"spring.cloud.nacos.discovery.watch.enabled"
,
matchIfMissing
=
true
)
public
NacosWatch
nacosWatch
(
NacosDiscoveryProperties
nacosDiscoveryProperties
)
{
return
new
NacosWatch
(
nacosDiscoveryProperties
);
}
}
\ No newline at end of file
xx-common/xx-common-platform-web/pom.xml
View file @
a05f1803
...
@@ -42,7 +42,10 @@
...
@@ -42,7 +42,10 @@
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter
</artifactId>
<artifactId>
spring-cloud-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<!-- 持久层 -->
<!-- 持久层 -->
<dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
...
...
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