use of com.typesafe.config.Config in project flink by apache.
the class RpcServiceUtils method createRpcService.
// ------------------------------------------------------------------------
// RPC instantiation
// ------------------------------------------------------------------------
/**
* Utility method to create RPC service from configuration and hostname, port.
*
* @param hostname The hostname/address that describes the TaskManager's data location.
* @param port If true, the TaskManager will not initiate the TCP network stack.
* @param configuration The configuration for the TaskManager.
* @return The rpc service which is used to start and connect to the TaskManager RpcEndpoint .
* @throws IOException Thrown, if the actor system can not bind to the address
* @throws Exception Thrown is some other error occurs while creating akka actor system
*/
public static RpcService createRpcService(String hostname, int port, Configuration configuration) throws Exception {
LOG.info("Starting AkkaRpcService at {}.", NetUtils.hostAndPortToUrlString(hostname, port));
final ActorSystem actorSystem;
try {
Config akkaConfig;
if (hostname != null && !hostname.isEmpty()) {
// remote akka config
akkaConfig = AkkaUtils.getAkkaConfig(configuration, hostname, port);
} else {
// local akka config
akkaConfig = AkkaUtils.getAkkaConfig(configuration);
}
LOG.debug("Using akka configuration \n {}.", akkaConfig);
actorSystem = AkkaUtils.createActorSystem(akkaConfig);
} catch (Throwable t) {
if (t instanceof ChannelException) {
Throwable cause = t.getCause();
if (cause != null && t.getCause() instanceof java.net.BindException) {
String address = NetUtils.hostAndPortToUrlString(hostname, port);
throw new IOException("Unable to bind AkkaRpcService actor system to address " + address + " - " + cause.getMessage(), t);
}
}
throw new Exception("Could not create TaskManager actor system", t);
}
final Time timeout = Time.milliseconds(AkkaUtils.getTimeout(configuration).toMillis());
return new AkkaRpcService(actorSystem, timeout);
}
use of com.typesafe.config.Config in project flink by apache.
the class JobManagerTest method testNullHostnameGoesToLocalhost.
@Test
public void testNullHostnameGoesToLocalhost() {
try {
Tuple2<String, Object> address = new Tuple2<String, Object>(null, 1772);
Config cfg = AkkaUtils.getAkkaConfig(new Configuration(), new Some<Tuple2<String, Object>>(address));
String hostname = cfg.getString("akka.remote.netty.tcp.hostname");
assertTrue(InetAddress.getByName(hostname).isLoopbackAddress());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of com.typesafe.config.Config in project riposte by Nike-Inc.
the class TypesafeConfigUtilTest method loadConfigForAppIdAndEnvironment_works_as_expected.
@Test
public void loadConfigForAppIdAndEnvironment_works_as_expected() {
// when
Config config = TypesafeConfigUtil.loadConfigForAppIdAndEnvironment("typesafeconfigserver", "compiletimetest");
// then
assertThat(config.getString("typesafeConfigServer.foo")).isEqualTo("overridevalue");
}
use of com.typesafe.config.Config in project helios by spotify.
the class HeliosConfig method loadConfig.
/**
* @param component The name of the component we're loading config for
* (i.e. Temp jobs, Helios solo)
* @return The root configuration loaded from the helios configuration files.
*/
static Config loadConfig(final String component) {
final ConfigResolveOptions resolveOptions = ConfigResolveOptions.defaults().setAllowUnresolved(true);
final Config baseConfig = ConfigFactory.load(BASE_CONFIG_FILE, ConfigParseOptions.defaults(), resolveOptions);
final Config appConfig = ConfigFactory.load(APP_CONFIG_FILE, ConfigParseOptions.defaults(), resolveOptions);
return appConfig.withFallback(baseConfig);
}
use of com.typesafe.config.Config in project webofneeds by researchstudio-sat.
the class MatcherSolrAppConfiguration method actorSystem.
/**
* Actor system singleton for this application.
*/
@Bean
public ActorSystem actorSystem() {
// load the Akka configuration
String seedNodes = "[";
for (String seed : clusterConfig.getSeedNodes()) {
seedNodes += "\"akka.tcp://" + clusterConfig.getName() + "@" + seed.trim() + "\",";
}
seedNodes += "]";
final Config applicationConf = ConfigFactory.load();
final Config config = ConfigFactory.parseString("akka.cluster.seed-nodes=" + seedNodes).withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.bind-port=" + clusterConfig.getLocalPort())).withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.hostname=" + clusterConfig.getNodeHost())).withFallback(ConfigFactory.parseString("akka.remote.netty.tcp.port=" + clusterConfig.getLocalPort())).withFallback(ConfigFactory.parseString("akka.cluster.roles=[matcher]")).withFallback(ConfigFactory.load(applicationConf));
ActorSystem system = ActorSystem.create(clusterConfig.getName(), config);
LoggingAdapter log = Logging.getLogger(system, this);
log.info("Using Akka system settings: " + system.settings().toString());
// initialize the application context in the Akka Spring Extension
SpringExtension.SpringExtProvider.get(system).initialize(applicationContext);
return system;
}
Aggregations