Skip to content

Commit

Permalink
Fixed issue with previous pull request. Added health indicator for ph…
Browse files Browse the repository at this point in the history
…ysical memory used on the instance. Also mark the service out-of-service if it crosses the threshold. (#315)
  • Loading branch information
ajoymajumdar committed Jul 16, 2016
1 parent b501fb4 commit 70ae5f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
Expand Up @@ -51,7 +51,6 @@
import com.netflix.genie.core.services.impl.MailServiceImpl;
import com.netflix.genie.core.services.impl.RandomizedClusterLoadBalancerImpl;
import com.netflix.spectator.api.Registry;
import com.sun.management.OperatingSystemMXBean;
import org.apache.commons.exec.Executor;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -64,7 +63,6 @@
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.mail.javamail.JavaMailSender;

import java.lang.management.ManagementFactory;
import java.util.List;

/**
Expand Down Expand Up @@ -343,14 +341,4 @@ public JobCoordinatorService jobCoordinatorService(
eventPublisher
);
}

/**
* Returns the operating system MX bean.
*
* @return The operating system MX bean.
*/
@Bean
public OperatingSystemMXBean operatingSystemMXBean() {
return (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
}
}
Expand Up @@ -21,6 +21,8 @@
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

import java.lang.management.ManagementFactory;

/**
* Health indicator for system memory usage. Also mark the service out-of-service if it crosses the threshold.
* @author amajumdar
Expand All @@ -39,14 +41,17 @@ public class MemoryHealthIndicator implements HealthIndicator {
* Constructor.
*
* @param maxUsedPhysicalMemoryPercentage The maximum physical memory threshold
* @param operatingSystemMXBean MX bean for operating system
*/
@Autowired
public MemoryHealthIndicator(
@Value("${genie.health.memory.usedPhysicalMemoryPercent:90}")
final double maxUsedPhysicalMemoryPercentage,
final OperatingSystemMXBean operatingSystemMXBean
final double maxUsedPhysicalMemoryPercentage
) {
this(maxUsedPhysicalMemoryPercentage, (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean());
}

MemoryHealthIndicator(final double maxUsedPhysicalMemoryPercentage,
final OperatingSystemMXBean operatingSystemMXBean) {
this.maxUsedPhysicalMemoryPercentage = maxUsedPhysicalMemoryPercentage;
this.operatingSystemMXBean = operatingSystemMXBean;
}
Expand Down

0 comments on commit 70ae5f7

Please sign in to comment.