Repository: reef Updated Branches: refs/heads/master bd617bd4f -> 9aaa65ec6
[REEF-1817] Port PerformanceCounters to a CoreCLR-Compliant System This addressed the issue by * Using performance counters only in the 4.5.1 build * Leaving DotNet Core performance monitoring unsupported for now JIRA: [REEF-1817](https://issues.apache.org/jira/browse/REEF-1817) Pull request: This closes #1335 Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/9aaa65ec Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/9aaa65ec Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/9aaa65ec Branch: refs/heads/master Commit: 9aaa65ec68c5b2eae76d46b1a3f3a78d567b7868 Parents: bd617bd Author: roganc <[email protected]> Authored: Wed Jul 19 15:05:55 2017 -0700 Committer: Markus Weimer <[email protected]> Committed: Wed Aug 2 16:18:40 2017 -0700 ---------------------------------------------------------------------- .../Runtime/MachineStatus.cs | 31 +++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/9aaa65ec/lang/cs/Org.Apache.REEF.Common/Runtime/MachineStatus.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Common/Runtime/MachineStatus.cs b/lang/cs/Org.Apache.REEF.Common/Runtime/MachineStatus.cs index c6ee2b6..6c78477 100644 --- a/lang/cs/Org.Apache.REEF.Common/Runtime/MachineStatus.cs +++ b/lang/cs/Org.Apache.REEF.Common/Runtime/MachineStatus.cs @@ -24,6 +24,10 @@ namespace Org.Apache.REEF.Common.Runtime { public class MachineStatus { +#if DOTNET_BUILD + private const string NotSupportedValue = "<UNSUPPORTED>"; + private const string NotSupportedMessage = "Machine Status is not supported on this OS"; +#else private static readonly PerformanceCounter CpuCounter; private static readonly PerformanceCounter RamCounter; @@ -60,12 +64,17 @@ namespace Org.Apache.REEF.Common.Runtime InstanceName = processName }; } +#endif public static string CurrentNodeCpuUsage { get { +#if DOTNET_BUILD + return NotSupportedValue + "%"; +#else return CpuCounter.NextValue() + "%"; +#endif } } @@ -73,7 +82,11 @@ namespace Org.Apache.REEF.Common.Runtime { get { - return RamCounter.NextValue() + "MB"; +#if DOTNET_BUILD + return NotSupportedValue + "MB"; +#else + return RamCounter.NextValue() + "MB"; +#endif } } @@ -81,7 +94,11 @@ namespace Org.Apache.REEF.Common.Runtime { get { +#if DOTNET_BUILD + return NotSupportedValue + "MB"; +#else return ((float)Process.WorkingSet64 / 1000000.0).ToString(CultureInfo.InvariantCulture) + "MB"; +#endif } } @@ -89,7 +106,11 @@ namespace Org.Apache.REEF.Common.Runtime { get { +#if DOTNET_BUILD + return NotSupportedValue + "MB"; +#else return ((float)Process.PeakWorkingSet64 / 1000000.0).ToString(CultureInfo.InvariantCulture) + "MB"; +#endif } } @@ -98,12 +119,19 @@ namespace Org.Apache.REEF.Common.Runtime { get { +#if DOTNET_BUILD + return NotSupportedValue + "MB"; +#else return ((float)ProcessCpuCounter.RawValue / 1000000.0) + "%"; +#endif } } public override string ToString() { +#if DOTNET_BUILD + return NotSupportedMessage; +#else string info = "No machine status information retrieved. Could be due to lack of admin right to get the info."; if (_checkStatus) { @@ -131,6 +159,7 @@ namespace Org.Apache.REEF.Common.Runtime } return info; +#endif } } }
