Skip to content

Commit

Permalink
Add handling for custom host name (QuantConnect#5043)
Browse files Browse the repository at this point in the history
* Add handling for custom host name

* Credit cost as decimal
  • Loading branch information
Martin-Molinero authored Dec 17, 2020
1 parent 8e410fc commit 6d824b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Common/Packets/AlgorithmNodePacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public AlgorithmNodePacket(PacketType type)
: base(type)
{ }

/// <summary>
/// The host name to use if any
/// </summary>
[JsonProperty(PropertyName = "sHostName")]
public string HostName;

/// <summary>
/// User Id placing request
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Common/Packets/Controls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public class Controls
/// <summary>
/// The cost associated with running this job
/// </summary>
[JsonProperty(PropertyName = "iCreditCost")]
public uint CreditCost;
[JsonProperty(PropertyName = "dCreditCost")]
public decimal CreditCost;

/// <summary>
/// Initializes a new default instance of the <see cref="Controls"/> class
Expand Down
4 changes: 4 additions & 0 deletions Engine/Results/BaseResultsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public abstract class BaseResultsHandler
private static readonly TextWriter StandardOut = Console.Out;
private static readonly TextWriter StandardError = Console.Error;

private string _hostName;

/// <summary>
/// The main loop update interval
/// </summary>
Expand Down Expand Up @@ -232,6 +234,7 @@ public virtual void Exit()
protected virtual Dictionary<string, string> GetServerStatistics(DateTime utcNow)
{
var serverStatistics = OS.GetServerStatistics();
serverStatistics["Hostname"] = _hostName;
var upTime = utcNow - StartTime;
serverStatistics["Up Time"] = $"{upTime.Days}d {upTime:hh\\:mm\\:ss}";
serverStatistics["Total RAM (MB)"] = RamAllocation;
Expand Down Expand Up @@ -305,6 +308,7 @@ protected virtual Dictionary<int, Order> GetDeltaOrders(int orderEventsStartPosi
/// <param name="transactionHandler">The transaction handler used to get the algorithms <see cref="Order"/> information</param>
public virtual void Initialize(AlgorithmNodePacket job, IMessagingHandler messagingHandler, IApi api, ITransactionHandler transactionHandler)
{
_hostName = job.HostName ?? Environment.MachineName;
MessagingHandler = messagingHandler;
TransactionHandler = transactionHandler;
CompileId = job.CompileId;
Expand Down

0 comments on commit 6d824b4

Please sign in to comment.