Review fixups
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/00709dd7 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/00709dd7 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/00709dd7 Branch: refs/heads/feature/GEODE-2632-10 Commit: 00709dd7a85821e4861db877c9db6ee50b207a63 Parents: f35a822 Author: Kirk Lund <[email protected]> Authored: Wed May 3 14:09:09 2017 -0700 Committer: Kirk Lund <[email protected]> Committed: Wed May 3 14:09:09 2017 -0700 ---------------------------------------------------------------------- .../session/catalina/DeltaSessionManager.java | 24 +- .../admin/internal/FlushToDiskRequest.java | 19 +- .../geode/cache/client/ClientCacheFactory.java | 3 +- .../internal/ClientRegionFactoryImpl.java | 17 +- .../cache/client/internal/ConnectionImpl.java | 4 +- .../geode/cache/client/internal/PoolImpl.java | 18 +- .../query/internal/CompiledComparison.java | 2 +- .../geode/cache/query/internal/CompiledIn.java | 2 +- .../query/internal/QueryExecutionContext.java | 18 +- .../cache/query/internal/QueryMonitor.java | 2 +- .../geode/cache/query/internal/QueryUtils.java | 59 ++--- .../query/internal/index/AbstractIndex.java | 15 +- .../query/internal/index/CompactRangeIndex.java | 10 +- .../index/FunctionalIndexCreationHelper.java | 10 +- .../cache/query/internal/index/HashIndex.java | 2 - .../cache/query/internal/index/RangeIndex.java | 67 +++-- .../internal/ClusterConfigurationService.java | 4 +- .../distributed/internal/InternalLocator.java | 1 + .../geode/internal/cache/CacheServerImpl.java | 6 +- .../geode/internal/cache/ColocationHelper.java | 28 ++- .../geode/internal/cache/DistributedRegion.java | 4 +- .../geode/internal/cache/LocalRegion.java | 8 +- .../internal/cache/PartitionAttributesImpl.java | 2 +- .../geode/internal/cache/PartitionedRegion.java | 252 ++++++------------- .../domain/SharedConfigurationStatus.java | 4 - .../cache/execute/PRColocationDUnitTest.java | 3 +- ...ersistenceEnabledGatewaySenderDUnitTest.java | 5 + 27 files changed, 217 insertions(+), 372 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java index 98a3db4..16274c5 100644 --- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java +++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java @@ -14,6 +14,8 @@ */ package org.apache.geode.modules.session.catalina; +import static org.apache.geode.internal.util.IOUtils.close; + import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedInputStream; @@ -714,9 +716,9 @@ public abstract class DeltaSessionManager extends ManagerBase throw e; } finally { if (error) { - closeQuietly(oos); - closeQuietly(bos); - closeQuietly(fos); + close(oos); + close(bos); + close(fos); } } @@ -747,12 +749,12 @@ public abstract class DeltaSessionManager extends ManagerBase } } catch (IOException e) { getLogger().error("Exception unloading sessions", e); - closeQuietly(oos); + close(oos); throw e; } // Flush and close the output stream - closeQuietly(oos); + close(oos); // Locally destroy the sessions we just wrote if (getSessionCache().isClientServer()) { @@ -923,7 +925,7 @@ public abstract class DeltaSessionManager extends ManagerBase } public Context getTheContext() { - if (Context.class.isInstance(getContainer())) { + if (getContainer() instanceof Context) { return (Context) getContainer(); } else { getLogger().error("Unable to unload sessions - container is of type " @@ -931,14 +933,4 @@ public abstract class DeltaSessionManager extends ManagerBase return null; } } - - private static void closeQuietly(Closeable closeable) { - if (closeable == null) { - return; - } - try { - closeable.close(); - } catch (IOException ignore) { - } - } } http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java index 71348be..b3c0df6 100644 --- a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java +++ b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java @@ -15,33 +15,32 @@ package org.apache.geode.admin.internal; import java.util.Collection; -import java.util.HashSet; import java.util.Set; +import org.apache.logging.log4j.Logger; + import org.apache.geode.CancelException; import org.apache.geode.cache.DiskStore; -import org.apache.geode.cache.persistence.PersistentID; import org.apache.geode.distributed.internal.DM; import org.apache.geode.distributed.internal.DistributionManager; import org.apache.geode.distributed.internal.ReplyException; import org.apache.geode.internal.admin.remote.AdminMultipleReplyProcessor; import org.apache.geode.internal.admin.remote.AdminResponse; import org.apache.geode.internal.admin.remote.CliLegacyMessage; -import org.apache.geode.internal.cache.DiskStoreImpl; import org.apache.geode.internal.cache.GemFireCacheImpl; import org.apache.geode.internal.cache.InternalCache; +import org.apache.geode.internal.logging.LogService; /** * A request to from an admin VM to all non admin members to start a backup. In the prepare phase of * the backup, the members will suspend bucket destroys to make sure buckets aren't missed during * the backup. - * - * */ public class FlushToDiskRequest extends CliLegacyMessage { + private static final Logger logger = LogService.getLogger(); public FlushToDiskRequest() { - + // nothing } public static void send(DM dm, Set recipients) { @@ -58,7 +57,7 @@ public class FlushToDiskRequest extends CliLegacyMessage { throw e; } } catch (InterruptedException e) { - e.printStackTrace(); + logger.debug(e); } AdminResponse response = request.createResponse((DistributionManager) dm); response.setSender(dm.getDistributionManagerId()); @@ -69,15 +68,13 @@ public class FlushToDiskRequest extends CliLegacyMessage { protected AdminResponse createResponse(DistributionManager dm) { InternalCache cache = GemFireCacheImpl.getInstance(); if (cache != null) { - Collection<DiskStore> diskStores = cache.listDiskStoresIncludingRegionOwned(); - for (DiskStore store : diskStores) { - store.flush(); - } + cache.listDiskStoresIncludingRegionOwned().forEach(DiskStore::flush); } return new FlushToDiskResponse(this.getSender()); } + @Override public int getDSFID() { return FLUSH_TO_DISK_REQUEST; } http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java b/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java index 0d678ca..4f89e98 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java +++ b/geode-core/src/main/java/org/apache/geode/cache/client/ClientCacheFactory.java @@ -14,6 +14,7 @@ */ package org.apache.geode.cache.client; +import static org.apache.commons.lang.StringUtils.isEmpty; import static org.apache.geode.distributed.ConfigurationProperties.*; import java.util.Properties; @@ -229,7 +230,7 @@ public class ClientCacheFactory { } { String propValue = this.dsProps.getProperty(LOCATORS); - if (propValue != null && !propValue.isEmpty()) { + if (isEmpty(propValue)) { throw new IllegalStateException( "On a client cache the locators property must be set to an empty string or not set. It was set to \"" + propValue + "\"."); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientRegionFactoryImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientRegionFactoryImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientRegionFactoryImpl.java index f1e2d7c..07806d9 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientRegionFactoryImpl.java +++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ClientRegionFactoryImpl.java @@ -14,6 +14,8 @@ */ package org.apache.geode.cache.client.internal; +import static org.apache.commons.lang.StringUtils.isEmpty; + import org.apache.geode.cache.AttributesFactory; import org.apache.geode.cache.CacheListener; import org.apache.geode.cache.CustomExpiry; @@ -218,7 +220,7 @@ public class ClientRegionFactoryImpl<K, V> implements ClientRegionFactory<K, V> @SuppressWarnings("deprecation") private RegionAttributes<K, V> createRegionAttributes() { RegionAttributes<K, V> ra = this.attrsFactory.create(); - if (ra.getPoolName() == null || ra.getPoolName().isEmpty()) { + if (isEmpty(ra.getPoolName())) { UserSpecifiedRegionAttributes<K, V> ura = (UserSpecifiedRegionAttributes<K, V>) ra; if (ura.requiresPoolName) { Pool dp = getDefaultPool(); @@ -232,17 +234,4 @@ public class ClientRegionFactoryImpl<K, V> implements ClientRegionFactory<K, V> } return ra; } - - // public ClientRegionFactory<K, V> addParallelGatewaySenderId( - // String parallelGatewaySenderId) { - // this.attrsFactory.addParallelGatewaySenderId(parallelGatewaySenderId); - // return this; - // } - // - // public ClientRegionFactory<K, V> addSerialGatewaySenderId( - // String serialGatewaySenderId) { - // this.attrsFactory.addSerialGatewaySenderId(serialGatewaySenderId); - // return this; - // } - } http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java index 1c7e0bb..f71b79b 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java +++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/ConnectionImpl.java @@ -160,9 +160,7 @@ public class ConnectionImpl implements Connection { commBuffer = null; try { theSocket.close(); - } catch (IOException ignore) { - // ignore - } catch (RuntimeException ignore) { + } catch (IOException | RuntimeException ignore) { // ignore } } http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java b/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java index 57b3992..133d7a8 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java +++ b/geode-core/src/main/java/org/apache/geode/cache/client/internal/PoolImpl.java @@ -14,6 +14,8 @@ */ package org.apache.geode.cache.client.internal; +import static org.apache.commons.lang.StringUtils.isEmpty; + import java.net.InetSocketAddress; import java.util.ArrayList; import java.util.Collections; @@ -238,9 +240,8 @@ public class PoolImpl implements InternalPool { statFactory = ds; } this.stats = this.startDisabled ? null - : new PoolStats(statFactory, - getName() + "->" + (serverGroup == null || serverGroup.isEmpty() ? "[any servers]" - : "[" + getServerGroup() + "]")); + : new PoolStats(statFactory, getName() + "->" + + (isEmpty(serverGroup) ? "[any servers]" : "[" + getServerGroup() + "]")); source = getSourceImpl(((PoolFactoryImpl.PoolAttributes) attributes).locatorCallback); endpointManager = new EndpointManagerImpl(name, ds, this.cancelCriterion, this.stats); @@ -1310,7 +1311,7 @@ public class PoolImpl implements InternalPool { } catch (VirtualMachineError e) { SystemFailure.initiateFailure(e); throw e; - } catch (CancelException e) { + } catch (CancelException ignore) { if (logger.isDebugEnabled()) { logger.debug("Pool task <{}> cancelled", this); } @@ -1428,14 +1429,7 @@ public class PoolImpl implements InternalPool { return cacheCriterion.generateCancelledException(e); } } else { - if (cacheCriterion == null) { - cacheCriterion = cache.getCancelCriterion(); - } else if (cacheCriterion != cache.getCancelCriterion()) { - /* - * If the cache instance has somehow changed, we need to get a reference to the new - * criterion. This is pretty unlikely because the cache closes all the pools when it shuts - * down, but I wanted to be safe. - */ + if (cacheCriterion == null || cacheCriterion != cache.getCancelCriterion()) { cacheCriterion = cache.getCancelCriterion(); } return cacheCriterion.generateCancelledException(e); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java index 6351e99..360d655 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledComparison.java @@ -566,7 +566,7 @@ public class CompiledComparison extends AbstractCompiledValue } finally { observer.afterIndexLookup(data); } - return QueryUtils.getconditionedRelationshipIndexResultsExpandedToTopOrCGJLevel(data, + return QueryUtils.getConditionedRelationshipIndexResultsExpandedToTopOrCGJLevel(data, indxInfo, context, completeExpansionNeeded, iterOperands, indpdntItrs); } else { // Asif . We are in this block , this itself guarantees that this http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java index db2c65b..2532f19 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/CompiledIn.java @@ -174,7 +174,7 @@ public class CompiledIn extends AbstractCompiledValue implements Indexable { if (pAndK != null) { CompiledValue path = pAndK._path; CompiledValue indexKey = pAndK._key; - IndexData indexData = QueryUtils.getAvailableIndexIfAny(path, context, this.TOK_EQ); + IndexData indexData = QueryUtils.getAvailableIndexIfAny(path, context, TOK_EQ); IndexProtocol index = null; if (indexData != null) { index = indexData.getIndex(); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryExecutionContext.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryExecutionContext.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryExecutionContext.java index eb51fcc..696e501 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryExecutionContext.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryExecutionContext.java @@ -14,8 +14,6 @@ */ package org.apache.geode.cache.query.internal; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -37,13 +35,10 @@ public class QueryExecutionContext extends ExecutionContext { private int nextFieldNum = 0; - private Query query; - - private IntOpenHashSet successfulBuckets; + private final Query query; private boolean cqQueryContext = false; - private List bucketList; private boolean indexUsed = false; @@ -67,11 +62,11 @@ public class QueryExecutionContext extends ExecutionContext { /** * List of query index names that the user has hinted on using */ - - private List<String> hints = null; + private ArrayList hints = null; public QueryExecutionContext(Object[] bindArguments, InternalCache cache) { super(bindArguments, cache); + this.query = null; } public QueryExecutionContext(Object[] bindArguments, InternalCache cache, Query query) { @@ -164,7 +159,6 @@ public class QueryExecutionContext extends ExecutionContext { @Override public void setBucketList(List list) { this.bucketList = list; - this.successfulBuckets = new IntOpenHashSet(); } @Override @@ -178,7 +172,7 @@ public class QueryExecutionContext extends ExecutionContext { @Override public PdxString getSavedPdxString(int index) { if (bindArgumentToPdxStringMap == null) { - bindArgumentToPdxStringMap = new HashMap<Integer, PdxString>(); + bindArgumentToPdxStringMap = new HashMap<>(); } PdxString pdxString = bindArgumentToPdxStringMap.get(index - 1); @@ -198,7 +192,7 @@ public class QueryExecutionContext extends ExecutionContext { } private void setHints(ArrayList<String> hints) { - this.hints = new ArrayList(); + this.hints = new ArrayList<>(); this.hints.addAll(hints); } @@ -207,7 +201,7 @@ public class QueryExecutionContext extends ExecutionContext { * @return true if the index name was hinted by the user */ public boolean isHinted(String indexName) { - return hints != null ? hints.contains(indexName) : false; + return hints != null && hints.contains(indexName); } /** http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java index 45b32ed..89885f1 100755 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryMonitor.java @@ -356,7 +356,7 @@ public class QueryMonitor implements Runnable { @Override public String toString() { - return new StringBuffer().append("QueryThreadTask[StartTime:").append(this.StartTime) + return new StringBuilder().append("QueryThreadTask[StartTime:").append(this.StartTime) .append(", queryThread:").append(this.queryThread).append(", threadId:") .append(this.queryThread.getId()).append(", query:").append(this.query.getQueryString()) .append(", queryExecutionStatus:").append(this.queryExecutionStatus).append(']') http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java index 6de88d9..bb0cbea 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/QueryUtils.java @@ -276,7 +276,10 @@ public class QueryUtils { rs = new ResultsBag(large, null); } - rs.addAll(small); + for (Iterator itr = small.iterator(); itr.hasNext();) { + Object element = itr.next(); + rs.add(element); + } return rs; } @@ -680,7 +683,8 @@ public class QueryUtils { StructTypeImpl elementType = (StructTypeImpl) resultSet.getCollectionType().getElementType(); - // TODO: Optimize the LinkedStructSet implementation so that + // TODO: Optimize the LinkedStructSet implementation so that Object[] can be added rather + // than Struct Object[] values = new Object[len]; int j = 0; @@ -870,7 +874,7 @@ public class QueryUtils { } // Do not use PrimaryKey Index - IndexData rhsIndxData = QueryUtils.getAvailableIndexIfAny(rhs, context, false /* */); + IndexData rhsIndxData = QueryUtils.getAvailableIndexIfAny(rhs, context, false); if (rhsIndxData == null) { // release the lock held on lhsIndex as it will not be used Index index = lhsIndxData.getIndex(); @@ -1083,8 +1087,8 @@ public class QueryUtils { int indexFieldsSize2 = resultType2 instanceof StructType ? ((StructTypeImpl) resultType2).getFieldNames().length : 1; /* - * even if th complete expansion is needed pass the flag of complete expansion as false. Thus - * for LHS & RHS we will get the expnasionList for that individual group. + * even if the complete expansion is needed pass the flag of complete expansion as false. Thus + * for LHS & RHS we will get the expansionList for that individual group. */ // NOTE: use false for completeExpansion irrespective of actual value @@ -1360,14 +1364,10 @@ public class QueryUtils { // Add this reconstructed value to the iter operand if any CompiledValue finalVal = reconstructedVal; if (iterOperands != null) { - // The type of CompiledJunction has to be AND junction as this - // function gets invoked only for AND . Also it is OK if we have - // iterOperands which - // itself is a CompiledJunction. We can have a tree of CompiledJunction - // with its - // operands being a CompiledComparison & a CompiledJunction. We can live - // without - // creating a flat structure + // The type of CompiledJunction has to be AND junction as this function gets invoked only + // for AND . Also it is OK if we have iterOperands which itself is a CompiledJunction. We + // can have a tree of CompiledJunction with its operands being a CompiledComparison & a + // CompiledJunction. We can live without creating a flat structure finalVal = new CompiledJunction(new CompiledValue[] {iterOperands, reconstructedVal}, OQLLexerTokenTypes.LITERAL_and); } @@ -1391,8 +1391,6 @@ public class QueryUtils { * given value, we require a 2 dimensional Object array. The cartesian of the two rows will * give us the set of tuples satisfying the join criteria. Each element of the row of * Object Array may be either an Object or a Struct object. - * - * * @param indxInfo An array of IndexInfo objects of size 2 , representing the range indexes of the * two operands. The other Index maps to the 0th Object array row of the List object ( data * ) & so on. @@ -1406,7 +1404,7 @@ public class QueryUtils { * composite condition in an OR junction. The returned Result is expanded either to the * CompositeGroupJunction level or to the top level as the case may be */ - static SelectResults getconditionedRelationshipIndexResultsExpandedToTopOrCGJLevel(List data, + static SelectResults getConditionedRelationshipIndexResultsExpandedToTopOrCGJLevel(List data, IndexInfo[] indxInfo, ExecutionContext context, boolean completeExpansionNeeded, CompiledValue iterOperands, RuntimeIterator[] indpdntItrs) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { @@ -1445,9 +1443,7 @@ public class QueryUtils { int size = totalFinalList.size(); for (int i = 0; i < size; ++i) { RuntimeIterator currItr = (RuntimeIterator) totalFinalList.get(i); - // If the runtimeIterators of scope not present in CheckSet add it - // to - // the expansion list + // If the runtimeIterators of scope not present in CheckSet add it to the expansion list if (!expnItrsAlreadyAccounted.contains(currItr)) { totalExpList.add(currItr); } @@ -1486,25 +1482,14 @@ public class QueryUtils { observer.beforeMergeJoinOfDoubleIndexResults(ich1.indxInfo._index, ich2.indxInfo._index, data); while (dataItr.hasNext()) { - // TODO: Change the code in range Index so that while collecting - // data - // instead of creating - // two dimensional object array , we create one dimensional Object - // array - // of size 2, & each elemnt - // stores an Object array + // TODO: Change the code in range Index so that while collecting data instead of creating + // two dimensional object array , we create one dimensional Object array of size 2, & each + // elemnt stores an Object array Object[][] values = (Object[][]) dataItr.next(); - // Before doing the cartesian of the Results , we need to clear - // the - // CheckSet of IndexCutDownExpansionHelper. This is needed because for - // a - // new key , the row - // of sets needs to be considered fresh as presence of old row in - // checkset - // may cause us to wrongly - // skip the similar row of a set , even when the row in its entirety - // is - // unique ( made by + // Before doing the cartesian of the Results , we need to clear the CheckSet of + // IndexCutDownExpansionHelper. This is needed because for a new key , the row of sets + // needs to be considered fresh as presence of old row in checkset may cause us to wrongly + // skip the similar row of a set , even when the row in its entirety is unique ( made by // different data in the other set) mergeAndExpandCutDownRelationshipIndexResults(values, returnSet, mappings, expansionListIterator, totalFinalList, context, totalCheckList, iterOperands, icdeh, http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java index 3837838..0c42566 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java @@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.Logger; import org.apache.geode.cache.Region; @@ -148,7 +149,7 @@ public abstract class AbstractIndex implements IndexProtocol { this.originalIndexedExpression = originalIndexedExpression; this.originalFromClause = originalFromClause; this.canonicalizedDefinitions = defintions; - if (projectionAttributes == null || projectionAttributes.isEmpty()) { + if (StringUtils.isEmpty(projectionAttributes)) { projectionAttributes = "*"; } this.projectionAttributes = projectionAttributes; @@ -585,7 +586,6 @@ public abstract class AbstractIndex implements IndexProtocol { SelectResults selectResults = (SelectResults) results; StructImpl structImpl = new StructImpl( (StructTypeImpl) selectResults.getCollectionType().getElementType(), values); - // lss.add(structImpl); selectResults.add(structImpl); } @@ -932,7 +932,7 @@ public abstract class AbstractIndex implements IndexProtocol { private Map dependencyGraph = null; - /* + /** * The boolean if true indicates that the 0th iterator is on entries . If the 0th iterator is on * collection of Region.Entry objects, then the RegionEntry object used in Index data objects is * obtained directly from its corresponding Region.Entry object. However if the 0th iterator is @@ -1139,7 +1139,7 @@ public abstract class AbstractIndex implements IndexProtocol { * the additional projection attribute. If the boolean isFirstItrOnEntry is true & additional * projection attribute is null, then the 0th iterator itself will evaluate to Region.Entry * Object. - * + * <p> * The 2nd element of Object Array contains the Struct object ( tuple) created. If the boolean * isFirstItrOnEntry is false, then the first attribute of the Struct object is obtained by * evaluating the additional projection attribute. @@ -1179,8 +1179,9 @@ public abstract class AbstractIndex implements IndexProtocol { RuntimeIterator iter = (RuntimeIterator) currrentRuntimeIters.get(i); tuple[i] = iter.evaluate(this.initContext); } - if (!this.isFirstItrOnEntry) + if (!this.isFirstItrOnEntry) { tuple[0] = this.additionalProj.evaluate(this.initContext); + } Support.Assert(this.indexResultSetType instanceof StructTypeImpl, "The Index ResultType should have been an instance of StructTypeImpl rather than ObjectTypeImpl. The indxeResultType is " + this.indexResultSetType); @@ -1253,8 +1254,8 @@ public abstract class AbstractIndex implements IndexProtocol { } /** - * // The struct type calculation is modified if the // 0th iterator is modified to make it - * dependent on Entry + * The struct type calculation is modified if the 0th iterator is modified to make it dependent + * on Entry */ private ObjectType createIndexResultSetType() { List currentIterators = this.initContext.getCurrentIterators(); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java index 139ce54..3c1ddc6 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/CompactRangeIndex.java @@ -455,15 +455,11 @@ public class CompactRangeIndex extends AbstractIndex { Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); boolean applyOrderBy = false; - boolean asc = true; List orderByAttrs = null; - boolean multiColOrderBy = false; if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); - asc = !csc.getCriterion(); applyOrderBy = true; - multiColOrderBy = orderByAttrs.size() > 1; } if (isEmpty()) { return; @@ -486,12 +482,12 @@ public class CompactRangeIndex extends AbstractIndex { int limit = -1; Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX); - if ((applyLimit != null) && applyLimit.booleanValue()) { + if (applyLimit != null && applyLimit) { limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT); } Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); - List orderByAttrs = null; + List orderByAttrs; boolean asc = true; boolean multiColOrderBy = false; if (orderByClause != null && orderByClause) { @@ -1303,7 +1299,7 @@ public class CompactRangeIndex extends AbstractIndex { Support.Assert(this.indexResultSetType != null, "IMQEvaluator::evaluate:The StrcutType should have been initialized during index creation"); } catch (Exception e) { - logger.warn(e); + logger.debug(e); throw new Error("Unable to reevaluate, this should not happen"); } return context; http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/FunctionalIndexCreationHelper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/FunctionalIndexCreationHelper.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/FunctionalIndexCreationHelper.java index 4b61ae4..3f2133c 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/FunctionalIndexCreationHelper.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/FunctionalIndexCreationHelper.java @@ -14,6 +14,8 @@ */ package org.apache.geode.cache.query.internal.index; +import static org.apache.commons.lang.StringUtils.isEmpty; + import java.util.ArrayList; import java.util.List; @@ -108,7 +110,7 @@ class FunctionalIndexCreationHelper extends IndexCreationHelper { prepareFromClause(imgr); prepareIndexExpression(indexedExpression); prepareProjectionAttributes(projectionAttributes); - Object[] data = modiyyIterDefToSuiteIMQ((CompiledIteratorDef) this.fromClauseIterators.get(0)); + Object[] data = modifyIterDefToSuiteIMQ((CompiledIteratorDef) this.fromClauseIterators.get(0)); if (data[0] == null || data[1] == null) { throw new IndexInvalidException( LocalizedStrings.FunctionalIndexCreationHelper_INVALID_FROM_CLAUSE_0 @@ -207,8 +209,8 @@ class FunctionalIndexCreationHelper extends IndexCreationHelper { if (i == 0) { CompiledValue cv = iterDef.getCollectionExpr(); this.addnlProjType = rIter.getElementType(); - String name; - if ((name = iterDef.getName()) == null || name.isEmpty()) { + String name = iterDef.getName(); + if (isEmpty(name)) { // In case the name of iterator is null or blank set it to index_internal_id name = this.canonicalizedIteratorNames[i]; } @@ -527,7 +529,7 @@ class FunctionalIndexCreationHelper extends IndexCreationHelper { this.projectionAttributes = projectionAttributes; } - private Object[] modiyyIterDefToSuiteIMQ(CompiledIteratorDef iterDef) + private Object[] modifyIterDefToSuiteIMQ(CompiledIteratorDef iterDef) throws IndexInvalidException { Object[] retValues = {null, null}; try { http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java index 58bd2bf..943ef62 100755 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/HashIndex.java @@ -480,9 +480,7 @@ public class HashIndex extends AbstractIndex { if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); - boolean asc = !csc.getCriterion(); applyOrderBy = true; - boolean multiColOrderBy = orderByAttrs.size() > 1; } evaluate(key, operator, results, iterOps, runtimeItr, context, keysToRemove, projAttrib, intermediateResults, isIntersection, limit, applyOrderBy, orderByAttrs); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java index 316c30d..b86caa4 100644 --- a/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java +++ b/geode-core/src/main/java/org/apache/geode/cache/query/internal/index/RangeIndex.java @@ -12,13 +12,10 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -/* - * RangeIndex.java - * - * Created on February 4, 2005, 11:10 AM - */ package org.apache.geode.cache.query.internal.index; +import static java.lang.Integer.*; + import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import java.util.ArrayList; @@ -58,21 +55,23 @@ import org.apache.geode.internal.cache.RegionEntry; import org.apache.geode.internal.cache.persistence.query.CloseableIterator; import org.apache.geode.internal.i18n.LocalizedStrings; -/** - */ public class RangeIndex extends AbstractIndex { protected volatile int valueToEntriesMapSize = 0; + /** * Map for valueOf(indexedExpression)=>RegionEntries. SortedMap<Object, (RegionEntry | * List<RegionEntry>)>. Package access for unit tests. */ final ConcurrentNavigableMap valueToEntriesMap = new ConcurrentSkipListMap(TypeUtils.getExtendedNumericComparator()); + // Map for RegionEntries=>value of indexedExpression (reverse map) final private RegionEntryToValuesMap entryToValuesMap; + // Map for RegionEntries=>values when indexedExpression evaluates to null protected RegionEntryToValuesMap nullMappedEntries; + // Map for RegionEntries=>values when indexedExpression evaluates to UNDEFINED protected RegionEntryToValuesMap undefinedMappedEntries; @@ -84,7 +83,7 @@ public class RangeIndex extends AbstractIndex { public static TestHook testHook; - // @todo need more specific list of exceptions + // TODO: need more specific list of exceptions /** * Create an Range Index that can be used when executing queries. * @@ -130,8 +129,6 @@ public class RangeIndex extends AbstractIndex { this.internalIndexStats.incUpdateTime(endTime - startTime); } - //// AbstractIndex implementation - void addMapping(RegionEntry entry) throws IMQException { // Save oldKeys somewhere first this.evaluator.evaluate(entry, true); @@ -254,6 +251,7 @@ public class RangeIndex extends AbstractIndex { continue; } else { this.internalIndexStats.incNumKeys(1); + // TODO: non-atomic operation on volatile int ++valueToEntriesMapSize; } } @@ -302,6 +300,7 @@ public class RangeIndex extends AbstractIndex { continue; } else { this.internalIndexStats.incNumKeys(1); + // TODO: non-atomic operation on volatile int ++valueToEntriesMapSize; } } @@ -343,7 +342,7 @@ public class RangeIndex extends AbstractIndex { private void removeOldMapping(RegionEntry entry, Object oldkeys) throws IMQException { if (oldkeys instanceof Collection) { - Iterator valuesIter = ((Collection) oldkeys).iterator(); + Iterator valuesIter = ((Iterable) oldkeys).iterator(); while (valuesIter.hasNext()) { Object key = valuesIter.next(); RegionEntryToValuesMap rvMap = (RegionEntryToValuesMap) this.valueToEntriesMap.get(key); @@ -474,6 +473,7 @@ public class RangeIndex extends AbstractIndex { rvMap = new RegionEntryToValuesMap(true /* use target list */); this.valueToEntriesMap.put(newKey, rvMap); this.internalIndexStats.incNumKeys(1); + // TODO: non-atomic operation on volatile int ++valueToEntriesMapSize; } rvMap.add(entry, value); @@ -509,7 +509,7 @@ public class RangeIndex extends AbstractIndex { undefinedMappedEntries.remove(entry); } } else if (values instanceof Collection) { - Iterator valuesIter = ((Collection) values).iterator(); + Iterator valuesIter = ((Iterable) values).iterator(); while (valuesIter.hasNext()) { Object key = valuesIter.next(); RegionEntryToValuesMap rvMap = (RegionEntryToValuesMap) this.valueToEntriesMap.get(key); @@ -709,7 +709,7 @@ public class RangeIndex extends AbstractIndex { size = this.valueToEntriesMap.containsKey(key) ? 1 : 0; } } else { - size = Integer.MAX_VALUE; + size = MAX_VALUE; } break; @@ -753,7 +753,7 @@ public class RangeIndex extends AbstractIndex { size = this.valueToEntriesMap.containsKey(key) ? 1 : 0; } } else { - size = Integer.MAX_VALUE; + size = MAX_VALUE; } break; } @@ -770,7 +770,7 @@ public class RangeIndex extends AbstractIndex { boolean multiColOrderBy = false; boolean asc = true; List orderByAttrs = null; - if (orderByClause != null && orderByClause.booleanValue()) { + if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); asc = !csc.getCriterion(); @@ -840,7 +840,7 @@ public class RangeIndex extends AbstractIndex { } default: { throw new IllegalArgumentException( - LocalizedStrings.RangeIndex_OPERATOR_0.toLocalizedString(Integer.valueOf(operator))); + LocalizedStrings.RangeIndex_OPERATOR_0.toLocalizedString(valueOf(operator))); } } // end switch } catch (ClassCastException ex) { @@ -997,7 +997,7 @@ public class RangeIndex extends AbstractIndex { return; } if (entriesMap instanceof SortedMap) { - if (((SortedMap) entriesMap).isEmpty()) { // bug#40514 + if (((Map) entriesMap).isEmpty()) { // bug#40514 return; } @@ -1053,7 +1053,7 @@ public class RangeIndex extends AbstractIndex { return; } assert entriesMap instanceof SortedMap; - Iterator entriesIter = ((SortedMap) entriesMap).entrySet().iterator(); + Iterator entriesIter = ((Map) entriesMap).entrySet().iterator(); Map.Entry entry = null; boolean foundKeyToRemove = false; while (entriesIter.hasNext()) { @@ -1078,8 +1078,8 @@ public class RangeIndex extends AbstractIndex { throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { boolean limitApplied = false; - if (entriesMap == null || result == null || (limitApplied = verifyLimit(result, limit))) { - if (limitApplied) { + if (entriesMap == null || result == null) { + if (verifyLimit(result, limit)) { QueryObserver observer = QueryObserverHolder.getInstance(); if (observer != null) { observer.limitAppliedAtIndexLevel(this, limit, result); @@ -1089,7 +1089,7 @@ public class RangeIndex extends AbstractIndex { } QueryObserver observer = QueryObserverHolder.getInstance(); if (entriesMap instanceof SortedMap) { - Iterator entriesIter = ((SortedMap) entriesMap).entrySet().iterator(); + Iterator entriesIter = ((Map) entriesMap).entrySet().iterator(); Map.Entry entry = null; boolean foundKeyToRemove = false; @@ -1180,8 +1180,8 @@ public class RangeIndex extends AbstractIndex { int limit = -1; Boolean applyLimit = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_LIMIT_AT_INDEX); - if (applyLimit != null && applyLimit.booleanValue()) { - limit = ((Integer) context.cacheGet(CompiledValue.RESULT_LIMIT)).intValue(); + if (applyLimit != null && applyLimit) { + limit = (Integer) context.cacheGet(CompiledValue.RESULT_LIMIT); } Boolean orderByClause = (Boolean) context.cacheGet(CompiledValue.CAN_APPLY_ORDER_BY_AT_INDEX); @@ -1189,7 +1189,7 @@ public class RangeIndex extends AbstractIndex { List orderByAttrs = null; boolean asc = true; boolean applyOrderBy = false; - if (orderByClause != null && orderByClause.booleanValue()) { + if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); asc = !csc.getCriterion(); @@ -1280,7 +1280,7 @@ public class RangeIndex extends AbstractIndex { List orderByAttrs = null; boolean multiColOrderBy = false; - if (orderByClause != null && orderByClause.booleanValue()) { + if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); asc = !csc.getCriterion(); @@ -1359,7 +1359,7 @@ public class RangeIndex extends AbstractIndex { boolean multiColOrderBy = false; List orderByAttrs = null; boolean asc = true; - if (orderByClause != null && orderByClause.booleanValue()) { + if (orderByClause != null && orderByClause) { orderByAttrs = (List) context.cacheGet(CompiledValue.ORDERBY_ATTRIB); CompiledSortCriterion csc = (CompiledSortCriterion) orderByAttrs.get(0); asc = !csc.getCriterion(); @@ -1396,7 +1396,7 @@ public class RangeIndex extends AbstractIndex { } public String dump() { - StringBuffer sb = new StringBuffer(toString()).append(" {\n"); + StringBuilder sb = new StringBuilder(toString()).append(" {\n"); sb.append("Null Values\n"); Iterator nI = nullMappedEntries.entrySet().iterator(); while (nI.hasNext()) { @@ -1428,11 +1428,12 @@ public class RangeIndex extends AbstractIndex { Iterator i1 = this.valueToEntriesMap.entrySet().iterator(); while (i1.hasNext()) { Map.Entry indexEntry = (Map.Entry) i1.next(); - sb.append(" Key = " + indexEntry.getKey()).append("\n"); - sb.append(" Value Type = ").append(" " + indexEntry.getValue().getClass().getName()) + sb.append(" Key = ").append(indexEntry.getKey()).append("\n"); + sb.append(" Value Type = ").append(" ").append(indexEntry.getValue().getClass().getName()) .append("\n"); if (indexEntry.getValue() instanceof Map) { - sb.append(" Value Size = ").append(" " + ((Map) indexEntry.getValue()).size()).append("\n"); + sb.append(" Value Size = ").append(" ").append(((Map) indexEntry.getValue()).size()) + .append("\n"); } Iterator i2 = ((RegionEntryToValuesMap) indexEntry.getValue()).entrySet().iterator(); while (i2.hasNext()) { @@ -1453,7 +1454,6 @@ public class RangeIndex extends AbstractIndex { return sb.toString(); } - public static void setTestHook(TestHook hook) { RangeIndex.testHook = hook; } @@ -1469,10 +1469,8 @@ public class RangeIndex extends AbstractIndex { public RangeIndexStatistics(String indexName) { this.vsdStats = new IndexStats(getRegion().getCache().getDistributedSystem(), indexName); - } - /** * Return the total number of times this index has been updated */ @@ -1520,7 +1518,6 @@ public class RangeIndex extends AbstractIndex { this.vsdStats.incUsesInProgress(delta); } - public void incReadLockCount(int delta) { this.vsdStats.incReadLockCount(delta); } @@ -1581,7 +1578,7 @@ public class RangeIndex extends AbstractIndex { @Override public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append("No Keys = ").append(getNumberOfKeys()).append("\n"); sb.append("No Values = ").append(getNumberOfValues()).append("\n"); sb.append("No Uses = ").append(getTotalUses()).append("\n"); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java index 0de3d24..10623b4 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterConfigurationService.java @@ -446,9 +446,9 @@ public class ClusterConfigurationService { for (Entry<String, Configuration> stringConfigurationEntry : configRegion.entrySet()) { Configuration config = stringConfigurationEntry.getValue(); for (String jar : config.getJarNames()) { - if (!getPathToJarOnThisLocator((String) stringConfigurationEntry.getKey(), jar).toFile() + if (!getPathToJarOnThisLocator(stringConfigurationEntry.getKey(), jar).toFile() .exists()) { - downloadJarFromOtherLocators((String) stringConfigurationEntry.getKey(), jar); + downloadJarFromOtherLocators(stringConfigurationEntry.getKey(), jar); } } } http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java index 6a230e3..8e51b9d 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalLocator.java @@ -1181,6 +1181,7 @@ public class InternalLocator extends Locator implements ConnectListener { @Override public SharedConfigurationStatusResponse call() throws InterruptedException { final InternalLocator locator = InternalLocator.this; + // TODO: this for-loop is probably not necessary as the if to break is always true for (int i = 0; i < MAX_RETRIES; i++) { if (locator.sharedConfig != null) { SharedConfigurationStatus status = locator.sharedConfig.getStatus(); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerImpl.java index c8d1954..670c697 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerImpl.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/CacheServerImpl.java @@ -83,7 +83,6 @@ import org.apache.geode.management.membership.ClientMembershipListener; */ @SuppressWarnings("deprecation") public class CacheServerImpl extends AbstractCacheServer implements DistributionAdvisee { - private static final Logger logger = LogService.getLogger(); private static final int FORCE_LOAD_UPDATE_FREQUENCY = getInteger( @@ -579,9 +578,10 @@ public class CacheServerImpl extends AbstractCacheServer implements Distribution "Could not create client subscription overflow directory: " + dir.getAbsolutePath()); } File[] dirs = {dir}; + DiskStoreFactory dsf = cache.createDiskStoreFactory(); - DiskStore bsi = - dsf.setAutoCompact(true).setDiskDirsAndSizes(dirs, new int[] {MAX_VALUE}).create("bsi"); + dsf.setAutoCompact(true).setDiskDirsAndSizes(dirs, new int[] {MAX_VALUE}).create("bsi"); + factory.setDiskStoreName("bsi"); // backward compatibility, it was sync factory.setDiskSynchronous(true); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/ColocationHelper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/ColocationHelper.java b/geode-core/src/main/java/org/apache/geode/internal/cache/ColocationHelper.java index c471021..ed08175 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/ColocationHelper.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/ColocationHelper.java @@ -15,7 +15,19 @@ package org.apache.geode.internal.cache; -import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.apache.logging.log4j.Logger; import org.apache.geode.cache.DiskStore; import org.apache.geode.cache.EntryDestroyedException; @@ -32,23 +44,13 @@ import org.apache.geode.internal.cache.persistence.PRPersistentConfig; import org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderQueue; import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.internal.logging.LogService; -import org.apache.geode.internal.logging.log4j.LocalizedMessage; - -import org.apache.logging.log4j.Logger; - -import java.io.Serializable; -import java.util.*; -import java.util.Map.Entry; /** * An utility class to retrieve colocated regions in a colocation hierarchy in various scenarios - * - * + * * @since GemFire 6.0 */ public class ColocationHelper { - - /** Logging mechanism for debugging */ private static final Logger logger = LogService.getLogger(); /** @@ -136,7 +138,7 @@ public class ColocationHelper { } if (prConf.getColocatedWith() != null) { if (prConf.getColocatedWith().equals(tempToBeColocatedWith.getFullPath()) - || (getLineSeparator() + prConf.getColocatedWith()) + || (Region.SEPARATOR + prConf.getColocatedWith()) .equals(tempToBeColocatedWith.getFullPath())) { colocatedRegions.add(prConf); tempcolocatedRegions.add(prConf); http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java index ad2e1c1..efe2723 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/DistributedRegion.java @@ -3210,9 +3210,7 @@ public class DistributedRegion extends LocalRegion implements CacheDistributionA // since we are playing the role return true; } - Set<InternalDistributedMember> members = this.distAdvisor.adviseGeneric(); - for (InternalDistributedMember member1 : members) { - DistributedMember member = (DistributedMember) member1; + for (DistributedMember member : this.distAdvisor.adviseGeneric()) { Set<Role> roles = member.getRoles(); if (roles.contains(role)) { return true; http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java index 55189a5..5d052fb 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java @@ -10134,7 +10134,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory, } Set successfulKeys = new HashSet(successfulPuts.size()); - successfulKeys.addAll(successfulPuts.getKeys()); + for (Object key : successfulPuts.getKeys()) { + successfulKeys.add(key); + } for (Iterator it = putAllOp.eventIterator(); it.hasNext();) { @Unretained @@ -10166,7 +10168,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory, } Set successfulKeys = new HashSet(successfulOps.size()); - successfulKeys.addAll(successfulOps.getKeys()); + for (Object key : successfulOps.getKeys()) { + successfulKeys.add(key); + } for (Iterator it = removeAllOp.eventIterator(); it.hasNext();) { @Unretained http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionAttributesImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionAttributesImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionAttributesImpl.java index a07ff27..161562a 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionAttributesImpl.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionAttributesImpl.java @@ -763,7 +763,7 @@ public class PartitionAttributesImpl implements PartitionAttributes, Cloneable, long availableOffHeapMemoryInMB = 0; if (testAvailableOffHeapMemory != null) { availableOffHeapMemoryInMB = - OffHeapStorage.parseOffHeapMemorySize(testAvailableOffHeapMemory) / (1024 << 10); + OffHeapStorage.parseOffHeapMemorySize(testAvailableOffHeapMemory) / (1024 * 1024); } else if (InternalDistributedSystem.getAnyInstance() == null) { this.localMaxMemoryExists = false; // fix 52033: return non-negative, non-zero temporary placeholder for offHeapLocalMaxMemory http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java index 4606b78..4e061ea 100755 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/PartitionedRegion.java @@ -451,7 +451,7 @@ public class PartitionedRegion extends LocalRegion private ScheduledExecutorService bucketSorter; - private ConcurrentMap<String, Integer[]> partitionsMap = new ConcurrentHashMap<>(); + private final ConcurrentMap<String, Integer[]> partitionsMap = new ConcurrentHashMap<>(); public ConcurrentMap<String, Integer[]> getPartitionsMap() { return this.partitionsMap; @@ -6488,11 +6488,6 @@ public class PartitionedRegion extends LocalRegion return this.prStats; } - // fix for bug #42945 - PR.size() does not pay attention to transaction state - // @Override - // public int entryCount() { - // return entryCount(null); - // } /* non-transactional size calculation */ @Override public int getRegionSize() { @@ -6511,10 +6506,12 @@ public class PartitionedRegion extends LocalRegion } } + @Override public int entryCount(Set<Integer> buckets) { return entryCount(buckets, false); } + @Override public int entryCount(Set<Integer> buckets, boolean estimate) { Map<Integer, SizeEntry> bucketSizes = null; if (buckets != null) { @@ -6554,8 +6551,6 @@ public class PartitionedRegion extends LocalRegion } } return size; - - } @Override @@ -6652,8 +6647,6 @@ public class PartitionedRegion extends LocalRegion return this.lockOwned; } - - private void basicLock() { if (enableAlerts) { ReplyProcessor21.forceSevereAlertProcessing(); @@ -7050,7 +7043,6 @@ public class PartitionedRegion extends LocalRegion + "be destroyed, unless all its children [%s] are destroyed", this.getFullPath(), childRegionList)); } - } } @@ -7073,12 +7065,6 @@ public class PartitionedRegion extends LocalRegion missingColocatedRegionLogger = null; } - public void addMissingColocatedRegionLogger() { - if (missingColocatedRegionLogger == null) { - missingColocatedRegionLogger = new ColocationLogger(this); - } - } - public void addMissingColocatedRegionLogger(String childName) { if (missingColocatedRegionLogger == null) { missingColocatedRegionLogger = new ColocationLogger(this); @@ -7101,37 +7087,6 @@ public class PartitionedRegion extends LocalRegion return Collections.emptyList(); } - /** - * Globally destroy the partitioned region by sending a message to a data store to do the destroy. - * - * @return true if the region was destroyed successfully - */ - private boolean destroyOnDataStore(Object aCallbackArgument) { - RegionAdvisor advisor = getRegionAdvisor(); - Set<InternalDistributedMember> attempted = new HashSet<InternalDistributedMember>(); - - checkReadiness(); - while (!isDestroyed()) { - Set<InternalDistributedMember> available = advisor.adviseInitializedDataStore(); - available.removeAll(attempted); - if (available.isEmpty()) { - return false; - } - InternalDistributedMember next = available.iterator().next(); - try { - DestroyRegionOnDataStoreMessage.send(next, this, aCallbackArgument); - return true; - } catch (ReplyException e) { - // try the next member - if (logger.isTraceEnabled()) { - logger.trace("Error destroying " + this + " on " + next, e); - } - } - } - - return true; - } - public void destroyParallelGatewaySenderRegion(Operation op, boolean cacheWrite, boolean lock, boolean callbackEvents) { @@ -7555,8 +7510,7 @@ public class PartitionedRegion extends LocalRegion * the region type and invokes the relevant method. * * @param destroyDiskRegion - true if the contents on disk should be destroyed - * @param event the RegionEvent <br> - * OVERRIDES + * @param event the RegionEvent */ @Override protected void postDestroyRegion(boolean destroyDiskRegion, RegionEventImpl event) { @@ -7564,11 +7518,6 @@ public class PartitionedRegion extends LocalRegion logger.debug("PartitionedRegion#postDestroyRegion: {}", this); } Assert.assertTrue(this.isDestroyed || this.isClosed); - // bruce disabled the dumping of entries to keep the size of dunit log files - // from growing unreasonably large - // if (this.dataStore != null && logger.isDebugEnabled()) { - // this.dataStore.dumpEntries(false); - // } // Fixes 44551 - wait for persistent buckets to finish // recovering before sending the destroy region message @@ -7703,13 +7652,13 @@ public class PartitionedRegion extends LocalRegion * @return true, if it is eligible for the region destroy */ private boolean checkIfAlreadyDestroyedOrOldReference() { - boolean isAlreadyDestroyedOrOldReference = false; PartitionRegionConfig prConfig = null; try { prConfig = prRoot.get(this.getRegionIdentifier()); } catch (CancelException ignore) { // ignore, metadata not accessible } + boolean isAlreadyDestroyedOrOldReference = false; if (null == prConfig) { isAlreadyDestroyedOrOldReference = true; } else { @@ -7743,7 +7692,6 @@ public class PartitionedRegion extends LocalRegion } } - @Override protected void generateLocalFilterRouting(InternalCacheEvent event) { if (event.getLocalFilterInfo() == null) { @@ -7751,7 +7699,6 @@ public class PartitionedRegion extends LocalRegion } } - /** * Invoke the cache writer before a put is performed. Each BucketRegion delegates to the * CacheWriter on the PartitionedRegion meaning that CacheWriters on a BucketRegion should only be @@ -7878,11 +7825,6 @@ public class PartitionedRegion extends LocalRegion } } - /* - * (non-Javadoc) - * - * @see org.apache.geode.internal.cache.LocalRegion#dumpBackingMap() - */ @Override public void dumpBackingMap() { dumpAllBuckets(true); @@ -7989,29 +7931,8 @@ public class PartitionedRegion extends LocalRegion return localPrimaryList; } - // /** - // * Gets the nodeList for a bucketId from B2N Region removing the nodes that - // * are not found in both membershipSet and prConfig meta-data region. - // * - // * @param bucketId - // * @return list of nodes for bucketId - // */ - // ArrayList getNodeList(Integer bucketId) - // { - // ArrayList nList = null; - // VersionedArrayList val = (VersionedArrayList)this.getBucket2Node().get( - // bucketId); - // if (val != null) { - // nList = this.getRedundancyProvider().verifyBucketNodes(val.getListCopy()); - // if (nList.size() == 0) { - // PartitionedRegionHelper.logForDataLoss(this, bucketId.intValue(), - // "getNodeList"); - // } - // } - // return nList; - // } - /** doesn't throw RegionDestroyedException, used by CacheDistributionAdvisor */ + @Override public DistributionAdvisee getParentAdvisee() { return (DistributionAdvisee) basicGetParentRegion(); } @@ -8200,8 +8121,8 @@ public class PartitionedRegion extends LocalRegion * * @since GemFire 5.1 */ - public static interface SetCollector { - public void receiveSet(Set theSet) throws IOException; + public interface SetCollector { + void receiveSet(Set theSet) throws IOException; } /** @@ -8345,7 +8266,6 @@ public class PartitionedRegion extends LocalRegion LocalizedStrings.IndexManager_INDEX_NAMED_0_ALREADY_EXISTS.toLocalizedString(indexName)); } - FutureTask<Index> oldIndexFutureTask = (FutureTask<Index>) ind; Index index = null; boolean interrupted = false; @@ -8577,7 +8497,6 @@ public class PartitionedRegion extends LocalRegion return bucketIndexes; } - private boolean sendCreateIndexesMessage(boolean remotelyOriginated, HashSet<IndexCreationData> indexDefinitions, Set<Index> indexes, HashMap<String, Exception> exceptionsMap) throws CacheException, ForceReattemptException { @@ -8585,7 +8504,7 @@ public class PartitionedRegion extends LocalRegion if (!remotelyOriginated) { logger.info( LocalizedStrings.PartitionedRegion_CREATED_INDEX_LOCALLY_SENDING_INDEX_CREATION_MESSAGE_TO_ALL_MEMBERS_AND_WILL_BE_WAITING_FOR_RESPONSE_0); - IndexCreationMsg.IndexCreationResponse response = null; + IndexCreationMsg.IndexCreationResponse response; try { response = (IndexCreationMsg.IndexCreationResponse) IndexCreationMsg.send(null, this, indexDefinitions); @@ -8603,15 +8522,14 @@ public class PartitionedRegion extends LocalRegion } } } - } catch (UnsupportedOperationException ex) { + } catch (UnsupportedOperationException ignore) { // if remote nodes are of older versions indexes will not be created // there, so remove index on this node as well. for (Index ind : indexes) { exceptionsMap.put(ind.getName(), new IndexCreationException( LocalizedStrings.PartitionedRegion_INDEX_CREATION_FAILED_ROLLING_UPGRADE - .toLocalizedString(), - ex)); + .toLocalizedString())); this.indexes.remove(ind); indexManager.removeIndex(ind); } @@ -8631,18 +8549,18 @@ public class PartitionedRegion extends LocalRegion return; } - RegionAdvisor advisor = (RegionAdvisor) (this.getCacheDistributionAdvisor()); - final Set recipients = advisor.adviseDataStore(); + RegionAdvisor advisor = (RegionAdvisor) getCacheDistributionAdvisor(); + final Set<InternalDistributedMember> recipients = advisor.adviseDataStore(); if (!recipients.contains(idM)) { logger.info(LocalizedMessage.create( LocalizedStrings.PartitionedRegion_NEWLY_ADDED_MEMBER_TO_THE_PR_IS_AN_ACCESSOR_AND_WILL_NOT_RECEIVE_INDEX_INFORMATION_0, idM)); return; } - // this should add the member to a synchornized set and then sent this member + // this should add the member to a synchronized set and then sent this member // and index creation msg latter after its completed creating the partitioned region. - IndexCreationMsg.IndexCreationResponse response = null; - IndexCreationMsg.IndexCreationResult result = null; + IndexCreationMsg.IndexCreationResponse response; + IndexCreationMsg.IndexCreationResult result; if (this.indexes.isEmpty()) { return; @@ -8670,7 +8588,7 @@ public class PartitionedRegion extends LocalRegion (IndexCreationMsg.IndexCreationResponse) IndexCreationMsg.send(idM, this, indexDefinitions); if (logger.isDebugEnabled()) { - logger.debug("Sending explictly index creation message to : {}", idM); + logger.debug("Sending explicitly index creation message to : {}", idM); } if (response != null) { @@ -8682,8 +8600,8 @@ public class PartitionedRegion extends LocalRegion ((PartitionedIndex) ind) .setRemoteBucketesIndexed(remoteIndexBucketsMap.get(ind.getName())); } - } catch (ForceReattemptException ignor) { - logger.info(LocalizedStrings.PartitionedRegion_FORCEREATTEMPT_EXCEPTION___0, ignor); + } catch (ForceReattemptException e) { + logger.info(LocalizedStrings.PartitionedRegion_FORCEREATTEMPT_EXCEPTION___0, e); } } } @@ -8709,10 +8627,9 @@ public class PartitionedRegion extends LocalRegion this)); try { - Iterator bucketIterator = dataStore.getAllLocalBuckets().iterator(); - while (bucketIterator.hasNext()) { + for (Object bucketEntryObject : dataStore.getAllLocalBuckets()) { LocalRegion bucket = null; - Map.Entry bucketEntry = (Map.Entry) bucketIterator.next(); + Map.Entry bucketEntry = (Map.Entry) bucketEntryObject; bucket = (LocalRegion) bucketEntry.getValue(); if (bucket != null) { bucket.waitForData(); @@ -8729,7 +8646,7 @@ public class PartitionedRegion extends LocalRegion if (logger.isDebugEnabled()) { logger.debug("Removed this many indexes on the buckets : {}", numBuckets); } - RemoveIndexesMessage.RemoveIndexesResponse response = null; + RemoveIndexesMessage.RemoveIndexesResponse response; if (!remotelyOriginated) { logger.info(LocalizedMessage.create( @@ -8754,7 +8671,6 @@ public class PartitionedRegion extends LocalRegion } // outer try block finally { - // this.indexes = null; this.indexes.clear(); } } @@ -8765,7 +8681,7 @@ public class PartitionedRegion extends LocalRegion * @param ind Index to be removed. * */ - public int removeIndex(Index ind, boolean remotelyOrignated) + public int removeIndex(Index ind, boolean remotelyOriginated) throws CacheException, ForceReattemptException { int numBuckets = 0; @@ -8792,9 +8708,9 @@ public class PartitionedRegion extends LocalRegion ind.getName(), ind); } - Index i = this.indexManager.getIndex(ind.getName()); - if (i != null) { - this.indexManager.removeIndex(i); + Index index1 = this.indexManager.getIndex(ind.getName()); + if (index1 != null) { + this.indexManager.removeIndex(index1); } // After removing from region wait for removing from index manager and @@ -8834,9 +8750,9 @@ public class PartitionedRegion extends LocalRegion ((PartitionedIndex) prIndex).releaseIndexWriteLockForRemove(); } - if (!remotelyOrignated) { + if (!remotelyOriginated) { // send remove index message. - RemoveIndexesMessage.RemoveIndexesResponse response = null; + RemoveIndexesMessage.RemoveIndexesResponse response; logger.info(LocalizedMessage.create( LocalizedStrings.PartitionedRegion_SENDING_REMOVEINDEX_MESSAGE_TO_ALL_THE_PARTICIPATING_PRS)); response = @@ -8862,22 +8778,18 @@ public class PartitionedRegion extends LocalRegion * @param indexName name of the index to be removed. */ public int removeIndex(String indexName) throws CacheException, ForceReattemptException { - int numbuckets = 0; - // remotely orignated removeindex - // IndexTask indexTask = new IndexTask(indexName); + int numBuckets = 0; + // remotely originated removeindex Object ind = this.indexes.get(indexName); // Check if the returned value is instance of Index (this means the index is // not in create phase, its created successfully). if (ind instanceof Index) { - numbuckets = removeIndex((Index) this.indexes.get(indexName), true); + numBuckets = removeIndex((Index) this.indexes.get(indexName), true); } - return numbuckets; + return numBuckets; } - /* - * @OVERRIDES - */ @Override public Object getValueInVM(Object key) throws EntryNotFoundException { if (this.dataStore == null) { @@ -8930,8 +8842,7 @@ public class PartitionedRegion extends LocalRegion * @throws ForceReattemptException if the caller should reattempt this request */ public List getBucketOwnersForValidation(int bucketId) throws ForceReattemptException { - // bucketid 1 => "vm A", false | "vm B", false | "vm C", true | "vm D", - // false + // bucketid 1 => "vm A", false | "vm B", false | "vm C", true | "vm D", false // bucketid 2 => List< Tuple(MemberId mem, Boolean isPrimary) > // remotely fetch each VM's bucket meta-data (versus looking at the bucket @@ -9028,25 +8939,24 @@ public class PartitionedRegion extends LocalRegion } } + @Override public synchronized void memberJoined(InternalDistributedMember id) { // bug #44684 - this notification has been moved to a point AFTER the // other member has finished initializing its region - // if (PartitionedRegion.this.isInitialized() && hasListener()) { - // RegionEventImpl event = new RegionEventImpl(PartitionedRegion.this, - // Operation.REGION_CREATE, null, true, id); - // dispatchListenerEvent(EnumListenerEvent.AFTER_REMOTE_REGION_CREATE, - // event); - // } + // required-roles functionality is not implemented for partitioned regions, // or it would be done here } + @Override public void quorumLost(Set<InternalDistributedMember> failures, List<InternalDistributedMember> remaining) {} + @Override public void memberSuspect(InternalDistributedMember id, InternalDistributedMember whoSuspected, String reason) {} + @Override public synchronized void memberDeparted(InternalDistributedMember id, boolean crashed) { if (PartitionedRegion.this.isInitialized() && hasListener()) { RegionEventImpl event = @@ -9054,7 +8964,7 @@ public class PartitionedRegion extends LocalRegion if (crashed) { dispatchListenerEvent(EnumListenerEvent.AFTER_REMOTE_REGION_CRASH, event); } else { - // @todo darrel: it would be nice to know if what actual op was done + // TODO: it would be nice to know if what actual op was done // could be close, local destroy, or destroy (or load snap?) if (DestroyRegionOperation.isRegionDepartureNotificationOk()) { dispatchListenerEvent(EnumListenerEvent.AFTER_REMOTE_REGION_DEPARTURE, event); @@ -9089,12 +8999,11 @@ public class PartitionedRegion extends LocalRegion return re; } - - @Override protected boolean usesDiskStore(RegionAttributes regionAttributes) { - if (regionAttributes.getPartitionAttributes().getLocalMaxMemory() <= 0) + if (regionAttributes.getPartitionAttributes().getLocalMaxMemory() <= 0) { return false; // see bug 42055 + } return super.usesDiskStore(regionAttributes); } @@ -9124,7 +9033,7 @@ public class PartitionedRegion extends LocalRegion logger.debug("PartitionedRegion {} handling {}", getFullPath(), event); } // Process event in remote data stores by sending message - Set allRemoteStores = getRegionAdvisor().adviseDataStore(true); + Set<InternalDistributedMember> allRemoteStores = getRegionAdvisor().adviseDataStore(true); if (logger.isDebugEnabled()) { logger.debug("PartitionedRegion {} sending InterestEvent message to:{}", getFullPath(), allRemoteStores); @@ -9182,9 +9091,8 @@ public class PartitionedRegion extends LocalRegion ExpirationAttributes attr = super.setRegionTimeToLive(timeToLive); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setRegionTimeToLive(timeToLive); } @@ -9207,9 +9115,8 @@ public class PartitionedRegion extends LocalRegion ExpirationAttributes attr = super.setRegionIdleTimeout(idleTimeout); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setRegionIdleTimeout(idleTimeout); } @@ -9233,9 +9140,8 @@ public class PartitionedRegion extends LocalRegion ExpirationAttributes attr = super.setEntryTimeToLive(timeToLive); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setEntryTimeToLive(timeToLive); } @@ -9264,9 +9170,8 @@ public class PartitionedRegion extends LocalRegion CustomExpiry expiry = super.setCustomEntryTimeToLive(custom); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setCustomEntryTimeToLive(custom); } @@ -9291,9 +9196,8 @@ public class PartitionedRegion extends LocalRegion ExpirationAttributes attr = super.setEntryIdleTimeout(idleTimeout); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setEntryIdleTimeout(idleTimeout); } @@ -9313,9 +9217,8 @@ public class PartitionedRegion extends LocalRegion CustomExpiry expiry = super.setCustomEntryIdleTimeout(custom); // Set to Bucket regions as well if (this.getDataStore() != null) { // not for accessors - Iterator iter = this.getDataStore().getAllLocalBuckets().iterator(); - while (iter.hasNext()) { - Map.Entry entry = (Map.Entry) iter.next(); + for (Object o : this.getDataStore().getAllLocalBuckets()) { + Map.Entry entry = (Map.Entry) o; Region bucketRegion = (Region) entry.getValue(); bucketRegion.getAttributesMutator().setCustomEntryIdleTimeout(custom); } @@ -9376,7 +9279,7 @@ public class PartitionedRegion extends LocalRegion HeapEvictor.BUCKET_SORTING_INTERVAL); } } - List<BucketRegion> bucketList = new ArrayList<BucketRegion>(); + List<BucketRegion> bucketList = new ArrayList<>(); if (!bucketSortedOnce.get()) { while (bucketSortedOnce.get() == false); } @@ -9385,6 +9288,7 @@ public class PartitionedRegion extends LocalRegion } class BucketSorterThread implements Runnable { + @Override public void run() { try { List<BucketRegion> bucketList = new ArrayList<BucketRegion>(); @@ -9464,7 +9368,6 @@ public class PartitionedRegion extends LocalRegion BucketRegion br = null; final Object entryKey = keyInfo.getKey(); try { - int count = 0; final int retryAttempts = calcRetry(); // TODO provide appropriate Operation and arg int bucketId = keyInfo.getBucketId(); @@ -9473,6 +9376,7 @@ public class PartitionedRegion extends LocalRegion keyInfo.getCallbackArg()); keyInfo.setBucketId(bucketId); } + int count = 0; while (count <= retryAttempts) { try { PartitionedRegionDataStore ds = getDataStore(); @@ -9516,16 +9420,16 @@ public class PartitionedRegion extends LocalRegion } @Override - public DistributedMember getOwnerForKey(KeyInfo keyInfo) { - if (keyInfo == null) { + public DistributedMember getOwnerForKey(KeyInfo key) { + if (key == null) { return super.getOwnerForKey(null); } // TODO provide appropriate Operation and arg - int bucketId = keyInfo.getBucketId(); + int bucketId = key.getBucketId(); if (bucketId == KeyInfo.UNKNOWN_BUCKET) { - bucketId = PartitionedRegionHelper.getHashKey(this, null, keyInfo.getKey(), - keyInfo.getValue(), keyInfo.getCallbackArg()); - keyInfo.setBucketId(bucketId); + bucketId = PartitionedRegionHelper.getHashKey(this, null, key.getKey(), key.getValue(), + key.getCallbackArg()); + key.setBucketId(bucketId); } return createBucket(bucketId, 0, null); } @@ -9573,8 +9477,6 @@ public class PartitionedRegion extends LocalRegion public String toString() { return "SizeEntry(" + size + ", primary=" + isPrimary + ")"; } - - } /** @@ -9595,8 +9497,6 @@ public class PartitionedRegion extends LocalRegion private String fromClause; - // public List p_list; - public String imports; public boolean loadEntries; @@ -9640,10 +9540,10 @@ public class PartitionedRegion extends LocalRegion /** * This starts creating the index. */ + @Override public PartitionedIndex call() throws IndexCreationException, IndexNameConflictException, IndexExistsException, ForceReattemptException { - // List list = p_list; - PartitionedIndex prIndex = null; + PartitionedIndex prIndex; if (dataStore != null) { prIndex = createIndexOnPRBuckets(); @@ -9669,7 +9569,6 @@ public class PartitionedRegion extends LocalRegion */ private PartitionedIndex createIndexOnPRBuckets() throws IndexNameConflictException, IndexExistsException, IndexCreationException { - // List list = p_list; Set localBuckets = getDataStore().getAllLocalBuckets(); Iterator it = localBuckets.iterator(); @@ -9678,18 +9577,15 @@ public class PartitionedRegion extends LocalRegion compiler.compileImports(imports); } - // list = compiler.compileFromClause(fromClause); - + // imports can be null PartitionedIndex parIndex = new PartitionedIndex(indexType, indexName, PartitionedRegion.this, - indexedExpression, fromClause, imports); // imports can be null - String modifiedFromClause; + indexedExpression, fromClause, imports); + // In cases where we have no data yet (creation from cache xml), it would leave the populated - // flag to false - // Not really an issue as a put will trigger bucket index creation which should set this the - // flag to true - // However if the region is empty, we should set this flag to true so it will be reported as - // used even though - // there is no data in the region + // flag to false Not really an issue as a put will trigger bucket index creation which should + // set this the flag to true However if the region is empty, we should set this flag to true + // so it will be reported as used even though there is no data in the region + if (!it.hasNext()) { parIndex.setPopulated(true); } @@ -9720,7 +9616,6 @@ public class PartitionedRegion extends LocalRegion } // End of bucket list return parIndex; } - } public List<FixedPartitionAttributesImpl> getFixedPartitionAttributesImpl() { @@ -9770,17 +9665,16 @@ public class PartitionedRegion extends LocalRegion * This data of the partitions (FixedPartitionAttributes with starting bucket id for the Fixed * Partitioned Region) is stored in metadata for each member. */ - private void calculateStartingBucketIDs(PartitionRegionConfig prConfig) { if (BEFORE_CALCULATE_STARTING_BUCKET_FLAG) { PartitionedRegionObserver pro = PartitionedRegionObserverHolder.getInstance(); pro.beforeCalculatingStartingBucketId(); } - int startingBucketID = 0; List<FixedPartitionAttributesImpl> fpaList = getFixedPartitionAttributesImpl(); if (this.getColocatedWith() == null) { Set<FixedPartitionAttributesImpl> elderFPAs = prConfig.getElderFPAs(); + int startingBucketID = 0; if (elderFPAs != null && !elderFPAs.isEmpty()) { int largestStartBucId = -1; for (FixedPartitionAttributesImpl fpa : elderFPAs) { http://git-wip-us.apache.org/repos/asf/geode/blob/00709dd7/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/SharedConfigurationStatus.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/SharedConfigurationStatus.java b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/SharedConfigurationStatus.java index fb687c8..3f93b6c 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/SharedConfigurationStatus.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/SharedConfigurationStatus.java @@ -14,10 +14,6 @@ */ package org.apache.geode.management.internal.configuration.domain; -/*** - * - * - */ public enum SharedConfigurationStatus { NOT_STARTED, STARTED, RUNNING, STOPPED, WAITING, UNDETERMINED }
