Skip to content

Commit

Permalink
Rewrite configuration layer to use Typesafe config
Browse files Browse the repository at this point in the history
* Add custom mapping to convert Typesafe Config to Atomix
* Add type registries for custom object types
  • Loading branch information
kuujo committed May 30, 2018
1 parent 6c73393 commit fbc9473
Show file tree
Hide file tree
Showing 249 changed files with 3,612 additions and 3,517 deletions.
16 changes: 1 addition & 15 deletions agent/src/main/java/io/atomix/agent/AtomixAgent.java
Expand Up @@ -21,7 +21,6 @@
import io.atomix.core.AtomixConfig;
import io.atomix.rest.ManagedRestService;
import io.atomix.rest.RestService;
import io.atomix.utils.config.Configs;
import io.atomix.utils.net.Address;
import io.atomix.utils.net.MalformedAddressException;
import net.sourceforge.argparse4j.ArgumentParsers;
Expand All @@ -34,7 +33,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.List;

/**
Expand Down Expand Up @@ -105,7 +103,7 @@ public static void main(String[] args) throws Exception {
// If a configuration was provided, merge the configuration's member information with the provided command line arguments.
AtomixConfig config;
if (configString != null) {
config = loadConfig(configString);
config = Atomix.config(configString);
} else {
config = new AtomixConfig();
}
Expand Down Expand Up @@ -182,18 +180,6 @@ public static void main(String[] args) throws Exception {
}
}

/**
* Loads a configuration from the given file.
*/
private static AtomixConfig loadConfig(String config) {
File configFile = new File(config);
if (configFile.exists()) {
return Configs.load(configFile, AtomixConfig.class, Thread.currentThread().getContextClassLoader());
} else {
return Configs.load(config, AtomixConfig.class, Thread.currentThread().getContextClassLoader());
}
}

static MemberId parseMemberId(String address) {
int endIndex = address.indexOf('@');
if (endIndex > 0) {
Expand Down
4 changes: 2 additions & 2 deletions cluster/src/main/java/io/atomix/cluster/AtomixCluster.java
Expand Up @@ -32,7 +32,7 @@
import io.atomix.utils.concurrent.Futures;
import io.atomix.utils.concurrent.SingleThreadContext;
import io.atomix.utils.concurrent.ThreadContext;
import io.atomix.utils.config.Configs;
import io.atomix.utils.config.ConfigMapper;
import io.atomix.utils.net.Address;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -233,7 +233,7 @@ public String toString() {
* Loads a configuration from the given file.
*/
private static ClusterConfig loadConfig(File config, ClassLoader classLoader) {
return Configs.load(config, ClusterConfig.class, classLoader);
return new ConfigMapper(classLoader).loadResources(ClusterConfig.class, config.getAbsolutePath());
}

/**
Expand Down
86 changes: 0 additions & 86 deletions config/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit fbc9473

Please sign in to comment.