Skip to content

Commit

Permalink
Merge pull request #12195 from Mak-Sym/per_node_cap_compatibility
Browse files Browse the repository at this point in the history
Fixing backward compatibility issue for PER_NODE capacity calculation algorithm
  • Loading branch information
pveentjer committed Apr 10, 2018
2 parents 5d04999 + 5db8dba commit 6a2e584
Showing 1 changed file with 12 additions and 8 deletions.
Expand Up @@ -53,6 +53,7 @@
public class EvictionChecker {

protected static final double ONE_HUNDRED_PERCENT = 100D;
private static final int MIN_SANE_PER_PARTITION_SIZE = 2;

protected final ILogger logger;
protected final MapServiceContext mapServiceContext;
Expand Down Expand Up @@ -123,14 +124,17 @@ public double translatePerNodeSizeToRecordStoreSize(RecordStore recordStore) {
int memberCount = nodeEngine.getClusterService().getSize(DATA_MEMBER_SELECTOR);
int partitionCount = nodeEngine.getPartitionService().getPartitionCount();

final double perNodeMaxRecordStoreSize = (1D * configuredMaxSize * memberCount / partitionCount);
if (perNodeMaxRecordStoreSize < 1
&& misconfiguredPerNodeMaxSizeWarningLogged.compareAndSet(false, true)) {
int minMaxSize = (int) Math.ceil((1D * partitionCount / memberCount));
String msg = "The max size configuration for map '%s' does not allow "
+ " any data in the map. Given the current cluster size of %d "
+ "members with %d partitions, max size should be at least %d.";
logger.warning(format(msg, mapConfig.getName(), memberCount, partitionCount, minMaxSize));
double perNodeMaxRecordStoreSize = (1D * configuredMaxSize * memberCount / partitionCount);
if (perNodeMaxRecordStoreSize < 1) {
perNodeMaxRecordStoreSize = MIN_SANE_PER_PARTITION_SIZE;
if (misconfiguredPerNodeMaxSizeWarningLogged.compareAndSet(false, true)) {
int minMaxSize = (int) Math.ceil((1D * partitionCount / memberCount));
int newSize = MIN_SANE_PER_PARTITION_SIZE * partitionCount / memberCount;
logger.warning(format("The max size configuration for map \"%s\" does not allow any data in the map. "
+ "Given the current cluster size of %d members with %d partitions, max size should be at "
+ "least %d. Map size is forced set to %d for backward compatibility", mapConfig.getName(),
memberCount, partitionCount, minMaxSize, newSize));
}
}
return perNodeMaxRecordStoreSize;
}
Expand Down

0 comments on commit 6a2e584

Please sign in to comment.