-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Works from local repos or with explicit POST to /monitor with path=<serviceId>, also supports webhooks from github and gitlab.
- Loading branch information
Showing
19 changed files
with
1,339 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-config</artifactId> | ||
<version>1.1.0.BUILD-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
<artifactId>spring-cloud-config-monitor</artifactId> | ||
<name>spring-cloud-config-monitor</name> | ||
<description>Spring Cloud Config Monitor</description> | ||
<properties> | ||
<main.basedir>${basedir}/../..</main.basedir> | ||
</properties> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-bus-parent</artifactId> | ||
<version>${spring-cloud-bus.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-config-server</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-bus</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<!-- Only needed at compile time --> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
84 changes: 84 additions & 0 deletions
84
.../org/springframework/cloud/config/monitor/CompositePropertyPathNotificationExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright 2015 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 org.springframework.cloud.config.monitor; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.AnnotationAwareOrderComparator; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
/** | ||
* A {@link PropertyPathNotificationExtractor} that cycles through a set of (ordered) delegates, | ||
* looking for the first non-null outcome. | ||
* | ||
* @author Dave Syer | ||
* | ||
*/ | ||
public class CompositePropertyPathNotificationExtractor | ||
implements PropertyPathNotificationExtractor { | ||
|
||
private List<PropertyPathNotificationExtractor> extractors; | ||
|
||
public CompositePropertyPathNotificationExtractor( | ||
List<PropertyPathNotificationExtractor> extractors) { | ||
this.extractors = new ArrayList<>(); | ||
if (extractors != null) { | ||
this.extractors.addAll(extractors); | ||
} | ||
this.extractors.add(new SimplePropertyPathNotificationExtractor()); | ||
AnnotationAwareOrderComparator.sort(this.extractors); | ||
} | ||
|
||
@Override | ||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, | ||
Map<String, Object> request) { | ||
for (PropertyPathNotificationExtractor extractor : this.extractors) { | ||
PropertyPathNotification result = extractor.extract(headers, request); | ||
if (result != null) { | ||
return result; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Order(Ordered.LOWEST_PRECEDENCE - 200) | ||
private static class SimplePropertyPathNotificationExtractor | ||
implements PropertyPathNotificationExtractor { | ||
|
||
@Override | ||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, | ||
Map<String, Object> request) { | ||
Object object = request.get("path"); | ||
if (object instanceof String) { | ||
return new PropertyPathNotification((String) object); | ||
} | ||
if (object instanceof Collection) { | ||
@SuppressWarnings("unchecked") | ||
Collection<String> collection = (Collection<String>) object; | ||
return new PropertyPathNotification(collection.toArray(new String[0])); | ||
} | ||
return null; | ||
} | ||
|
||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...in/java/org/springframework/cloud/config/monitor/EnvironmentMonitorAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2015 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 org.springframework.cloud.config.monitor; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
|
||
/** | ||
* @author Dave Syer | ||
* | ||
*/ | ||
@Configuration | ||
@ConditionalOnWebApplication | ||
@Import(FileMonitorConfiguration.class) | ||
public class EnvironmentMonitorAutoConfiguration { | ||
|
||
@Autowired(required=false) | ||
private List<PropertyPathNotificationExtractor> extractors; | ||
|
||
@Bean | ||
public PropertyPathEndpoint propertyPathEndpoint() { | ||
return new PropertyPathEndpoint(new CompositePropertyPathNotificationExtractor(this.extractors)); | ||
} | ||
} |
Oops, something went wrong.
8d8e07a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! lot's of people asking for this.
8d8e07a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try to fullfill this requirement then :)
Hi,
I will try to give all inputs firstly:
ConfigServerApplication/application.yml
spring:
cloud:
config:
server:
native:
searchLocations: /space/projects/springConfigServer/configserver-master/src/main/localConfigRepo
I am running the application as standalone jar : java -jar target/configserver-0.0.1-SNAPSHOT.jar --spring.profiles.active=native
there is another application which is a client of configServer.For now it seems like to be get it's initial configuration from configserver.Actually it is a zuulProxy application and and i am trying to keep&fetch&refresh it's zuul.routes information the configServer.
I am running both applications and changing the related application's config at the specified directory in the first step.
But while the Config Server is running up it says : o.s.c.c.m.FileMonitorConfiguration : Not monitoring for local config changes
I have read the below links but a bit confused about to build up a auto-refresh functioning CfgSrvClient- CfgServer application pair..maintaining spring dependencies is terrieble ..it makes me feel solving a crossword which is written kiril alphabet. And of course changing atributes does not take affect on the client side..
Maybe it is just bec.of dependency mess..
Do you have any idea what i am doing wrong ?
Kind regards
8d8e07a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea sorry (but you didn't mention using the bus anywhere - you need that to send the refresh messages). Perhaps a question on stack overflow would be better than a comment on an old commit?
8d8e07a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx..i am quite new to spring world..
But i think i have found the bug..
it is already explained by you..
I can see that migrating a boot app to a cloud app almost impossible for me.
I need to build it from strach from a sample cloud app step by step...
Hope to see you in stackoverflow..
Kind regards..