You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2019/04/30 17:16:56 UTC
[geode] branch develop updated: GEODE-6673: remove unneeded HashSet
creations (#3517)
This is an automated email from the ASF dual-hosted git repository.
dschneider pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 76c98e8 GEODE-6673: remove unneeded HashSet creations (#3517)
76c98e8 is described below
commit 76c98e8cae602fded710f7c05caaaf5d669b8745
Author: Darrel Schneider <ds...@pivotal.io>
AuthorDate: Tue Apr 30 10:16:34 2019 -0700
GEODE-6673: remove unneeded HashSet creations (#3517)
no longer allocates unneeded HashSet instances in _distribute() method
---
.../internal/cache/DistributedCacheOperation.java | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
index e22cdac..1699a7b 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedCacheOperation.java
@@ -390,7 +390,7 @@ public abstract class DistributedCacheOperation {
Set cachelessNodes = Collections.emptySet();
Set adviseCacheServers;
- Set<InternalDistributedMember> cachelessNodesWithNoCacheServer = new HashSet<>();
+ Set<InternalDistributedMember> cachelessNodesWithNoCacheServer = Collections.emptySet();
if (region.getDistributionConfig().getDeltaPropagation() && this.supportsDeltaPropagation()) {
cachelessNodes = region.getCacheDistributionAdvisor().adviseEmptys();
if (!cachelessNodes.isEmpty()) {
@@ -405,10 +405,11 @@ public abstract class DistributedCacheOperation {
recipients.removeAll(list);
cachelessNodes.addAll(list);
}
-
- cachelessNodesWithNoCacheServer.addAll(cachelessNodes);
- adviseCacheServers = region.getCacheDistributionAdvisor().adviseCacheServers();
- cachelessNodesWithNoCacheServer.removeAll(adviseCacheServers);
+ if (!cachelessNodes.isEmpty()) {
+ cachelessNodesWithNoCacheServer = new HashSet<>(cachelessNodes);
+ adviseCacheServers = region.getCacheDistributionAdvisor().adviseCacheServers();
+ cachelessNodesWithNoCacheServer.removeAll(adviseCacheServers);
+ }
}
if (recipients.isEmpty() && adjunctRecipients.isEmpty() && needsOldValueInCacheOp.isEmpty()
@@ -595,7 +596,7 @@ public abstract class DistributedCacheOperation {
}
}
- if (cachelessNodesWithNoCacheServer.size() > 0) {
+ if (!cachelessNodesWithNoCacheServer.isEmpty()) {
msg.resetRecipients();
msg.setRecipients(cachelessNodesWithNoCacheServer);
msg.setSendDelta(false);
@@ -608,17 +609,16 @@ public abstract class DistributedCacheOperation {
failures = newFailures;
}
}
+ // Add it back for size calculation ahead
+ cachelessNodes.addAll(cachelessNodesWithNoCacheServer);
}
- // Add it back for size calculation ahead
- cachelessNodes.addAll(cachelessNodesWithNoCacheServer);
}
if (failures != null && !failures.isEmpty() && logger.isDebugEnabled()) {
logger.debug("Failed sending ({}) to {} while processing event:{}", msg, failures, event);
}
- Set<InternalDistributedMember> adjunctRecipientsWithNoCacheServer =
- new HashSet<InternalDistributedMember>();
+ Set<InternalDistributedMember> adjunctRecipientsWithNoCacheServer = Collections.emptySet();
// send partitioned region listener notification messages now
if (!adjunctRecipients.isEmpty()) {
if (cachelessNodes.size() > 0) {
@@ -630,8 +630,7 @@ public abstract class DistributedCacheOperation {
recipients.addAll(cachelessNodes);
}
}
-
- adjunctRecipientsWithNoCacheServer.addAll(adjunctRecipients);
+ adjunctRecipientsWithNoCacheServer = new HashSet<>(adjunctRecipients);
adviseCacheServers = ((Bucket) region).getPartitionedRegion()
.getCacheDistributionAdvisor().adviseCacheServers();
adjunctRecipientsWithNoCacheServer.removeAll(adviseCacheServers);