Skip to content

Commit

Permalink
Merge pull request #33 from petabridge/dev
Browse files Browse the repository at this point in the history
v0.2.6 Release
  • Loading branch information
Aaronontheweb authored Apr 14, 2019
2 parents e236906 + 804bebd commit 51e4a55
Show file tree
Hide file tree
Showing 61 changed files with 729 additions and 570 deletions.
5 changes: 2 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#### 0.2.5 April 14 2019 ####
* Upgraded to Akka.Cluster v1.3.12
* Upgraded to [Akka.HealthCheck.Cluster v0.2.1](https://github.com/petabridge/akkadotnet-healthcheck/releases/tag/0.2.1)
#### 0.2.6 April 14 2019 ####
* Lengthened throttling window on `DownloadCoordinator`
32 changes: 18 additions & 14 deletions src/Lighthouse/LighthouseHostFactory.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using System;
// -----------------------------------------------------------------------
// <copyright file="LighthouseHostFactory.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.IO;
using System.Linq;
using System.Net;
using Akka.Actor;
using Akka.Bootstrap.Docker;
using Akka.Configuration;
using WebCrawler.Shared.DevOps;
using ConfigurationException = Akka.Configuration.ConfigurationException;

namespace Lighthouse
{
/// <summary>
/// Launcher for the Lighthouse <see cref="ActorSystem"/>
/// Launcher for the Lighthouse <see cref="ActorSystem" />
/// </summary>
public static class LighthouseHostFactory
{
Expand All @@ -23,9 +26,7 @@ public static ActorSystem LaunchLighthouse()

var lighthouseConfig = clusterConfig.GetConfig("lighthouse");
if (lighthouseConfig != null && string.IsNullOrEmpty(systemName))
{
systemName = lighthouseConfig.GetString("actorsystem", systemName);
}

var ipAddress = clusterConfig.GetString("akka.remote.dot-netty.tcp.public-hostname");
var port = clusterConfig.GetInt("akka.remote.dot-netty.tcp.port");
Expand All @@ -36,7 +37,8 @@ public static ActorSystem LaunchLighthouse()
* Sanity check
*/
Console.WriteLine($"[Lighthouse] ActorSystem: {systemName}; IP: {ipAddress}; PORT: {port}");
Console.WriteLine("[Lighthouse] Performing pre-boot sanity check. Should be able to parse address [{0}]", selfAddress);
Console.WriteLine("[Lighthouse] Performing pre-boot sanity check. Should be able to parse address [{0}]",
selfAddress);
selfAddress = new Address("akka.tcp", systemName, ipAddress.Trim(), port).ToString();
Console.WriteLine("[Lighthouse] Parse successful.");

Expand All @@ -52,22 +54,24 @@ public static ActorSystem LaunchLighthouse()

if (seeds.Count > 1)
{
injectedClusterConfigString = seeds.Aggregate("akka.cluster.seed-nodes = [", (current, seed) => current + (@"""" + seed + @""", "));
injectedClusterConfigString = seeds.Aggregate("akka.cluster.seed-nodes = [",
(current, seed) => current + @"""" + seed + @""", ");
injectedClusterConfigString += "]";
}
else
{
injectedClusterConfigString = "akka.cluster.seed-nodes = [\""+ selfAddress +"\"]";
injectedClusterConfigString = "akka.cluster.seed-nodes = [\"" + selfAddress + "\"]";
}
}



var finalConfig = injectedClusterConfigString != null ? injectedClusterConfigString
.WithFallback(clusterConfig) : clusterConfig;
var finalConfig = injectedClusterConfigString != null
? injectedClusterConfigString
.WithFallback(clusterConfig)
: clusterConfig;

return ActorSystem.Create(systemName, finalConfig)
.StartPbm();
}
}
}
}
37 changes: 13 additions & 24 deletions src/Lighthouse/LighthouseService.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,34 @@
// Copyright 2014-2015 Aaron Stannard, Petabridge LLC
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// -----------------------------------------------------------------------
// <copyright file="LighthouseService.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster;
using Petabridge.Cmd.Cluster;
using Petabridge.Cmd.Host;

namespace Lighthouse
{
public class LighthouseService
{
private ActorSystem _lighthouseSystem;

public void Start()
{
_lighthouseSystem = LighthouseHostFactory.LaunchLighthouse();
}

/// <summary>
/// Task completes once the Lighthouse <see cref="ActorSystem"/> has terminated.
/// Task completes once the Lighthouse <see cref="ActorSystem" /> has terminated.
/// </summary>
/// <remarks>
/// Doesn't actually invoke termination. Need to call <see cref="StopAsync"/> for that.
/// Doesn't actually invoke termination. Need to call <see cref="StopAsync" /> for that.
/// </remarks>
public Task TerminationHandle => _lighthouseSystem.WhenTerminated;

public void Start()
{
_lighthouseSystem = LighthouseHostFactory.LaunchLighthouse();
}

public async Task StopAsync()
{
await CoordinatedShutdown.Get(_lighthouseSystem).Run();
}
}
}
}
18 changes: 10 additions & 8 deletions src/Lighthouse/Program.NetCore.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using System.Diagnostics;
// -----------------------------------------------------------------------
// <copyright file="Program.NetCore.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;

namespace Lighthouse
{
Expand All @@ -16,11 +21,8 @@ public static void Main(string[] args)
await lighthouseService.StopAsync();
};

Console.CancelKeyPress += async (sender, eventArgs) =>
{
await lighthouseService.StopAsync();
};
lighthouseService.TerminationHandle.Wait();
Console.CancelKeyPress += async (sender, eventArgs) => { await lighthouseService.StopAsync(); };
lighthouseService.TerminationHandle.Wait();
}
}
}
}
12 changes: 7 additions & 5 deletions src/WebCrawler.CrawlService/CrawlerService.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
// -----------------------------------------------------------------------
// <copyright file="CrawlerService.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System.Threading.Tasks;
using Akka.Actor;
using Akka.Bootstrap.Docker;
using WebCrawler.Shared.Config;
using WebCrawler.Shared.DevOps;

Expand All @@ -28,4 +30,4 @@ public async Task Stop()
await CoordinatedShutdown.Get(ClusterSystem).Run(CoordinatedShutdown.ClrExitReason.Instance);
}
}
}
}
14 changes: 10 additions & 4 deletions src/WebCrawler.CrawlService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
using System;
// -----------------------------------------------------------------------
// <copyright file="Program.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;

namespace WebCrawler.CrawlService
{
class Program
internal class Program
{
static void Main(string[] args)
private static void Main(string[] args)
{
var crawlerService = new CrawlerService();
crawlerService.Start();
Expand All @@ -23,4 +29,4 @@ static void Main(string[] args)
crawlerService.WhenTerminated.Wait();
}
}
}
}
15 changes: 11 additions & 4 deletions src/WebCrawler.Shared.DevOps.Tests/ActorSystemStartupSpecs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
using System;
// -----------------------------------------------------------------------
// <copyright file="ActorSystemStartupSpecs.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using Akka.Actor;
Expand All @@ -7,7 +13,6 @@
using Akka.HealthCheck.Liveness;
using Akka.HealthCheck.Readiness;
using Akka.TestKit.Xunit2;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -16,7 +21,9 @@ namespace WebCrawler.Shared.DevOps.Tests
public class ActorSystemStartupSpecs : TestKit
{
public ActorSystemStartupSpecs(ITestOutputHelper helper)
: base(Akka.Configuration.Config.Empty.ApplyOpsConfig(), output: helper) { }
: base(Akka.Configuration.Config.Empty.ApplyOpsConfig(), output: helper)
{
}

[Fact(DisplayName = "Instrumented ActorSystem should start HealthChecks automatically")]
public void ActorSystem_should_start_HealthChecks_automatically()
Expand Down Expand Up @@ -46,4 +53,4 @@ public void ActorSystem_should_start_HealthChecks_automatically()
//AkkaHealthCheck.For(Sys).ReadinessProvider.Should().BeOfType<ClusterReadinessProbeProvider>();
}
}
}
}
8 changes: 7 additions & 1 deletion src/WebCrawler.Shared.DevOps.Tests/Config/OpsConfigSpec.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// -----------------------------------------------------------------------
// <copyright file="OpsConfigSpec.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using FluentAssertions;
using WebCrawler.Shared.DevOps.Config;
using Xunit;
Expand All @@ -13,4 +19,4 @@ public void Should_load_default_OpsConfig()
config.Should().NotBeNull();
}
}
}
}
36 changes: 20 additions & 16 deletions src/WebCrawler.Shared.DevOps/Config/OpsConfig.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
// -----------------------------------------------------------------------
// <copyright file="OpsConfig.cs" company="Petabridge, LLC">
// Copyright (C) 2015 - 2019 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------

using System;
using Akka.Configuration;

namespace WebCrawler.Shared.DevOps.Config
{
/// <summary>
/// Holder for shared configuration data used by all WebCrawler services
/// Holder for shared configuration data used by all WebCrawler services
/// </summary>
public class OpsConfig
{
/// <summary>
/// Name of the <see cref="Environment"/> variable used to look for Phobos
/// Name of the <see cref="Environment" /> variable used to look for Phobos
/// </summary>
public const string PHOBOS_ENABLED = "PHOBOS_ENABLED";

/// <summary>
/// Name of the <see cref="Environment"/> variable used to direct Phobos' StatsD
/// output.
/// Name of the <see cref="Environment" /> variable used to direct Phobos' StatsD
/// output.
/// </summary>
public const string STATSD_URL = "STATSD_URL";

/// <summary>
/// Name of the <see cref="Environment"/> variable used to direct Phobos' StatsD
/// output.
/// Name of the <see cref="Environment" /> variable used to direct Phobos' StatsD
/// output.
/// </summary>
public const string STATSD_PORT = "STATSD_PORT";

Expand All @@ -34,17 +38,17 @@ public static Akka.Configuration.Config GetOpsConfig()

public static Akka.Configuration.Config GetPhobosConfig()
{

var rawPhobosConfig = ConfigurationFactory.FromResource<OpsConfig>("WebCrawler.Shared.DevOps.Config.crawler.Phobos.conf");
var rawPhobosConfig =
ConfigurationFactory.FromResource<OpsConfig>("WebCrawler.Shared.DevOps.Config.crawler.Phobos.conf");
var statsdUrl = Environment.GetEnvironmentVariable(STATSD_URL);
var statsDPort = Environment.GetEnvironmentVariable(STATSD_PORT);
if (!string.IsNullOrEmpty(statsdUrl) && int.TryParse(statsDPort, out var portNum))
{
return ConfigurationFactory.ParseString($"phobos.monitoring.statsd.endpoint=\"{statsdUrl}\"" + Environment.NewLine +
$"phobos.monitoring.statsd.port={portNum}").WithFallback(rawPhobosConfig);
}
return ConfigurationFactory.ParseString($"phobos.monitoring.statsd.endpoint=\"{statsdUrl}\"" +
Environment.NewLine +
$"phobos.monitoring.statsd.port={portNum}")
.WithFallback(rawPhobosConfig);

return rawPhobosConfig;
}
}
}
}
Loading

0 comments on commit 51e4a55

Please sign in to comment.