This is an automated email from the ASF dual-hosted git repository. prhomberg pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git
commit b033979a44819b4a1c4125396c207c7cd5ab0348 Author: Patrick Rhomberg <[email protected]> AuthorDate: Tue Nov 28 15:54:27 2017 -0800 GEODE-3955: Preparing, refactoring, and addition of test utility * Cleanup of DescribeRegionCommand for better readability and testability. * Flattened unnecessarily-nested logic blocks * Removed dead class fields from RegionDescription, RegionAttributesDefault * GetRegionDescriptionFunction implements Function instead of extending deprecated FunctionAdapter * Added waitTilGatewaySendersAreReady to MemberVM, MemberStarterRule --- .../internal/cli/commands/CreateRegionCommand.java | 2 +- .../cli/commands/DescribeRegionCommand.java | 225 +++++++++------------ .../internal/cli/commands/GfshCommand.java | 2 +- .../internal/cli/domain/RegionAttributesInfo.java | 8 +- .../internal/cli/domain/RegionDescription.java | 115 ++++------- .../functions/GetRegionDescriptionFunction.java | 5 +- .../internal/cli/util/RegionAttributesDefault.java | 14 -- .../apache/geode/test/dunit/rules/MemberVM.java | 25 ++- .../geode/test/junit/rules/MemberStarterRule.java | 6 + 9 files changed, 168 insertions(+), 234 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java index 732ca09..889107c 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java @@ -299,7 +299,7 @@ public class CreateRegionCommand implements GfshCommand { if (!specifiedGatewaySenders.isEmpty()) { return ResultBuilder.createUserErrorResult(CliStrings.format( CliStrings.CREATE_REGION__MSG__SPECIFY_VALID_GATEWAYSENDER_ID_UNKNOWN_0, - new Object[] {gatewaySenderIds})); + gatewaySenderIds)); } } } diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeRegionCommand.java index ebbdb6c..971f54e 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeRegionCommand.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/DescribeRegionCommand.java @@ -15,7 +15,6 @@ package org.apache.geode.management.internal.cli.commands; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -55,153 +54,129 @@ public class DescribeRegionCommand implements GfshCommand { @CliOption(key = CliStrings.DESCRIBE_REGION__NAME, optionContext = ConverterHint.REGION_PATH, help = CliStrings.DESCRIBE_REGION__NAME__HELP, mandatory = true) String regionName) { - Result result; - InternalCache cache = getCache(); ResultCollector<?, ?> rc = - CliUtil.executeFunction(getRegionDescription, regionName, CliUtil.getAllMembers(cache)); + CliUtil.executeFunction(getRegionDescription, regionName, getAllNormalMembers(cache)); List<?> resultList = (List<?>) rc.getResult(); - // The returned result could be a region description with per member and /or single local - // region - Object[] results = resultList.toArray(); - List<RegionDescription> regionDescriptionList = new ArrayList<>(); - - for (int i = 0; i < results.length; i++) { - - if (results[i] instanceof RegionDescriptionPerMember) { - RegionDescriptionPerMember regionDescPerMember = (RegionDescriptionPerMember) results[i]; - - if (regionDescPerMember != null) { - RegionDescription regionDescription = new RegionDescription(); - regionDescription.add(regionDescPerMember); - - for (int j = i + 1; j < results.length; j++) { - if (results[j] != null && results[j] instanceof RegionDescriptionPerMember) { - RegionDescriptionPerMember preyRegionDescPerMember = - (RegionDescriptionPerMember) results[j]; - if (regionDescription.add(preyRegionDescPerMember)) { - results[j] = null; - } - } - } - regionDescriptionList.add(regionDescription); - } - } else if (results[i] instanceof Throwable) { - Throwable t = (Throwable) results[i]; - LogWrapper.getInstance().info(t.getMessage(), t); + // Log any errors received. + resultList.stream().filter(Throwable.class::isInstance).map(Throwable.class::cast) + .forEach(t -> LogWrapper.getInstance().info(t.getMessage(), t)); + + // Aggregate PerMember data to to a single RegionDescription + RegionDescription regionDescription = new RegionDescription(); + resultList.stream().filter(RegionDescriptionPerMember.class::isInstance) + .map(RegionDescriptionPerMember.class::cast).forEach(regionDescription::add); + + // No point in displaying the scope for PR's + if (regionDescription.isPartition()) { + regionDescription.getCndRegionAttributes().remove(RegionAttributesNames.SCOPE); + } else { + String scope = regionDescription.getCndRegionAttributes().get(RegionAttributesNames.SCOPE); + if (scope != null) { + scope = scope.toLowerCase().replace('_', '-'); + regionDescription.getCndRegionAttributes().put(RegionAttributesNames.SCOPE, scope); } } - if (regionDescriptionList.isEmpty()) { + return buildDescriptionResult(regionName, regionDescription); + } + + public Result buildDescriptionResult(String regionName, RegionDescription regionDescription) { + if (regionDescription.isEmpty()) { return ResultBuilder .createUserErrorResult(CliStrings.format(CliStrings.REGION_NOT_FOUND, regionName)); } CompositeResultData crd = ResultBuilder.createCompositeResultData(); + CompositeResultData.SectionResultData regionSection = crd.addSection(); + regionSection.addSeparator('-'); + regionSection.addData("Name", regionDescription.getName()); - for (RegionDescription regionDescription : regionDescriptionList) { - // No point in displaying the scope for PR's - if (regionDescription.isPartition()) { - regionDescription.getCndRegionAttributes().remove(RegionAttributesNames.SCOPE); - } else { - String scope = regionDescription.getCndRegionAttributes().get(RegionAttributesNames.SCOPE); - if (scope != null) { - scope = scope.toLowerCase().replace('_', '-'); - regionDescription.getCndRegionAttributes().put(RegionAttributesNames.SCOPE, scope); - } - } - CompositeResultData.SectionResultData regionSection = crd.addSection(); - regionSection.addSeparator('-'); - regionSection.addData("Name", regionDescription.getName()); - - String dataPolicy = - regionDescription.getDataPolicy().toString().toLowerCase().replace('_', ' '); - regionSection.addData("Data Policy", dataPolicy); + String dataPolicy = + regionDescription.getDataPolicy().toString().toLowerCase().replace('_', ' '); + regionSection.addData("Data Policy", dataPolicy); - String memberType; + String memberType; - if (regionDescription.isAccessor()) { - memberType = CliStrings.DESCRIBE_REGION__ACCESSOR__MEMBER; - } else { - memberType = CliStrings.DESCRIBE_REGION__HOSTING__MEMBER; - } - regionSection.addData(memberType, - CliUtil.convertStringSetToString(regionDescription.getHostingMembers(), '\n')); - regionSection.addSeparator('.'); - - TabularResultData commonNonDefaultAttrTable = regionSection.addSection().addTable(); - - commonNonDefaultAttrTable.setHeader(CliStrings - .format(CliStrings.DESCRIBE_REGION__NONDEFAULT__COMMONATTRIBUTES__HEADER, memberType)); - // Common Non Default Region Attributes - Map<String, String> cndRegionAttrsMap = regionDescription.getCndRegionAttributes(); - - // Common Non Default Eviction Attributes - Map<String, String> cndEvictionAttrsMap = regionDescription.getCndEvictionAttributes(); - - // Common Non Default Partition Attributes - Map<String, String> cndPartitionAttrsMap = regionDescription.getCndPartitionAttributes(); - - writeCommonAttributesToTable(commonNonDefaultAttrTable, - CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, cndRegionAttrsMap); - writeCommonAttributesToTable(commonNonDefaultAttrTable, - CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, cndEvictionAttrsMap); - writeCommonAttributesToTable(commonNonDefaultAttrTable, - CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, cndPartitionAttrsMap); - - // Member-wise non default Attributes - Map<String, RegionDescriptionPerMember> regDescPerMemberMap = - regionDescription.getRegionDescriptionPerMemberMap(); - Set<String> members = regDescPerMemberMap.keySet(); - - TabularResultData table = regionSection.addSection().addTable(); - - boolean setHeader = false; - for (String member : members) { - RegionDescriptionPerMember regDescPerMem = regDescPerMemberMap.get(member); - Map<String, String> ndRa = regDescPerMem.getNonDefaultRegionAttributes(); - Map<String, String> ndEa = regDescPerMem.getNonDefaultEvictionAttributes(); - Map<String, String> ndPa = regDescPerMem.getNonDefaultPartitionAttributes(); - - // Get all the member-specific non-default attributes by removing the common keys - ndRa.keySet().removeAll(cndRegionAttrsMap.keySet()); - ndEa.keySet().removeAll(cndEvictionAttrsMap.keySet()); - ndPa.keySet().removeAll(cndPartitionAttrsMap.keySet()); - - // Scope is not valid for PR's - if (regionDescription.isPartition()) { - if (ndRa.get(RegionAttributesNames.SCOPE) != null) { - ndRa.remove(RegionAttributesNames.SCOPE); - } + if (regionDescription.isAccessor()) { + memberType = CliStrings.DESCRIBE_REGION__ACCESSOR__MEMBER; + } else { + memberType = CliStrings.DESCRIBE_REGION__HOSTING__MEMBER; + } + regionSection.addData(memberType, + CliUtil.convertStringSetToString(regionDescription.getHostingMembers(), '\n')); + regionSection.addSeparator('.'); + + TabularResultData commonNonDefaultAttrTable = regionSection.addSection().addTable(); + + commonNonDefaultAttrTable.setHeader(CliStrings + .format(CliStrings.DESCRIBE_REGION__NONDEFAULT__COMMONATTRIBUTES__HEADER, memberType)); + // Common Non Default Region Attributes + Map<String, String> cndRegionAttrsMap = regionDescription.getCndRegionAttributes(); + + // Common Non Default Eviction Attributes + Map<String, String> cndEvictionAttrsMap = regionDescription.getCndEvictionAttributes(); + + // Common Non Default Partition Attributes + Map<String, String> cndPartitionAttrsMap = regionDescription.getCndPartitionAttributes(); + + writeCommonAttributesToTable(commonNonDefaultAttrTable, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, cndRegionAttrsMap); + writeCommonAttributesToTable(commonNonDefaultAttrTable, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, cndEvictionAttrsMap); + writeCommonAttributesToTable(commonNonDefaultAttrTable, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, cndPartitionAttrsMap); + + // Member-wise non default Attributes + Map<String, RegionDescriptionPerMember> regDescPerMemberMap = + regionDescription.getRegionDescriptionPerMemberMap(); + Set<String> members = regDescPerMemberMap.keySet(); + + TabularResultData table = regionSection.addSection().addTable(); + + boolean setHeader = false; + for (String member : members) { + RegionDescriptionPerMember regDescPerMem = regDescPerMemberMap.get(member); + Map<String, String> ndRa = regDescPerMem.getNonDefaultRegionAttributes(); + Map<String, String> ndEa = regDescPerMem.getNonDefaultEvictionAttributes(); + Map<String, String> ndPa = regDescPerMem.getNonDefaultPartitionAttributes(); + + // Get all the member-specific non-default attributes by removing the common keys + ndRa.keySet().removeAll(cndRegionAttrsMap.keySet()); + ndEa.keySet().removeAll(cndEvictionAttrsMap.keySet()); + ndPa.keySet().removeAll(cndPartitionAttrsMap.keySet()); + + // Scope is not valid for PR's + if (regionDescription.isPartition()) { + if (ndRa.get(RegionAttributesNames.SCOPE) != null) { + ndRa.remove(RegionAttributesNames.SCOPE); } + } - List<FixedPartitionAttributesInfo> fpaList = regDescPerMem.getFixedPartitionAttributes(); + List<FixedPartitionAttributesInfo> fpaList = regDescPerMem.getFixedPartitionAttributes(); - if (!(ndRa.isEmpty() && ndEa.isEmpty() && ndPa.isEmpty()) || fpaList != null) { - setHeader = true; - boolean memberNameAdded; - memberNameAdded = writeAttributesToTable(table, - CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, ndRa, member, false); - memberNameAdded = writeAttributesToTable(table, - CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, ndEa, member, memberNameAdded); - memberNameAdded = - writeAttributesToTable(table, CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, - ndPa, member, memberNameAdded); + if (!ndRa.isEmpty() || !ndEa.isEmpty() || !ndPa.isEmpty() || fpaList != null) { + setHeader = true; + boolean memberNameAdded; + memberNameAdded = writeAttributesToTable(table, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__REGION, ndRa, member, false); + memberNameAdded = writeAttributesToTable(table, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__EVICTION, ndEa, member, memberNameAdded); + memberNameAdded = writeAttributesToTable(table, + CliStrings.DESCRIBE_REGION__ATTRIBUTE__TYPE__PARTITION, ndPa, member, memberNameAdded); - writeFixedPartitionAttributesToTable(table, fpaList, member, memberNameAdded); - } + writeFixedPartitionAttributesToTable(table, fpaList, member, memberNameAdded); } + } - if (setHeader) { - table.setHeader(CliStrings.format( - CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER, memberType)); - } + if (setHeader) { + table.setHeader(CliStrings.format( + CliStrings.DESCRIBE_REGION__NONDEFAULT__PERMEMBERATTRIBUTES__HEADER, memberType)); } - result = ResultBuilder.buildResult(crd); - return result; + return ResultBuilder.buildResult(crd); } private void writeCommonAttributesToTable(TabularResultData table, String attributeType, @@ -213,7 +188,7 @@ public class DescribeRegionCommand implements GfshCommand { for (String attributeName : attributes) { String attributeValue = attributesMap.get(attributeName); - String type, memName; + String type; if (!isTypeAdded) { type = attributeType; diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java index b251d64..565a044 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/GfshCommand.java @@ -118,7 +118,7 @@ public interface GfshCommand extends CommandMarker { } /** - * Get All members, exclusing locators + * Get All members, excluding locators */ default Set<DistributedMember> getAllNormalMembers(InternalCache cache) { return CliUtil.getAllNormalMembers(cache); diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java index 18ad530..64201eb 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java @@ -170,15 +170,15 @@ public class RegionAttributesInfo implements Serializable { PartitionAttributes<?, ?> partitionAttributes = ra.getPartitionAttributes(); EvictionAttributes evictionAttributes = ra.getEvictionAttributes(); - - if (partitionAttributes != null) + if (partitionAttributes != null) { partitionAttributesInfo = new PartitionAttributesInfo(partitionAttributes); + } if (evictionAttributes != null) { evictionAttributesInfo = new EvictionAttributesInfo(evictionAttributes); } - this.offHeap = ra.getOffHeap(); + offHeap = ra.getOffHeap(); } @@ -305,7 +305,7 @@ public class RegionAttributesInfo implements Serializable { } public boolean getOffHeap() { - return this.offHeap; + return offHeap; } @Override diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionDescription.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionDescription.java index d0d5640..9f829b7 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionDescription.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionDescription.java @@ -17,21 +17,15 @@ package org.apache.geode.management.internal.cli.domain; import java.io.Serializable; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Set; import org.apache.geode.cache.DataPolicy; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.Scope; /*** * Data class which contains description of a region and provides the aggregated view of the region * Used by describe region command - * - * */ public class RegionDescription implements Serializable { @@ -40,9 +34,7 @@ public class RegionDescription implements Serializable { private boolean isPartition; private boolean isPersistent; private boolean isReplicate; - private boolean haslocalDataStorage; private boolean isLocal = false; - private boolean isReplicatedProxy = false;; private boolean isAccessor = false; @@ -55,9 +47,7 @@ public class RegionDescription implements Serializable { private Scope scope; private DataPolicy dataPolicy; - public RegionDescription() { - - } + public RegionDescription() {} public DataPolicy getDataPolicy() { return this.dataPolicy; @@ -70,14 +60,13 @@ public class RegionDescription implements Serializable { /** * Adds the RegionDescription per member to the aggregated view * - * @param regionDescPerMember - * + * @return boolean describing if description was successfully added */ public boolean add(RegionDescriptionPerMember regionDescPerMember) { boolean isAdded = false; if (regionDescPerMemberMap == null) { - regionDescPerMemberMap = new HashMap<String, RegionDescriptionPerMember>(); + regionDescPerMemberMap = new HashMap<>(); regionDescPerMemberMap.put(regionDescPerMember.getHostingMember(), regionDescPerMember); this.scope = regionDescPerMember.getScope(); this.dataPolicy = regionDescPerMember.getDataPolicy(); @@ -85,70 +74,53 @@ public class RegionDescription implements Serializable { isPartition = this.dataPolicy.withPartitioning(); isPersistent = this.dataPolicy.withPersistence(); isReplicate = this.dataPolicy.withReplication(); - haslocalDataStorage = this.dataPolicy.withStorage(); isLocal = this.scope.isLocal(); isAccessor = regionDescPerMember.isAccessor(); // COPY - this.cndRegionAttributes = new HashMap<String, String>(); + this.cndRegionAttributes = new HashMap<>(); this.cndRegionAttributes.putAll(regionDescPerMember.getNonDefaultRegionAttributes()); - this.cndPartitionAttributes = new HashMap<String, String>(); + this.cndPartitionAttributes = new HashMap<>(); this.cndPartitionAttributes.putAll(regionDescPerMember.getNonDefaultPartitionAttributes()); - this.cndEvictionAttributes = new HashMap<String, String>(); + this.cndEvictionAttributes = new HashMap<>(); this.cndEvictionAttributes.putAll(regionDescPerMember.getNonDefaultEvictionAttributes()); - if (this.dataPolicy.equals(DataPolicy.EMPTY) && this.scope.equals(Scope.DISTRIBUTED_ACK)) { - isReplicatedProxy = true; - } - - // Don't have to show the scope for PR's + isAdded = true; + } else if (this.scope.equals(regionDescPerMember.getScope()) + && this.name.equals(regionDescPerMember.getName()) + && this.dataPolicy.equals(regionDescPerMember.getDataPolicy()) + && this.isAccessor == regionDescPerMember.isAccessor()) { + regionDescPerMemberMap.put(regionDescPerMember.getHostingMember(), regionDescPerMember); + findCommon(cndRegionAttributes, regionDescPerMember.getNonDefaultRegionAttributes()); + findCommon(cndEvictionAttributes, regionDescPerMember.getNonDefaultEvictionAttributes()); + findCommon(cndPartitionAttributes, regionDescPerMember.getNonDefaultPartitionAttributes()); isAdded = true; - } else { - if (this.scope.equals(regionDescPerMember.getScope()) - && this.name.equals(regionDescPerMember.getName()) - && this.dataPolicy.equals(regionDescPerMember.getDataPolicy()) - && this.isAccessor == regionDescPerMember.isAccessor()) { - - regionDescPerMemberMap.put(regionDescPerMember.getHostingMember(), regionDescPerMember); - findCommon(cndRegionAttributes, regionDescPerMember.getNonDefaultRegionAttributes()); - findCommon(cndEvictionAttributes, regionDescPerMember.getNonDefaultEvictionAttributes()); - findCommon(cndPartitionAttributes, regionDescPerMember.getNonDefaultPartitionAttributes()); - - isAdded = true; - } } return isAdded; } - private void findCommon(Map<String, String> commonNdMap, Map<String, String> incomingNdMap) { - // First get the intersection of the both maps - - Set<String> commonNdKeySet = commonNdMap.keySet(); - Set<String> incomingNdKeySet = incomingNdMap.keySet(); - - commonNdKeySet.retainAll(incomingNdKeySet); - - // Now compare the values - // Take a copy of the set to avoid a CME - Iterator<String> commonKeysIter = (new HashSet<String>(commonNdKeySet)).iterator(); - - while (commonKeysIter.hasNext()) { - String attribute = commonKeysIter.next(); - String commonNdValue = commonNdMap.get(attribute); - String incomingNdValue = incomingNdMap.get(attribute); - - if (commonNdValue != null) { - if (!commonNdValue.equals(incomingNdValue)) { - // Remove it from the commonNdMa - commonNdMap.remove(attribute); - } - } else { - if (incomingNdValue != null) { - commonNdMap.remove(attribute); - } + /** + * Removes any key-value pairs from @commonValuesMap that do not agree with the respective + * key-value pairs of @additionalValuesMap + * + * @param commonValuesMap Common values map, whose key set will be reduced. + * @param additionalValuesMap Incoming values map, against which @commonValuesMap. + */ + static void findCommon(Map<String, String> commonValuesMap, + Map<String, String> additionalValuesMap) { + + Set<String> sharedKeySet = commonValuesMap.keySet(); + sharedKeySet.retainAll(additionalValuesMap.keySet()); + + for (String sharedKey : new HashSet<>(sharedKeySet)) { + String commonNdValue = commonValuesMap.get(sharedKey); + String incomingNdValue = additionalValuesMap.get(sharedKey); + if (commonNdValue != null && !commonNdValue.equals(incomingNdValue) + || commonNdValue == null && incomingNdValue != null) { + commonValuesMap.remove(sharedKey); } } } @@ -190,25 +162,16 @@ public class RegionDescription implements Serializable { return this.isReplicate; } - public boolean hasLocalStorage() { - return this.haslocalDataStorage; - } - public boolean isLocal() { return this.isLocal; } - public boolean isReplicatedProxy() { - return this.isReplicatedProxy; - } - public boolean isAccessor() { return this.isAccessor; } - /*** - * Get + * Gets the common, non-default region attributes * * @return Map containing attribute name and its associated value */ @@ -217,7 +180,7 @@ public class RegionDescription implements Serializable { } /*** - * Gets the common non-default Eviction Attributes + * Gets the common, non-default eviction attributes * * @return Map containing attribute name and its associated value */ @@ -226,7 +189,7 @@ public class RegionDescription implements Serializable { } /*** - * Gets the common non-default PartitionAttributes + * Gets the common, non-default partition attributes * * @return Map containing attribute name and its associated value */ @@ -238,11 +201,13 @@ public class RegionDescription implements Serializable { return this.regionDescPerMemberMap; } - public String toString() { StringBuilder sb = new StringBuilder(); return sb.toString(); } + public boolean isEmpty() { + return regionDescPerMemberMap == null || regionDescPerMemberMap.isEmpty(); + } } diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GetRegionDescriptionFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GetRegionDescriptionFunction.java index afaeac5..d13446c 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GetRegionDescriptionFunction.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/GetRegionDescriptionFunction.java @@ -16,14 +16,13 @@ package org.apache.geode.management.internal.cli.functions; import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheClosedException; import org.apache.geode.cache.Region; -import org.apache.geode.cache.execute.FunctionAdapter; +import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionContext; import org.apache.geode.internal.InternalEntity; import org.apache.geode.management.internal.cli.domain.RegionDescriptionPerMember; -public class GetRegionDescriptionFunction extends FunctionAdapter implements InternalEntity { +public class GetRegionDescriptionFunction implements Function, InternalEntity { private static final long serialVersionUID = 1L; diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesDefault.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesDefault.java index 1cbb9e2..34da600 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesDefault.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesDefault.java @@ -14,17 +14,12 @@ */ package org.apache.geode.management.internal.cli.util; -import java.util.List; - import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.EvictionAction; -import org.apache.geode.cache.EvictionAlgorithm; import org.apache.geode.cache.ExpirationAction; import org.apache.geode.cache.PartitionAttributesFactory; import org.apache.geode.cache.Scope; import org.apache.geode.internal.cache.AbstractRegion; -import org.apache.geode.management.internal.cli.domain.EvictionAttributesInfo; -import org.apache.geode.management.internal.cli.domain.PartitionAttributesInfo; /*** * Contains the default values for the region attributes @@ -36,26 +31,19 @@ public class RegionAttributesDefault { public static final boolean CLONING_ENABLED = false; public static final boolean CONCURRENCY_CHECK_ENABLED = true; public static final boolean ENABLE_ASYNC_CONFLATION = false; - public static final boolean ENABLE_GATEWAY = false; public static final boolean ENABLE_SUBSCRIPTION_CONFLATION = false; public static final boolean IGNORE_JTA = false; public static final boolean INDEX_MAINTENANCE_SYNCHRONOUS = true; public static final boolean MULTICAST_ENABLED = false; public static final int CONCURRENCY_LEVEL = 16; public static final String DISK_STORE_NAME = ""; - public static final String GATEWAY_HUB_ID = ""; public static final int INITIAL_CAPACITY = 16; public static final float LOAD_FACTOR = 0.75f; public static final String POOL_NAME = ""; public static final boolean STATISTICS_ENABLED = false; public static final boolean IS_LOCK_GRANTOR = false; - public static final String cacheListenerClassNames = ""; - public static final String cacheLoaderClassName = ""; - public static final String cacheWriterClassName = ""; public static final String COMPRESSOR_CLASS_NAME = null; - public static final PartitionAttributesInfo partitionAttributesInfo = null; - public static final EvictionAttributesInfo evictionAttributesInfo = null; public static final int ENTRY_TIME_TO_LIVE = 0; public static final int REGION_TIME_TO_LIVE = 0; public static final int ENTRY_IDLE_TIMEOUT = 0; @@ -68,14 +56,12 @@ public class RegionAttributesDefault { // PA // Partition attributes public static final int REDUNDANT_COPIES = 0; - public static final long TOTAL_MAX_MEMORY = PartitionAttributesFactory.GLOBAL_MAX_MEMORY_DEFAULT; public static final int TOTAL_NUM_BUCKETS = PartitionAttributesFactory.GLOBAL_MAX_BUCKETS_DEFAULT; public static final String COLOCATED_WITH = ""; public static final long RECOVERY_DELAY = PartitionAttributesFactory.RECOVERY_DELAY_DEFAULT; public static final long STARTUP_RECOVERY_DELAY = PartitionAttributesFactory.STARTUP_RECOVERY_DELAY_DEFAULT; public static final String PARTITION_RESOLVER = ""; - public static final List<String> PARTITION_LISTENERS = null; // EVICTION ATTRIBUTES diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java index a61fabb..2f0d729 100644 --- a/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java +++ b/geode-core/src/test/java/org/apache/geode/test/dunit/rules/MemberVM.java @@ -15,11 +15,15 @@ package org.apache.geode.test.dunit.rules; +import static org.awaitility.Awaitility.await; + import java.io.File; import java.util.Arrays; +import java.util.concurrent.TimeUnit; import org.apache.commons.io.FileUtils; +import org.apache.geode.management.DistributedSystemMXBean; import org.apache.geode.test.dunit.AsyncInvocation; import org.apache.geode.test.dunit.SerializableCallableIF; import org.apache.geode.test.dunit.SerializableRunnableIF; @@ -118,9 +122,8 @@ public class MemberVM implements Member { } else // if using the dunit/vm dir as the preset working dir, need to cleanup dir except // the locator0view* file, so that regions/indexes won't get persisted across tests - Arrays.stream(getWorkingDir().listFiles((dir, name) -> { - return !name.startsWith("locator0view"); - })).forEach(FileUtils::deleteQuietly); + Arrays.stream(getWorkingDir().listFiles((dir, name) -> !name.startsWith("locator0view"))) + .forEach(FileUtils::deleteQuietly); } public static void invokeInEveryMember(SerializableRunnableIF runnableIF, MemberVM... members) { @@ -131,10 +134,8 @@ public class MemberVM implements Member { * this should called on a locatorVM or a serverVM with jmxManager enabled */ public void waitTillRegionsAreReadyOnServers(String regionPath, int serverCount) { - vm.invoke(() -> { - LocatorServerStartupRule.memberStarter.waitTillRegionIsReadyOnServers(regionPath, - serverCount); - }); + vm.invoke(() -> LocatorServerStartupRule.memberStarter + .waitTillRegionIsReadyOnServers(regionPath, serverCount)); } public void waitTillDiskstoreIsReady(String diskstoreName, int serverCount) { @@ -143,10 +144,12 @@ public class MemberVM implements Member { } public void waitTillAsyncEventQueuesAreReadyOnServers(String queueId, int serverCount) { - vm.invoke(() -> { - LocatorServerStartupRule.memberStarter.waitTillAsyncEventQueuesAreReadyOnServers(queueId, - serverCount); - }); + vm.invoke(() -> LocatorServerStartupRule.memberStarter + .waitTillAsyncEventQueuesAreReadyOnServers(queueId, serverCount)); } + public void waitTilGatewaySendersAreReady(int expectedGatewayObjectCount) throws Exception { + vm.invoke(() -> LocatorServerStartupRule.memberStarter + .waitTilGatewaySendersAreReady(expectedGatewayObjectCount)); + } } diff --git a/geode-core/src/test/java/org/apache/geode/test/junit/rules/MemberStarterRule.java b/geode-core/src/test/java/org/apache/geode/test/junit/rules/MemberStarterRule.java index e2dcc9c..a817ef4 100644 --- a/geode-core/src/test/java/org/apache/geode/test/junit/rules/MemberStarterRule.java +++ b/geode-core/src/test/java/org/apache/geode/test/junit/rules/MemberStarterRule.java @@ -259,6 +259,12 @@ public abstract class MemberStarterRule<T> extends SerializableExternalResource return count; } + public void waitTilGatewaySendersAreReady(int expectedGatewayObjectCount) throws Exception { + DistributedSystemMXBean dsMXBean = getManagementService().getDistributedSystemMXBean(); + await().atMost(30, TimeUnit.SECONDS) + .until(() -> dsMXBean.listGatewaySenderObjectNames().length == expectedGatewayObjectCount); + } + public void waitTillDiskStoreIsReady(String diskstoreName, int serverCount) { await().atMost(30, TimeUnit.SECONDS) .until(() -> getDiskStoreCount(diskstoreName) == serverCount); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
