Permalink
Browse files

V1.9.0 add memory to taint calc. Update dea.advertise message.

  • Loading branch information...
1 parent 3b903ea commit e7495b3311b7fe13801a6c67f61789e1fce83b58 @lukebakken lukebakken committed Oct 18, 2012
View
@@ -5,7 +5,7 @@ setlocal
set VCVARSALL="C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
set SLN="%~dp0\IronFoundry.sln"
-set VERSION=1.8.0
+set VERSION=1.9.0
set NOCLEAN=0
if /i "%1"=="NOCLEAN" set NOCLEAN=1
View
@@ -1,8 +1,8 @@
-get-childitem src -include bin,obj -recurse | where { $_.psIsContainer -eq $true } | foreach ($_) {
- write-host -foregroundcolor 'yellow' "Removing: $_"
- remove-item $_ -recurse -force
-}
-get-childitem test -include bin,obj -recurse | where { $_.psIsContainer -eq $true } | foreach ($_) {
- write-host -foregroundcolor 'yellow' "Removing: $_"
- remove-item $_ -recurse -force
-}
+get-childitem src -include bin,obj -recurse | where { $_.psIsContainer -eq $true } | foreach ($_) {
+ write-host -foregroundcolor 'yellow' "Removing: $_"
+ remove-item $_ -recurse -force
+}
+get-childitem test -include bin,obj -recurse | where { $_.psIsContainer -eq $true } | foreach ($_) {
+ write-host -foregroundcolor 'yellow' "Removing: $_"
+ remove-item $_ -recurse -force
+}
@@ -11,7 +11,7 @@
Set localRoute to a value other than 127.0.0.1 if you have multiple NICs and are not sending the correct IP to the Nats Host (unlikely)
natsUser and natsPassword attributes must be present even if empty for installer to work.
-->
- <ironFoundryDea natsHost="10.91.2.37"
+ <ironFoundryDea natsHost="172.21.114.11"
natsPort="4222"
natsUser="nats"
natsPassword="nats"
@@ -39,6 +39,7 @@ public sealed class Agent : IAgent
private bool shutting_down = false;
private ushort maxMemoryMB;
+ private ushort reservedMemoryMB;
private VcapComponentDiscover discoverMessage;
@@ -224,6 +225,8 @@ private void ProcessDeaStart(string message, string reply)
dropletManager.Add(droplet.ID, instance);
TakeSnapshot();
+
+ reservedMemoryMB += instance.MemQuotaMB;
}
}
}
@@ -269,6 +272,10 @@ private void ProcessDeaLocate(string message, string reply)
private void ProcessDeaDiscover(string message, string reply)
{
+ const ushort TaintMsPerApp = 10;
+ const ushort TaintMsForMem = 100;
+ const ushort TaintMaxDelay = 250;
+
if (shutting_down)
{
return;
@@ -282,9 +289,12 @@ private void ProcessDeaDiscover(string message, string reply)
uint delay = 0;
dropletManager.ForAllInstances(discover.DropletID, (instance) =>
{
- delay += 10; // NB: 10 milliseconds delay per app
+ delay += TaintMsPerApp;
});
- messagingProvider.Publish(reply, helloMessage, Math.Min(delay, 250));
+
+ float memPercent = reservedMemoryMB / ((float)maxMemoryMB);
+ delay += (ushort)(memPercent * TaintMsForMem);
+ messagingProvider.Publish(reply, helloMessage, Math.Min(delay, TaintMaxDelay));
}
else
{
@@ -311,6 +321,7 @@ private void ProcessDeaStop(string message, string reply)
{
instance.OnDeaStop();
StopDroplet(instance);
+ reservedMemoryMB -= instance.MemQuotaMB;
}
});
}
@@ -536,7 +547,8 @@ private void SendAdvertise()
{
return;
}
- var message = new Advertise(messagingProvider.UniqueIdentifier, 4096, 0, true); // TODO mem
+ ushort availableMemoryMB = (ushort)(maxMemoryMB - reservedMemoryMB);
+ var message = new Advertise(messagingProvider.UniqueIdentifier, availableMemoryMB, true);
messagingProvider.Publish(message);
}
@@ -585,6 +597,8 @@ private void RecoverExistingDroplets()
dropletManager.FromSnapshot(snapshot);
SendHeartbeat();
TakeSnapshot();
+ reservedMemoryMB = 0;
+ dropletManager.ForAllInstances((instance) => reservedMemoryMB += instance.MemQuotaMB);
}
}
@@ -295,6 +295,7 @@ private class MessageTimer : Timer
public MessageTimer(uint delay, string message) : base(delay)
{
+ this.AutoReset = false;
this.message = message;
}
@@ -321,7 +322,7 @@ private void DoPublish(string subject, Message message, uint delay = 0)
}
else
{
- var delayTimer = new MessageTimer(delay, formattedMessage) { AutoReset = false };
+ var delayTimer = new MessageTimer(delay, formattedMessage);
delayTimer.Elapsed += DelayedPublishElapsedHandler;
delayTimer.Enabled = true;
}
@@ -20,24 +20,20 @@ public override string PublishSubject
[JsonProperty(PropertyName = "available_memory")]
public uint AvailableMemory { get; private set; }
- [JsonProperty(PropertyName = "currently_pending")]
- public ushort CurrentlyPending { get; private set; }
-
- [JsonProperty(PropertyName = "ready")]
- public bool Ready { get; private set; }
-
[JsonProperty(PropertyName = "runtimes")]
public string[] Runtimes
{
get { return Constants.SupportedRuntimes; }
}
- public Advertise(Guid id, uint availableMemory, ushort currentlyPending, bool ready)
+ [JsonProperty(PropertyName = "prod")]
+ public bool Prod { get; private set; }
+
+ public Advertise(Guid id, uint availableMemory, bool prod)
{
- this.ID = id;
- this.AvailableMemory = availableMemory;
- this.CurrentlyPending = currentlyPending;
- this.Ready = ready;
+ this.ID = id;
+ this.AvailableMemory = availableMemory;
+ this.Prod = prod;
}
}
}
@@ -99,6 +99,12 @@ public DateTime StartDate
[JsonProperty(PropertyName = "mem_quota")]
public uint MemQuotaBytes { get; set; }
+ [JsonIgnore]
+ public ushort MemQuotaMB
+ {
+ get { return (ushort)(MemQuotaBytes / (1024 * 1024)); }
+ }
+
[JsonProperty(PropertyName = "disk_quota")]
public uint DiskQuotaBytes { get; set; }
@@ -8,5 +8,5 @@
[assembly: AssemblyDescription("https://github.com/IronFoundry/ironfoundry")]
[assembly: AssemblyProduct("Iron Foundry")]
[assembly: AssemblyTrademark("Iron Foundry")]
-[assembly: AssemblyFileVersion("1.8.0.0")]
-[assembly: AssemblyVersion("1.8.0.0")]
+[assembly: AssemblyFileVersion("1.9.0.0")]
+[assembly: AssemblyVersion("1.9.0.0")]

0 comments on commit e7495b3

Please sign in to comment.