Skip to content

Commit

Permalink
close #671
Browse files Browse the repository at this point in the history
Changed ConfigurationFactory to load App.Config automatically from disk
Modified TimeServer example to use auto-loading config
  • Loading branch information
Aaronontheweb committed Feb 26, 2015
1 parent c4070e7 commit edd6d94
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 105 deletions.
5 changes: 3 additions & 2 deletions src/core/Akka/Configuration/ConfigurationFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -37,8 +38,8 @@ public static Config ParseString(string hocon)
/// <returns>Config.</returns>
public static Config Load()
{
var section = new AkkaConfigurationSection();
Config config = section.AkkaConfig;
var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka") ?? new AkkaConfigurationSection();
var config = section.AkkaConfig;

return config;
}
Expand Down
55 changes: 52 additions & 3 deletions src/examples/TimeServer/TimeClient/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<akka>
<hocon>
<![CDATA[
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = off
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/timeChecker{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
port = 0 #bind to any available port
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
]]>
</hocon>
</akka>
</configuration>
51 changes: 1 addition & 50 deletions src/examples/TimeServer/TimeClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class Program

private static void Main(string[] args)
{
using (var system = ActorSystem.Create("TimeClient", Config))
using (var system = ActorSystem.Create("TimeClient"))
{
var tmp = system.ActorSelection("akka.tcp://TimeServer@localhost:9391/user/time");
Console.Title = string.Format("TimeClient {0}", Process.GetCurrentProcess().Id);
Expand Down Expand Up @@ -63,54 +63,5 @@ public void Handle(CheckTime message)
_timeServer.Tell("gettime", Self);
}
}

public static Config Config
{
get
{
return ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = off
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/timeChecker{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 0 #bind to any available port
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
");
}
}
}
}
49 changes: 49 additions & 0 deletions src/examples/TimeServer/TimeServer/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<akka>
<hocon>
<![CDATA[
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/time{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
port = 9391
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
]]>
</hocon>
</akka>
</configuration>
51 changes: 1 addition & 50 deletions src/examples/TimeServer/TimeServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Program
{
static void Main(string[] args)
{
using (var system = ActorSystem.Create("TimeServer", Config))
using (var system = ActorSystem.Create("TimeServer"))
{
Console.Title = "Server";
var server = system.ActorOf<TimeServerActor>("time");
Expand All @@ -20,55 +20,6 @@ static void Main(string[] args)
}
}

public static Config Config
{
get
{
return ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/time{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 9391
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
");
}
}

public class TimeServerActor : TypedActor, IHandle<string>
{
private readonly LoggingAdapter _log = Context.GetLogger();
Expand Down

3 comments on commit edd6d94

@Petabridge-CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Akka.NET :: Akka.NET PR Build Build 59 is now running

@Petabridge-CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Akka.NET :: Akka.NET PR Build Build 59 outcome was FAILURE
Summary: System.Exception: xUnit failed for the following assemblies: D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Persistence.Tests\bin\Release\Akka.Persistence.Tests.dll, D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Tests\bin\Release\Akka.Tests.dll ... Build time: 00:09:11

Failed tests

Akka.Tests.dll: Akka.Tests.Actor.ActorBecomeTests.Given_actor_that_has_called_default_Become_without_overwriting_previous_handler_When_calling_unbecome_Then_the_previous_handler_is_used: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ActorBecomeTests.When_calling_become_Then_the_new_handler_is_used: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ActorBecomeTests.Given_actor_that_has_called_default_Become_twice_When_calling_unbecome_Then_the_default_handler_is_used_and_not_the_last_handler: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.InboxSpec.Inbox_have_a_default_and_custom_timeouts: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Test_that_actor_cannot_call_receive_out_of_construction_and_become: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_an_EchoActor_When_receiving_messages_Then_messages_should_be_sent_back: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_actor_that_has_replaced_its_initial_handler_When_it_restarts_Then_uses_the_initial_handler: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_actor_that_has_pushed_a_new_handler_When_it_restarts_Then_uses_the_initial_handler: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_an_actor_which_uses_predicates_When_sending_different_messages_Then_correct_handler_should_be_invoked: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_an_actor_with_ReceiveAny_When_sending_different_messages_Then_correct_handler_should_be_invoked: <no details avaliable>

Akka.Tests.dll: Akka.Tests.Actor.ReceiveActorTests.Given_actor_When_it_calls_Become_Then_it_switches_handler: <no details avaliable>


##### there are 12 more failed tests, see build details

@Aaronontheweb
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, that's a major problem. Definitely broke something. Let me see what's up.

Please sign in to comment.