DistributedRegion extends LocalRegion implements InternalDistributedRegion { void cleanUpAfterFailedGII(boolean recoverFromDisk) { DiskRegion dskRgn = getDiskRegion(); if (recoverFromDisk && dskRgn != null && dskRgn.isBackup()) { dskRgn.resetRecoveredEntries(this); return; } if (!getRegionMap().isEmpty()) { lockFailedInitialImageWriteLock(); try { closeEntries(); if (getDiskRegion() != null) { getDiskRegion().clear(this, null); } getImageState().getLeftMembers(); getImageState().getVersionTags(); if (indexManager != null) { try { indexManager.rerunIndexCreationQuery(); } catch (Exception ex) { if (logger.isDebugEnabled()) { logger.debug("Exception while clearing indexes after GII failure.", ex); } } } } finally { unlockFailedInitialImageWriteLock(); } } } protected  DistributedRegion(String regionName, RegionAttributes attrs, LocalRegion parentRegion,
      InternalCache cache, InternalRegionArguments internalRegionArgs,
      StatisticsClock statisticsClock); boolean allowsPersistence(); @Override boolean virtualPut(EntryEventImpl event, boolean ifNew, boolean ifOld,
      Object expectedOldValue, boolean requireOldValue, long lastModified,
      boolean overwriteDestroyed, boolean invokeCallbacks, boolean throwConcurrentModificaiton); @Override void basicPutPart3(EntryEventImpl event, RegionEntry entry, boolean isInitialized,
      long lastModified, boolean invokeCallbacks, boolean ifNew, boolean ifOld,
      Object expectedOldValue, boolean requireOldValue); @Override boolean hasSeenEvent(EntryEventImpl event); @Override void checkForLimitedOrNoAccess(); @Override void handleReliableDistribution(Set successfulRecipients); boolean doesNotDistribute(); @Override boolean shouldSyncForCrashedMember(InternalDistributedMember id); @Override boolean requiresReliabilityCheck(); @Override void localDestroy(Object key, Object aCallbackArgument); @Override void invalidate(Object key, Object aCallbackArgument); @Override Lock getRegionDistributedLock(); @Override Lock getDistributedLock(Object key); @Override void preInitialize(); @Override void initialize(InputStream snapshotInputStream, InternalDistributedMember imageTarget,
      InternalRegionArguments internalRegionArgs); void scheduleSynchronizeForLostMember(InternalDistributedMember member,
      VersionSource lostVersionID, long delay); void setRegionSynchronizeScheduled(VersionSource lostMemberVersionID); boolean setRegionSynchronizedWithIfNotScheduled(VersionSource lostMemberVersionID); boolean isInitializedWithWait(); @Override boolean lockWhenRegionIsInitializing(); @Override void unlockWhenRegionIsInitializing(); @Override void basicBridgeRemove(Object key, Object expectedOldValue, Object p_callbackArg,
      ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent); @Override void basicBridgeDestroy(Object key, Object p_callbackArg, ClientProxyMembershipID memberId,
      boolean fromClient, EntryEventImpl clientEvent); @Override void basicBridgeInvalidate(Object key, Object p_callbackArg,
      ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent); @Override void basicDestroy(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue); @Override void basicDestroyPart3(RegionEntry re, EntryEventImpl event, boolean inTokenMode,
      boolean duringRI, boolean invokeCallbacks, Object expectedOldValue); @Override void basicInvalidate(EntryEventImpl event); DistributionConfig getDistributionConfig(); @Override CacheDistributionAdvisor getDistributionAdvisor(); @Override CacheDistributionAdvisor getCacheDistributionAdvisor(); PersistenceAdvisor getPersistenceAdvisor(); PersistentMemberID getPersistentID(); @Override Profile getProfile(); @Override void fillInProfile(Profile profile); DistributedLockService getLockService(); @Override boolean isLockGrantor(); @Override void becomeLockGrantor(); @Override boolean cacheWriteBeforeDestroy(EntryEventImpl event, Object expectedOldValue); @Override void postCreateRegion(); @Override void cleanupFailedInitialization(); @Override void handleCacheClose(Operation operation); @Override void cacheWriteBeforePut(EntryEventImpl event, Set netWriteRecipients,
      CacheWriter localWriter, boolean requireOldValue, Object expectedOldValue); @Override void addGatewaySenderId(String gatewaySenderId); @Override void removeGatewaySenderId(String gatewaySenderId); @Override void addAsyncEventQueueId(String asyncEventQueueId); @Override void removeAsyncEventQueueId(String asyncEventQueueId); @Override Iterator<RegionEntry> getBestIterator(boolean includeValues); @Override long postPutAllSend(DistributedPutAllOperation putAllOp,
      VersionedObjectList successfulPuts); @Override long postRemoveAllSend(DistributedRemoveAllOperation op,
      VersionedObjectList successfulOps); @Override VersionedObjectList basicRemoveAll(final Collection<Object> keys,
      final DistributedRemoveAllOperation removeAllOp, final List<VersionTag> retryVersions); Set waitForRequiredRoles(long timeout); boolean isRoleInRegionMembership(Role role); @Override void remoteRegionInitialized(CacheProfile profile); @Override DistributionAdvisee getParentAdvisee(); @Override DistributedMember getOwnerForKey(KeyInfo key); @Override ResultCollector executeFunction(final DistributedRegionFunctionExecutor execution,
      final Function function, final Object args, final ResultCollector rc, final Set filter,
      final ServerToClientFunctionResultSender sender); @Override void removeCriticalMember(DistributedMember member); @Override MemoryThresholdInfo getAtomicThresholdInfo(); boolean hasNetLoader(); @Override Set adviseNetWrite(); @VisibleForTesting SenderIdMonitor getSenderIdMonitor(); @MutableForTesting
  static boolean TEST_HOOK_ADD_PROFILE; @MutableForTesting
  static boolean ignoreReconnect; }
@Test public void cleanUpAfterFailedInitialImageDoesNotCloseEntriesIfIsPersistentRegionAndRecoveredFromDisk() { DistributedRegion distributedRegion = mock(DistributedRegion.class); DiskRegion diskRegion = mock(DiskRegion.class); doCallRealMethod().when(distributedRegion).cleanUpAfterFailedGII(true); when(distributedRegion.getDiskRegion()).thenReturn(diskRegion); when(diskRegion.isBackup()).thenReturn(true); distributedRegion.cleanUpAfterFailedGII(true); verify(diskRegion).resetRecoveredEntries(eq(distributedRegion)); verify(distributedRegion, never()).closeEntries(); }