Skip to content

Commit

Permalink
Fix MaxCpuUsage placement strategy NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
grkvlt committed Dec 4, 2014
1 parent bfdaa75 commit b140003
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import brooklyn.config.ConfigKey;
import brooklyn.entity.basic.ConfigKeys;
import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.container.docker.DockerHost;
import brooklyn.entity.container.docker.DockerInfrastructure;
import brooklyn.location.docker.DockerHostLocation;
Expand Down Expand Up @@ -52,7 +53,10 @@ public boolean apply(DockerHostLocation input) {
}
if (maxCpu == null) maxCpu = DEFAULT_MAX_CPU_USAGE;

Boolean serviceUp = input.getOwner().getAttribute(SoftwareProcess.SERVICE_UP);
Double currentCpu = input.getOwner().getAttribute(DockerHost.CPU_USAGE);
if (!Boolean.TRUE.equals(serviceUp) || currentCpu == null) return false; // reject

boolean accept = currentCpu < maxCpu;
if (LOG.isDebugEnabled()) {
LOG.debug("Location {} CPU usage is {}: {}", new Object[] { input, currentCpu, accept ? "accepted" : "rejected" });
Expand Down

0 comments on commit b140003

Please sign in to comment.