You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2017/05/12 22:18:31 UTC
[28/51] [abbrv] [partial] geode git commit: GEODE-2632: change
dependencies on GemFireCacheImpl to InternalCache
http://git-wip-us.apache.org/repos/asf/geode/blob/654d65b5/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 e8daa18..2985fdb 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
@@ -12,9 +12,9 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-
package org.apache.geode.internal.cache;
+import static org.apache.geode.internal.lang.SystemUtils.getLineSeparator;
import static org.apache.geode.internal.offheap.annotations.OffHeapIdentifier.ENTRY_EVENT_NEW_VALUE;
import org.apache.geode.CancelCriterion;
@@ -22,6 +22,7 @@ import org.apache.geode.CancelException;
import org.apache.geode.CopyHelper;
import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
+import org.apache.geode.Delta;
import org.apache.geode.DeltaSerializationException;
import org.apache.geode.InternalGemFireError;
import org.apache.geode.InternalGemFireException;
@@ -63,7 +64,6 @@ import org.apache.geode.cache.RegionAttributes;
import org.apache.geode.cache.RegionDestroyedException;
import org.apache.geode.cache.RegionEvent;
import org.apache.geode.cache.RegionExistsException;
-import org.apache.geode.cache.RegionMembershipListener;
import org.apache.geode.cache.RegionReinitializedException;
import org.apache.geode.cache.Scope;
import org.apache.geode.cache.StatisticsDisabledException;
@@ -117,7 +117,6 @@ import org.apache.geode.i18n.StringId;
import org.apache.geode.internal.Assert;
import org.apache.geode.internal.ClassLoadUtil;
import org.apache.geode.internal.HeapDataOutputStream;
-import org.apache.geode.internal.InternalStatisticsDisabledException;
import org.apache.geode.internal.NanoTimer;
import org.apache.geode.internal.Version;
import org.apache.geode.internal.cache.AbstractRegionMap.ARMLockTestHook;
@@ -138,6 +137,7 @@ import org.apache.geode.internal.cache.execute.RegionFunctionContextImpl;
import org.apache.geode.internal.cache.execute.ServerToClientFunctionResultSender;
import org.apache.geode.internal.cache.ha.ThreadIdentifier;
import org.apache.geode.internal.cache.lru.LRUEntry;
+import org.apache.geode.internal.cache.partitioned.Bucket;
import org.apache.geode.internal.cache.partitioned.RedundancyAlreadyMetException;
import org.apache.geode.internal.cache.persistence.DiskExceptionHandler;
import org.apache.geode.internal.cache.persistence.DiskRecoveryStore;
@@ -167,6 +167,7 @@ import org.apache.geode.internal.logging.log4j.LocalizedMessage;
import org.apache.geode.internal.logging.log4j.LogMarker;
import org.apache.geode.internal.offheap.OffHeapHelper;
import org.apache.geode.internal.offheap.ReferenceCountHelper;
+import org.apache.geode.internal.offheap.Releasable;
import org.apache.geode.internal.offheap.StoredObject;
import org.apache.geode.internal.offheap.annotations.Released;
import org.apache.geode.internal.offheap.annotations.Retained;
@@ -193,7 +194,6 @@ import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -212,17 +212,24 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
/**
* Implementation of a local scoped-region. Note that this class has a different meaning starting
* with 3.0. In previous versions, a LocalRegion was the representation of a region in the VM.
* Starting with 3.0, a LocalRegion is a non-distributed region. The subclass DistributedRegion adds
* distribution behavior.
- *
*/
@SuppressWarnings("deprecation")
public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
ResourceListener<MemoryEvent>, DiskExceptionHandler, DiskRecoveryStore {
- private static final Logger logger = LogService.getLogger();
+
+ // package-private to avoid synthetic accessor
+ static final Logger logger = LogService.getLogger();
+
private static final Pattern NAME_PATTERN = Pattern.compile("[aA-zZ0-9-_.]+");
/**
@@ -231,7 +238,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @since GemFire 5.7
*/
public interface TestCallable {
- public void call(LocalRegion r, Operation op, RegionEntry re);
+ void call(LocalRegion r, Operation op, RegionEntry re);
}
// view types for iterators
@@ -239,7 +246,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
KEYS, VALUES, ENTRIES
}
- // iniitialization level
+ // initialization level
public static final int AFTER_INITIAL_IMAGE = 0;
public static final int BEFORE_INITIAL_IMAGE = 1;
@@ -249,60 +256,70 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* thread local to indicate that this thread should bypass the initialization Latch
*/
- private static final ThreadLocal initializationThread = new ThreadLocal();
+ private static final ThreadLocal<Integer> initializationThread = new ThreadLocal();
/* thread local to indicate its for persist data convert tool */
- protected static final ThreadLocal isConversion = new ThreadLocal();
+ static final ThreadLocal isConversion = new ThreadLocal();
// user attributes //
private Object regionUserAttribute;
- protected Map entryUserAttributes; // @todo darrel: shouldn't this be an
-
- // identity map whose key is a RegionEntry?
+ // TODO: shouldn't this be an identity map whose key is a RegionEntry?
+ Map entryUserAttributes;
private final String regionName;
protected final LocalRegion parentRegion;
- // set to true only if isDestroyed is also true
- // and region is about to be recreated due to reinitialization by loading
- // of a snapshot, etc.
+ /**
+ * set to true only if isDestroyed is also true and region is about to be recreated due to
+ * reinitialization by loading of a snapshot, etc.
+ */
private volatile boolean reinitialized_old = false;
protected volatile boolean isDestroyed = false;
- // In case of parallel wan, when a destroy is called on userPR, it waits for
- // parallelQueue to drain and then destroys paralleQueue. In this time if
- // operation like put happens on userPR then it will keep on building parallel
- // queue increasing time of userPR to get destroyed.this volatile boolean will
- // block such put operation by throwing RegionDestroyedException
- protected volatile boolean isDestroyedForParallelWAN = false;
+ /**
+ * In case of parallel wan, when a destroy is called on userPR, it waits for parallelQueue to
+ * drain and then destroys parallelQueue. In this time if operation like put happens on userPR
+ * then it will keep on building parallel queue increasing time of userPR to get destroyed.this
+ * volatile boolean will block such put operation by throwing RegionDestroyedException
+ */
+ volatile boolean isDestroyedForParallelWAN = false;
- // set to true after snapshot is loaded, to help get initial image
- // make sure this is the right incarnation of this region
+ /**
+ * set to true after snapshot is loaded, to help get initial image make sure this is the right
+ * incarnation of this region
+ */
private volatile boolean reinitialized_new = false;
/** Lock used to prevent multiple concurrent destroy region operations */
private Semaphore destroyLock;
- // guarded by regionExpiryLock.
+ /** GuardedBy regionExpiryLock. */
private RegionTTLExpiryTask regionTTLExpiryTask = null;
- // guarded by regionExpiryLock.
+
+ /** GuardedBy regionExpiryLock. */
private RegionIdleExpiryTask regionIdleExpiryTask = null;
private final Object regionExpiryLock = new Object();
- // guarded by regionExpiryLock. Keeps track of how many txs are writing to this region.
+
+ /**
+ * GuardedBy regionExpiryLock. Keeps track of how many txs are writing to this region.
+ */
private int txRefCount;
private final ConcurrentHashMap<RegionEntry, EntryExpiryTask> entryExpiryTasks =
- new ConcurrentHashMap<RegionEntry, EntryExpiryTask>();
+ new ConcurrentHashMap<>();
/**
* Set to true after an invalidate region expiration so we don't get multiple expirations
*/
volatile boolean regionInvalid = false;
+ /**
+ * TODO: make this private and introduce wrappers
+ */
public final RegionMap entries;
/**
@@ -311,11 +328,10 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
private final boolean supportsTX;
/** tracks threadID->seqno information for this region */
- protected EventTracker eventTracker;
+ EventTracker eventTracker;
/**
- * tracks region-level version information for members. See
- * https://wiki.gemstone.com/display/gfe70/Consistency+in+Replicated+Regions+and+WAN
+ * tracks region-level version information for members
*/
private RegionVersionVector versionVector;
@@ -340,7 +356,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// you can't trust the assignment of a volatile (as indicated above)
// to mean that the the thing being assigned is fully formed, only
// those things *before* the assignment are fully formed. mthomas 10/02/2005
- private volatile boolean entriesInitialized;
+ private final boolean entriesInitialized;
/**
* contains Regions themselves // marked volatile to make sure it is fully initialized before
@@ -350,17 +366,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
private final Object subregionsLock = new Object();
- // Used for synchronizzing access to client Cqs
- // private final Object clientCqsSync = new Object();
-
/**
* Prevents access to this region until it is done initializing, except for some special
* initializing operations such as replying to create region messages In JDK 1.5 we will use
* java.util.concurrent.CountDownLatch instead of org.apache.geode.internal.util.CountDownLatch.
*/
- protected final StoppableCountDownLatch initializationLatchBeforeGetInitialImage;
+ final StoppableCountDownLatch initializationLatchBeforeGetInitialImage;
- protected final StoppableCountDownLatch initializationLatchAfterGetInitialImage;
+ final StoppableCountDownLatch initializationLatchAfterGetInitialImage;
/**
* Used to hold off cache listener events until the afterRegionCreate is called
@@ -387,10 +400,10 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* Used for serializing netSearch and netLoad on a per key basis. CM <Object, Future>
*/
- protected final ConcurrentMap getFutures = new ConcurrentHashMap();
+ private final ConcurrentMap getFutures = new ConcurrentHashMap();
- /*
- * Asif: This boolean needs to be made true if the test needs to receive a synchronous callback
+ /**
+ * TODO: This boolean needs to be made true if the test needs to receive a synchronous callback
* just after clear on map is done. Its visibility is default so that only tests present in
* org.apache.geode.internal.cache will be able to see it
*/
@@ -400,46 +413,45 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* A flag used to indicate that this Region is being used as an administrative Region, holding
* meta-data for a PartitionedRegion
*/
- final private boolean isUsedForPartitionedRegionAdmin;
+ private final boolean isUsedForPartitionedRegionAdmin;
- final private boolean isUsedForPartitionedRegionBucket;
+ private final boolean isUsedForPartitionedRegionBucket;
- final private boolean isUsedForMetaRegion;
+ private final boolean isUsedForMetaRegion;
- final private boolean isMetaRegionWithTransactions;
+ private final boolean isMetaRegionWithTransactions;
- final private boolean isUsedForSerialGatewaySenderQueue;
+ private final boolean isUsedForSerialGatewaySenderQueue;
- final private boolean isUsedForParallelGatewaySenderQueue;
+ private final boolean isUsedForParallelGatewaySenderQueue;
- final private AbstractGatewaySender serialGatewaySender;
+ private final AbstractGatewaySender serialGatewaySender;
/**
* The factory used to create the LoaderHelper when a loader is invoked
*/
- protected final LoaderHelperFactory loaderHelperFactory;
+ final LoaderHelperFactory loaderHelperFactory;
/**
- * Allow for different cacheperfstats locations... primarily for PartitionedRegions
+ * Allow for different CachePerfStats locations... primarily for PartitionedRegions
*/
private final CachePerfStats cachePerfStats;
- private final boolean hasOwnStats;
+ private final boolean hasOwnStats;
private final ImageState imageState;
+
/**
* Register interest count to track if any register interest is in progress for this region. This
* count will be incremented when register interest starts and decremented when register interest
* finishes.
- *
- * @guarded.By {@link #imageState}
+ * <p>
+ * since always written while holding an exclusive write lock and only read while holding a read
+ * lock it does not need to be atomic or protected by any other sync.
+ * <p>
+ * GuardedBy {@link #imageState}
*/
- private int riCnt =
- 0; /*
- * since always written while holding an exclusive write lock and only read while holding a
- * read lock it does not need to be atomic or protected by any other sync.
- */
-
+ private int riCnt = 0;
/**
* Map of subregion full paths to serial numbers. These are subregions that were destroyed when
@@ -453,55 +465,49 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
*/
public final AtomicBoolean memoryThresholdReached = new AtomicBoolean(false);
- // Lock for updating PR MetaData on client side
+ /**
+ * Lock for updating PR MetaData on client side
+ * <p>
+ * TODO: move this to ClientMetadataService into {@code Map<Region, Lock>}
+ */
public final Lock clientMetaDataLock = new ReentrantLock();
/**
* There seem to be cases where a region can be created and yet the distributed system is not yet
* in place...
- *
- *
*/
protected class Stopper extends CancelCriterion {
@Override
public String cancelInProgress() {
- // ---
// This grossness is necessary because there are instances where the
// region can exist without having a cache (XML creation)
checkFailure();
- Cache c = LocalRegion.this.getCache();
- if (c == null) {
+ Cache cache = LocalRegion.this.getCache();
+ if (cache == null) {
return LocalizedStrings.LocalRegion_THE_CACHE_IS_NOT_AVAILABLE.toLocalizedString();
}
- // --- end of grossness
- return c.getCancelCriterion().cancelInProgress();
+ return cache.getCancelCriterion().cancelInProgress();
}
- /*
- * (non-Javadoc)
- *
- * @see org.apache.geode.CancelCriterion#generateCancelledException(java.lang.Throwable)
- */
@Override
public RuntimeException generateCancelledException(Throwable e) {
- // ---
// This grossness is necessary because there are instances where the
// region can exist without having a cache (XML creation)
checkFailure();
- Cache c = LocalRegion.this.getCache();
- if (c == null) {
+ Cache cache = LocalRegion.this.getCache();
+ if (cache == null) {
return new CacheClosedException("No cache", e);
}
- // --- end of grossness
- return c.getCancelCriterion().generateCancelledException(e);
+ return cache.getCancelCriterion().generateCancelledException(e);
}
}
protected final CancelCriterion stopper = createStopper();
- protected CancelCriterion createStopper() {
+ // TODO: change createStopper to be private (fix EventTrackerTest)
+ public CancelCriterion createStopper() {
return new Stopper();
}
@@ -516,7 +522,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
*
* Currently used by the OpLog layer.
*/
- private final static ThreadLocal<LocalRegion> initializingRegion = new ThreadLocal<LocalRegion>();
+ private static final ThreadLocal<LocalRegion> initializingRegion = new ThreadLocal<LocalRegion>();
/**
* Get the current initializing region as set in the ThreadLocal.
@@ -524,7 +530,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* Note that this value is cleared after the initialization of LocalRegion is done so is valid
* only for the duration of region creation and initialization.
*/
- public static LocalRegion getInitializingRegion() {
+ static LocalRegion getInitializingRegion() {
return initializingRegion.get();
}
@@ -532,11 +538,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return this.stopper;
}
- protected Map<String, CacheServiceProfile> cacheServiceProfiles;
-
- ////////////////// Public Methods ///////////////////////////////////////////
+ Map<String, CacheServiceProfile> cacheServiceProfiles;
- static String calcFullPath(String regionName, LocalRegion parentRegion) {
+ private static String calcFullPath(String regionName, LocalRegion parentRegion) {
StringBuilder buf = null;
if (parentRegion == null) {
buf = new StringBuilder(regionName.length() + 1);
@@ -553,9 +557,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* Creates new region
*/
protected LocalRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion,
- GemFireCacheImpl cache, InternalRegionArguments internalRegionArgs)
- throws DiskAccessException {
+ InternalCache cache, InternalRegionArguments internalRegionArgs) throws DiskAccessException {
super(cache, attrs, regionName, internalRegionArgs);
+
// Initialized here (and defers to parent) to fix GEODE-128
this.EXPIRY_UNITS_MS = parentRegion != null ? parentRegion.EXPIRY_UNITS_MS
: Boolean.getBoolean(EXPIRY_MS_PROPERTY);
@@ -602,15 +606,17 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- this.dsi = findDiskStore(attrs, internalRegionArgs);
+ this.diskStoreImpl = findDiskStore(attrs, internalRegionArgs);
this.diskRegion = createDiskRegion(internalRegionArgs);
this.entries = createRegionMap(internalRegionArgs);
this.entriesInitialized = true;
this.subregions = new ConcurrentHashMap();
+
// we only need a destroy lock if this is a root
if (parentRegion == null) {
initRoot();
}
+
if (internalRegionArgs.getLoaderHelperFactory() != null) {
this.loaderHelperFactory = internalRegionArgs.getLoaderHelperFactory();
} else {
@@ -636,8 +642,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
// initialize client to server proxy
- this.srp = (this.getPoolName() != null) ? new ServerRegionProxy(this) : null;
- this.imageState = new UnsharedImageState(this.srp != null,
+ this.serverRegionProxy = this.getPoolName() != null ? new ServerRegionProxy(this) : null;
+ this.imageState = new UnsharedImageState(this.serverRegionProxy != null,
getDataPolicy().withReplication() || getDataPolicy().isPreloaded(),
getAttributes().getDataPolicy().withPersistence(), this.stopper);
@@ -648,7 +654,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
|| isMetaRegionWithTransactions();
this.testCallable = internalRegionArgs.getTestCallable();
-
}
private RegionMap createRegionMap(InternalRegionArguments internalRegionArgs) {
@@ -673,10 +678,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* initialize the event tracker. Not all region implementations want or need one of these. Regions
- * that require one should reimplement this method and create one like so: <code><pre>
- * this.eventTracker = new EventTracker(this.cache);
- * this.eventTracker.start();
- * </pre></code>
+ * that require one should reimplement this method and create one like so:
+ *
+ * <pre>
+ * {@code
+ * this.eventTracker = new EventTracker(this.cache);
+ * this.eventTracker.start();
+ * }
+ * </pre>
*/
void createEventTracker() {
// if LocalRegion is changed to have an event tracker, then the initialize()
@@ -684,12 +693,10 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// region finishes initialization
}
-
/**
- *
* Other region classes may track events using different mechanisms than EventTrackers
*/
- protected EventTracker getEventTracker() {
+ EventTracker getEventTracker() {
return this.eventTracker;
}
@@ -699,7 +706,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/** returns object used to guard the size() operation during tombstone removal */
- public Object getSizeGuard() {
+ Object getSizeGuard() {
if (!this.concurrencyChecksEnabled) {
return new Object();
} else {
@@ -709,21 +716,20 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/** initializes a new version vector for this region */
- protected void createVersionVector() {
-
+ void createVersionVector() {
this.versionVector = RegionVersionVector.create(getVersionMember(), this);
- if (dataPolicy.withPersistence()) {
+ if (this.dataPolicy.withPersistence()) {
// copy the versions that we have recovered from disk into
// the version vector.
RegionVersionVector diskVector = this.diskRegion.getRegionVersionVector();
this.versionVector.recordVersions(diskVector.getCloneForTransmission());
- } else if (!dataPolicy.withStorage()) {
+ } else if (!this.dataPolicy.withStorage()) {
// version vectors are currently only necessary in empty regions for
// tracking canonical member IDs
this.versionVector.turnOffRecordingForEmptyRegion();
}
- if (this.srp != null) {
+ if (this.serverRegionProxy != null) {
this.versionVector.setIsClientVector();
}
this.cache.getDistributionManager().addMembershipListener(this.versionVector);
@@ -749,7 +755,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* Test hook - returns the version stamp for an entry in the form of a version tag
*
- * @param key
* @return the entry version information
*/
public VersionTag getVersionTag(Object key) {
@@ -781,16 +786,16 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* @since GemFire 5.7
*/
- protected final ServerRegionProxy srp;
+ final ServerRegionProxy serverRegionProxy;
private final InternalDataView sharedDataView;
- public final ServerRegionProxy getServerProxy() {
- return this.srp;
+ public ServerRegionProxy getServerProxy() {
+ return this.serverRegionProxy;
}
- public final boolean hasServerProxy() {
- return this.srp != null;
+ public boolean hasServerProxy() {
+ return this.serverRegionProxy != null;
}
/** Returns true if the ExpiryTask is currently allowed to expire. */
@@ -798,9 +803,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return true;
}
- void performExpiryTimeout(ExpiryTask p_task) throws CacheException {
- if (p_task != null) {
- p_task.basicPerformTimeout(false);
+ void performExpiryTimeout(ExpiryTask expiryTask) throws CacheException {
+ if (expiryTask != null) {
+ expiryTask.basicPerformTimeout(false);
}
}
@@ -809,37 +814,28 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
public void handleMarker() {
-
RegionEventImpl event = new RegionEventImpl(this, Operation.MARKER, null, false, getMyId(),
false /* generate EventID */);
dispatchListenerEvent(EnumListenerEvent.AFTER_REGION_LIVE, event);
}
+ @Override
public AttributesMutator getAttributesMutator() {
checkReadiness();
return this;
}
- public Region createSubregion(String subregionName, RegionAttributes regionAttributes)
+ @Override
+ public Region createSubregion(String subregionName, RegionAttributes aRegionAttributes)
throws RegionExistsException, TimeoutException {
try {
- return createSubregion(subregionName, regionAttributes,
+ return createSubregion(subregionName, aRegionAttributes,
new InternalRegionArguments().setDestroyLockFlag(true).setRecreateFlag(false));
- } catch (IOException e) {
- // only happens when loading a snapshot, not here
- InternalGemFireError assErr = new InternalGemFireError(
- LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString());
- assErr.initCause(e);
- throw assErr;
-
- } catch (ClassNotFoundException e) {
+ } catch (IOException | ClassNotFoundException e) {
// only happens when loading a snapshot, not here
- InternalGemFireError assErr = new InternalGemFireError(
- LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString());
- assErr.initCause(e);
- throw assErr;
-
+ throw new InternalGemFireError(
+ LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString(), e);
}
}
@@ -850,27 +846,32 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
*/
@Override
protected InternalDistributedMember getMyId() {
- return this.cache.getMyId();
+ return this.cache.getInternalDistributedSystem().getDistributedMember();
}
public VersionSource getVersionMember() {
- if (dataPolicy.withPersistence()) {
+ if (this.dataPolicy.withPersistence()) {
return getDiskStore().getDiskStoreID();
} else {
- return this.cache.getMyId();
+ return this.cache.getInternalDistributedSystem().getDistributedMember();
}
}
+ // TODO: createSubregion method is too complex for IDE to analyze
public Region createSubregion(String subregionName, RegionAttributes attrs,
InternalRegionArguments internalRegionArgs)
throws RegionExistsException, TimeoutException, IOException, ClassNotFoundException {
+
checkReadiness();
- LocalRegion newRegion = null;
RegionAttributes regionAttributes = attrs;
- attrs = cache.invokeRegionBefore(this, subregionName, attrs, internalRegionArgs);
+ // TODO: attrs is reassigned but never used
+ attrs = this.cache.invokeRegionBefore(this, subregionName, attrs, internalRegionArgs);
+
final InputStream snapshotInputStream = internalRegionArgs.getSnapshotInputStream();
final boolean getDestroyLock = internalRegionArgs.getDestroyLockFlag();
final InternalDistributedMember imageTarget = internalRegionArgs.getImageTarget();
+
+ LocalRegion newRegion = null;
try {
if (getDestroyLock)
acquireDestroyLock();
@@ -885,7 +886,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
validateRegionName(subregionName, internalRegionArgs);
validateSubregionAttributes(regionAttributes);
- String regionPath = calcFullPath(subregionName, this);
// lock down the subregionsLock
// to prevent other threads from adding a region to it in toRegion
@@ -918,13 +918,12 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
: new DistributedRegion(subregionName, regionAttributes, this, this.cache,
internalRegionArgs);
}
- Object o = this.subregions.putIfAbsent(subregionName, newRegion);
+ Object previousValue = this.subregions.putIfAbsent(subregionName, newRegion);
- Assert.assertTrue(o == null);
+ Assert.assertTrue(previousValue == null);
Assert.assertTrue(!newRegion.isInitialized());
- //
if (logger.isDebugEnabled()) {
logger.debug("Subregion created: {}", newRegion.getFullPath());
}
@@ -936,8 +935,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
} // endif: existing == null
} // end synchronization
} finally {
- if (getDestroyLock)
+ if (getDestroyLock) {
releaseDestroyLock();
+ }
}
// Fix for bug 42127 - moved to outside of the destroy lock.
@@ -950,7 +950,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
throw new RegionExistsException(existing);
}
-
boolean success = false;
try {
newRegion.checkReadiness();
@@ -959,23 +958,26 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
internalRegionArgs
.setIndexes(((UserSpecifiedRegionAttributes) regionAttributes).getIndexes());
}
- newRegion.initialize(snapshotInputStream, imageTarget, internalRegionArgs); // releases
- // initialization
- // Latches
+
+ // releases initialization Latches
+ newRegion.initialize(snapshotInputStream, imageTarget, internalRegionArgs);
+
// register the region with resource manager to get memory events
if (!newRegion.isInternalRegion()) {
if (!newRegion.isDestroyed) {
- cache.getInternalResourceManager().addResourceListener(ResourceType.MEMORY, newRegion);
+ this.cache.getInternalResourceManager().addResourceListener(ResourceType.MEMORY,
+ newRegion);
if (!newRegion.getOffHeap()) {
newRegion.initialCriticalMembers(
- cache.getInternalResourceManager().getHeapMonitor().getState().isCritical(),
- cache.getResourceAdvisor().adviseCritialMembers());
+ this.cache.getInternalResourceManager().getHeapMonitor().getState().isCritical(),
+ this.cache.getResourceAdvisor().adviseCritialMembers());
} else {
- newRegion.initialCriticalMembers(cache.getInternalResourceManager().getHeapMonitor()
- .getState().isCritical()
- || cache.getInternalResourceManager().getOffHeapMonitor().getState().isCritical(),
- cache.getResourceAdvisor().adviseCritialMembers());
+ newRegion.initialCriticalMembers(
+ this.cache.getInternalResourceManager().getHeapMonitor().getState().isCritical()
+ || this.cache.getInternalResourceManager().getOffHeapMonitor().getState()
+ .isCritical(),
+ this.cache.getResourceAdvisor().adviseCritialMembers());
}
// synchronization would be done on ManagementAdapter.regionOpLock
@@ -990,7 +992,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
} catch (CancelException | RegionDestroyedException | RedundancyAlreadyMetException e) {
// don't print a call stack
throw e;
- } catch (final RuntimeException validationException) {
+ } catch (RuntimeException validationException) {
logger
.warn(
LocalizedMessage.create(
@@ -1001,7 +1003,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
if (!success) {
this.cache.setRegionByPath(newRegion.getFullPath(), null);
initializationFailed(newRegion);
- cache.getInternalResourceManager(false).removeResourceListener(newRegion);
+ this.cache.getInternalResourceManager(false).removeResourceListener(newRegion);
}
}
@@ -1018,10 +1020,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- cache.invokeRegionAfter(newRegion);
+ this.cache.invokeRegionAfter(newRegion);
return newRegion;
}
+ @Override
public void create(Object key, Object value, Object aCallbackArgument)
throws TimeoutException, EntryExistsException, CacheWriterException {
long startPut = CachePerfStats.getStatTime();
@@ -1034,11 +1037,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- public final void validatedCreate(EntryEventImpl event, long startPut)
+ private void validatedCreate(EntryEventImpl event, long startPut)
throws TimeoutException, EntryExistsException, CacheWriterException {
if (event.getEventId() == null && generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
// Fix for 42448 - Only make create with null a local invalidate for
// normal regions. Otherwise, it will become a distributed invalidate.
@@ -1061,8 +1064,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
@Retained
- public final EntryEventImpl newCreateEntryEvent(Object key, Object value,
- Object aCallbackArgument) {
+ private EntryEventImpl newCreateEntryEvent(Object key, Object value, Object aCallbackArgument) {
validateArguments(key, value, aCallbackArgument);
checkReadiness();
@@ -1079,9 +1081,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* SingleWriteSingleReadRegionQueue.SingleReadWriteMetaRegion to return false as the event
* propagation from those regions do not need EventID objects
*
- * <p>
- * author Asif
- *
* @return boolean indicating whether to generate eventID or not
*/
@Override
@@ -1089,7 +1088,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return !isUsedForPartitionedRegionAdmin();
}
- public final Object destroy(Object key, Object aCallbackArgument)
+ @Override
+ public Object destroy(Object key, Object aCallbackArgument)
throws TimeoutException, EntryNotFoundException, CacheWriterException {
@Released
EntryEventImpl event = newDestroyEntryEvent(key, aCallbackArgument);
@@ -1107,7 +1107,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
public Object validatedDestroy(Object key, EntryEventImpl event)
throws TimeoutException, EntryNotFoundException, CacheWriterException {
if (event.getEventId() == null && generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
basicDestroy(event, true, // cacheWrite
null); // expectedOldValue
@@ -1119,7 +1119,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
@Retained
- public final EntryEventImpl newDestroyEntryEvent(Object key, Object aCallbackArgument) {
+ EntryEventImpl newDestroyEntryEvent(Object key, Object aCallbackArgument) {
validateKey(key);
validateCallbackArg(aCallbackArgument);
checkReadiness();
@@ -1129,6 +1129,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
aCallbackArgument, false, getMyId());
}
+ @Override
public void destroyRegion(Object aCallbackArgument)
throws CacheWriterException, TimeoutException {
getDataView().checkSupportsRegionDestroy();
@@ -1153,36 +1154,37 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @param keyInfo to which the value is associated
* @param updateStats true if the entry stats should be updated.
* @param disableCopyOnRead if true then disable copy on read
- * @param preferCD true if the preferred result form is CachedDeserializable
+ * @param preferCachedDeserializable true if the preferred result form is CachedDeserializable
* @param clientEvent client's event, if any (for version tag retrieval)
* @param returnTombstones whether destroyed entries should be returned
* @param retainResult if true then the result may be a retained off-heap reference
* @return the value for the given key
*/
- public final Object getDeserializedValue(RegionEntry re, final KeyInfo keyInfo,
- final boolean updateStats, boolean disableCopyOnRead, boolean preferCD,
+ public Object getDeserializedValue(RegionEntry regionEntry, final KeyInfo keyInfo,
+ final boolean updateStats, boolean disableCopyOnRead, boolean preferCachedDeserializable,
EntryEventImpl clientEvent, boolean returnTombstones, boolean retainResult) {
if (this.diskRegion != null) {
this.diskRegion.setClearCountReference();
}
try {
- if (re == null) {
- re = this.entries.getEntry(keyInfo.getKey());
+ if (regionEntry == null) {
+ regionEntry = this.entries.getEntry(keyInfo.getKey());
}
// skip updating the stats if the value is null
// TODO - We need to clean up the callers of the this class so that we can
// update the statistics here, where it would make more sense.
- if (re == null) {
+ if (regionEntry == null) {
return null;
}
final Object value;
- if (clientEvent != null && re.getVersionStamp() != null) {
+ if (clientEvent != null && regionEntry.getVersionStamp() != null) {
// defer the lruUpdateCallback to prevent a deadlock (see bug 51121).
final boolean disabled = this.entries.disableLruUpdateCallback();
try {
- synchronized (re) { // bug #51059 value & version must be obtained atomically
- clientEvent.setVersionTag(re.getVersionStamp().asVersionTag());
- value = getDeserialized(re, updateStats, disableCopyOnRead, preferCD, retainResult);
+ synchronized (regionEntry) { // bug #51059 value & version must be obtained atomically
+ clientEvent.setVersionTag(regionEntry.getVersionStamp().asVersionTag());
+ value = getDeserialized(regionEntry, updateStats, disableCopyOnRead,
+ preferCachedDeserializable, retainResult);
}
} finally {
if (disabled) {
@@ -1196,13 +1198,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
} else {
- value = getDeserialized(re, updateStats, disableCopyOnRead, preferCD, retainResult);
+ value = getDeserialized(regionEntry, updateStats, disableCopyOnRead,
+ preferCachedDeserializable, retainResult);
}
if (logger.isTraceEnabled() && !(this instanceof HARegion)) {
logger.trace(
"getDeserializedValue for {} returning version: {} returnTombstones: {} value: {}",
- keyInfo.getKey(),
- (re.getVersionStamp() == null ? "null" : re.getVersionStamp().asVersionTag()),
+ keyInfo.getKey(), regionEntry.getVersionStamp() == null ? "null"
+ : regionEntry.getVersionStamp().asVersionTag(),
returnTombstones, value);
}
return value;
@@ -1214,11 +1217,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/**
- *
- * @param re
- * @param updateStats
* @param disableCopyOnRead if true then do not make a copy on read
- * @param preferCD true if the preferred result form is CachedDeserializable
+ * @param preferCachedDeserializable true if the preferred result form is CachedDeserializable
* @param retainResult if true then the result may be a retained off-heap reference
* @return the value found, which can be
* <ul>
@@ -1228,18 +1228,18 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* </ul>
*/
@Retained
- protected final Object getDeserialized(RegionEntry re, boolean updateStats,
- boolean disableCopyOnRead, boolean preferCD, boolean retainResult) {
- assert !retainResult || preferCD;
+ Object getDeserialized(RegionEntry regionEntry, boolean updateStats, boolean disableCopyOnRead,
+ boolean preferCachedDeserializable, boolean retainResult) {
+ assert !retainResult || preferCachedDeserializable;
boolean disabledLRUCallback = this.entries.disableLruUpdateCallback();
try {
@Retained
- Object v = null;
+ Object value;
try {
if (retainResult) {
- v = re.getValueRetain(this);
+ value = regionEntry.getValueRetain(this);
} else {
- v = re.getValue(this);
+ value = regionEntry.getValue(this);
}
} catch (DiskAccessException dae) {
this.handleDiskAccessException(dae);
@@ -1247,34 +1247,32 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
// skip updating the stats if the value is null
- if (v == null) {
+ if (value == null) {
return null;
}
- if (v instanceof CachedDeserializable) {
- if (!preferCD) {
+ if (value instanceof CachedDeserializable) {
+ if (!preferCachedDeserializable) {
if (isCopyOnRead()) {
if (disableCopyOnRead) {
- v = ((CachedDeserializable) v).getDeserializedForReading();
+ value = ((CachedDeserializable) value).getDeserializedForReading();
} else {
- v = ((CachedDeserializable) v).getDeserializedWritableCopy(this, re);
+ value = ((CachedDeserializable) value).getDeserializedWritableCopy(this, regionEntry);
}
} else {
- v = ((CachedDeserializable) v).getDeserializedValue(this, re);
+ value = ((CachedDeserializable) value).getDeserializedValue(this, regionEntry);
}
}
} else if (!disableCopyOnRead) {
- v = conditionalCopy(v);
+ value = conditionalCopy(value);
}
if (updateStats) {
- updateStatsForGet(re, v != null && !Token.isInvalid(v));
+ updateStatsForGet(regionEntry, value != null && !Token.isInvalid(value));
}
- return v;
+ return value;
} catch (IllegalArgumentException i) {
- IllegalArgumentException iae = new IllegalArgumentException(LocalizedStrings.DONT_RELEASE
- .toLocalizedString("Error while deserializing value for key=" + re.getKey()));
- iae.initCause(i);
- throw iae;
+ throw new IllegalArgumentException(LocalizedStrings.DONT_RELEASE
+ .toLocalizedString("Error while deserializing value for key=" + regionEntry.getKey()), i);
} finally {
if (disabledLRUCallback) {
this.entries.enableLruUpdateCallback();
@@ -1294,8 +1292,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return result;
}
- /*
- * @see BucketRegion#getSerialized(KeyInfo, boolean, boolean)
+ /**
+ * @see BucketRegion#getSerialized(KeyInfo, boolean, boolean, ClientProxyMembershipID,
+ * EntryEventImpl, boolean)
*/
public Object get(Object key, Object aCallbackArgument, boolean generateCallbacks,
boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient,
@@ -1324,7 +1323,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* find the value if it is not local
*/
@Retained
- public Object getRetained(Object key, Object aCallbackArgument, boolean generateCallbacks,
+ private Object getRetained(Object key, Object aCallbackArgument, boolean generateCallbacks,
boolean disableCopyOnRead, ClientProxyMembershipID requestingClient,
EntryEventImpl clientEvent, boolean returnTombstones, boolean opScopeIsLocal)
throws TimeoutException, CacheLoaderException {
@@ -1392,7 +1391,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @param re optional region entry, fetched if null
* @param key the key used to fetch the region entry
*/
- final public void recordMiss(final RegionEntry re, Object key) {
+ public void recordMiss(final RegionEntry re, Object key) {
if (!this.statisticsEnabled) {
return;
}
@@ -1408,25 +1407,19 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* optimized to only allow one thread to do a search/load, other threads wait on a future
*
- * @param keyInfo
- * @param p_isCreate true if call found no entry; false if updating an existing entry
- * @param generateCallbacks
- * @param p_localValue the value retrieved from the region for this object.
+ * @param isCreate true if call found no entry; false if updating an existing entry
+ * @param localValue the value retrieved from the region for this object.
* @param disableCopyOnRead if true then do not make a copy
* @param preferCD true if the preferred result form is CachedDeserializable
* @param clientEvent the client event, if any
* @param returnTombstones whether to return tombstones
*/
@Retained
- Object nonTxnFindObject(KeyInfo keyInfo, boolean p_isCreate, boolean generateCallbacks,
- Object p_localValue, boolean disableCopyOnRead, boolean preferCD,
+ Object nonTxnFindObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks,
+ Object localValue, boolean disableCopyOnRead, boolean preferCD,
ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent,
boolean returnTombstones) throws TimeoutException, CacheLoaderException {
- final Object key = keyInfo.getKey();
- Object localValue = p_localValue;
- boolean isCreate = p_isCreate;
- Object[] valueAndVersion = null;
@Retained
Object result = null;
FutureResult thisFuture = new FutureResult(this.stopper);
@@ -1434,7 +1427,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// only one thread can get their future into the map for this key at a time
if (otherFuture != null) {
try {
- valueAndVersion = (Object[]) otherFuture.get();
+ Object[] valueAndVersion = (Object[]) otherFuture.get();
if (valueAndVersion != null) {
result = valueAndVersion[0];
if (clientEvent != null) {
@@ -1453,24 +1446,22 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
result = conditionalCopy(result);
}
// what was a miss is now a hit
- RegionEntry re = null;
if (isCreate) {
- re = basicGetEntry(keyInfo.getKey());
- updateStatsForGet(re, true);
+ RegionEntry regionEntry = basicGetEntry(keyInfo.getKey());
+ updateStatsForGet(regionEntry, true);
}
return result;
}
// if value == null, try our own search/load
- } catch (InterruptedException e) {
+ } catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
// TODO check a CancelCriterion here?
return null;
} catch (ExecutionException e) {
// unexpected since there is no background thread
- InternalGemFireError err = new InternalGemFireError(
- LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString());
- err.initCause(err);
- throw err;
+ // NOTE: this was creating InternalGemFireError and initCause with itself
+ throw new InternalGemFireError(
+ LocalizedStrings.LocalRegion_UNEXPECTED_EXCEPTION.toLocalizedString(), e);
}
}
// didn't find a future, do one more probe for the entry to catch a race
@@ -1492,11 +1483,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
} else {
- // This code was moved from PartitionedRegion.nonTxnFindObject(). That method has been
- // removed.
// For PRs we don't want to deserialize the value and we can't use findObjectInSystem
- // because
- // it can invoke code that is transactional.
+ // because it can invoke code that is transactional.
result =
getSharedDataView().findObject(keyInfo, this, isCreate, generateCallbacks, localValue,
disableCopyOnRead, preferCD, requestingClient, clientEvent, returnTombstones);
@@ -1510,7 +1498,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// findObjectInSystem does not call conditionalCopy
} finally {
if (result != null) {
- VersionTag tag = (clientEvent == null) ? null : clientEvent.getVersionTag();
+ VersionTag tag = clientEvent == null ? null : clientEvent.getVersionTag();
thisFuture.set(new Object[] {result, tag});
} else {
thisFuture.set(null);
@@ -1539,7 +1527,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
*
* @since GemFire 4.0
*/
- protected Object conditionalCopy(Object o) {
+ Object conditionalCopy(Object o) {
if (isCopyOnRead() && !Token.isInvalid(o)) {
return CopyHelper.copy(o);
} else {
@@ -1549,34 +1537,23 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
private final String fullPath;
+ @Override
public String getFullPath() {
return this.fullPath;
}
- // public String getFullPath() {
- // // work way up to root region, prepending
- // // the region names to a buffer
- // StringBuffer buf = new StringBuffer(SEPARATOR);
- // Assert.assertTrue(this.regionName != null);
- // buf.append(this.regionName);
- // LocalRegion r = this;
- // while ((r = r.parentRegion) != null) {
- // buf.insert(0, r.regionName);
- // buf.insert(0, SEPARATOR_CHAR);
- // }
- // return buf.toString();
- // }
-
+ @Override
public Region getParentRegion() {
- // checkReadiness();
return this.parentRegion;
}
+ @Override
public Region getSubregion(String path) {
checkReadiness();
return getSubregion(path, false);
}
+ @Override
public void invalidateRegion(Object aCallbackArgument) throws TimeoutException {
getDataView().checkSupportsRegionInvalidate();
validateCallbackArg(aCallbackArgument);
@@ -1588,6 +1565,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
basicInvalidateRegion(event);
}
+ @Override
public Object put(Object key, Object value, Object aCallbackArgument)
throws TimeoutException, CacheWriterException {
long startPut = CachePerfStats.getStatTime();
@@ -1600,11 +1578,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- public final Object validatedPut(EntryEventImpl event, long startPut)
+ Object validatedPut(EntryEventImpl event, long startPut)
throws TimeoutException, CacheWriterException {
if (event.getEventId() == null && generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
Object oldValue = null;
if (basicPut(event, false, // ifNew
@@ -1625,8 +1603,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
@Retained
- public final EntryEventImpl newUpdateEntryEvent(Object key, Object value,
- Object aCallbackArgument) {
+ EntryEventImpl newUpdateEntryEvent(Object key, Object value, Object aCallbackArgument) {
validateArguments(key, value, aCallbackArgument);
if (value == null) {
@@ -1670,31 +1647,27 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// 10. If any exception is caught while invoking the delta callbacks, throw it back.
// 11. Wrap any checked exception in InternalGemFireException before throwing it.
try {
- boolean extractDelta = false;
// How costly is this if check?
- if (this.getSystem().getConfig().getDeltaPropagation()
- && value instanceof org.apache.geode.Delta) {
+ if (getSystem().getConfig().getDeltaPropagation() && value instanceof Delta) {
+ boolean extractDelta = false;
if (!this.hasServerProxy()) {
- if ((this instanceof PartitionedRegion)) {
+ if (this instanceof PartitionedRegion) {
if (((PartitionedRegion) this).getRedundantCopies() > 0) {
extractDelta = true;
} else {
InternalDistributedMember ids = (InternalDistributedMember) PartitionRegionHelper
.getPrimaryMemberForKey(this, event.getKey());
if (ids != null) {
- if (this.getSystem().getMemberId().equals(ids.getId())) {
- extractDelta = hasAdjunctRecipientsNeedingDelta(event);
- } else {
- extractDelta = true;
- }
+ extractDelta = !this.getSystem().getMemberId().equals(ids.getId())
+ || hasAdjunctRecipientsNeedingDelta(event);
} else {
extractDelta = true;
}
}
- } else if ((this instanceof DistributedRegion)
+ } else if (this instanceof DistributedRegion
&& !((DistributedRegion) this).scope.isDistributedNoAck()
- && ((DistributedRegion) this).getCacheDistributionAdvisor().adviseCacheOp()
- .size() > 0) {
+ && !((CacheDistributionAdvisee) this).getCacheDistributionAdvisor().adviseCacheOp()
+ .isEmpty()) {
extractDelta = true;
}
if (!extractDelta && ClientHealthMonitor.getInstance() != null) {
@@ -1730,29 +1703,27 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
@SuppressWarnings("unchecked")
private boolean hasAdjunctRecipientsNeedingDelta(EntryEventImpl event) {
- PartitionedRegion pr = ((PartitionedRegion) this);
- BucketRegion br = null;
- FilterRoutingInfo filterRouting = null;
- Set twoMessages = Collections.EMPTY_SET;
- Set adjunctRecipients = Collections.EMPTY_SET;
- Set cacheservers = null;
+ PartitionedRegion partitionedRegion = (PartitionedRegion) this;
+ BucketRegion bucketRegion;
int bId = event.getKeyInfo().getBucketId();
try {
- br = pr.dataStore.getInitializedBucketForId(event.getKey(), bId);
- } catch (ForceReattemptException fre) {
+ bucketRegion = partitionedRegion.dataStore.getInitializedBucketForId(event.getKey(), bId);
+ } catch (ForceReattemptException ignore) {
return true;
}
Set<InternalDistributedMember> recipients =
- br.getCacheDistributionAdvisor().adviseUpdate(event);
- twoMessages = br.getBucketAdvisor().adviseRequiresTwoMessages();
- CacheDistributionAdvisor cda = pr.getCacheDistributionAdvisor();
- filterRouting = cda.adviseFilterRouting(event, recipients);
- adjunctRecipients = br.getAdjunctReceivers(event, recipients, twoMessages, filterRouting);
- cacheservers = cda.adviseCacheServers();
- return !Collections.disjoint(adjunctRecipients, cacheservers);
+ bucketRegion.getCacheDistributionAdvisor().adviseUpdate(event);
+ Set<Object> twoMessages = bucketRegion.getBucketAdvisor().adviseRequiresTwoMessages();
+ CacheDistributionAdvisor cda = partitionedRegion.getCacheDistributionAdvisor();
+ FilterRoutingInfo filterRouting = cda.adviseFilterRouting(event, recipients);
+ Set<Object> adjunctRecipients =
+ bucketRegion.getAdjunctReceivers(event, recipients, twoMessages, filterRouting);
+ Set cacheServerMembers = cda.adviseCacheServers();
+ return !Collections.disjoint(adjunctRecipients, cacheServerMembers);
}
+ @Override
public Region.Entry getEntry(Object key) {
validateKey(key);
checkReadiness();
@@ -1770,7 +1741,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* Just like getEntry but also updates the stats that get would have depending on a flag. See bug
* 42410. Also skips discovering JTA
*
- * @param key
* @return the entry if it exists; otherwise null.
*/
public Entry accessEntry(Object key, boolean updateStats) {
@@ -1786,32 +1756,31 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/** a fast estimate of total number of entries locally in the region */
public long getEstimatedLocalSize() {
- RegionMap rm;
if (!this.isDestroyed) {
long size;
// if region has not been initialized yet, then get the estimate from
// disk region's recovery map if available
+ RegionMap regionMap;
if (!this.initialized && this.diskRegion != null
- && (rm = this.diskRegion.getRecoveredEntryMap()) != null && (size = rm.size()) > 0) {
+ && (regionMap = this.diskRegion.getRecoveredEntryMap()) != null
+ && (size = regionMap.size()) > 0) {
return size;
}
- if ((rm = getRegionMap()) != null) {
- return rm.size();
+ if ((regionMap = getRegionMap()) != null) {
+ return regionMap.size();
}
}
return 0;
}
/**
- * @param keyInfo
* @param access true if caller wants last accessed time updated
* @param allowTombstones whether an entry with a TOMBSTONE value can be returned
- * @return TODO
*/
protected Region.Entry nonTXGetEntry(KeyInfo keyInfo, boolean access, boolean allowTombstones) {
final Object key = keyInfo.getKey();
RegionEntry re = this.entries.getEntry(key);
- boolean miss = (re == null || re.isDestroyedOrRemoved());
+ boolean miss = re == null || re.isDestroyedOrRemoved();
if (access) {
updateStatsForGet(re, !miss);
}
@@ -1826,12 +1795,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return null;
}
- Region.Entry ren = new NonTXEntry(re);
- // long start=0, end=0;
- // start = System.currentTimeMillis();
- // end = System.currentTimeMillis();
- // System.out.println("getEntry: " + (end-start));
- return ren;
+ return new NonTXEntry(re);
}
/**
@@ -1846,32 +1810,26 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* {@link #isDestroyed()} this method will not return true if the cache is closing but has not yet
* started closing this region.
*/
- public boolean isThisRegionBeingClosedOrDestroyed() {
+ boolean isThisRegionBeingClosedOrDestroyed() {
return this.isDestroyed;
}
/** returns true if this region has been destroyed */
+ @Override
public boolean isDestroyed() {
if (isClosed()) {
return true; // for bug 42328
}
+
boolean isTraceEnabled = logger.isTraceEnabled();
- // boolean result = false;
+
if (this.isDestroyed) {
if (isTraceEnabled) {
logger.trace("isDestroyed: true, this.isDestroyed: {}", getFullPath());
}
return true;
}
- // if (!isInitialized()) { // don't return true if still initializing
- // if (finestEnabled) {
- // log.finest("isDestroyed: false, not initialized: " + getFullPath());
- // }
- // return false;
- // }
- // @todo we could check parents here if we want this to be more accurate,
- // and the isDestroyed field could be made volatile as well.
- // if (this.parentRegion != null) return this.parentRegion.isDestroyed();
+
if (isTraceEnabled) {
logger.trace("isDestroyed: false : {}", getFullPath());
}
@@ -1879,15 +1837,17 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/** a variant of subregions() that does not perform a readiness check */
- protected Set basicSubregions(boolean recursive) {
+ Set basicSubregions(boolean recursive) {
return new SubregionsSet(recursive);
}
+ @Override
public Set subregions(boolean recursive) {
checkReadiness();
return new SubregionsSet(recursive);
}
+ @Override
public Set entrySet(boolean recursive) {
checkReadiness();
checkForNoAccess();
@@ -1928,21 +1888,25 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return new EntriesSet(this, false, IteratorType.KEYS, allowTombstones);
}
+ @Override
public Collection values() {
checkReadiness();
checkForNoAccess();
return new EntriesSet(this, false, IteratorType.VALUES, false);
}
+ @Override
public Object getUserAttribute() {
return this.regionUserAttribute;
}
+ @Override
public void setUserAttribute(Object value) {
checkReadiness();
this.regionUserAttribute = value;
}
+ @Override
public boolean containsKey(Object key) {
checkReadiness();
checkForNoAccess();
@@ -1957,12 +1921,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
} else {
try {
Entry entry = getDataView().getEntry(getKeyInfo(key), this, true);
- if (entry == null) {
- return false;
- } else {
- return (entry.getValue() == Token.TOMBSTONE);
- }
- } catch (EntryDestroyedException e) {
+ return entry != null && entry.getValue() == Token.TOMBSTONE;
+ } catch (EntryDestroyedException ignore) {
return true;
}
}
@@ -1973,24 +1933,20 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
if (contains && this.imageState.isClient()) {
// fix for bug #40871 - concurrent RI causes containsKey for destroyed entry
// to return true
- RegionEntry re = this.entries.getEntry(keyInfo.getKey());
- // TODO:KIRK:OK if (re == null || Token.isRemoved(re.getValueInVM(this))) {
- if (re == null || re.isDestroyedOrRemoved()) {
+ RegionEntry regionEntry = this.entries.getEntry(keyInfo.getKey());
+ if (regionEntry == null || regionEntry.isDestroyedOrRemoved()) {
contains = false;
}
}
return contains;
}
+ @Override
public boolean containsValueForKey(Object key) {
discoverJTA();
return getDataView().containsValueForKey(getKeyInfo(key), this);
}
- /**
- * @param keyInfo
- * @return TODO
- */
protected boolean nonTXContainsValueForKey(KeyInfo keyInfo) {
checkReadiness();
checkForNoAccess();
@@ -2002,8 +1958,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
boolean result = entry != null;
if (result) {
ReferenceCountHelper.skipRefCountTracking();
- Object val = entry.getTransformedValue(); // no need to decompress since we only want to
- // know if we have an existing value
+ // no need to decompress since we only want to know if we have an existing value
+ Object val = entry.getTransformedValue();
if (val instanceof StoredObject) {
OffHeapHelper.release(val);
ReferenceCountHelper.unskipRefCountTracking();
@@ -2024,12 +1980,13 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
+ @Override
public RegionAttributes getAttributes() {
// to fix bug 35134 allow attribute access on closed regions
- // checkReadiness();
return this;
}
+ @Override
public String getName() {
return this.regionName;
}
@@ -2053,10 +2010,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* may change the number of entries in this region while this method is being invoked.
*
* @see RegionMap#size
- *
- * author David Whitlock
*/
- public final int entryCount() {
+ public int entryCount() {
return getDataView().entryCount(this);
}
@@ -2070,11 +2025,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return getDataView().entryCount(this);
}
- public int entryCountEstimate(final TXStateInterface tx, Set<Integer> buckets,
- boolean entryCountEstimate) {
- return entryCount(buckets, entryCountEstimate);
- }
-
/**
* @return size after considering imageState
*/
@@ -2091,9 +2041,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
/**
- * Returns the <code>DiskRegion</code> that this region uses to access data on disk.
+ * Returns the {@code DiskRegion} that this region uses to access data on disk.
*
- * @return <code>null</code> if disk regions are not being used
+ * @return {@code null} if disk regions are not being used
*
* @since GemFire 3.2
*/
@@ -2101,6 +2051,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
return this.diskRegion;
}
+ @Override
public DiskRegionView getDiskRegionView() {
return getDiskRegion();
}
@@ -2114,28 +2065,12 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- /**
- *
- * Initially called by EvictorThread.run
- *
- * @since GemFire 3.5.1
- */
- public void checkLRU() {
- if (this.entriesInitialized) {
- try {
- this.entries.lruUpdateCallback();
- } catch (DiskAccessException dae) {
- this.handleDiskAccessException(dae);
- throw dae;
- }
- }
- }
-
- protected boolean isOverflowEnabled() {
+ private boolean isOverflowEnabled() {
EvictionAttributes ea = getAttributes().getEvictionAttributes();
return ea != null && ea.getAction().isOverflowToDisk();
}
+ @Override
public void writeToDisk() {
if (this.diskRegion == null) {
DataPolicy dp = getDataPolicy();
@@ -2165,6 +2100,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* This implementation only checks readiness and scope
*/
+ @Override
public Lock getRegionDistributedLock() throws IllegalStateException {
checkReadiness();
checkForLimitedOrNoAccess();
@@ -2177,6 +2113,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* This implementation only checks readiness and scope
*/
+ @Override
public Lock getDistributedLock(Object key) throws IllegalStateException {
checkReadiness();
checkForLimitedOrNoAccess();
@@ -2186,6 +2123,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
LocalizedStrings.LocalRegion_ONLY_SUPPORTED_FOR_GLOBAL_SCOPE_NOT_LOCAL.toLocalizedString());
}
+ @Override
public void invalidate(Object key, Object aCallbackArgument)
throws TimeoutException, EntryNotFoundException {
checkReadiness();
@@ -2197,14 +2135,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* Destroys entry without performing validations. Call this after validating key, callback arg,
* and runtime state.
*/
- protected void validatedInvalidate(Object key, Object aCallbackArgument)
+ void validatedInvalidate(Object key, Object aCallbackArgument)
throws TimeoutException, EntryNotFoundException {
@Released
EntryEventImpl event = EntryEventImpl.create(this, Operation.INVALIDATE, key, null,
aCallbackArgument, false, getMyId());
try {
if (generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
basicInvalidate(event);
} finally {
@@ -2212,6 +2150,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
+ @Override
public void localDestroy(Object key, Object aCallbackArgument) throws EntryNotFoundException {
validateKey(key);
checkReadiness();
@@ -2220,7 +2159,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
EntryEventImpl event = EntryEventImpl.create(this, Operation.LOCAL_DESTROY, key, null,
aCallbackArgument, false, getMyId());
if (generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
try {
basicDestroy(event, false, null); // expectedOldValue
@@ -2241,6 +2180,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
+ @Override
public void localDestroyRegion(Object aCallbackArgument) {
getDataView().checkSupportsRegionDestroy();
RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_LOCAL_DESTROY,
@@ -2262,8 +2202,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
+ @Override
public void close() {
-
RegionEventImpl event = new RegionEventImpl(this, Operation.REGION_CLOSE, null, false,
getMyId(), generateEventID()/* generate EventID */);
try {
@@ -2287,17 +2227,18 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- public void localInvalidate(Object key, Object callbackArgument) throws EntryNotFoundException {
+ @Override
+ public void localInvalidate(Object key, Object aCallbackArgument) throws EntryNotFoundException {
validateKey(key);
checkReadiness();
checkForNoAccess();
@Released
EntryEventImpl event = EntryEventImpl.create(this, Operation.LOCAL_INVALIDATE, key,
- null/* newValue */, callbackArgument, false, getMyId());
+ null/* newValue */, aCallbackArgument, false, getMyId());
try {
if (generateEventID()) {
- event.setNewEventId(cache.getDistributedSystem());
+ event.setNewEventId(this.cache.getDistributedSystem());
}
event.setLocalInvalid(true);
basicInvalidate(event);
@@ -2306,6 +2247,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
+ @Override
public void localInvalidateRegion(Object aCallbackArgument) {
getDataView().checkSupportsRegionInvalidate();
checkReadiness();
@@ -2321,28 +2263,21 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @param system the distributed system whose cache contains the root of interest
* @return the LocalRegion or null if not found
*/
- public static LocalRegion getRegionFromPath(DistributedSystem system, String path) {
- Cache c = GemFireCacheImpl.getInstance();
- if (c == null) {
+ static LocalRegion getRegionFromPath(DistributedSystem system, String path) {
+ Cache cache = GemFireCacheImpl.getInstance();
+ if (cache == null) {
return null;
} else {
- return (LocalRegion) c.getRegion(path);
+ return (LocalRegion) cache.getRegion(path);
}
}
- // public void dumpEntryMapStats(PrintStream out) {
- // ((ConcurrentHashMap)this.entries).dumpStats(out);
- // }
-
- ////////////////// Protected Methods ////////////////////////////////////////
-
/**
* Do any extra initialization required. Region is already visible in parent's subregion map. This
* method releases the initialization Latches, so subclasses should call this super method last
* after performing additional initialization.
*
* @param imageTarget ignored, used by subclass for get initial image
- * @param internalRegionArgs
* @see DistributedRegion#initialize(InputStream, InternalDistributedMember,
* InternalRegionArguments)
*/
@@ -2353,7 +2288,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// Subclasses may have already called this method, but this is
// acceptable because addResourceListener won't add it twice
if (!this.isDestroyed) {
- cache.getInternalResourceManager().addResourceListener(ResourceType.MEMORY, this);
+ this.cache.getInternalResourceManager().addResourceListener(ResourceType.MEMORY, this);
}
}
@@ -2368,20 +2303,19 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
try {
this.diskRegion.initializeOwner(this);
this.diskRegion.finishInitializeOwner(this, GIIStatus.NO_GII);
- { // This block was added so that early recovery could figure out that
- // this data needs to be recovered from disk. Local regions used to
- // not bother assigning a memberId but that is what the early
- // recovery
- // code uses to figure out that a region needs to be recovered.
- PersistentMemberID oldId = this.diskRegion.getMyInitializingID();
- if (oldId == null) {
- oldId = this.diskRegion.getMyPersistentID();
- }
- if (oldId == null) {
- PersistentMemberID newId = this.diskRegion.generatePersistentID();
- this.diskRegion.setInitializing(newId);
- this.diskRegion.setInitialized();
- }
+ // This block was added so that early recovery could figure out that
+ // this data needs to be recovered from disk. Local regions used to
+ // not bother assigning a memberId but that is what the early
+ // recovery
+ // code uses to figure out that a region needs to be recovered.
+ PersistentMemberID oldId = this.diskRegion.getMyInitializingID();
+ if (oldId == null) {
+ oldId = this.diskRegion.getMyPersistentID();
+ }
+ if (oldId == null) {
+ PersistentMemberID newId = this.diskRegion.generatePersistentID();
+ this.diskRegion.setInitializing(newId);
+ this.diskRegion.setInitialized();
}
} catch (DiskAccessException dae) {
releaseAfterRegionCreateEventLatch();
@@ -2402,7 +2336,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
throw dae;
}
}
+
releaseAfterGetInitialImageLatch();
+
if (logger.isDebugEnabled()) {
logger.debug("Calling addExpiryTasks for {}", this);
}
@@ -2416,7 +2352,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
rescheduleEntryExpiryTasks(); // called after gii to fix bug 35214
}
initialized();
- } catch (RegionDestroyedException e) {
+ } catch (RegionDestroyedException ignore) {
// whether it is this region or a parent region that is destroyed,
// then so must we be
Assert.assertTrue(isDestroyed());
@@ -2424,15 +2360,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
}
- protected void createOQLIndexes(InternalRegionArguments internalRegionArgs) {
+ void createOQLIndexes(InternalRegionArguments internalRegionArgs) {
createOQLIndexes(internalRegionArgs, false);
}
- protected void createOQLIndexes(InternalRegionArguments internalRegionArgs,
- boolean recoverFromDisk) {
+ void createOQLIndexes(InternalRegionArguments internalRegionArgs, boolean recoverFromDisk) {
if (internalRegionArgs == null || internalRegionArgs.getIndexes() == null
- || internalRegionArgs.getIndexes().size() == 0) {
+ || internalRegionArgs.getIndexes().isEmpty()) {
return;
}
if (logger.isDebugEnabled()) {
@@ -2444,9 +2379,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
if (this.indexManager == null) {
this.indexManager = IndexUtils.getIndexManager(this, true);
}
- Set<Index> indexes = new HashSet<Index>();
- Set<Index> prIndexes = new HashSet<Index>();
- int initLevel = 0;
DiskRegion dr = this.getDiskRegion();
boolean isOverflowToDisk = false;
if (dr != null) {
@@ -2460,6 +2392,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
dr.waitForAsyncRecovery();
}
}
+ Set<Index> indexes = new HashSet<Index>();
+ Set<Index> prIndexes = new HashSet<>();
+ int initLevel = 0;
try {
// Release the initialization latch for index creation.
initLevel = LocalRegion.setThreadInitLevelRequirement(ANY_INIT);
@@ -2485,10 +2420,9 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
if (logger.isDebugEnabled()) {
logger.debug("QueryService Index creation process for {}" + icd.getIndexName());
}
- DefaultQueryService qs =
- (DefaultQueryService) this.getGemFireCache().getLocalQueryService();
+ DefaultQueryService qs = (DefaultQueryService) getGemFireCache().getLocalQueryService();
String fromClause =
- (icd.getIndexType() == IndexType.FUNCTIONAL || icd.getIndexType() == IndexType.HASH)
+ icd.getIndexType() == IndexType.FUNCTIONAL || icd.getIndexType() == IndexType.HASH
? icd.getIndexFromClause() : this.getFullPath();
// load entries during initialization only for non overflow regions
indexes.add(
@@ -2504,11 +2438,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// Other case is when bucket regions are created dynamically, in that case ignore the
// exception.
if (internalRegionArgs.getDeclarativeIndexCreation()) {
- InternalGemFireError err =
- new InternalGemFireError(LocalizedStrings.GemFireCache_INDEX_CREATION_EXCEPTION_1
- .toLocalizedString(new Object[] {icd.getIndexName(), this.getFullPath()}));
- err.initCause(ex);
- throw err;
+ throw new InternalGemFireError(LocalizedStrings.GemFireCache_INDEX_CREATION_EXCEPTION_1
+ .toLocalizedString(icd.getIndexName(), this.getFullPath()), ex);
}
}
}
@@ -2536,7 +2467,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/**
* Populate the indexes with region entries
*/
- protected void populateOQLIndexes(Set<Index> indexes) {
+ private void populateOQLIndexes(Set<Index> indexes) {
logger.info(LocalizedMessage.create(LocalizedStrings.GemFireCache_INDEX_LOADING));
try {
this.indexManager.populateIndexes(indexes);
@@ -2558,14 +2489,14 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
releaseAfterRegionCreateEventLatch();
}
- protected void releaseBeforeGetInitialImageLatch() {
+ void releaseBeforeGetInitialImageLatch() {
if (logger.isDebugEnabled()) {
logger.debug("Releasing Initialization Latch (before initial image) for {}", getFullPath());
}
releaseLatch(this.initializationLatchBeforeGetInitialImage);
}
- protected final void releaseAfterGetInitialImageLatch() {
+ final void releaseAfterGetInitialImageLatch() {
if (logger.isDebugEnabled()) {
logger.debug("Releasing Initialization Latch (after initial image) for {}", getFullPath());
}
@@ -2587,11 +2518,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @since GemFire 5.0
*/
private void waitForRegionCreateEvent() {
- StoppableCountDownLatch l = this.afterRegionCreateEventLatch;
- if (l != null && l.getCount() == 0) {
+ StoppableCountDownLatch latch = this.afterRegionCreateEventLatch;
+ if (latch != null && latch.getCount() == 0) {
return;
}
- waitOnInitialization(l);
+ waitOnInitialization(latch);
}
private static void releaseLatch(StoppableCountDownLatch latch) {
@@ -2606,17 +2537,16 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @param eventSet collects the events for all destroyed regions if null, then we're closing so
* don't send events to callbacks or destroy the disk region
*/
- private void recursiveDestroyRegion(Set eventSet, RegionEventImpl p_event, boolean cacheWrite)
+ private void recursiveDestroyRegion(Set eventSet, RegionEventImpl regionEvent, boolean cacheWrite)
throws CacheWriterException, TimeoutException {
- RegionEventImpl event = p_event;
- final boolean isClose = event.getOperation().isClose();
+ final boolean isClose = regionEvent.getOperation().isClose();
// do the cacheWriter beforeRegionDestroy first to fix bug 47736
if (eventSet != null && cacheWrite) {
try {
- cacheWriteBeforeRegionDestroy(event);
+ cacheWriteBeforeRegionDestroy(regionEvent);
} catch (CancelException e) {
// I don't think this should ever happens: bulletproofing for bug 39454
- if (!cache.forcedDisconnect()) {
+ if (!this.cache.forcedDisconnect()) {
logger.warn(
LocalizedMessage.create(
LocalizedStrings.LocalRegion_RECURSIVEDESTROYREGION_PROBLEM_IN_CACHEWRITEBEFOREREGIONDESTROY),
@@ -2638,7 +2568,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
if (!isInternalRegion()) {
getCachePerfStats().incRegions(-1);
}
- cache.getInternalResourceManager(false).removeResourceListener(this);
+ this.cache.getInternalResourceManager(false).removeResourceListener(this);
if (getMembershipAttributes().hasRequiredRoles()) {
if (!isInternalRegion()) {
getCachePerfStats().incReliableRegions(-1);
@@ -2649,8 +2579,8 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// because of the SystemMemberCacheEventProcessor. Once we have
// a way to check for existence of SystemMemberCacheEventProcessor listeners
// then the add only needs to be done if hasListener || hasAdminListener
- if (eventSet != null) { // && hasListener())
- eventSet.add(event);
+ if (eventSet != null) {
+ eventSet.add(regionEvent);
}
try {
@@ -2658,49 +2588,52 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// from this subregion map
Collection values = this.subregions.values();
for (Iterator itr = values.iterator(); itr.hasNext();) {
- Object element = itr.next(); // element is a LocalRegion
- LocalRegion rgn;
+ // element is a LocalRegion
+ Object element = itr.next();
+ LocalRegion region;
try {
LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE);
try {
- rgn = toRegion(element); // converts to a LocalRegion
+ // converts to a LocalRegion
+ region = toRegion(element);
} finally {
LocalRegion.setThreadInitLevelRequirement(LocalRegion.AFTER_INITIAL_IMAGE);
}
- } catch (CancelException e) {
- rgn = (LocalRegion) element; // ignore, keep going through the motions though
- } catch (RegionDestroyedException rde) {
+ } catch (CancelException ignore) {
+ // ignore, keep going through the motions though
+ region = (LocalRegion) element;
+ } catch (RegionDestroyedException ignore) {
// SharedRegionData was destroyed
continue;
}
// if the region is destroyed, then it is a race condition with
// failed initialization removing it from the parent subregion map
- if (rgn.isDestroyed) {
+ if (region.isDestroyed) {
continue;
}
- /** ** BEGIN operating on subregion of this region (rgn) *** */
+ // BEGIN operating on subregion of this region (rgn)
if (eventSet != null) {
- event = (RegionEventImpl) event.clone();
- event.region = rgn;
+ regionEvent = (RegionEventImpl) regionEvent.clone();
+ regionEvent.region = region;
}
try {
- rgn.recursiveDestroyRegion(eventSet, event, cacheWrite);
- if (!rgn.isInternalRegion()) {
- InternalDistributedSystem system = rgn.cache.getInternalDistributedSystem();
- system.handleResourceEvent(ResourceEvent.REGION_REMOVE, rgn);
+ region.recursiveDestroyRegion(eventSet, regionEvent, cacheWrite);
+ if (!region.isInternalRegion()) {
+ InternalDistributedSystem system = region.cache.getInternalDistributedSystem();
+ system.handleResourceEvent(ResourceEvent.REGION_REMOVE, region);
}
} catch (CancelException e) {
// I don't think this should ever happen: bulletproofing for bug 39454
- if (!cache.forcedDisconnect()) {
+ if (!this.cache.forcedDisconnect()) {
logger.warn(LocalizedMessage.create(
LocalizedStrings.LocalRegion_RECURSIVEDESTROYREGION_RECURSION_FAILED_DUE_TO_CACHE_CLOSURE_REGION_0,
- rgn.getFullPath()), e);
+ region.getFullPath()), e);
}
}
itr.remove(); // remove from this subregion map;
- /** ** END operating on subregion of this region *** */
+ // END operating on subregion of this region
} // for
try {
@@ -2716,7 +2649,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
} catch (CancelException e) {
// I don't think this should ever happens: bulletproofing for bug 39454
- if (!cache.forcedDisconnect()) {
+ if (!this.cache.forcedDisconnect()) {
logger.warn(LocalizedMessage.create(
LocalizedStrings.LocalRegion_BASICDESTROYREGION_INDEX_REMOVAL_FAILED_DUE_TO_CACHE_CLOSURE_REGION_0,
getFullPath()), e);
@@ -2724,7 +2657,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
}
} finally {
// mark this region as destroyed.
- if (event.isReinitializing()) {
+ if (regionEvent.isReinitializing()) {
this.reinitialized_old = true;
}
this.cache.setRegionByPath(getFullPath(), null);
@@ -2748,7 +2681,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
// if eventSet is null then we need to close the listener as well
// otherwise, the listener will be closed after the destroy event
try {
- postDestroyRegion(!isClose, event);
+ postDestroyRegion(!isClose, regionEvent);
} catch (CancelException e) {
logger.warn(LocalizedMessage.create(
LocalizedStrings.LocalRegion_RECURSIVEDESTROYREGION_POSTDESTROYREGION_FAILED_DUE_TO_CACHE_CLOSURE_REGION_0,
@@ -2798,7 +2731,7 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
*
* @param entryKey the missing entry's key.
*/
- public void checkEntryNotFound(Object entryKey) {
+ void checkEntryNotFound(Object entryKey) {
checkReadiness();
// Localized string for partitioned region is generic enough for general use
throw new EntryNotFoundException(
@@ -2814,15 +2747,13 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
* @param preferCD return the CacheDeserializable, if that's what the value is.
* @param requestingClient the client making the request, if any
* @param clientEvent the client's event, if any. If not null, we set the version tag
- * @param returnTombstones TODO
* @return the deserialized value
- * @see LocalRegion#findObjectInSystem(KeyInfo, boolean, TXStateInterface, boolean, Object,
- * boolean, boolean, ClientProxyMembershipID, EntryEventImpl, boolean)
*/
protected Object findObjectInSystem(KeyInfo keyInfo, boolean isCreate, TXStateInterface tx,
boolean generateCallbacks, Object localValue, boolean disableCopyOnRead, boolean preferCD,
ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent,
boolean returnTombstones) throws CacheLoaderException, TimeoutException {
+
final Object key = keyInfo.getKey();
final Object aCallbackArgument = keyInfo.getCallbackArg();
Object value = null;
@@ -2832,13 +2763,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
/*
* First lets try the server
*/
- {
- ServerRegionProxy mySRP = getServerProxy();
- if (mySRP != null) {
- holder = new VersionTagHolder();
- value = mySRP.get(key, aCallbackArgument, holder);
- fromServer = value != null;
- }
+ ServerRegionProxy mySRP = getServerProxy();
+
<TRUNCATED>