Skip to content

Commit

Permalink
Polish apache#4541 : [Feature] Add local File System DynamicConfigura…
Browse files Browse the repository at this point in the history
…tionFactory‘s extension
  • Loading branch information
mercyblitz committed Jul 15, 2019
1 parent f51b394 commit 9e58caa
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 18 deletions.
4 changes: 4 additions & 0 deletions dubbo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,9 @@
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
import org.apache.dubbo.common.config.Environment;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;

import static org.apache.dubbo.common.extension.ExtensionLoader.getExtensionLoader;

Expand Down Expand Up @@ -133,6 +132,20 @@ default String getConfigs(String key, String group) throws IllegalStateException
*/
String getConfigs(String key, String group, long timeout) throws IllegalStateException;


/**
* Publish Config mapped to the given key and the given group.
*
* @param key the key to represent a configuration
* @param content the content of configuration
* @return <code>true</code> if success, or <code>false</code>
* @throws UnsupportedOperationException If the under layer does not support
* @since 2.7.4
*/
default boolean publishConfig(String key, String content) throws UnsupportedOperationException {
return publishConfig(key, DEFAULT_GROUP, content);
}

/**
* Publish Config mapped to the given key and the given group.
*
Expand All @@ -155,38 +168,38 @@ default boolean publishConfig(String key, String group, String content) throws U
* @throws UnsupportedOperationException If the under layer does not support
* @since 2.7.4
*/
default SortedSet<String> getConfigKeys(String group) throws UnsupportedOperationException {
default Set<String> getConfigKeys(String group) throws UnsupportedOperationException {
throw new UnsupportedOperationException("No support");
}

/**
* Get the {@link SortedMap} with with config keys and contents value by the specified group
* Get the {@link Map} with with config keys and contents value by the specified group
*
* @param group the specified group
* @return the read-only non-null sorted {@link SortedMap map}
* @return the read-only non-null sorted {@link Map map}
* @throws UnsupportedOperationException If the under layer does not support
* @since 2.7.4
*/
default SortedMap<String, String> getConfigs(String group) throws UnsupportedOperationException {
default Map<String, String> getConfigs(String group) throws UnsupportedOperationException {
return getConfigs(group, -1);
}

/**
* Get the {@link SortedMap} with with config keys and content value by the specified group
* Get the {@link Map} with with config keys and content value by the specified group
*
* @param group the specified group
* @param timeout the millisecond for timeout
* @return the read-only non-null sorted {@link SortedMap map}
* @return the read-only non-null sorted {@link Map map}
* @throws UnsupportedOperationException If the under layer does not support
* @throws IllegalStateException If timeout exceeds
* @since 2.7.4
*/
default SortedMap<String, String> getConfigs(String group, long timeout) throws UnsupportedOperationException,
default Map<String, String> getConfigs(String group, long timeout) throws UnsupportedOperationException,
IllegalStateException {
SortedMap<String, String> configs = new TreeMap<>();
SortedSet<String> configKeys = getConfigKeys(group);
Map<String, String> configs = new LinkedHashMap<>();
Set<String> configKeys = getConfigKeys(group);
configKeys.forEach(key -> configs.put(key, getConfig(key, group, timeout)));
return Collections.unmodifiableSortedMap(configs);
return Collections.unmodifiableMap(configs);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.apache.dubbo.common.extension.SPI;

/**
*
* The factory interface to create the instance of {@link DynamicConfiguration}
*/
@SPI("nop")
@SPI("filesystem") // 2.7.4 change the
public interface DynamicConfigurationFactory {

DynamicConfiguration getDynamicConfiguration(URL url);
Expand Down
Loading

0 comments on commit 9e58caa

Please sign in to comment.