Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Add CurrentMemoryLimit to IContainer #21

Merged
merged 1 commit into from Apr 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions IronFoundry.Container.Test/ContainerTests.cs
Expand Up @@ -505,6 +505,14 @@ public void WhenContainerNotActive_Throws()

Assert.Throws<InvalidOperationException>(action);
}

[Fact]
public void ReturnsMemoryLimit()
{
ulong limitInBytes = 2048;
JobObject.GetJobMemoryLimit().Returns(limitInBytes);
Assert.Equal(limitInBytes, Container.CurrentMemoryLimit());
}
}

public class RemoveProperty : ContainerTests
Expand Down
6 changes: 6 additions & 0 deletions IronFoundry.Container/Container.cs
Expand Up @@ -46,6 +46,7 @@ public interface IContainer : IDisposable
IContainerProcess Run(ProcessSpec spec, IProcessIO io);

void LimitMemory(ulong limitInBytes);
ulong CurrentMemoryLimit();

void SetProperty(string name, string value);
string GetProperty(string name);
Expand Down Expand Up @@ -170,6 +171,11 @@ public void LimitMemory(ulong limitInBytes)
this.jobObject.SetJobMemoryLimit(limitInBytes);
}

public ulong CurrentMemoryLimit()
{
return jobObject.GetJobMemoryLimit();
}

public void Destroy()
{
Stop(true);
Expand Down
5 changes: 5 additions & 0 deletions IronFoundry.Warden/Containers/ContainerStub.cs
Expand Up @@ -301,6 +301,11 @@ public void LimitMemory(LimitMemoryInfo info)
jobObjectLimits.LimitMemory(info.LimitInBytes);
}

public ulong CurrentMemoryLimit()
{
throw new NotImplementedException();
}

private void MemoryLimitReached(object sender, EventArgs e)
{
var handler = outOfMemoryHandler;
Expand Down