On Tue, Jan 14, 2014 at 11:03 AM, √iktor Ҡlang <[email protected]>wrote:

> System name is not settable inside the configuration.
>
>
> https://stackoverflow.com/questions/16202501/how-can-i-override-a-typesafe-config-list-value-on-the-command-line
>
> Cheers,
> √
>
>
> On Tue, Jan 14, 2014 at 10:48 AM, Amit Mula <[email protected]> wrote:
>
>> Hello Patrik,
>>
>> I have some more queries :
>>
>> 1. can I store custom keys of mine in the application.conf file? Like if
>> I want to keep a key in the file by which all the actor systems will be
>> named.
>>
>
Yes you can.


> Application.conf looks like below :
>>
>> akka {
>> systemName = "F3System"
>> extensions = ["akka.contrib.pattern.DistributedPubSubExtension"]
>>    actor {
>>     provider = "akka.cluster.ClusterActorRefProvider"
>>   }
>>   remote {
>>     log-remote-lifecycle-events = off
>>     netty.tcp {
>>       hostname = "127.0.0.1"
>>       port = 0
>>     }
>>   }
>>
>>   cluster {
>>     seed-nodes = [
>>     "akka.tcp://[email protected]:2552",
>>     "akka.tcp://[email protected]:2553"]
>>
>>     auto-down = on
>>
>>     roles = []
>>
>>     role {
>>       # Minimum required number of members of a certain role before the
>> leader
>>       # changes member status of 'Joining' members to 'Up'. Typically
>> used together
>>       # with 'Cluster.registerOnMemberUp' to defer some action, such as
>> starting
>>       # actors, until the cluster has reached a certain size.
>>       # E.g. to require 2 nodes with role 'frontend' and 3 nodes with
>> role 'backend':
>>       #   frontend.min-nr-of-members = 2
>>       #   backend.min-nr-of-members = 3
>>       #<role-name>.min-nr-of-members = 1
>>     }
>>
>>   }
>>   }
>>
>>
>> so can I read the *systemName* using 
>> *System.getProperty("akka.cluster.systemName");
>> *If not, is there any other way to do this?
>>
>
Load the config and load it from the config.

Config config = ConfigFactory.load();
String systemName = config.getString("akka.systemName");
ActorSystem system = ActorSystem.create(systemName, config);



>
>> 2. How can I pass the role names as command line arguments?
>>
>> I tried with *System.setProperty("akka.cluster.roles", args[1]); *but it
>> didnt work. However, *System.setProperty("akka.remote.netty.tcp.port",
>> args[0]); *works for me.
>>
>
Roles is a string-list and the syntax for setting that from the command
line to System.properties is

-Dakka.cluster.roles.0=worker

I would recommend against setting System.properties in the program to
override config, because the config library cache system properties and
will only use the values that was available on the first ConfigFactory.load.
(command line as shown above is fine)

Instead, use config.withFallback, e.g.

Config config =
ConfigFactory.parseString("akka.cluster.roles=[\"worker\"]").withFallback(ConfigFactory.load());
ActorSystem.create("Sys", config);

Cheers,
Patrik


>  --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> Cheers,
> √
>
> * Viktor Klang*
> *Director of Engineering*
> Typesafe <http://www.typesafe.com/>
>
> Twitter: @viktorklang
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to