Search in sources :

Example 1 with Config

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);
}
Also used : ActorSystem(akka.actor.ActorSystem) AkkaRpcService(org.apache.flink.runtime.rpc.akka.AkkaRpcService) Config(com.typesafe.config.Config) Time(org.apache.flink.api.common.time.Time) IOException(java.io.IOException) ChannelException(org.jboss.netty.channel.ChannelException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ChannelException(org.jboss.netty.channel.ChannelException)

Example 2 with Config

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());
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Tuple2(scala.Tuple2) Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 3 with Config

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");
}
Also used : Config(com.typesafe.config.Config) Test(org.junit.Test)

Example 4 with Config

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);
}
Also used : ConfigResolveOptions(com.typesafe.config.ConfigResolveOptions) Config(com.typesafe.config.Config)

Example 5 with Config

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;
}
Also used : ActorSystem(akka.actor.ActorSystem) Config(com.typesafe.config.Config) SolrMatcherConfig(won.matcher.solr.config.SolrMatcherConfig) ClusterConfig(won.matcher.service.common.config.ClusterConfig) LoggingAdapter(akka.event.LoggingAdapter) Bean(org.springframework.context.annotation.Bean)

Aggregations

Config (com.typesafe.config.Config)489 Test (org.junit.Test)182 FeatureVector (com.airbnb.aerosolve.core.FeatureVector)117 Test (org.testng.annotations.Test)109 Properties (java.util.Properties)59 Map (java.util.Map)42 Path (org.apache.hadoop.fs.Path)41 Set (java.util.Set)37 HashMap (java.util.HashMap)34 URI (java.net.URI)32 HashSet (java.util.HashSet)32 IOException (java.io.IOException)22 Configuration (org.apache.hadoop.conf.Configuration)22 ArrayList (java.util.ArrayList)16 DrillConfig (org.apache.drill.common.config.DrillConfig)15 URL (java.net.URL)14 BaseTest (org.apache.drill.test.BaseTest)13 GobblinScopeTypes (org.apache.gobblin.broker.gobblin_scopes.GobblinScopeTypes)13 ImmutableMap (com.google.common.collect.ImmutableMap)11 File (java.io.File)11