Skip to content

Commit

Permalink
STORM-2859: Fix a number of issues with NormalizedResources when reso…
Browse files Browse the repository at this point in the history
…urce totals are zero
  • Loading branch information
srdo committed Jan 4, 2018
1 parent 873028b commit 8aae491
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ public static boolean downloadUpdatedBlob(Map<String, Object> conf, BlobStore bl
// Catching and logging KeyNotFoundException because, if
// there is a subsequent update and delete, the non-leader
// nimbodes might throw an exception.
LOG.info("KeyNotFoundException {}", knf);
LOG.info("KeyNotFoundException", knf);
} catch (Exception exp) {
// Logging an exception while client is connecting
LOG.error("Exception {}", exp);
LOG.error("Exception", exp);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,25 @@ public class NormalizedResourceOffer extends NormalizedResources {
private double totalMemory;

/**
* Create a new normalized set of resources. Note that memory is not covered here becasue it is not consistent in requests vs offers
* Create a new normalized set of resources. Note that memory is not covered here because it is not consistent in requests vs offers
* because of how on heap vs off heap is used.
*
* @param resources the resources to be normalized.
*/
public NormalizedResourceOffer(Map<String, ? extends Number> resources) {
super(resources, null);
totalMemory = getNormalizedResources().getOrDefault(Constants.COMMON_TOTAL_MEMORY_RESOURCE_NAME, 0.0);
}

public NormalizedResourceOffer() {
super(null, null);
this((Map<String, ? extends Number>)null);
}

public NormalizedResourceOffer(NormalizedResourceOffer other) {
super(other);
this.totalMemory = other.totalMemory;
}

@Override
protected void initializeMemory(Map<String, Double> normalizedResources) {
totalMemory = normalizedResources.getOrDefault(Constants.COMMON_TOTAL_MEMORY_RESOURCE_NAME, 0.0);
}

@Override
public double getTotalMemoryMb() {
return totalMemory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private static Map<String, Double> parseResources(String input) {
private double offHeap;

/**
* Create a new normalized set of resources. Note that memory is not covered here becasue it is not consistent in requests vs offers
* Create a new normalized set of resources. Note that memory is not covered here because it is not consistent in requests vs offers
* because of how on heap vs off heap is used.
*
* @param resources the resources to be normalized.
Expand All @@ -119,6 +119,7 @@ private static Map<String, Double> parseResources(String input) {
private NormalizedResourceRequest(Map<String, ? extends Number> resources,
Map<String, Object> topologyConf) {
super(resources, getDefaultResources(topologyConf));
initializeMemory(getNormalizedResources());
}

public NormalizedResourceRequest(ComponentCommon component, Map<String, Object> topoConf) {
Expand All @@ -131,6 +132,7 @@ public NormalizedResourceRequest(Map<String, Object> topoConf) {

public NormalizedResourceRequest() {
super(null, null);
initializeMemory(getNormalizedResources());
}

@Override
Expand All @@ -141,8 +143,7 @@ public Map<String,Double> toNormalizedMap() {
return ret;
}

@Override
protected void initializeMemory(Map<String, Double> normalizedResources) {
private void initializeMemory(Map<String, Double> normalizedResources) {
onHeap = normalizedResources.getOrDefault(Constants.COMMON_ONHEAP_MEMORY_RESOURCE_NAME, 0.0);
offHeap = normalizedResources.getOrDefault(Constants.COMMON_OFFHEAP_MEMORY_RESOURCE_NAME, 0.0);
}
Expand Down
Loading

0 comments on commit 8aae491

Please sign in to comment.