You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2019/05/31 22:02:52 UTC
[geode] branch develop updated: GEODE-6588: Cleanup static analyzer
warnings and generics (#3646)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 30ddcbd GEODE-6588: Cleanup static analyzer warnings and generics (#3646)
30ddcbd is described below
commit 30ddcbd82770249b68e090954beedf7ac77e7d93
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Fri May 31 15:02:39 2019 -0700
GEODE-6588: Cleanup static analyzer warnings and generics (#3646)
---
.../main/java/org/apache/geode/SystemFailure.java | 55 +-
.../geode/distributed/DistributedSystem.java | 20 +-
.../internal/ClusterDistributionManager.java | 2 +-
.../internal/InternalDistributedSystem.java | 470 +++++-----
.../geode/internal/cache/AbstractRegion.java | 440 +++++----
.../geode/internal/cache/GemFireCacheImpl.java | 994 ++++++++++-----------
.../geode/internal/cache/InternalRegion.java | 4 +-
.../apache/geode/internal/cache/LocalRegion.java | 89 +-
.../DisconnectingOutOfOffHeapMemoryListener.java | 22 +-
.../internal/util/concurrent/FutureResult.java | 50 +-
...nectingOutOfOffHeapMemoryListenerJUnitTest.java | 7 +-
11 files changed, 989 insertions(+), 1164 deletions(-)
diff --git a/geode-core/src/main/java/org/apache/geode/SystemFailure.java b/geode-core/src/main/java/org/apache/geode/SystemFailure.java
index fe102a6..2e3efbf 100644
--- a/geode-core/src/main/java/org/apache/geode/SystemFailure.java
+++ b/geode-core/src/main/java/org/apache/geode/SystemFailure.java
@@ -158,12 +158,8 @@ public final class SystemFailure {
**/
static final String JVM_CORRUPTION =
"JVM corruption has been detected";
- static final String CALLING_SYSTEM_EXIT =
+ private static final String CALLING_SYSTEM_EXIT =
"Since this is a dedicated cache server and the JVM has been corrupted, this process will now terminate. Permission to call System#exit(int) was given in the following context.";
- public static final String DISTRIBUTION_HALTED_MESSAGE =
- "Distribution halted due to JVM corruption";
- public static final String DISTRIBUTED_SYSTEM_DISCONNECTED_MESSAGE =
- "Distributed system disconnected due to JVM corruption";
/**
* the underlying failure
@@ -270,8 +266,8 @@ public final class SystemFailure {
* This can be set with the system property <code>gemfire.WATCHDOG_WAIT</code>. The default is 15
* sec.
*/
- public static final int WATCHDOG_WAIT =
- Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "WATCHDOG_WAIT", 15).intValue();
+ private static final int WATCHDOG_WAIT =
+ Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "WATCHDOG_WAIT", 15);
/**
* This is the watchdog thread
@@ -347,7 +343,7 @@ public final class SystemFailure {
/**
* This is the run loop for the watchdog thread.
*/
- protected static void runWatchDog() {
+ private static void runWatchDog() {
boolean warned = false;
@@ -376,10 +372,7 @@ public final class SystemFailure {
logWarning(WATCHDOG_NAME, "Unable to initialize watchdog", t);
return;
}
- for (;;) {
- if (stopping) {
- return;
- }
+ while (!stopping) {
try {
if (isCacheClosing) {
break;
@@ -451,7 +444,6 @@ public final class SystemFailure {
ExitCode.FATAL.doSystemExit();
}
-
logInfo(WATCHDOG_NAME, "exiting");
return;
} catch (Throwable t) {
@@ -486,7 +478,7 @@ public final class SystemFailure {
* @guarded.By {@link #memorySync}
*/
@MakeNotStatic
- static long minimumMemoryThreshold = Long.getLong(
+ private static long minimumMemoryThreshold = Long.getLong(
DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.chronic_memory_threshold", 1048576);
/**
@@ -498,7 +490,7 @@ public final class SystemFailure {
*
* @see #setFailureMemoryThreshold(long)
*/
- public static final long MEMORY_POLL_INTERVAL =
+ private static final long MEMORY_POLL_INTERVAL =
Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MEMORY_POLL_INTERVAL", 1);
/**
@@ -524,7 +516,7 @@ public final class SystemFailure {
*
* @since GemFire 6.5
*/
- public static final boolean MONITOR_MEMORY =
+ private static final boolean MONITOR_MEMORY =
Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MONITOR_MEMORY");
/**
@@ -584,7 +576,7 @@ public final class SystemFailure {
/**
* This is the run loop for the proctor thread
*/
- protected static void runProctor() {
+ private static void runProctor() {
// Note that the javadocs say this can return Long.MAX_VALUE.
final long maxMemory = Runtime.getRuntime().maxMemory();
@@ -592,15 +584,11 @@ public final class SystemFailure {
final OutOfMemoryError oome = new OutOfMemoryError(
String.format(
"%s : memory has remained chronically below %s bytes (out of a maximum of %s ) for %s sec.",
- new Object[] {PROCTOR_NAME, Long.valueOf(minimumMemoryThreshold),
- Long.valueOf(maxMemory), Integer.valueOf(WATCHDOG_WAIT)}));
+ PROCTOR_NAME, minimumMemoryThreshold, maxMemory, WATCHDOG_WAIT));
logFine(PROCTOR_NAME,
"Starting, threshold = " + minimumMemoryThreshold + "; max = " + maxMemory);
- for (;;) {
- if (isCacheClosing) {
- break;
- }
+ while (!isCacheClosing) {
if (stopping) {
return;
}
@@ -723,14 +711,9 @@ public final class SystemFailure {
*/
private static final boolean DEBUG = false;
- /**
- * If true, we track the progress of emergencyClose on System.err
- */
- public static final boolean TRACE_CLOSE = false;
-
- protected static final String WATCHDOG_NAME = "SystemFailure Watchdog";
+ private static final String WATCHDOG_NAME = "SystemFailure Watchdog";
- protected static final String PROCTOR_NAME = "SystemFailure Proctor";
+ private static final String PROCTOR_NAME = "SystemFailure Proctor";
/**
* break any potential circularity in {@link #loadEmergencyClasses()}
@@ -776,22 +759,12 @@ public final class SystemFailure {
* system.
*/
public static void emergencyClose() {
- if (TRACE_CLOSE) {
- System.err.println("SystemFailure: closing GemFireCache");
- }
GemFireCacheImpl.emergencyClose();
- if (TRACE_CLOSE) {
- System.err.println("SystemFailure: closing admins");
- }
RemoteGfManagerAgent.emergencyClose();
// If memory was the problem, make an explicit attempt at this point to clean up.
System.gc();
-
- if (TRACE_CLOSE) {
- System.err.println("SystemFailure: end of emergencyClose");
- }
}
/**
@@ -804,7 +777,7 @@ public final class SystemFailure {
* have, instead of wrapping it with one pertinent to the current context. See bug 38394.
*
*/
- private static void throwFailure() throws InternalGemFireError, Error {
+ private static void throwFailure() throws Error {
if (failure != null)
throw failure;
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
index bc913d2..a17627d 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/DistributedSystem.java
@@ -12,6 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package org.apache.geode.distributed;
import static org.apache.geode.distributed.ConfigurationProperties.CONSERVE_SOCKETS;
@@ -27,8 +28,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-import org.apache.logging.log4j.Logger;
-
import org.apache.geode.CancelCriterion;
import org.apache.geode.LogWriter;
import org.apache.geode.StatisticsFactory;
@@ -42,7 +41,6 @@ import org.apache.geode.distributed.internal.DistributionConfig;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.Assert;
import org.apache.geode.internal.ClassPathLoader;
-import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.tcp.ConnectionTable;
import org.apache.geode.internal.util.IOUtils;
@@ -91,7 +89,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
*/
@MakeNotStatic
protected static volatile List<InternalDistributedSystem> existingSystems =
- Collections.EMPTY_LIST;
+ Collections.emptyList();
/**
* This lock must be changed to add or remove a system. It is notified when a system is removed.
*
@@ -99,10 +97,6 @@ public abstract class DistributedSystem implements StatisticsFactory {
*/
protected static final Object existingSystemsLock = new Object();
- private static final Logger logger = LogService.getLogger();
-
- //////////////////////// Static Methods ////////////////////////
-
/**
* Connects to a GemFire distributed system with a configuration supplemented by the given
* properties. See {@linkplain ConfigurationProperties} for available GemFire properties and their
@@ -170,7 +164,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
if (size == 0) {
existingSystems = Collections.singletonList(newSystem);
} else {
- ArrayList l = new ArrayList(size + 1);
+ ArrayList<InternalDistributedSystem> l = new ArrayList<>(size + 1);
l.addAll(existingSystems);
l.add(0, newSystem);
existingSystems = Collections.unmodifiableList(l);
@@ -178,21 +172,20 @@ public abstract class DistributedSystem implements StatisticsFactory {
}
}
- protected static boolean removeSystem(InternalDistributedSystem oldSystem) {
+ protected static void removeSystem(InternalDistributedSystem oldSystem) {
synchronized (existingSystemsLock) {
List<InternalDistributedSystem> listOfSystems = new ArrayList<>(existingSystems);
boolean result = listOfSystems.remove(oldSystem);
if (result) {
int size = listOfSystems.size();
if (size == 0) {
- existingSystems = Collections.EMPTY_LIST;
+ existingSystems = Collections.emptyList();
} else if (size == 1) {
existingSystems = Collections.singletonList(listOfSystems.get(0));
} else {
existingSystems = Collections.unmodifiableList(listOfSystems);
}
}
- return result;
}
}
@@ -294,6 +287,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
* @throws IllegalStateException This VM has {@linkplain #disconnect() disconnected} from the
* distributed system.
*/
+ @Deprecated
public abstract LogWriter getLogWriter();
/**
@@ -304,6 +298,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
* distributed system.
* @since GemFire 5.5
*/
+ @Deprecated
public abstract LogWriter getSecurityLogWriter();
/**
@@ -591,6 +586,7 @@ public abstract class DistributedSystem implements StatisticsFactory {
* @since GemFire 5.0
* @deprecated As of 9.0, please use {@link #getPropertiesFileURL()}
*/
+ @Deprecated
public static URL getPropertyFileURL() {
return getPropertiesFileURL();
}
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
index a8d1c08..316d099 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/ClusterDistributionManager.java
@@ -3387,7 +3387,7 @@ public class ClusterDistributionManager implements DistributionManager {
public void membershipFailure(String reason, Throwable t) {
exceptionInThreads = true;
rootCause = t;
- getSystem().disconnect(reason, t, true);
+ getSystem().disconnect(reason, true);
}
@Override
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
index 39e7101..4e109b3 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java
@@ -12,6 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package org.apache.geode.distributed.internal;
import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
@@ -41,6 +42,7 @@ import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import io.micrometer.core.instrument.MeterRegistry;
@@ -153,13 +155,7 @@ public class InternalDistributedSystem extends DistributedSystem
public static volatile DistributedSystem systemAttemptingReconnect;
@Immutable
- public static final CreationStackGenerator DEFAULT_CREATION_STACK_GENERATOR =
- new CreationStackGenerator() {
- @Override
- public Throwable generateCreationStack(final DistributionConfig config) {
- return null;
- }
- };
+ public static final CreationStackGenerator DEFAULT_CREATION_STACK_GENERATOR = config -> null;
// the following is overridden from DistributedTestCase to fix #51058
@MutableForTesting
@@ -270,11 +266,13 @@ public class InternalDistributedSystem extends DistributedSystem
/**
* The log writer used to log information messages
*/
+ @Deprecated
protected InternalLogWriter logWriter = null;
/**
* The log writer used to log security related messages
*/
+ @Deprecated
protected InternalLogWriter securityLogWriter = null;
/**
@@ -323,7 +321,7 @@ public class InternalDistributedSystem extends DistributedSystem
*/
// needs to be ordered
@MakeNotStatic
- private static final Set<ConnectListener> connectListeners = new LinkedHashSet();
+ private static final Set<ConnectListener> connectListeners = new LinkedHashSet<>();
/**
* auto-reconnect listeners
@@ -359,7 +357,7 @@ public class InternalDistributedSystem extends DistributedSystem
/**
* A property to append to existing log-file instead of truncating it.
*/
- public static final String APPEND_TO_LOG_FILE = GEMFIRE_PREFIX + "append-log";
+ private static final String APPEND_TO_LOG_FILE = GEMFIRE_PREFIX + "append-log";
//////////////////// Configuration Fields ////////////////////
@@ -415,8 +413,8 @@ public class InternalDistributedSystem extends DistributedSystem
this.deltaEnabledOnServer = deltaEnabledOnServer;
}
- public static boolean removeSystem(InternalDistributedSystem oldSystem) {
- return DistributedSystem.removeSystem(oldSystem);
+ public static void removeSystem(InternalDistributedSystem oldSystem) {
+ DistributedSystem.removeSystem(oldSystem);
}
/**
@@ -442,8 +440,7 @@ public class InternalDistributedSystem extends DistributedSystem
InternalDistributedSystem result = null;
synchronized (existingSystemsLock) {
if (!existingSystems.isEmpty()) {
- InternalDistributedSystem existingSystem =
- (InternalDistributedSystem) existingSystems.get(0);
+ InternalDistributedSystem existingSystem = existingSystems.get(0);
if (existingSystem.isConnected()) {
result = existingSystem;
}
@@ -484,6 +481,7 @@ public class InternalDistributedSystem extends DistributedSystem
/**
* @return a log writer, or null if there is no distributed system available
*/
+ @Deprecated
public static LogWriter getLogger() {
InternalDistributedSystem sys = getAnyInstance();
if (sys != null && sys.logWriter != null) {
@@ -492,6 +490,7 @@ public class InternalDistributedSystem extends DistributedSystem
return null;
}
+ @Deprecated
public static InternalLogWriter getStaticInternalLogWriter() {
InternalDistributedSystem sys = getAnyInstance();
if (sys != null) {
@@ -500,10 +499,12 @@ public class InternalDistributedSystem extends DistributedSystem
return null;
}
+ @Deprecated
public InternalLogWriter getInternalLogWriter() {
- return this.logWriter;
+ return logWriter;
}
+ @Deprecated
public InternalLogWriter getSecurityInternalLogWriter() {
InternalDistributedSystem sys = getAnyInstance();
if (sys != null) {
@@ -516,7 +517,7 @@ public class InternalDistributedSystem extends DistributedSystem
* reset the reconnectAttempt counter for a new go at reconnecting
*/
private static void resetReconnectAttemptCounter() {
- reconnectAttemptCounter = 0;
+ reconnectAttemptCounter.set(0);
}
/**
@@ -543,21 +544,21 @@ public class InternalDistributedSystem extends DistributedSystem
isReconnectingDS = config.isReconnecting();
quorumChecker = config.quorumChecker();
- ((DistributionConfigImpl) this.originalConfig).checkForDisallowedDefaults(); // throws
- // IllegalStateEx
- this.shareSockets = this.originalConfig.getConserveSockets();
- this.startTime = System.currentTimeMillis();
- this.grc = new GrantorRequestProcessor.GrantorRequestContext(stopper);
+ ((DistributionConfigImpl) originalConfig).checkForDisallowedDefaults(); // throws
+ // IllegalStateEx
+ shareSockets = originalConfig.getConserveSockets();
+ startTime = System.currentTimeMillis();
+ grc = new GrantorRequestProcessor.GrantorRequestContext(stopper);
- this.creationStack =
- TEST_CREATION_STACK_GENERATOR.get().generateCreationStack(this.originalConfig);
+ creationStack =
+ TEST_CREATION_STACK_GENERATOR.get().generateCreationStack(originalConfig);
statisticsManager =
statisticsManagerFactory.create(originalConfig.getName(), startTime, statsDisabled);
}
public SecurityService getSecurityService() {
- return this.securityService;
+ return securityService;
}
public void setSecurityService(SecurityService securityService) {
@@ -609,13 +610,13 @@ public class InternalDistributedSystem extends DistributedSystem
* Returns true if system is a loner (for testing)
*/
public boolean isLoner() {
- return this.isLoner;
+ return isLoner;
}
private MemoryAllocator offHeapStore = null;
public MemoryAllocator getOffHeapStore() {
- return this.offHeapStore;
+ return offHeapStore;
}
/**
@@ -636,24 +637,24 @@ public class InternalDistributedSystem extends DistributedSystem
* Initializes this connection to a distributed system with the current configuration state.
*/
private void initialize(SecurityManager securityManager, PostProcessor postProcessor) {
- if (this.originalConfig.getLocators().equals("")) {
- if (this.originalConfig.getMcastPort() != 0) {
+ if (originalConfig.getLocators().equals("")) {
+ if (originalConfig.getMcastPort() != 0) {
throw new GemFireConfigException("The " + LOCATORS + " attribute can not be empty when the "
+ MCAST_PORT + " attribute is non-zero.");
} else {
// no distribution
- this.isLoner = true;
+ isLoner = true;
}
}
- this.config = new RuntimeDistributionConfigImpl(this);
+ config = new RuntimeDistributionConfigImpl(this);
- this.securityService = SecurityServiceFactory.create(
- this.config.getSecurityProps(),
+ securityService = SecurityServiceFactory.create(
+ config.getSecurityProps(),
securityManager, postProcessor);
- if (!this.isLoner) {
- this.attemptingToReconnect = (reconnectAttemptCounter > 0);
+ if (!isLoner) {
+ attemptingToReconnect = (reconnectAttemptCounter.get() > 0);
}
try {
SocketCreatorFactory.setDistributionConfig(config);
@@ -664,33 +665,33 @@ public class InternalDistributedSystem extends DistributedSystem
// LOG: create LogWriterLogger(s) for backwards compatibility of getLogWriter and
// getSecurityLogWriter
- if (this.logWriter == null) {
- this.logWriter =
- LogWriterFactory.createLogWriterLogger(this.config, false);
- this.logWriter.fine("LogWriter is created.");
+ if (logWriter == null) {
+ logWriter =
+ LogWriterFactory.createLogWriterLogger(config, false);
+ logWriter.fine("LogWriter is created.");
}
// logWriter.info("Created log writer for IDS@"+System.identityHashCode(this));
- if (this.securityLogWriter == null) {
+ if (securityLogWriter == null) {
// LOG: whole new LogWriterLogger instance for security
- this.securityLogWriter =
- LogWriterFactory.createLogWriterLogger(this.config, true);
- this.securityLogWriter.fine("SecurityLogWriter is created.");
+ securityLogWriter =
+ LogWriterFactory.createLogWriterLogger(config, true);
+ securityLogWriter.fine("SecurityLogWriter is created.");
}
loggingSession.startSession();
- this.clock = new DSClock(this.isLoner);
+ clock = new DSClock(isLoner);
- if (this.attemptingToReconnect && logger.isDebugEnabled()) {
+ if (attemptingToReconnect && logger.isDebugEnabled()) {
logger.debug(
"This thread is initializing a new DistributedSystem in order to reconnect to other members");
}
// Note we need loners to load the license in case they are a
// cache server and will need to enforce the member limit
if (Boolean.getBoolean(InternalLocator.FORCE_LOCATOR_DM_TYPE)) {
- this.locatorDMTypeForced = true;
+ locatorDMTypeForced = true;
}
initializeServices();
@@ -698,9 +699,9 @@ public class InternalDistributedSystem extends DistributedSystem
// Initialize the Diffie-Hellman and public/private keys
try {
- EncryptorImpl.initCertsMap(this.config.getSecurityProps());
- EncryptorImpl.initPrivateKey(this.config.getSecurityProps());
- EncryptorImpl.initDHKeys(this.config);
+ EncryptorImpl.initCertsMap(config.getSecurityProps());
+ EncryptorImpl.initPrivateKey(config.getSecurityProps());
+ EncryptorImpl.initDHKeys(config);
} catch (Exception ex) {
throw new GemFireSecurityException(
"Problem in initializing keys for client authentication",
@@ -710,7 +711,7 @@ public class InternalDistributedSystem extends DistributedSystem
final long offHeapMemorySize =
OffHeapStorage.parseOffHeapMemorySize(getConfig().getOffHeapMemorySize());
- this.offHeapStore = OffHeapStorage.createOffHeapStorage(this, offHeapMemorySize, this);
+ offHeapStore = OffHeapStorage.createOffHeapStorage(this, offHeapMemorySize, this);
// Note: this can only happen on a linux system
if (getConfig().getLockMemory()) {
@@ -743,16 +744,16 @@ public class InternalDistributedSystem extends DistributedSystem
throw new SystemConnectException("Startup has been interrupted", e);
}
- synchronized (this.isConnectedMutex) {
- this.isConnected = true;
+ synchronized (isConnectedMutex) {
+ isConnected = true;
}
- if (!this.isLoner) {
+ if (!isLoner) {
try {
- if (this.quorumChecker != null) {
- this.quorumChecker.suspend();
+ if (quorumChecker != null) {
+ quorumChecker.suspend();
}
- this.dm = ClusterDistributionManager.create(this);
+ dm = ClusterDistributionManager.create(this);
// fix bug #46324
if (InternalLocator.hasLocator()) {
InternalLocator locator = InternalLocator.getLocator();
@@ -760,20 +761,20 @@ public class InternalDistributedSystem extends DistributedSystem
InternalLocator.getLocatorStrings(), locator.isSharedConfigurationEnabled());
}
} finally {
- if (this.dm == null && this.quorumChecker != null) {
- this.quorumChecker.resume();
+ if (dm == null && quorumChecker != null) {
+ quorumChecker.resume();
}
setDisconnected();
}
} else {
- this.dm = new LonerDistributionManager(this, this.logWriter);
+ dm = new LonerDistributionManager(this, logWriter);
}
- Assert.assertTrue(this.dm != null);
- Assert.assertTrue(this.dm.getSystem() == this);
+ Assert.assertTrue(dm != null);
+ Assert.assertTrue(dm.getSystem() == this);
try {
- this.id = this.dm.getMembershipPort();
+ id = dm.getMembershipPort();
} catch (DistributedSystemDisconnectedException e) {
// bug #48144 - The dm's channel threw an NPE. It now throws this exception
// but during startup we should instead throw a SystemConnectException
@@ -782,10 +783,10 @@ public class InternalDistributedSystem extends DistributedSystem
e);
}
- synchronized (this.isConnectedMutex) {
- this.isConnected = true;
+ synchronized (isConnectedMutex) {
+ isConnected = true;
}
- if (attemptingToReconnect && (this.startedLocator == null)) {
+ if (attemptingToReconnect && (startedLocator == null)) {
try {
startInitLocator();
} catch (InterruptedException e) {
@@ -807,13 +808,13 @@ public class InternalDistributedSystem extends DistributedSystem
// was created
InternalInstantiator.logInstantiators();
} catch (RuntimeException ex) {
- this.config.close();
+ config.close();
throw ex;
}
- this.reconnected = this.attemptingToReconnect;
- this.attemptingToReconnect = false;
- reconnectAttemptCounter = 0; // reset reconnect count since we just got a new connection
+ reconnected = attemptingToReconnect;
+ attemptingToReconnect = false;
+ reconnectAttemptCounter.set(0);
}
private void startSampler() {
@@ -823,24 +824,24 @@ public class InternalDistributedSystem extends DistributedSystem
sampler = loggingSession.getLogFile()
.map(logFile -> new GemFireStatSampler(this, logFile))
.orElseGet(() -> new GemFireStatSampler(this));
- this.sampler.start();
+ sampler.start();
}
/**
* @since GemFire 5.7
*/
private void startInitLocator() throws InterruptedException {
- String locatorString = this.originalConfig.getStartLocator();
+ String locatorString = originalConfig.getStartLocator();
if (locatorString.length() == 0) {
return;
}
// when reconnecting we don't want to join with a colocated locator unless
// there is a quorum of the old members available
- if (attemptingToReconnect && !this.isConnected) {
- if (this.quorumChecker != null) {
+ if (attemptingToReconnect && !isConnected) {
+ if (quorumChecker != null) {
logger.info("performing a quorum check to see if location services can be started early");
- if (!quorumChecker.checkForQuorum(3L * this.config.getMemberTimeout())) {
+ if (!quorumChecker.checkForQuorum(3L * config.getMemberTimeout())) {
logger.info("quorum check failed - not allowing location services to start early");
return;
}
@@ -849,21 +850,21 @@ public class InternalDistributedSystem extends DistributedSystem
}
DistributionLocatorId locId = new DistributionLocatorId(locatorString);
try {
- this.startedLocator =
+ startedLocator =
InternalLocator.createLocator(locId.getPort(), NullLoggingSession.create(), null,
logWriter, securityLogWriter, locId.getHost().getAddress(),
locId.getHostnameForClients(), originalConfig.toProperties(), false);
// if locator is started this way, cluster config is not enabled, set the flag correctly
- this.startedLocator.getConfig().setEnableClusterConfiguration(false);
+ startedLocator.getConfig().setEnableClusterConfiguration(false);
boolean startedPeerLocation = false;
try {
- this.startedLocator.startPeerLocation();
+ startedLocator.startPeerLocation();
startedPeerLocation = true;
} finally {
if (!startedPeerLocation) {
- this.startedLocator.stop();
+ startedLocator.stop();
}
}
} catch (IOException e) {
@@ -877,7 +878,7 @@ public class InternalDistributedSystem extends DistributedSystem
* @since GemFire 5.7
*/
private void endInitLocator() throws IOException {
- InternalLocator loc = this.startedLocator;
+ InternalLocator loc = startedLocator;
if (loc != null) {
boolean finished = false;
try {
@@ -895,8 +896,8 @@ public class InternalDistributedSystem extends DistributedSystem
/**
* record a locator as a dependent of this distributed system
*/
- public void setDependentLocator(InternalLocator theLocator) {
- this.startedLocator = theLocator;
+ void setDependentLocator(InternalLocator theLocator) {
+ startedLocator = theLocator;
}
/**
@@ -922,16 +923,16 @@ public class InternalDistributedSystem extends DistributedSystem
@Override
public boolean isConnected() {
- if (this.dm == null) {
+ if (dm == null) {
return false;
}
- if (this.dm.getCancelCriterion().isCancelInProgress()) {
+ if (dm.getCancelCriterion().isCancelInProgress()) {
return false;
}
- if (this.isDisconnecting) {
+ if (isDisconnecting) {
return false;
}
- return this.isConnected;
+ return isConnected;
}
/*
@@ -941,7 +942,7 @@ public class InternalDistributedSystem extends DistributedSystem
* query if the distributed system is fully disconnected or not.
*/
public boolean isDisconnected() {
- return !this.isConnected;
+ return !isConnected;
}
public StatisticsManager getStatisticsManager() {
@@ -1106,11 +1107,11 @@ public class InternalDistributedSystem extends DistributedSystem
@Override
public long getId() {
- return this.id;
+ return id;
}
public long getStartTime() {
- return this.startTime;
+ return startTime;
}
/**
@@ -1147,37 +1148,37 @@ public class InternalDistributedSystem extends DistributedSystem
}
public boolean isDisconnecting() {
- if (this.dm == null) {
+ if (dm == null) {
return true;
}
- if (this.dm.getCancelCriterion().isCancelInProgress()) {
+ if (dm.getCancelCriterion().isCancelInProgress()) {
return true;
}
- if (!this.isConnected) {
+ if (!isConnected) {
return true;
}
- return this.isDisconnecting;
+ return isDisconnecting;
}
@Override
public LogWriter getLogWriter() {
- return this.logWriter;
+ return logWriter;
}
public DSClock getClock() {
- return this.clock;
+ return clock;
}
@Override
public LogWriter getSecurityLogWriter() {
- return this.securityLogWriter;
+ return securityLogWriter;
}
/**
* Returns the stat sampler
*/
public GemFireStatSampler getStatSampler() {
- return this.sampler;
+ return sampler;
}
/**
@@ -1200,15 +1201,14 @@ public class InternalDistributedSystem extends DistributedSystem
* distribution to fail (e.g., this member was shunned)
*
* @param reason a string describing why the disconnect is occurring
- * @param cause an optional exception showing the reason for abnormal disconnect
* @param shunned whether this member was shunned by the membership coordinator
*/
- public void disconnect(String reason, Throwable cause, boolean shunned) {
+ public void disconnect(String reason, boolean shunned) {
boolean isForcedDisconnect = dm.getRootCause() instanceof ForcedDisconnectException;
boolean rejoined = false;
- this.reconnected = false;
- if (isForcedDisconnect && !this.isReconnectingDS) {
- this.forcedDisconnect = true;
+ reconnected = false;
+ if (isForcedDisconnect && !isReconnectingDS) {
+ forcedDisconnect = true;
resetReconnectAttemptCounter();
rejoined = tryReconnect(true, reason, GemFireCacheImpl.getInstance());
}
@@ -1222,7 +1222,7 @@ public class InternalDistributedSystem extends DistributedSystem
* interrupt it.
*/
private static final long MAX_DISCONNECT_WAIT =
- Long.getLong("DistributionManager.DISCONNECT_WAIT", 10 * 1000).longValue();
+ Long.getLong("DistributionManager.DISCONNECT_WAIT", 10 * 1000);
/**
* Run a disconnect listener, checking for errors and honoring the timeout
@@ -1232,23 +1232,18 @@ public class InternalDistributedSystem extends DistributedSystem
*/
private void runDisconnect(final DisconnectListener dc) {
// Create a general handler for running the disconnect
- Runnable r = new Runnable() {
- @Override
- public void run() {
- try {
- isDisconnectThread.set(Boolean.TRUE);
- dc.onDisconnect(InternalDistributedSystem.this);
- } catch (CancelException e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Disconnect listener <{}> thwarted by cancellation: {}", dc, e,
- logger.isTraceEnabled() ? e : null);
- }
+ // Launch it and wait a little bit
+ Thread t = new LoggingThread(dc.toString(), false, () -> {
+ try {
+ isDisconnectThread.set(Boolean.TRUE);
+ dc.onDisconnect(InternalDistributedSystem.this);
+ } catch (CancelException e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Disconnect listener <{}> thwarted by cancellation: {}", dc, e,
+ traceException(e));
}
}
- };
-
- // Launch it and wait a little bit
- Thread t = new LoggingThread(dc.toString(), false, r);
+ });
try {
t.start();
t.join(MAX_DISCONNECT_WAIT);
@@ -1277,12 +1272,16 @@ public class InternalDistributedSystem extends DistributedSystem
}
+ private Exception traceException(CancelException e) {
+ return logger.isTraceEnabled() ? e : null;
+ }
+
public boolean isDisconnectThread() {
- return this.isDisconnectThread.get();
+ return isDisconnectThread.get();
}
public void setIsDisconnectThread() {
- this.isDisconnectThread.set(Boolean.TRUE);
+ isDisconnectThread.set(Boolean.TRUE);
}
/**
@@ -1296,8 +1295,7 @@ public class InternalDistributedSystem extends DistributedSystem
dc.onDisconnect(this);
} catch (DistributedSystemDisconnectedException e) {
if (logger.isDebugEnabled()) {
- logger.debug("Disconnect listener <{}> thwarted by shutdown: {}", dc, e,
- logger.isTraceEnabled() ? e : null);
+ logger.debug("Disconnect listener <{}> thwarted by shutdown: {}", dc, e, traceException(e));
}
}
}
@@ -1314,7 +1312,7 @@ public class InternalDistributedSystem extends DistributedSystem
HashSet<ShutdownListener> shutdownListeners = new HashSet<>();
for (;;) {
DisconnectListener listener;
- synchronized (this.disconnectListeners) {
+ synchronized (disconnectListeners) {
Iterator<DisconnectListener> itr = disconnectListeners.iterator();
if (!itr.hasNext()) {
return shutdownListeners;
@@ -1372,9 +1370,9 @@ public class InternalDistributedSystem extends DistributedSystem
// that appeared in the interim.
for (;;) {
// Pluck next listener from the list
- DisconnectListener dcListener = null;
+ DisconnectListener dcListener;
ShutdownListener sdListener = null;
- synchronized (this.disconnectListeners) {
+ synchronized (disconnectListeners) {
Iterator<DisconnectListener> itr = disconnectListeners.iterator();
if (!itr.hasNext()) {
break;
@@ -1436,46 +1434,36 @@ public class InternalDistributedSystem extends DistributedSystem
* @see SystemFailure#emergencyClose()
*/
public void emergencyClose() {
- final boolean DEBUG = SystemFailure.TRACE_CLOSE;
if (dm != null) {
MembershipManager mm = dm.getMembershipManager();
if (mm != null) {
- if (DEBUG) {
- System.err.println("DEBUG: closing membership manager");
- }
mm.emergencyClose();
- if (DEBUG) {
- System.err.println("DEBUG: back from closing membership manager");
- }
}
}
// Garbage collection
// Leave dm alone; its CancelCriterion will help people die
- this.isConnected = false;
+ isConnected = false;
if (dm != null) {
dm.setRootCause(SystemFailure.getFailure());
}
- this.isDisconnecting = true;
- this.disconnectListeners.clear();
- if (DEBUG) {
- System.err.println("DEBUG: done with InternalDistributedSystem#emergencyClose");
- }
+ isDisconnecting = true;
+ disconnectListeners.clear();
}
private void setDisconnected() {
- synchronized (this.isConnectedMutex) {
- this.isConnected = false;
+ synchronized (isConnectedMutex) {
+ isConnected = false;
isConnectedMutex.notifyAll();
}
}
private void waitDisconnected() {
- synchronized (this.isConnectedMutex) {
- while (this.isConnected) {
+ synchronized (isConnectedMutex) {
+ while (isConnected) {
boolean interrupted = Thread.interrupted();
try {
- this.isConnectedMutex.wait();
+ isConnectedMutex.wait();
} catch (InterruptedException e) {
interrupted = true;
getLogWriter()
@@ -1544,23 +1532,23 @@ public class InternalDistributedSystem extends DistributedSystem
// While still holding the lock, make sure this instance is
// marked as shutting down
synchronized (this) {
- if (this.isDisconnecting) {
+ if (isDisconnecting) {
// It's already started, but don't return
// to the caller until it has completed.
waitDisconnected();
return;
} // isDisconnecting
- this.isDisconnecting = true;
+ isDisconnecting = true;
if (!preparingForReconnect) {
// move cancelReconnect above this synchronized block fix for bug 35202
- if (this.reconnectDS != null) {
+ if (reconnectDS != null) {
// break recursion
if (isDebugEnabled) {
- logger.debug("disconnecting reconnected DS: {}", this.reconnectDS);
+ logger.debug("disconnecting reconnected DS: {}", reconnectDS);
}
- InternalDistributedSystem r = this.reconnectDS;
- this.reconnectDS = null;
+ InternalDistributedSystem r = reconnectDS;
+ reconnectDS = null;
r.disconnect(false, null, false);
}
} // !reconnect
@@ -1573,19 +1561,19 @@ public class InternalDistributedSystem extends DistributedSystem
shutdownListeners = doDisconnects(attemptingToReconnect);
}
- if (!this.attemptingToReconnect) {
+ if (!attemptingToReconnect) {
alertingSession.stopSession();
}
} finally { // be ABSOLUTELY CERTAIN that dm closed
try {
// Do the bulk of the close...
- this.dm.close();
+ dm.close();
// we close the locator after the DM so that when split-brain detection
// is enabled, loss of the locator doesn't cause the DM to croak
- if (this.startedLocator != null) {
- this.startedLocator.stop(forcedDisconnect, preparingForReconnect, false);
- this.startedLocator = null;
+ if (startedLocator != null) {
+ startedLocator.stop(forcedDisconnect, preparingForReconnect, false);
+ startedLocator = null;
}
} finally { // timer canceled
// bug 38501: this has to happen *after*
@@ -1611,12 +1599,12 @@ public class InternalDistributedSystem extends DistributedSystem
InternalFunctionService.unregisterAllFunctions();
- if (this.sampler != null) {
- this.sampler.stop();
- this.sampler = null;
+ if (sampler != null) {
+ sampler.stop();
+ sampler = null;
}
- if (!this.attemptingToReconnect) {
+ if (!attemptingToReconnect) {
loggingSession.stopSession();
}
@@ -1630,12 +1618,12 @@ public class InternalDistributedSystem extends DistributedSystem
} finally {
try {
removeSystem(this);
- if (!this.attemptingToReconnect) {
+ if (!attemptingToReconnect) {
loggingSession.shutdown();
}
alertingSession.shutdown();
// Close the config object
- this.config.close();
+ config.close();
} finally {
// Finally, mark ourselves as disconnected
setDisconnected();
@@ -1650,14 +1638,14 @@ public class InternalDistributedSystem extends DistributedSystem
*/
public DistributionManager getDistributionManager() {
checkConnected();
- return this.dm;
+ return dm;
}
/**
* Returns the distribution manager without checking for connected or not so can also return null.
*/
public DistributionManager getDM() {
- return this.dm;
+ return dm;
}
/**
@@ -1667,8 +1655,8 @@ public class InternalDistributedSystem extends DistributedSystem
*
* @return the quorum checking service
*/
- public QuorumChecker getQuorumChecker() {
- return this.quorumChecker;
+ QuorumChecker getQuorumChecker() {
+ return quorumChecker;
}
/**
@@ -1692,9 +1680,9 @@ public class InternalDistributedSystem extends DistributedSystem
Boolean b = ConnectionTable.getThreadOwnsResourcesRegistration();
if (b == null) {
// thread does not have a preference so return default
- return !this.shareSockets;
+ return !shareSockets;
} else {
- return b.booleanValue();
+ return b;
}
}
@@ -1706,7 +1694,7 @@ public class InternalDistributedSystem extends DistributedSystem
*/
public boolean sameSystemAs(Properties props) {
DistributionConfig other = DistributionConfigImpl.produce(props);
- DistributionConfig me = this.getConfig();
+ DistributionConfig me = getConfig();
if (!me.getBindAddress().equals(other.getBindAddress())) {
return false;
@@ -1734,7 +1722,7 @@ public class InternalDistributedSystem extends DistributedSystem
* @since GemFire 4.0
*/
private static String canonicalizeLocators(String locators) {
- SortedSet sorted = new TreeSet();
+ SortedSet<String> sorted = new TreeSet<>();
StringTokenizer st = new StringTokenizer(locators, ",");
while (st.hasMoreTokens()) {
String l = st.nextToken();
@@ -1747,7 +1735,7 @@ public class InternalDistributedSystem extends DistributedSystem
canonical.append(locId.getHostName());
}
canonical.append("[");
- canonical.append(String.valueOf(locId.getPort()));
+ canonical.append(locId.getPort());
canonical.append("]");
sorted.add(canonical.toString());
}
@@ -1766,7 +1754,7 @@ public class InternalDistributedSystem extends DistributedSystem
* Returns the current configuration of this distributed system.
*/
public DistributionConfig getConfig() {
- return this.config;
+ return config;
}
public AlertingService getAlertingService() {
@@ -1808,15 +1796,16 @@ public class InternalDistributedSystem extends DistributedSystem
*/
@Override
public String getMemberId() {
- return String.valueOf(this.dm.getId());
+ return String.valueOf(dm.getId());
}
@Override
public InternalDistributedMember getDistributedMember() {
- return this.dm.getId();
+ return dm.getId();
}
@Override
+ @SuppressWarnings("unchecked")
public Set<DistributedMember> getAllOtherMembers() {
return (Set) dm.getAllOtherMembers();
}
@@ -1860,7 +1849,7 @@ public class InternalDistributedSystem extends DistributedSystem
* Returns the configuration this distributed system was created with.
*/
public DistributionConfig getOriginalConfig() {
- return this.originalConfig;
+ return originalConfig;
}
/////////////////////// Utility Methods ///////////////////////
@@ -1894,7 +1883,7 @@ public class InternalDistributedSystem extends DistributedSystem
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Connected ");
- String name = this.getName();
+ String name = getName();
if (name != null && !name.equals("")) {
sb.append("\"");
sb.append(name);
@@ -1905,7 +1894,7 @@ public class InternalDistributedSystem extends DistributedSystem
sb.append(") ");
sb.append("to distributed system using ");
- int port = this.config.getMcastPort();
+ int port = config.getMcastPort();
if (port != 0) {
sb.append("multicast port ");
sb.append(port);
@@ -1913,11 +1902,11 @@ public class InternalDistributedSystem extends DistributedSystem
} else {
sb.append("locators \"");
- sb.append(this.config.getLocators());
+ sb.append(config.getLocators());
sb.append("\" ");
}
- File logFile = this.config.getLogFile();
+ File logFile = config.getLogFile();
sb.append("logging to ");
if (logFile == null || logFile.equals(new File(""))) {
sb.append("standard out ");
@@ -1928,9 +1917,9 @@ public class InternalDistributedSystem extends DistributedSystem
}
sb.append(" started at ");
- sb.append((new Date(this.startTime)).toString());
+ sb.append((new Date(startTime)).toString());
- if (!this.isConnected()) {
+ if (!isConnected()) {
sb.append(" (closed)");
}
@@ -2097,8 +2086,8 @@ public class InternalDistributedSystem extends DistributedSystem
* invoked when this connection to the distributed system is disconnected.
*/
public void addDisconnectListener(DisconnectListener listener) {
- synchronized (this.disconnectListeners) {
- this.disconnectListeners.add(listener);
+ synchronized (disconnectListeners) {
+ disconnectListeners.add(listener);
boolean disconnectThreadBoolean = isDisconnectThread.get();
@@ -2107,9 +2096,9 @@ public class InternalDistributedSystem extends DistributedSystem
// Do this test _after_ adding the listener to narrow the window.
// It's possible to miss it still and never invoke the listener, but
// other shutdown conditions will presumably get flagged.
- String reason = this.stopper.cancelInProgress();
+ String reason = stopper.cancelInProgress();
if (reason != null) {
- this.disconnectListeners.remove(listener); // don't leave in the list!
+ disconnectListeners.remove(listener); // don't leave in the list!
throw new DistributedSystemDisconnectedException(
String.format("No listeners permitted after shutdown: %s",
reason),
@@ -2124,8 +2113,8 @@ public class InternalDistributedSystem extends DistributedSystem
* this connection to the distributed system is disconnected.
*/
public void removeDisconnectListener(DisconnectListener listener) {
- synchronized (this.disconnectListeners) {
- this.disconnectListeners.remove(listener);
+ synchronized (disconnectListeners) {
+ disconnectListeners.remove(listener);
}
}
@@ -2151,12 +2140,12 @@ public class InternalDistributedSystem extends DistributedSystem
@Override
public Properties getProperties() {
- return this.config.toProperties();
+ return config.toProperties();
}
@Override
public Properties getSecurityProperties() {
- return this.config.getSecurityProps();
+ return config.getSecurityProps();
}
/**
@@ -2259,7 +2248,7 @@ public class InternalDistributedSystem extends DistributedSystem
* Integer representing number of tries already made to reconnect and that failed.
*/
@MakeNotStatic
- private static volatile int reconnectAttemptCounter = 0;
+ private static final AtomicInteger reconnectAttemptCounter = new AtomicInteger();
/**
* Boolean indicating if DS needs to reconnect and reconnect is in progress.
@@ -2299,15 +2288,14 @@ public class InternalDistributedSystem extends DistributedSystem
*/
@Override
public boolean isReconnecting() {
- InternalDistributedSystem rds = this.reconnectDS;
+ InternalDistributedSystem rds = reconnectDS;
if (!attemptingToReconnect) {
return false;
}
if (reconnectCancelled) {
return false;
}
- boolean newDsConnected = (rds == null || !rds.isConnected());
- return newDsConnected;
+ return (rds == null || !rds.isConnected());
}
@@ -2316,8 +2304,8 @@ public class InternalDistributedSystem extends DistributedSystem
* one of the connection attempts. If the connection succeeds this state is cleared and this
* method will commence to return false.
*/
- public boolean isReconnectingDS() {
- return this.isReconnectingDS;
+ boolean isReconnectingDS() {
+ return isReconnectingDS;
}
/**
@@ -2325,9 +2313,9 @@ public class InternalDistributedSystem extends DistributedSystem
* isReconnectingDS returns true. This is used to connect the new DM to the distributed system
* through RemoteTransportConfig.
*/
- public MembershipInformation oldDSMembershipInfo() {
- if (this.quorumChecker != null) {
- return this.quorumChecker.getMembershipInfo();
+ MembershipInformation oldDSMembershipInfo() {
+ if (quorumChecker != null) {
+ return quorumChecker.getMembershipInfo();
}
return null;
}
@@ -2337,14 +2325,14 @@ public class InternalDistributedSystem extends DistributedSystem
* of required-roles
*/
public boolean reconnected() {
- return this.reconnected;
+ return reconnected;
}
/**
* Returns true if this DS has been kicked out of the distributed system
*/
public boolean forcedDisconnect() {
- return this.forcedDisconnect;
+ return forcedDisconnect;
}
/**
@@ -2357,11 +2345,11 @@ public class InternalDistributedSystem extends DistributedSystem
* it.
*/
private void cancelReconnect() {
- this.reconnectCancelled = true;
+ reconnectCancelled = true;
if (isReconnecting()) {
- synchronized (this.reconnectLock) { // should the synchronized be first on this and
+ synchronized (reconnectLock) { // should the synchronized be first on this and
// then on this.reconnectLock.
- this.reconnectLock.notifyAll();
+ reconnectLock.notifyAll();
}
}
}
@@ -2378,13 +2366,13 @@ public class InternalDistributedSystem extends DistributedSystem
*/
public boolean tryReconnect(boolean forcedDisconnect, String reason, InternalCache oldCache) {
final boolean isDebugEnabled = logger.isDebugEnabled();
- if (this.isReconnectingDS && forcedDisconnect) {
+ if (isReconnectingDS && forcedDisconnect) {
return false;
}
synchronized (InternalCacheBuilder.class) {
synchronized (GemFireCacheImpl.class) {
// bug 39329: must lock reconnectLock *after* the cache
- synchronized (this.reconnectLock) {
+ synchronized (reconnectLock) {
if (!forcedDisconnect && !oldCache.isClosed()
&& oldCache.getCachePerfStats().getReliableRegionsMissing() == 0) {
if (isDebugEnabled) {
@@ -2397,7 +2385,7 @@ public class InternalDistributedSystem extends DistributedSystem
logger.debug("tryReconnect: forcedDisconnect={}", forcedDisconnect);
}
if (forcedDisconnect) {
- if (this.config.getDisableAutoReconnect()) {
+ if (config.getDisableAutoReconnect()) {
if (isDebugEnabled) {
logger.debug("tryReconnect: auto reconnect after forced disconnect is disabled");
}
@@ -2405,7 +2393,7 @@ public class InternalDistributedSystem extends DistributedSystem
}
}
reconnect(forcedDisconnect, reason);
- return this.reconnectDS != null && this.reconnectDS.isConnected();
+ return reconnectDS != null && reconnectDS.isConnected();
} // synchronized reconnectLock
} // synchronized cache
} // synchronized CacheFactory.class
@@ -2416,7 +2404,7 @@ public class InternalDistributedSystem extends DistributedSystem
* Returns the value for the number of time reconnect has been tried. Test method used by DUnit.
*/
public static int getReconnectAttemptCounter() {
- return reconnectAttemptCounter;
+ return reconnectAttemptCounter.get();
}
/**
@@ -2439,7 +2427,7 @@ public class InternalDistributedSystem extends DistributedSystem
// If reconnecting for forced-disconnect we ignore max-tries and keep attempting
// to join the distributed system until successful
- this.attemptingToReconnect = true;
+ attemptingToReconnect = true;
InternalDistributedSystem ids = InternalDistributedSystem.getAnyInstance();
if (ids == null) {
ids = this;
@@ -2460,8 +2448,8 @@ public class InternalDistributedSystem extends DistributedSystem
}
DistributionConfig oldConfig = ids.getConfig();
- Properties configProps = this.config.toProperties();
- configProps.putAll(this.config.toSecurityProperties());
+ Properties configProps = config.toProperties();
+ configProps.putAll(config.toSecurityProperties());
int timeOut = oldConfig.getMaxWaitTimeForReconnect();
int memberTimeout = oldConfig.getMemberTimeout();
@@ -2484,8 +2472,8 @@ public class InternalDistributedSystem extends DistributedSystem
}
// get the membership manager for quorum checks
- MembershipManager mbrMgr = this.dm.getMembershipManager();
- this.quorumChecker = mbrMgr.getQuorumChecker();
+ MembershipManager mbrMgr = dm.getMembershipManager();
+ quorumChecker = mbrMgr.getQuorumChecker();
if (logger.isDebugEnabled()) {
if (quorumChecker == null) {
logger.debug("No quorum checks will be performed during reconnect attempts");
@@ -2507,7 +2495,7 @@ public class InternalDistributedSystem extends DistributedSystem
systemAttemptingReconnect = this;
}
try {
- while (this.reconnectDS == null || !this.reconnectDS.isConnected()) {
+ while (reconnectDS == null || !reconnectDS.isConnected()) {
if (isReconnectCancelled()) {
break;
}
@@ -2516,7 +2504,7 @@ public class InternalDistributedSystem extends DistributedSystem
if (isDebugEnabled) {
logger.debug("Max number of tries : {} and max time out : {}", maxTries, timeOut);
}
- if (reconnectAttemptCounter >= maxTries) {
+ if (reconnectAttemptCounter.get() >= maxTries) {
if (isDebugEnabled) {
logger.debug(
"Stopping the checkrequiredrole thread because reconnect : {} reached the max number of reconnect tries : {}",
@@ -2533,7 +2521,7 @@ public class InternalDistributedSystem extends DistributedSystem
}
}
- reconnectAttemptCounter++;
+ reconnectAttemptCounter.getAndIncrement();
if (isReconnectCancelled()) {
return;
@@ -2566,12 +2554,12 @@ public class InternalDistributedSystem extends DistributedSystem
"Attempting to reconnect to the distributed system. This is attempt #{}.",
reconnectAttemptCounter);
- int saveNumberOfTries = reconnectAttemptCounter;
+ int saveNumberOfTries = reconnectAttemptCounter.get();
try {
// notify listeners of each attempt and then again after successful
- notifyReconnectListeners(this, this.reconnectDS, true);
+ notifyReconnectListeners(this, reconnectDS, true);
- if (this.locatorDMTypeForced) {
+ if (locatorDMTypeForced) {
System.setProperty(InternalLocator.FORCE_LOCATOR_DM_TYPE, "true");
}
@@ -2602,12 +2590,12 @@ public class InternalDistributedSystem extends DistributedSystem
}
}
- if (this.reconnectCancelled) {
+ if (reconnectCancelled) {
newDS.disconnect();
continue;
}
- this.reconnectDS = newDS;
+ reconnectDS = newDS;
} catch (SystemConnectException e) {
logger.debug("Attempt to reconnect failed with SystemConnectException");
@@ -2630,14 +2618,14 @@ public class InternalDistributedSystem extends DistributedSystem
reconnectException = e;
return;
} finally {
- if (this.locatorDMTypeForced) {
+ if (locatorDMTypeForced) {
System.getProperties().remove(InternalLocator.FORCE_LOCATOR_DM_TYPE);
}
- reconnectAttemptCounter = saveNumberOfTries;
+ reconnectAttemptCounter.set(saveNumberOfTries);
}
- DistributionManager newDM = this.reconnectDS.getDistributionManager();
+ DistributionManager newDM = reconnectDS.getDistributionManager();
if (newDM instanceof ClusterDistributionManager) {
// Admin systems don't carry a cache, but for others we can now create
// a cache
@@ -2656,7 +2644,7 @@ public class InternalDistributedSystem extends DistributedSystem
if (!cache.isClosed()) {
createAndStartCacheServers(cacheServerCreation, cache);
if (cache.getCachePerfStats().getReliableRegionsMissing() == 0) {
- reconnectAttemptCounter = 0;
+ reconnectAttemptCounter.set(0);
}
}
@@ -2708,7 +2696,7 @@ public class InternalDistributedSystem extends DistributedSystem
} else {
reconnectDS.isReconnectingDS = false;
if (reconnectDS.isConnected()) {
- notifyReconnectListeners(this, this.reconnectDS, false);
+ notifyReconnectListeners(this, reconnectDS, false);
}
}
@@ -2789,16 +2777,16 @@ public class InternalDistributedSystem extends DistributedSystem
* @throws IllegalStateException when the configuration is not the same other returns
*/
public void validateSameProperties(Properties propsToCheck, boolean isConnected) {
- if (!this.sameAs(propsToCheck, isConnected)) {
+ if (!sameAs(propsToCheck, isConnected)) {
StringBuilder sb = new StringBuilder();
DistributionConfig wanted = DistributionConfigImpl.produce(propsToCheck);
- String[] validAttributeNames = this.originalConfig.getAttributeNames();
+ String[] validAttributeNames = originalConfig.getAttributeNames();
for (String attName : validAttributeNames) {
Object expectedAtt = wanted.getAttributeObject(attName);
String expectedAttStr = expectedAtt.toString();
- Object actualAtt = this.originalConfig.getAttributeObject(attName);
+ Object actualAtt = originalConfig.getAttributeObject(attName);
String actualAttStr = actualAtt.toString();
sb.append(" ");
sb.append(attName);
@@ -2819,7 +2807,7 @@ public class InternalDistributedSystem extends DistributedSystem
sb.append("\n");
}
- if (this.creationStack == null) {
+ if (creationStack == null) {
throw new IllegalStateException(
String.format(
"A connection to a distributed system already exists in this VM. It has the following configuration:%s",
@@ -2829,7 +2817,7 @@ public class InternalDistributedSystem extends DistributedSystem
String.format(
"A connection to a distributed system already exists in this VM. It has the following configuration:%s",
sb.toString()),
- this.creationStack);
+ creationStack);
}
}
}
@@ -2901,13 +2889,13 @@ public class InternalDistributedSystem extends DistributedSystem
} else {
endTime += TimeUnit.MILLISECONDS.convert(time, units);
}
- synchronized (this.reconnectLock) {
+ synchronized (reconnectLock) {
while (isReconnecting()) {
- if (this.reconnectCancelled) {
+ if (reconnectCancelled) {
break;
}
if (time != 0) {
- this.reconnectLock.wait(sleepTime);
+ reconnectLock.wait(sleepTime);
}
if (time == 0 || System.currentTimeMillis() > endTime) {
break;
@@ -2918,32 +2906,32 @@ public class InternalDistributedSystem extends DistributedSystem
throw new DistributedSystemDisconnectedException(
"Reconnect attempts terminated due to exception", reconnectException);
}
- InternalDistributedSystem recon = this.reconnectDS;
+ InternalDistributedSystem recon = reconnectDS;
return !attemptingToReconnect && recon != null && recon.isConnected();
}
}
@Override
public DistributedSystem getReconnectedSystem() {
- return this.reconnectDS;
+ return reconnectDS;
}
@Override
public void stopReconnecting() {
- this.reconnectCancelled = true;
- synchronized (this.reconnectLock) {
- this.reconnectLock.notify();
+ reconnectCancelled = true;
+ synchronized (reconnectLock) {
+ reconnectLock.notify();
}
disconnect(false, "stopReconnecting was invoked", false);
- this.attemptingToReconnect = false;
+ attemptingToReconnect = false;
}
public void stopReconnectingNoDisconnect() {
- this.reconnectCancelled = true;
- synchronized (this.reconnectLock) {
- this.reconnectLock.notify();
+ reconnectCancelled = true;
+ synchronized (reconnectLock) {
+ reconnectLock.notify();
}
- this.attemptingToReconnect = false;
+ attemptingToReconnect = false;
}
/**
@@ -2958,11 +2946,11 @@ public class InternalDistributedSystem extends DistributedSystem
}
public void setCache(InternalCache instance) {
- this.dm.setCache(instance);
+ dm.setCache(instance);
}
public InternalCache getCache() {
- return this.dm == null ? null : this.dm.getCache();
+ return dm == null ? null : dm.getCache();
}
private static StatisticsManagerFactory defaultStatisticsManagerFactory() {
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
index 182c899..a011a99 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractRegion.java
@@ -185,8 +185,6 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
protected Set<String> gatewaySenderIds;
- private boolean isGatewaySenderEnabled = false;
-
protected Set<String> asyncEventQueueIds;
private Set<String> visibleAsyncEventQueueIds;
@@ -274,108 +272,108 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
private final PoolFinder poolFinder;
/** Creates a new instance of AbstractRegion */
- protected AbstractRegion(InternalCache cache, RegionAttributes attrs, String regionName,
+ protected AbstractRegion(InternalCache cache, RegionAttributes<?, ?> attrs, String regionName,
InternalRegionArguments internalRegionArgs, PoolFinder poolFinder) {
this.poolFinder = poolFinder;
this.cache = cache;
- this.serialNumber = DistributionAdvisor.createSerialNumber();
- this.isPdxTypesRegion = PeerTypeRegistration.REGION_NAME.equals(regionName);
- this.lastAccessedTime = new AtomicLong(cacheTimeMillis());
- this.lastModifiedTime = new AtomicLong(this.lastAccessedTime.get());
- this.dataPolicy = attrs.getDataPolicy(); // do this one first
- this.scope = attrs.getScope();
+ serialNumber = DistributionAdvisor.createSerialNumber();
+ isPdxTypesRegion = PeerTypeRegistration.REGION_NAME.equals(regionName);
+ lastAccessedTime = new AtomicLong(cacheTimeMillis());
+ lastModifiedTime = new AtomicLong(lastAccessedTime.get());
+ dataPolicy = attrs.getDataPolicy(); // do this one first
+ scope = attrs.getScope();
- this.offHeap = attrs.getOffHeap();
+ offHeap = attrs.getOffHeap();
// fix bug #52033 by invoking setOffHeap now (localMaxMemory may now be the temporary
// placeholder for off-heap until DistributedSystem is created
// found non-null PartitionAttributes and offHeap is true so let's setOffHeap on PA now
PartitionAttributes<?, ?> partitionAttributes1 = attrs.getPartitionAttributes();
- if (this.offHeap && partitionAttributes1 != null) {
+ if (offHeap && partitionAttributes1 != null) {
PartitionAttributesImpl impl = (PartitionAttributesImpl) partitionAttributes1;
impl.setOffHeap(true);
}
evictionAttributes = new EvictionAttributesImpl(attrs.getEvictionAttributes());
- if (attrs.getPartitionAttributes() != null && this.evictionAttributes.getAlgorithm()
+ if (attrs.getPartitionAttributes() != null && evictionAttributes.getAlgorithm()
.isLRUMemory() && attrs.getPartitionAttributes().getLocalMaxMemory() != 0
- && this.evictionAttributes
+ && evictionAttributes
.getMaximum() != attrs.getPartitionAttributes().getLocalMaxMemory()) {
logger.warn(
"For region {} with data policy PARTITION, memory LRU eviction attribute maximum has been reset from {}MB to local-max-memory {}MB",
- new Object[] {regionName, this.evictionAttributes.getMaximum(),
+ new Object[] {regionName, evictionAttributes.getMaximum(),
attrs.getPartitionAttributes().getLocalMaxMemory()});
- this.evictionAttributes.setMaximum(attrs.getPartitionAttributes().getLocalMaxMemory());
+ evictionAttributes.setMaximum(attrs.getPartitionAttributes().getLocalMaxMemory());
}
storeCacheListenersField(attrs.getCacheListeners());
assignCacheLoader(attrs.getCacheLoader());
assignCacheWriter(attrs.getCacheWriter());
- this.regionTimeToLive = attrs.getRegionTimeToLive().getTimeout();
- this.regionTimeToLiveExpirationAction = attrs.getRegionTimeToLive().getAction();
+ regionTimeToLive = attrs.getRegionTimeToLive().getTimeout();
+ regionTimeToLiveExpirationAction = attrs.getRegionTimeToLive().getAction();
setRegionTimeToLiveAtts();
- this.regionIdleTimeout = attrs.getRegionIdleTimeout().getTimeout();
- this.regionIdleTimeoutExpirationAction = attrs.getRegionIdleTimeout().getAction();
+ regionIdleTimeout = attrs.getRegionIdleTimeout().getTimeout();
+ regionIdleTimeoutExpirationAction = attrs.getRegionIdleTimeout().getAction();
setRegionIdleTimeoutAttributes();
- this.entryTimeToLive = attrs.getEntryTimeToLive().getTimeout();
- this.entryTimeToLiveExpirationAction = attrs.getEntryTimeToLive().getAction();
+ entryTimeToLive = attrs.getEntryTimeToLive().getTimeout();
+ entryTimeToLiveExpirationAction = attrs.getEntryTimeToLive().getAction();
setEntryTimeToLiveAttributes();
- this.customEntryTimeToLive = attrs.getCustomEntryTimeToLive();
- this.entryIdleTimeout = attrs.getEntryIdleTimeout().getTimeout();
- this.entryIdleTimeoutExpirationAction = attrs.getEntryIdleTimeout().getAction();
+ customEntryTimeToLive = attrs.getCustomEntryTimeToLive();
+ entryIdleTimeout = attrs.getEntryIdleTimeout().getTimeout();
+ entryIdleTimeoutExpirationAction = attrs.getEntryIdleTimeout().getAction();
setEntryIdleTimeoutAttributes();
- this.customEntryIdleTimeout = attrs.getCustomEntryIdleTimeout();
+ customEntryIdleTimeout = attrs.getCustomEntryIdleTimeout();
updateEntryExpiryPossible();
- this.statisticsEnabled = attrs.getStatisticsEnabled();
- this.ignoreJTA = attrs.getIgnoreJTA();
- this.isLockGrantor = attrs.isLockGrantor();
- this.keyConstraint = attrs.getKeyConstraint();
- this.valueConstraint = attrs.getValueConstraint();
- this.initialCapacity = attrs.getInitialCapacity();
- this.loadFactor = attrs.getLoadFactor();
- this.concurrencyLevel = attrs.getConcurrencyLevel();
- this.setConcurrencyChecksEnabled(
+ statisticsEnabled = attrs.getStatisticsEnabled();
+ ignoreJTA = attrs.getIgnoreJTA();
+ isLockGrantor = attrs.isLockGrantor();
+ keyConstraint = attrs.getKeyConstraint();
+ valueConstraint = attrs.getValueConstraint();
+ initialCapacity = attrs.getInitialCapacity();
+ loadFactor = attrs.getLoadFactor();
+ concurrencyLevel = attrs.getConcurrencyLevel();
+ setConcurrencyChecksEnabled(
attrs.getConcurrencyChecksEnabled() && supportsConcurrencyChecks());
- this.earlyAck = attrs.getEarlyAck();
- this.gatewaySenderIds = attrs.getGatewaySenderIds();
- this.asyncEventQueueIds = attrs.getAsyncEventQueueIds();
+ earlyAck = attrs.getEarlyAck();
+ gatewaySenderIds = attrs.getGatewaySenderIds();
+ asyncEventQueueIds = attrs.getAsyncEventQueueIds();
initializeVisibleAsyncEventQueueIds(internalRegionArgs);
setAllGatewaySenderIds();
- this.enableSubscriptionConflation = attrs.getEnableSubscriptionConflation();
- this.publisher = attrs.getPublisher();
- this.enableAsyncConflation = attrs.getEnableAsyncConflation();
- this.indexMaintenanceSynchronous = attrs.getIndexMaintenanceSynchronous();
- this.mcastEnabled = attrs.getMulticastEnabled();
- this.partitionAttributes = attrs.getPartitionAttributes();
- this.membershipAttributes = attrs.getMembershipAttributes();
- this.subscriptionAttributes = attrs.getSubscriptionAttributes();
- this.cloningEnable = attrs.getCloningEnabled();
- this.poolName = attrs.getPoolName();
- if (this.poolName != null) {
+ enableSubscriptionConflation = attrs.getEnableSubscriptionConflation();
+ publisher = attrs.getPublisher();
+ enableAsyncConflation = attrs.getEnableAsyncConflation();
+ indexMaintenanceSynchronous = attrs.getIndexMaintenanceSynchronous();
+ mcastEnabled = attrs.getMulticastEnabled();
+ partitionAttributes = attrs.getPartitionAttributes();
+ membershipAttributes = attrs.getMembershipAttributes();
+ subscriptionAttributes = attrs.getSubscriptionAttributes();
+ cloningEnable = attrs.getCloningEnabled();
+ poolName = attrs.getPoolName();
+ if (poolName != null) {
PoolImpl cp = getPool();
if (cp == null) {
throw new IllegalStateException(
String.format("The connection pool %s has not been created",
- this.poolName));
+ poolName));
}
cp.attach();
- if (cp.getMultiuserAuthentication() && !this.getDataPolicy().isEmpty()) {
+ if (cp.getMultiuserAuthentication() && !getDataPolicy().isEmpty()) {
throw new IllegalStateException(
"Region must have empty data-policy " + "when multiuser-authentication is true.");
}
}
- this.diskStoreName = attrs.getDiskStoreName();
- this.isDiskSynchronous = attrs.isDiskSynchronous();
- if (this.diskStoreName == null) {
- this.diskWriteAttributes = attrs.getDiskWriteAttributes();
- this.isDiskSynchronous = this.diskWriteAttributes.isSynchronous(); // fixes bug 41313
- this.diskDirs = attrs.getDiskDirs();
- this.diskSizes = attrs.getDiskDirSizes();
+ diskStoreName = attrs.getDiskStoreName();
+ isDiskSynchronous = attrs.isDiskSynchronous();
+ if (diskStoreName == null) {
+ diskWriteAttributes = attrs.getDiskWriteAttributes();
+ isDiskSynchronous = diskWriteAttributes.isSynchronous(); // fixes bug 41313
+ diskDirs = attrs.getDiskDirs();
+ diskSizes = attrs.getDiskDirSizes();
}
- this.compressor = attrs.getCompressor();
+ compressor = attrs.getCompressor();
// enable concurrency checks for persistent regions
if (!attrs.getConcurrencyChecksEnabled() && attrs.getDataPolicy().withPersistence()
&& supportsConcurrencyChecks()) {
@@ -386,11 +384,11 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@VisibleForTesting
AbstractRegion() {
- this.cache = null;
- this.serialNumber = 0;
- this.isPdxTypesRegion = false;
- this.lastAccessedTime = new AtomicLong(0);
- this.lastModifiedTime = new AtomicLong(0);
+ cache = null;
+ serialNumber = 0;
+ isPdxTypesRegion = false;
+ lastAccessedTime = new AtomicLong(0);
+ lastModifiedTime = new AtomicLong(0);
evictionAttributes = new EvictionAttributesImpl();
poolFinder = (a) -> null;
}
@@ -404,9 +402,10 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Deprecated
public void setIgnoreJTA(boolean ignore) {
- this.ignoreJTA = ignore;
+ ignoreJTA = ignore;
}
+ @SuppressWarnings("unchecked")
@Override
public void create(Object key, Object value)
throws TimeoutException, EntryExistsException, CacheWriterException {
@@ -424,6 +423,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
return get(key, null, true, null);
}
+ @SuppressWarnings("unchecked")
@Override
public Object put(Object key, Object value) throws TimeoutException, CacheWriterException {
return put(key, value, null);
@@ -523,8 +523,8 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
StringBuilder buf = new StringBuilder();
buf.append(getClass().getName());
buf.append("[path='").append(getFullPath()).append("';scope=").append(getScope())
- .append("';dataPolicy=").append(this.getDataPolicy());
- if (this.getConcurrencyChecksEnabled()) {
+ .append("';dataPolicy=").append(getDataPolicy());
+ if (getConcurrencyChecksEnabled()) {
buf.append("; concurrencyChecksEnabled");
}
return buf;
@@ -539,7 +539,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
public CacheLoader getCacheLoader() {
readWriteLockForCacheLoader.readLock().lock();
try {
- return this.cacheLoader;
+ return cacheLoader;
} finally {
readWriteLockForCacheLoader.readLock().unlock();
}
@@ -549,7 +549,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
public CacheWriter getCacheWriter() {
readWriteLockForCacheWriter.readLock().lock();
try {
- return this.cacheWriter;
+ return cacheWriter;
} finally {
readWriteLockForCacheWriter.readLock().unlock();
}
@@ -562,7 +562,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
* @since GemFire 5.7
*/
CacheLoader basicGetLoader() {
- return this.cacheLoader;
+ return cacheLoader;
}
/**
@@ -573,104 +573,104 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public CacheWriter basicGetWriter() {
- return this.cacheWriter;
+ return cacheWriter;
}
@Override
public Class getKeyConstraint() {
- return this.keyConstraint;
+ return keyConstraint;
}
@Override
public Class getValueConstraint() {
- return this.valueConstraint;
+ return valueConstraint;
}
private volatile ExpirationAttributes regionTimeToLiveAtts;
private void setRegionTimeToLiveAtts() {
- this.regionTimeToLiveAtts =
- new ExpirationAttributes(this.regionTimeToLive, this.regionTimeToLiveExpirationAction);
+ regionTimeToLiveAtts =
+ new ExpirationAttributes(regionTimeToLive, regionTimeToLiveExpirationAction);
}
@Override
public ExpirationAttributes getRegionTimeToLive() {
- return this.regionTimeToLiveAtts;
+ return regionTimeToLiveAtts;
}
private volatile ExpirationAttributes regionIdleTimeoutAttributes;
private void setRegionIdleTimeoutAttributes() {
- this.regionIdleTimeoutAttributes =
- new ExpirationAttributes(this.regionIdleTimeout, this.regionIdleTimeoutExpirationAction);
+ regionIdleTimeoutAttributes =
+ new ExpirationAttributes(regionIdleTimeout, regionIdleTimeoutExpirationAction);
}
@Override
public ExpirationAttributes getRegionIdleTimeout() {
- return this.regionIdleTimeoutAttributes;
+ return regionIdleTimeoutAttributes;
}
private volatile ExpirationAttributes entryTimeToLiveAtts;
void setEntryTimeToLiveAttributes() {
- this.entryTimeToLiveAtts =
- new ExpirationAttributes(this.entryTimeToLive, this.entryTimeToLiveExpirationAction);
+ entryTimeToLiveAtts =
+ new ExpirationAttributes(entryTimeToLive, entryTimeToLiveExpirationAction);
}
@Override
public ExpirationAttributes getEntryTimeToLive() {
- return this.entryTimeToLiveAtts;
+ return entryTimeToLiveAtts;
}
@Override
public CustomExpiry getCustomEntryTimeToLive() {
- return this.customEntryTimeToLive;
+ return customEntryTimeToLive;
}
private volatile ExpirationAttributes entryIdleTimeoutAttributes;
private void setEntryIdleTimeoutAttributes() {
- this.entryIdleTimeoutAttributes =
- new ExpirationAttributes(this.entryIdleTimeout, this.entryIdleTimeoutExpirationAction);
+ entryIdleTimeoutAttributes =
+ new ExpirationAttributes(entryIdleTimeout, entryIdleTimeoutExpirationAction);
}
@Override
public ExpirationAttributes getEntryIdleTimeout() {
- return this.entryIdleTimeoutAttributes;
+ return entryIdleTimeoutAttributes;
}
@Override
public CustomExpiry getCustomEntryIdleTimeout() {
- return this.customEntryIdleTimeout;
+ return customEntryIdleTimeout;
}
@Override
public MirrorType getMirrorType() {
- if (this.getDataPolicy().isNormal() || this.getDataPolicy().isPreloaded()
- || this.getDataPolicy().isEmpty() || this.getDataPolicy().withPartitioning()) {
+ if (getDataPolicy().isNormal() || getDataPolicy().isPreloaded()
+ || getDataPolicy().isEmpty() || getDataPolicy().withPartitioning()) {
return MirrorType.NONE;
- } else if (this.getDataPolicy().withReplication()) {
+ } else if (getDataPolicy().withReplication()) {
return MirrorType.KEYS_VALUES;
} else {
throw new IllegalStateException(
String.format("No mirror type corresponds to data policy %s",
- this.getDataPolicy()));
+ getDataPolicy()));
}
}
@Override
public String getPoolName() {
- return this.poolName;
+ return poolName;
}
@Override
public DataPolicy getDataPolicy() {
- return this.dataPolicy;
+ return dataPolicy;
}
@Override
public Scope getScope() {
- return this.scope;
+ return scope;
}
@Override
@@ -688,26 +688,26 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
public boolean isPdxTypesRegion() {
- return this.isPdxTypesRegion;
+ return isPdxTypesRegion;
}
@Override
public Set<String> getGatewaySenderIds() {
- return this.gatewaySenderIds;
+ return gatewaySenderIds;
}
@Override
public Set<String> getAsyncEventQueueIds() {
- return this.asyncEventQueueIds;
+ return asyncEventQueueIds;
}
Set<String> getVisibleAsyncEventQueueIds() {
- return this.visibleAsyncEventQueueIds;
+ return visibleAsyncEventQueueIds;
}
@Override
public Set<String> getAllGatewaySenderIds() {
- return this.allGatewaySenderIds;
+ return allGatewaySenderIds;
}
/**
@@ -717,12 +717,12 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
List<Integer> getRemoteDsIds(Set<String> allGatewaySenderIds) throws IllegalStateException {
int sz = allGatewaySenderIds.size();
- Set<GatewaySender> allGatewaySenders = this.cache.getAllGatewaySenders();
- if ((sz > 0 || this.isPdxTypesRegion) && !allGatewaySenders.isEmpty()) {
+ Set<GatewaySender> allGatewaySenders = cache.getAllGatewaySenders();
+ if ((sz > 0 || isPdxTypesRegion) && !allGatewaySenders.isEmpty()) {
List<Integer> allRemoteDSIds = new ArrayList<>(sz);
for (GatewaySender sender : allGatewaySenders) {
// This is for all regions except pdx Region
- if (!this.isPdxTypesRegion) {
+ if (!isPdxTypesRegion) {
// Make sure we are distributing to only those senders whose id
// is available on this region
if (allGatewaySenderIds.contains(sender.getId())) {
@@ -737,10 +737,6 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
return null;
}
- boolean isGatewaySenderEnabled() {
- return this.isGatewaySenderEnabled;
- }
-
@Immutable
private static final CacheListener[] EMPTY_LISTENERS = new CacheListener[0];
@@ -760,7 +756,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
* Sets the cacheListeners field.
*/
private void storeCacheListenersField(CacheListener[] value) {
- synchronized (this.clSync) {
+ synchronized (clSync) {
if (value != null && value.length != 0) {
CacheListener[] cacheListeners = new CacheListener[value.length];
System.arraycopy(value, 0, cacheListeners, 0, cacheListeners.length);
@@ -768,7 +764,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
} else {
value = EMPTY_LISTENERS;
}
- this.cacheListeners = value;
+ cacheListeners = value;
}
}
@@ -777,24 +773,24 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
* the returned array.
*/
CacheListener[] fetchCacheListenersField() {
- return this.cacheListeners;
+ return cacheListeners;
}
@Override
public int getInitialCapacity() {
- return this.initialCapacity;
+ return initialCapacity;
}
@Override
public float getLoadFactor() {
- return this.loadFactor;
+ return loadFactor;
}
abstract boolean isCurrentlyLockGrantor();
@Override
public boolean isLockGrantor() {
- return this.isLockGrantor;
+ return isLockGrantor;
}
/**
@@ -803,27 +799,27 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public boolean getMulticastEnabled() {
- return this.mcastEnabled;
+ return mcastEnabled;
}
@Override
public boolean getStatisticsEnabled() {
- return this.statisticsEnabled;
+ return statisticsEnabled;
}
@Override
public boolean getIgnoreJTA() {
- return this.ignoreJTA;
+ return ignoreJTA;
}
@Override
public int getConcurrencyLevel() {
- return this.concurrencyLevel;
+ return concurrencyLevel;
}
@Override
public boolean getConcurrencyChecksEnabled() {
- return this.concurrencyChecksEnabled;
+ return concurrencyChecksEnabled;
}
public void setConcurrencyChecksEnabled(boolean concurrencyChecksEnabled) {
@@ -837,7 +833,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public boolean getEarlyAck() {
- return this.earlyAck;
+ return earlyAck;
}
/*
@@ -846,7 +842,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Deprecated
@Override
public boolean getPublisher() {
- return this.publisher;
+ return publisher;
}
@Override
@@ -861,12 +857,12 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public boolean getEnableSubscriptionConflation() {
- return this.enableSubscriptionConflation;
+ return enableSubscriptionConflation;
}
@Override
public boolean getEnableAsyncConflation() {
- return this.enableAsyncConflation;
+ return enableAsyncConflation;
}
/*
@@ -875,7 +871,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Deprecated
@Override
public DiskWriteAttributes getDiskWriteAttributes() {
- return this.diskWriteAttributes;
+ return diskWriteAttributes;
}
@Override
@@ -883,32 +879,32 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public String getDiskStoreName() {
- return this.diskStoreName;
+ return diskStoreName;
}
@Override
public boolean isDiskSynchronous() {
- return this.isDiskSynchronous;
+ return isDiskSynchronous;
}
@Override
public boolean getIndexMaintenanceSynchronous() {
- return this.indexMaintenanceSynchronous;
+ return indexMaintenanceSynchronous;
}
@Override
public PartitionAttributes getPartitionAttributes() {
- return this.partitionAttributes;
+ return partitionAttributes;
}
@Override
public MembershipAttributes getMembershipAttributes() {
- return this.membershipAttributes;
+ return membershipAttributes;
}
@Override
public SubscriptionAttributes getSubscriptionAttributes() {
- return this.subscriptionAttributes;
+ return subscriptionAttributes;
}
/**
@@ -916,18 +912,16 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public IndexManager getIndexManager() {
- return this.indexManager;
+ return indexManager;
}
/**
* This method call is guarded by imSync lock created for each region. Set IndexManger for region.
*/
@Override
- public IndexManager setIndexManager(IndexManager indexManager) {
+ public void setIndexManager(IndexManager indexManager) {
checkReadiness();
- IndexManager oldIdxManager = this.indexManager;
this.indexManager = indexManager;
- return oldIdxManager;
}
/**
@@ -937,7 +931,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public Object getIMSync() {
- return this.imSync;
+ return imSync;
}
// The ThreadLocal is used to identify if the thread is an
@@ -999,19 +993,17 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
private void setAllGatewaySenderIds() {
if (getGatewaySenderIds().isEmpty() && getAsyncEventQueueIds().isEmpty()) {
- this.allGatewaySenderIds = Collections.emptySet(); // fix for bug 45774
+ allGatewaySenderIds = Collections.emptySet(); // fix for bug 45774
}
- Set<String> tmp = new HashSet<String>(this.getGatewaySenderIds());
- for (String asyncQueueId : this.getAsyncEventQueueIds()) {
+ Set<String> tmp = new HashSet<>(getGatewaySenderIds());
+ for (String asyncQueueId : getAsyncEventQueueIds()) {
tmp.add(AsyncEventQueueImpl.getSenderIdFromAsyncEventQueueId(asyncQueueId));
}
- this.allGatewaySenderIds = Collections.unmodifiableSet(tmp);
+ allGatewaySenderIds = Collections.unmodifiableSet(tmp);
}
private void initializeVisibleAsyncEventQueueIds(InternalRegionArguments internalRegionArgs) {
- Set<String> visibleAsyncEventQueueIds = new CopyOnWriteArraySet<>();
- // Add all configured aeqIds
- visibleAsyncEventQueueIds.addAll(getAsyncEventQueueIds());
+ Set<String> visibleAsyncEventQueueIds = new CopyOnWriteArraySet<>(getAsyncEventQueueIds());
// Remove all internal aeqIds from internal region args if necessary
if (internalRegionArgs.getInternalAsyncEventQueueIds() != null) {
visibleAsyncEventQueueIds.removeAll(internalRegionArgs.getInternalAsyncEventQueueIds());
@@ -1028,15 +1020,15 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
CacheListener wcl = wrapRegionMembershipListener(aListener);
boolean changed = false;
- synchronized (this.clSync) {
- CacheListener[] oldListeners = this.cacheListeners;
+ synchronized (clSync) {
+ CacheListener[] oldListeners = cacheListeners;
if (oldListeners == null || oldListeners.length == 0) {
- this.cacheListeners = new CacheListener[] {wcl};
+ cacheListeners = new CacheListener[] {wcl};
changed = true;
} else {
List<CacheListener> listeners = Arrays.asList(oldListeners);
if (!listeners.contains(aListener)) {
- this.cacheListeners =
+ cacheListeners =
(CacheListener[]) ArrayUtils.insert(oldListeners, oldListeners.length, wcl);
}
}
@@ -1064,29 +1056,28 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
* Initialize any wrapped RegionMembershipListeners in the cache listener list
*/
void initPostCreateRegionMembershipListeners(Set initialMembers) {
- synchronized (this.clSync) {
+ synchronized (clSync) {
DistributedMember[] members = null;
CacheListener[] newListeners = null;
- for (int i = 0; i < this.cacheListeners.length; i++) {
- CacheListener cl = this.cacheListeners[i];
+ for (int i = 0; i < cacheListeners.length; i++) {
+ CacheListener cl = cacheListeners[i];
if (cl instanceof WrappedRegionMembershipListener) {
WrappedRegionMembershipListener wrml = (WrappedRegionMembershipListener) cl;
if (!wrml.isInitialized()) {
if (members == null) {
- members = (DistributedMember[]) initialMembers
- .toArray(new DistributedMember[initialMembers.size()]);
+ members = (DistributedMember[]) initialMembers.toArray(new DistributedMember[0]);
}
wrml.initialMembers(this, members);
if (newListeners == null) {
- newListeners = new CacheListener[this.cacheListeners.length];
- System.arraycopy(this.cacheListeners, 0, newListeners, 0, newListeners.length);
+ newListeners = new CacheListener[cacheListeners.length];
+ System.arraycopy(cacheListeners, 0, newListeners, 0, newListeners.length);
}
newListeners[i] = wrml.getWrappedListener();
}
}
}
if (newListeners != null) {
- this.cacheListeners = newListeners;
+ cacheListeners = newListeners;
}
}
}
@@ -1102,10 +1093,10 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
}
CacheListener[] oldListeners;
- synchronized (this.clSync) {
- oldListeners = this.cacheListeners;
+ synchronized (clSync) {
+ oldListeners = cacheListeners;
if (listenersToAdd == null || listenersToAdd.length == 0) {
- this.cacheListeners = EMPTY_LISTENERS;
+ cacheListeners = EMPTY_LISTENERS;
} else { // we have some listeners to add
if (Arrays.asList(listenersToAdd).contains(null)) {
throw new IllegalArgumentException(
@@ -1113,7 +1104,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
CacheListener[] newCacheListeners = new CacheListener[listenersToAdd.length];
System.arraycopy(listenersToAdd, 0, newCacheListeners, 0, newCacheListeners.length);
- this.cacheListeners = newCacheListeners;
+ cacheListeners = newCacheListeners;
}
}
// moved the following out of the sync for bug 34512
@@ -1143,17 +1134,17 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
"removeCacheListener parameter was null");
}
boolean changed = false;
- synchronized (this.clSync) {
- CacheListener[] oldListeners = this.cacheListeners;
+ synchronized (clSync) {
+ CacheListener[] oldListeners = cacheListeners;
if (oldListeners != null && oldListeners.length > 0) {
- List newListeners = new ArrayList(Arrays.asList(oldListeners));
+ List<CacheListener> newListeners = new ArrayList<>(Arrays.asList(oldListeners));
if (newListeners.remove(aListener)) {
if (newListeners.isEmpty()) {
- this.cacheListeners = EMPTY_LISTENERS;
+ cacheListeners = EMPTY_LISTENERS;
} else {
CacheListener[] newCacheListeners = new CacheListener[newListeners.size()];
newListeners.toArray(newCacheListeners);
- this.cacheListeners = newCacheListeners;
+ cacheListeners = newCacheListeners;
}
closeCacheCallback(aListener);
if (newListeners.isEmpty()) {
@@ -1184,7 +1175,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
private void assignCacheLoader(CacheLoader cl) {
readWriteLockForCacheLoader.writeLock().lock();
try {
- this.cacheLoader = cl;
+ cacheLoader = cl;
} finally {
readWriteLockForCacheLoader.writeLock().unlock();
}
@@ -1214,7 +1205,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
void checkEntryTimeoutAction(String mode, ExpirationAction ea) {
- if ((this.getDataPolicy().withReplication() || this.getDataPolicy().withPartitioning())
+ if ((getDataPolicy().withReplication() || getDataPolicy().withPartitioning())
&& (ea == ExpirationAction.LOCAL_DESTROY || ea == ExpirationAction.LOCAL_INVALIDATE)) {
throw new IllegalArgumentException(
String.format("%s action is incompatible with this region's data policy.",
@@ -1230,14 +1221,14 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
"idleTimeout must not be null");
}
checkEntryTimeoutAction("idleTimeout", idleTimeout.getAction());
- if (!this.statisticsEnabled) {
+ if (!statisticsEnabled) {
throw new IllegalStateException(
"Cannot set idle timeout when statistics are disabled.");
}
ExpirationAttributes oldAttrs = getEntryIdleTimeout();
- this.entryIdleTimeout = idleTimeout.getTimeout();
- this.entryIdleTimeoutExpirationAction = idleTimeout.getAction();
+ entryIdleTimeout = idleTimeout.getTimeout();
+ entryIdleTimeoutExpirationAction = idleTimeout.getAction();
setEntryIdleTimeoutAttributes();
updateEntryExpiryPossible();
idleTimeoutChanged(oldAttrs);
@@ -1247,13 +1238,13 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public CustomExpiry setCustomEntryIdleTimeout(CustomExpiry custom) {
checkReadiness();
- if (custom != null && !this.statisticsEnabled) {
+ if (custom != null && !statisticsEnabled) {
throw new IllegalStateException(
"Cannot set idle timeout when statistics are disabled.");
}
CustomExpiry old = getCustomEntryIdleTimeout();
- this.customEntryIdleTimeout = custom;
+ customEntryIdleTimeout = custom;
updateEntryExpiryPossible();
idleTimeoutChanged(getEntryIdleTimeout());
return old;
@@ -1267,13 +1258,13 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
"timeToLive must not be null");
}
checkEntryTimeoutAction("timeToLive", timeToLive.getAction());
- if (!this.statisticsEnabled) {
+ if (!statisticsEnabled) {
throw new IllegalStateException(
"Cannot set time to live when statistics are disabled");
}
ExpirationAttributes oldAttrs = getEntryTimeToLive();
- this.entryTimeToLive = timeToLive.getTimeout();
- this.entryTimeToLiveExpirationAction = timeToLive.getAction();
+ entryTimeToLive = timeToLive.getTimeout();
+ entryTimeToLiveExpirationAction = timeToLive.getAction();
setEntryTimeToLiveAttributes();
updateEntryExpiryPossible();
timeToLiveChanged(oldAttrs);
@@ -1283,12 +1274,12 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public CustomExpiry setCustomEntryTimeToLive(CustomExpiry custom) {
checkReadiness();
- if (custom != null && !this.statisticsEnabled) {
+ if (custom != null && !statisticsEnabled) {
throw new IllegalStateException(
"Cannot set custom time to live when statistics are disabled");
}
CustomExpiry old = getCustomEntryTimeToLive();
- this.customEntryTimeToLive = custom;
+ customEntryTimeToLive = custom;
updateEntryExpiryPossible();
timeToLiveChanged(getEntryTimeToLive());
return old;
@@ -1314,23 +1305,23 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
throw new IllegalArgumentException(
"idleTimeout must not be null");
}
- if (this.getAttributes().getDataPolicy().withPartitioning()) {
+ if (getAttributes().getDataPolicy().withPartitioning()) {
validatePRRegionExpirationAttributes(idleTimeout);
}
if (idleTimeout.getAction() == ExpirationAction.LOCAL_INVALIDATE
- && this.getDataPolicy().withReplication()) {
+ && getDataPolicy().withReplication()) {
throw new IllegalArgumentException(
String.format("%s action is incompatible with this region's data policy.",
"idleTimeout"));
}
- if (!this.statisticsEnabled) {
+ if (!statisticsEnabled) {
throw new IllegalStateException(
"Cannot set idle timeout when statistics are disabled.");
}
ExpirationAttributes oldAttrs = getRegionIdleTimeout();
- this.regionIdleTimeout = idleTimeout.getTimeout();
- this.regionIdleTimeoutExpirationAction = idleTimeout.getAction();
- this.setRegionIdleTimeoutAttributes();
+ regionIdleTimeout = idleTimeout.getTimeout();
+ regionIdleTimeoutExpirationAction = idleTimeout.getAction();
+ setRegionIdleTimeoutAttributes();
regionIdleTimeoutChanged(oldAttrs);
return oldAttrs;
}
@@ -1342,24 +1333,24 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
throw new IllegalArgumentException(
"timeToLive must not be null");
}
- if (this.getAttributes().getDataPolicy().withPartitioning()) {
+ if (getAttributes().getDataPolicy().withPartitioning()) {
validatePRRegionExpirationAttributes(timeToLive);
}
if (timeToLive.getAction() == ExpirationAction.LOCAL_INVALIDATE
- && this.getDataPolicy().withReplication()) {
+ && getDataPolicy().withReplication()) {
throw new IllegalArgumentException(
String.format("%s action is incompatible with this region's data policy.",
"timeToLive"));
}
- if (!this.statisticsEnabled) {
+ if (!statisticsEnabled) {
throw new IllegalStateException(
"Cannot set time to live when statistics are disabled");
}
ExpirationAttributes oldAttrs = getRegionTimeToLive();
- this.regionTimeToLive = timeToLive.getTimeout();
- this.regionTimeToLiveExpirationAction = timeToLive.getAction();
- this.setRegionTimeToLiveAtts();
+ regionTimeToLive = timeToLive.getTimeout();
+ regionTimeToLiveExpirationAction = timeToLive.getAction();
+ setRegionTimeToLiveAtts();
regionTimeToLiveChanged(timeToLive);
return oldAttrs;
}
@@ -1368,20 +1359,20 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
public void becomeLockGrantor() {
checkReadiness();
checkForLimitedOrNoAccess();
- if (this.scope != Scope.GLOBAL) {
+ if (scope != Scope.GLOBAL) {
throw new IllegalStateException(
"Cannot set lock grantor when scope is not global");
}
if (isCurrentlyLockGrantor())
return; // nothing to do... already lock grantor
- this.isLockGrantor = true;
+ isLockGrantor = true;
}
@Override
public CacheStatistics getStatistics() {
// prefer region destroyed exception over statistics disabled exception
checkReadiness();
- if (!this.statisticsEnabled) {
+ if (!statisticsEnabled) {
throw new StatisticsDisabledException(
String.format("Statistics disabled for region ' %s '",
getFullPath()));
@@ -1419,19 +1410,19 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
private long basicGetLastModifiedTime() {
- return this.lastModifiedTime.get();
+ return lastModifiedTime.get();
}
private long basicGetLastAccessedTime() {
- return this.lastAccessedTime.get();
+ return lastAccessedTime.get();
}
private void basicSetLastModifiedTime(long t) {
- this.lastModifiedTime.set(t);
+ lastModifiedTime.set(t);
}
private void basicSetLastAccessedTime(long t) {
- this.lastAccessedTime.set(t);
+ lastAccessedTime.set(t);
}
/**
@@ -1491,23 +1482,23 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
protected void setLastModifiedTime(long time) {
- if (time > this.lastModifiedTime.get()) {
- this.lastModifiedTime.set(time);
+ if (time > lastModifiedTime.get()) {
+ lastModifiedTime.set(time);
}
- if (time > this.lastAccessedTime.get()) {
- this.lastAccessedTime.set(time);
+ if (time > lastAccessedTime.get()) {
+ lastAccessedTime.set(time);
}
}
void setLastAccessedTime(long time, boolean hit) {
- this.lastAccessedTime.set(time);
+ lastAccessedTime.set(time);
if (hit) {
if (trackHits) {
- this.hitCount.getAndIncrement();
+ hitCount.getAndIncrement();
}
} else {
if (trackMisses) {
- this.missCount.getAndIncrement();
+ missCount.getAndIncrement();
}
}
}
@@ -1521,21 +1512,21 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public long getHitCount() {
- return this.hitCount.get();
+ return hitCount.get();
}
@Override
public long getMissCount() {
- return this.missCount.get();
+ return missCount.get();
}
@Override
public void resetCounts() {
if (trackMisses) {
- this.missCount.set(0);
+ missCount.set(0);
}
if (trackHits) {
- this.hitCount.set(0);
+ hitCount.set(0);
}
}
@@ -1553,7 +1544,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
protected void cacheLoaderChanged(CacheLoader oldLoader) {
readWriteLockForCacheLoader.readLock().lock();
try {
- if (this.cacheLoader != oldLoader) {
+ if (cacheLoader != oldLoader) {
closeCacheCallback(oldLoader);
}
} finally {
@@ -1575,7 +1566,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
protected void cacheWriterChanged(CacheWriter oldWriter) {
readWriteLockForCacheWriter.readLock().lock();
try {
- if (this.cacheWriter != oldWriter) {
+ if (cacheWriter != oldWriter) {
closeCacheCallback(oldWriter);
}
} finally {
@@ -1634,15 +1625,15 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
private boolean entryExpiryPossible = false;
protected void updateEntryExpiryPossible() {
- this.entryExpiryPossible = !isProxy() && (hasTimeToLive() || hasIdleTimeout());
+ entryExpiryPossible = !isProxy() && (hasTimeToLive() || hasIdleTimeout());
}
private boolean hasTimeToLive() {
- return this.entryTimeToLive > 0 || this.customEntryTimeToLive != null;
+ return entryTimeToLive > 0 || customEntryTimeToLive != null;
}
private boolean hasIdleTimeout() {
- return this.entryIdleTimeout > 0 || this.customEntryIdleTimeout != null;
+ return entryIdleTimeout > 0 || customEntryIdleTimeout != null;
}
/**
@@ -1650,15 +1641,15 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public boolean isEntryExpiryPossible() {
- return this.entryExpiryPossible;
+ return entryExpiryPossible;
}
ExpirationAction getEntryExpirationAction() {
- if (this.entryIdleTimeoutExpirationAction != null) {
- return this.entryIdleTimeoutExpirationAction;
+ if (entryIdleTimeoutExpirationAction != null) {
+ return entryIdleTimeoutExpirationAction;
}
- if (this.entryTimeToLiveExpirationAction != null) {
- return this.entryTimeToLiveExpirationAction;
+ if (entryTimeToLiveExpirationAction != null) {
+ return entryTimeToLiveExpirationAction;
}
return null;
}
@@ -1668,7 +1659,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public boolean isEntryEvictionPossible() {
- return this.evictionAttributes != null && !this.evictionAttributes.getAlgorithm().isNone();
+ return evictionAttributes != null && !evictionAttributes.getAlgorithm().isNone();
}
/** is this a region that supports versioning? */
@@ -1710,12 +1701,12 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public EvictionAttributes getEvictionAttributes() {
- return this.evictionAttributes;
+ return evictionAttributes;
}
@Override
public EvictionAttributesMutator getEvictionAttributesMutator() {
- return new EvictionAttributesMutatorImpl(this, this.evictionAttributes);
+ return new EvictionAttributesMutatorImpl(this, evictionAttributes);
}
/**
@@ -1764,22 +1755,22 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
* relation to other regions or other instances of this region during the life of this JVM.
*/
public int getSerialNumber() {
- return this.serialNumber;
+ return serialNumber;
}
@Override
public InternalCache getCache() {
- return this.cache;
+ return cache;
}
@Override
public long cacheTimeMillis() {
- return this.cache.getInternalDistributedSystem().getClock().cacheTimeMillis();
+ return cache.getInternalDistributedSystem().getClock().cacheTimeMillis();
}
@Override
public RegionService getRegionService() {
- return this.cache;
+ return cache;
}
@Override
@@ -1819,7 +1810,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public boolean getCloningEnabled() {
- return this.cloningEnable;
+ return cloningEnable;
}
@Override
@@ -1835,7 +1826,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
}
public InternalCache getGemFireCache() {
- return this.cache;
+ return cache;
}
@Override
@@ -1843,6 +1834,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
return cache;
}
+ @SuppressWarnings("unchecked")
@Override
public RegionSnapshotService getSnapshotService() {
return new RegionSnapshotServiceImpl(this);
@@ -1850,7 +1842,7 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
@Override
public Compressor getCompressor() {
- return this.compressor;
+ return compressor;
}
/**
@@ -1858,12 +1850,12 @@ public abstract class AbstractRegion implements InternalRegion, AttributesMutato
*/
@Override
public ExtensionPoint<Region<?, ?>> getExtensionPoint() {
- return this.extensionPoint;
+ return extensionPoint;
}
@Override
public boolean getOffHeap() {
- return this.offHeap;
+ return offHeap;
}
@Override
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
index a512b76..eab2054 100755
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
@@ -36,6 +36,7 @@ import java.net.InetSocketAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -286,12 +287,6 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
new CopyOnWriteArraySet<>();
/**
- * Define gemfire.Cache.ASYNC_EVENT_LISTENERS=true to invoke event listeners in the background
- */
- private static final boolean ASYNC_EVENT_LISTENERS =
- Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "Cache.ASYNC_EVENT_LISTENERS");
-
- /**
* Name of the default pool.
*/
public static final String DEFAULT_POOL_NAME = "DEFAULT";
@@ -658,14 +653,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
final StringBuilder sb = new StringBuilder();
sb.append("GemFireCache[");
sb.append("id = ").append(System.identityHashCode(this));
- sb.append("; isClosing = ").append(this.isClosing);
+ sb.append("; isClosing = ").append(isClosing);
sb.append("; isShutDownAll = ").append(isCacheAtShutdownAll());
- sb.append("; created = ").append(this.creationDate);
- sb.append("; server = ").append(this.isServer);
- sb.append("; copyOnRead = ").append(this.copyOnRead);
- sb.append("; lockLease = ").append(this.lockLease);
- sb.append("; lockTimeout = ").append(this.lockTimeout);
- if (this.creationStack != null) {
+ sb.append("; created = ").append(creationDate);
+ sb.append("; server = ").append(isServer);
+ sb.append("; copyOnRead = ").append(copyOnRead);
+ sb.append("; lockLease = ").append(lockLease);
+ sb.append("; lockTimeout = ").append(lockTimeout);
+ if (creationStack != null) {
// TODO: eliminate anonymous inner class and maybe move this to ExceptionUtils
sb.append(System.lineSeparator()).append("Creation context:").append(System.lineSeparator());
OutputStream os = new OutputStream() {
@@ -675,14 +670,15 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
};
PrintStream ps = new PrintStream(os);
- this.creationStack.printStackTrace(ps);
+ creationStack.printStackTrace(ps);
}
sb.append("]");
return sb.toString();
}
/** Map of Futures used to track Regions that are being reinitialized */
- private final ConcurrentMap reinitializingRegions = new ConcurrentHashMap();
+ private final ConcurrentMap<String, FutureResult<InternalRegion>> reinitializingRegions =
+ new ConcurrentHashMap<>();
/**
* Returns the last created instance of GemFireCache
@@ -780,7 +776,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
this.isClient = isClient;
this.poolFactory = poolFactory;
this.cacheConfig = cacheConfig; // do early for bug 43213
- this.pdxRegistry = typeRegistry;
+ pdxRegistry = typeRegistry;
this.meterRegistry = meterRegistry;
this.meterSubregistries = meterSubregistries;
@@ -791,23 +787,23 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// start JTA transaction manager within this synchronized block
// to prevent race with cache close. fixes bug 43987
JNDIInvoker.mapTransactions(internalDistributedSystem);
- this.system = internalDistributedSystem;
- this.dm = this.system.getDistributionManager();
+ system = internalDistributedSystem;
+ dm = system.getDistributionManager();
if (!isClient) {
- this.configurationResponse = requestSharedConfiguration();
+ configurationResponse = requestSharedConfiguration();
// apply the cluster's properties configuration and initialize security using that
// configuration
- ccLoader.applyClusterPropertiesConfiguration(this.configurationResponse,
- this.system.getConfig());
+ ccLoader.applyClusterPropertiesConfiguration(configurationResponse,
+ system.getConfig());
- this.securityService =
- SecurityServiceFactory.create(this.system.getConfig().getSecurityProps(), cacheConfig);
- this.system.setSecurityService(this.securityService);
+ securityService =
+ SecurityServiceFactory.create(system.getConfig().getSecurityProps(), cacheConfig);
+ system.setSecurityService(securityService);
} else {
// create a no-op security service for client
- this.securityService = SecurityServiceFactory.create();
+ securityService = SecurityServiceFactory.create();
}
DistributionConfig systemConfig = internalDistributedSystem.getConfig();
@@ -819,61 +815,61 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (disableJmx) {
logger.info("Running with JMX disabled.");
} else {
- this.resourceEventsListener = new ManagementListener(this.system);
- this.system.addResourceListener(this.resourceEventsListener);
- if (this.system.isLoner()) {
- this.system.getInternalLogWriter()
+ resourceEventsListener = new ManagementListener(system);
+ system.addResourceListener(resourceEventsListener);
+ if (system.isLoner()) {
+ system.getInternalLogWriter()
.info("Running in local mode since no locators were specified.");
}
}
} else {
logger.info("Running in client mode");
- this.resourceEventsListener = null;
+ resourceEventsListener = null;
}
// Don't let admin-only VMs create Cache's just yet.
- if (this.dm.getDMType() == ClusterDistributionManager.ADMIN_ONLY_DM_TYPE) {
+ if (dm.getDMType() == ClusterDistributionManager.ADMIN_ONLY_DM_TYPE) {
throw new IllegalStateException(
"Cannot create a Cache in an admin-only VM.");
}
- this.rootRegions = new HashMap<>();
+ rootRegions = new HashMap<>();
- this.cqService = CqServiceProvider.create(this);
+ cqService = CqServiceProvider.create(this);
// Create the CacheStatistics
- CachePerfStats.enableClockStats = this.system.getConfig().getEnableTimeStatistics();
- this.cachePerfStats = new CachePerfStats(internalDistributedSystem.getStatisticsManager());
+ CachePerfStats.enableClockStats = system.getConfig().getEnableTimeStatistics();
+ cachePerfStats = new CachePerfStats(internalDistributedSystem.getStatisticsManager());
- this.transactionManager = new TXManagerImpl(this.cachePerfStats, this);
- this.dm.addMembershipListener(this.transactionManager);
+ transactionManager = new TXManagerImpl(cachePerfStats, this);
+ dm.addMembershipListener(transactionManager);
- this.creationDate = new Date();
+ creationDate = new Date();
- this.persistentMemberManager = new PersistentMemberManager();
+ persistentMemberManager = new PersistentMemberManager();
if (useAsyncEventListeners) {
- this.eventThreadPool = LoggingExecutors.newThreadPoolWithFixedFeed("Message Event Thread",
+ eventThreadPool = LoggingExecutors.newThreadPoolWithFixedFeed("Message Event Thread",
command -> {
ConnectionTable.threadWantsSharedResources();
command.run();
- }, EVENT_THREAD_LIMIT, this.cachePerfStats.getEventPoolHelper(), 1000,
+ }, EVENT_THREAD_LIMIT, cachePerfStats.getEventPoolHelper(), 1000,
getThreadMonitorObj(),
EVENT_QUEUE_LIMIT);
} else {
- this.eventThreadPool = null;
+ eventThreadPool = null;
}
// Initialize the advisor here, but wait to exchange profiles until cache is fully built
- this.resourceAdvisor = ResourceAdvisor.createResourceAdvisor(this);
+ resourceAdvisor = ResourceAdvisor.createResourceAdvisor(this);
// Initialize the advisor here, but wait to exchange profiles until cache is fully built
- this.jmxAdvisor = JmxManagerAdvisor
+ jmxAdvisor = JmxManagerAdvisor
.createJmxManagerAdvisor(new JmxManagerAdvisee(getCacheForProcessingClientRequests()));
- this.resourceManager = InternalResourceManager.createResourceManager(this);
- this.serialNumber = DistributionAdvisor.createSerialNumber();
+ resourceManager = InternalResourceManager.createResourceManager(this);
+ serialNumber = DistributionAdvisor.createSerialNumber();
getInternalResourceManager().addResourceListener(ResourceType.HEAP_MEMORY, getHeapEvictor());
@@ -885,8 +881,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
getOffHeapEvictor());
}
- this.recordedEventSweeper = createEventTrackerExpiryTask();
- this.tombstoneService = TombstoneService.initialize(this);
+ recordedEventSweeper = createEventTrackerExpiryTask();
+ tombstoneService = TombstoneService.initialize(this);
TypeRegistry.init();
basicSetPdxSerializer(this.cacheConfig.getPdxSerializer());
@@ -899,32 +895,32 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
HARegionQueue.setMessageSyncInterval(HARegionQueue.DEFAULT_MESSAGE_SYNC_INTERVAL);
}
FunctionService.registerFunction(new PRContainsValueFunction());
- this.expirationScheduler = new ExpirationScheduler(this.system);
+ expirationScheduler = new ExpirationScheduler(system);
// uncomment following line when debugging CacheExistsException
if (DEBUG_CREATION_STACK) {
- this.creationStack = new Exception(
+ creationStack = new Exception(
String.format("Created GemFireCache %s", toString()));
}
- this.txEntryStateFactory = TXEntryState.getFactory();
+ txEntryStateFactory = TXEntryState.getFactory();
if (XML_PARAMETERIZATION_ENABLED) {
// If product properties file is available replace properties from there
- Properties userProps = this.system.getConfig().getUserDefinedProps();
+ Properties userProps = system.getConfig().getUserDefinedProps();
if (userProps != null && !userProps.isEmpty()) {
- this.resolver = new CacheXmlPropertyResolver(false,
+ resolver = new CacheXmlPropertyResolver(false,
PropertyResolver.NO_SYSTEM_PROPERTIES_OVERRIDE, userProps);
} else {
- this.resolver = new CacheXmlPropertyResolver(false,
+ resolver = new CacheXmlPropertyResolver(false,
PropertyResolver.NO_SYSTEM_PROPERTIES_OVERRIDE, null);
}
} else {
- this.resolver = null;
+ resolver = null;
}
SystemFailure.signalCacheCreate();
- this.diskMonitor = new DiskStoreMonitor(systemConfig.getLogFile());
+ diskMonitor = new DiskStoreMonitor(systemConfig.getLogFile());
addRegionEntrySynchronizationListener(new GatewaySenderQueueEntrySynchronizationListener());
backupService = new BackupService(this);
@@ -965,13 +961,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void reLoadClusterConfiguration() throws IOException, ClassNotFoundException {
- this.configurationResponse = requestSharedConfiguration();
- if (this.configurationResponse != null) {
- ccLoader.deployJarsReceivedFromClusterConfiguration(this.configurationResponse);
- ccLoader.applyClusterPropertiesConfiguration(this.configurationResponse,
- this.system.getConfig());
- ccLoader.applyClusterXmlConfiguration(this, this.configurationResponse,
- this.system.getConfig().getGroups());
+ configurationResponse = requestSharedConfiguration();
+ if (configurationResponse != null) {
+ ccLoader.deployJarsReceivedFromClusterConfiguration(configurationResponse);
+ ccLoader.applyClusterPropertiesConfiguration(configurationResponse,
+ system.getConfig());
+ ccLoader.applyClusterXmlConfiguration(this, configurationResponse,
+ system.getConfig().getGroups());
initializeDeclarativeCache();
}
}
@@ -990,12 +986,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public SecurityService getSecurityService() {
- return this.securityService;
+ return securityService;
}
@Override
public boolean isRESTServiceRunning() {
- return this.isRESTServiceRunning;
+ return isRESTServiceRunning;
}
@Override
@@ -1009,7 +1005,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public RestAgent getRestAgent() {
- return this.restAgent;
+ return restAgent;
}
/**
@@ -1017,14 +1013,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
* running
*/
ConfigurationResponse requestSharedConfiguration() {
- final DistributionConfig config = this.system.getConfig();
+ final DistributionConfig config = system.getConfig();
- if (!(this.dm instanceof ClusterDistributionManager)) {
+ if (!(dm instanceof ClusterDistributionManager)) {
return null;
}
// do nothing if this vm is/has locator or this is a client
- if (this.dm.getDMType() == ClusterDistributionManager.LOCATOR_DM_TYPE || this.isClient
+ if (dm.getDMType() == ClusterDistributionManager.LOCATOR_DM_TYPE || isClient
|| Locator.getLocator() != null) {
return null;
}
@@ -1045,7 +1041,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
try {
ConfigurationResponse response = ccLoader.requestConfigurationFromLocators(
- this.system.getConfig().getGroups(), locatorsWithClusterConfig.keySet());
+ system.getConfig().getGroups(), locatorsWithClusterConfig.keySet());
// log the configuration received from the locator
logger.info("Received cluster configuration from the locator");
@@ -1118,7 +1114,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean isClient() {
- return this.isClient;
+ return isClient;
}
/**
@@ -1129,7 +1125,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean hasPool() {
- return this.isClient || !getAllPools().isEmpty();
+ return isClient || !getAllPools().isEmpty();
}
private static Collection<Pool> getAllPools() {
@@ -1148,10 +1144,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public synchronized Pool getDefaultPool() {
- if (this.defaultPool == null) {
+ if (defaultPool == null) {
determineDefaultPool();
}
- return this.defaultPool;
+ return defaultPool;
}
/**
@@ -1171,10 +1167,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
// set ClassPathLoader and then deploy cluster config jars
- ClassPathLoader.setLatestToDefault(this.system.getConfig().getDeployWorkingDir());
+ ClassPathLoader.setLatestToDefault(system.getConfig().getDeployWorkingDir());
try {
- ccLoader.deployJarsReceivedFromClusterConfiguration(this.configurationResponse);
+ ccLoader.deployJarsReceivedFromClusterConfiguration(configurationResponse);
} catch (IOException | ClassNotFoundException e) {
throw new GemFireConfigException(
"Exception while deploying the jars received as a part of cluster Configuration",
@@ -1182,7 +1178,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
SystemMemberCacheEventProcessor.send(this, Operation.CACHE_CREATE);
- this.resourceAdvisor.initializationGate();
+ resourceAdvisor.initializationGate();
// Register function that we need to execute to fetch available REST service endpoints in DS
FunctionService.registerFunction(new FindRestEnabledServersFunction());
@@ -1194,10 +1190,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// we will not be ready for all the events that cache.xml
// processing can deliver (region creation, etc.).
// This call may need to be moved inside initializeDeclarativeCache.
- this.jmxAdvisor.initializationGate(); // Entry to GemFire Management service
+ jmxAdvisor.initializationGate(); // Entry to GemFire Management service
// this starts up the ManagementService, register and federate the internal beans
- this.system.handleResourceEvent(ResourceEvent.CACHE_CREATE, this);
+ system.handleResourceEvent(ResourceEvent.CACHE_CREATE, this);
initializeServices();
@@ -1220,7 +1216,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// I don't want init to throw an exception that came from the close.
// I want it to throw the original exception that came from initializeDeclarativeCache.
}
- this.configurationResponse = null;
+ configurationResponse = null;
}
}
@@ -1228,16 +1224,16 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
startRestAgentServer(this);
- this.isInitialized = true;
+ isInitialized = true;
}
void applyJarAndXmlFromClusterConfig() {
- if (this.configurationResponse == null) {
+ if (configurationResponse == null) {
// Deploy all the jars from the deploy working dir.
ClassPathLoader.getLatest().getJarDeployer().loadPreviouslyDeployedJarsFromDisk();
}
- ccLoader.applyClusterXmlConfiguration(this, this.configurationResponse,
- this.system.getConfig().getGroups());
+ ccLoader.applyClusterXmlConfiguration(this, configurationResponse,
+ system.getConfig().getGroups());
}
/**
@@ -1248,26 +1244,26 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
ServiceLoader<CacheService> loader = ServiceLoader.load(CacheService.class);
for (CacheService service : loader) {
service.init(this);
- this.services.put(service.getInterface(), service);
- this.system.handleResourceEvent(ResourceEvent.CACHE_SERVICE_CREATE, service);
+ services.put(service.getInterface(), service);
+ system.handleResourceEvent(ResourceEvent.CACHE_SERVICE_CREATE, service);
logger.info("Initialized cache service {}", service.getClass().getName());
}
}
private boolean isServerNode() {
- return this.system.getDistributedMember()
+ return system.getDistributedMember()
.getVmKind() != ClusterDistributionManager.LOCATOR_DM_TYPE
- && this.system.getDistributedMember()
+ && system.getDistributedMember()
.getVmKind() != ClusterDistributionManager.ADMIN_ONLY_DM_TYPE
&& !isClient();
}
private void startRestAgentServer(GemFireCacheImpl cache) {
- if (this.system.getConfig().getStartDevRestApi() && isServerNode()) {
- this.restAgent = new RestAgent(this.system.getConfig(), this.securityService);
- this.restAgent.start(cache);
+ if (system.getConfig().getStartDevRestApi() && isServerNode()) {
+ restAgent = new RestAgent(system.getConfig(), securityService);
+ restAgent.start(cache);
} else {
- this.restAgent = null;
+ restAgent = null;
}
}
@@ -1275,12 +1271,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public URL getCacheXmlURL() {
- if (this.getMyId().getVmKind() == ClusterDistributionManager.LOCATOR_DM_TYPE) {
+ if (getMyId().getVmKind() == ClusterDistributionManager.LOCATOR_DM_TYPE) {
return null;
}
File xmlFile = testCacheXml;
if (xmlFile == null) {
- xmlFile = this.system.getConfig().getCacheXmlFile();
+ xmlFile = system.getConfig().getCacheXmlFile();
}
if (xmlFile.getName().isEmpty()) {
return null;
@@ -1344,7 +1340,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
private void initializeDeclarativeCache()
throws TimeoutException, CacheWriterException, GatewayException, RegionExistsException {
URL url = getCacheXmlURL();
- String cacheXmlDescription = this.cacheConfig.getCacheXMLDescription();
+ String cacheXmlDescription = cacheConfig.getCacheXMLDescription();
if (url == null && cacheXmlDescription == null) {
initializePdxRegistry();
readyDynamicRegionFactory();
@@ -1370,17 +1366,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
url.toString(), ex));
} catch (CacheXmlException ex) {
- CacheXmlException newEx =
- new CacheXmlException(String.format("While reading Cache XML %s. %s",
- url, ex.getMessage()));
- /*
- * TODO: why use setStackTrace and initCause? removal breaks several tests: OplogRVVJUnitTest,
- * NewDeclarativeIndexCreationJUnitTest CacheXml70DUnitTest, CacheXml80DUnitTest,
- * CacheXml81DUnitTest, CacheXmlGeode10DUnitTest RegionManagementDUnitTest
- */
- newEx.setStackTrace(ex.getStackTrace());
- newEx.initCause(ex.getCause());
- throw newEx;
+ throw new CacheXmlException(String.format("While reading Cache XML %s. %s",
+ url, ex.getMessage()), ex.getCause());
} finally {
closeQuietly(stream);
@@ -1416,14 +1403,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public synchronized void initializePdxRegistry() {
- if (this.pdxRegistry == null) {
+ if (pdxRegistry == null) {
// The member with locator is initialized with a NullTypePdxRegistration
- if (this.getMyId().getVmKind() == ClusterDistributionManager.LOCATOR_DM_TYPE) {
- this.pdxRegistry = new TypeRegistry(this, true);
+ if (getMyId().getVmKind() == ClusterDistributionManager.LOCATOR_DM_TYPE) {
+ pdxRegistry = new TypeRegistry(this, true);
} else {
- this.pdxRegistry = new TypeRegistry(this, false);
+ pdxRegistry = new TypeRegistry(this, false);
}
- this.pdxRegistry.initialize();
+ pdxRegistry.initialize();
}
}
@@ -1470,10 +1457,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (reason != null) {
return reason;
}
- if (GemFireCacheImpl.this.disconnectCause != null) {
- return GemFireCacheImpl.this.disconnectCause.getMessage();
+ if (disconnectCause != null) {
+ return disconnectCause.getMessage();
}
- if (GemFireCacheImpl.this.isClosing) {
+ if (isClosing) {
return "The cache is closed."; // this + ": closed";
}
return null;
@@ -1490,24 +1477,24 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (result != null) {
return result;
}
- if (GemFireCacheImpl.this.disconnectCause == null) {
+ if (disconnectCause == null) {
// No root cause, specify the one given and be done with it.
return new CacheClosedException(reason, throwable);
}
if (throwable == null) {
// Caller did not specify any root cause, so just use our own.
- return new CacheClosedException(reason, GemFireCacheImpl.this.disconnectCause);
+ return new CacheClosedException(reason, disconnectCause);
}
// Attempt to stick rootCause at tail end of the exception chain.
try {
- ThrowableUtils.setRootCause(throwable, GemFireCacheImpl.this.disconnectCause);
+ ThrowableUtils.setRootCause(throwable, disconnectCause);
return new CacheClosedException(reason, throwable);
} catch (IllegalStateException ignore) {
// Bug 39496 (JRockit related) Give up. The following
// error is not entirely sane but gives the correct general picture.
- return new CacheClosedException(reason, GemFireCacheImpl.this.disconnectCause);
+ return new CacheClosedException(reason, disconnectCause);
}
}
}
@@ -1516,13 +1503,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public CancelCriterion getCancelCriterion() {
- return this.stopper;
+ return stopper;
}
/** return true if the cache was closed due to being shunned by other members */
@Override
public boolean forcedDisconnect() {
- return this.forcedDisconnect || this.system.forcedDisconnect();
+ return forcedDisconnect || system.forcedDisconnect();
}
/** return a CacheClosedException with the given reason */
@@ -1537,8 +1524,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
CacheClosedException result;
if (cause != null) {
result = new CacheClosedException(reason, cause);
- } else if (this.disconnectCause != null) {
- result = new CacheClosedException(reason, this.disconnectCause);
+ } else if (disconnectCause != null) {
+ result = new CacheClosedException(reason, disconnectCause);
} else {
result = new CacheClosedException(reason);
}
@@ -1548,7 +1535,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
/** if the cache was forcibly closed this exception will reflect the cause */
@Override
public Throwable getDisconnectCause() {
- return this.disconnectCause;
+ return disconnectCause;
}
/**
@@ -1565,7 +1552,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean keepDurableSubscriptionsAlive() {
- return this.keepAlive;
+ return keepAlive;
}
/**
@@ -1595,13 +1582,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
* @see SystemFailure#emergencyClose()
*/
public static void emergencyClose() {
- final boolean DEBUG = SystemFailure.TRACE_CLOSE;
-
GemFireCacheImpl cache = getInstance();
if (cache == null) {
- if (DEBUG) {
- System.err.println("GemFireCache#emergencyClose: no instance");
- }
return;
}
@@ -1610,20 +1592,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Shut down messaging first
InternalDistributedSystem ids = cache.system;
if (ids != null) {
- if (DEBUG) {
- System.err.println("DEBUG: emergencyClose InternalDistributedSystem");
- }
ids.emergencyClose();
}
cache.disconnectCause = SystemFailure.getFailure();
cache.isClosing = true;
- // Clear cache servers
- if (DEBUG) {
- System.err.println("DEBUG: Close cache servers");
- }
-
for (InternalCacheServer cacheServer : cache.allCacheServers) {
Acceptor acceptor = cacheServer.getAcceptor();
if (acceptor != null) {
@@ -1637,15 +1611,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
acceptor.emergencyClose();
}
- if (DEBUG) {
- System.err.println("DEBUG: closing client resources");
- }
PoolManagerImpl.emergencyClose();
- if (DEBUG) {
- System.err.println("DEBUG: closing gateway hubs");
- }
-
// rootRegions is intentionally *not* synchronized. The
// implementation of clear() does not currently allocate objects.
cache.rootRegions.clear();
@@ -1653,14 +1620,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// partitionedRegions is intentionally *not* synchronized, The
// implementation of clear() does not currently allocate objects.
cache.partitionedRegions.clear();
- if (DEBUG) {
- System.err.println("DEBUG: done with cache emergency close");
- }
}
@Override
public boolean isCacheAtShutdownAll() {
- return this.isShutDownAll.get();
+ return isShutDownAll.get();
}
/**
@@ -1685,10 +1649,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
}
}
- if (!this.isShutDownAll.compareAndSet(false, true)) {
+ if (!isShutDownAll.compareAndSet(false, true)) {
// it's already doing shutdown by another thread
try {
- this.shutDownAllFinished.await();
+ shutDownAllFinished.await();
} catch (InterruptedException ignore) {
logger.debug(
"Shutdown all interrupted while waiting for another thread to do the shutDownAll");
@@ -1736,7 +1700,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
close("Shut down all members", null, false, true);
} finally {
- this.shutDownAllFinished.countDown();
+ shutDownAllFinished.countDown();
}
}
}
@@ -1757,6 +1721,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (partitionedRegion.isDataStore() && partitionedRegion.getDataStore() != null
&& partitionedRegion.getDataPolicy() == DataPolicy.PERSISTENT_PARTITION) {
int numBuckets = partitionedRegion.getTotalNumberOfBuckets();
+ @SuppressWarnings("unchecked")
Map<InternalDistributedMember, PersistentMemberID>[] bucketMaps = new Map[numBuckets];
PartitionedRegionDataStore dataStore = partitionedRegion.getDataStore();
@@ -1922,23 +1887,23 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public DistributedLockService getPartitionedRegionLockService() {
- synchronized (this.prLockServiceLock) {
- this.stopper.checkCancelInProgress(null);
- if (this.prLockService == null) {
+ synchronized (prLockServiceLock) {
+ stopper.checkCancelInProgress(null);
+ if (prLockService == null) {
try {
- this.prLockService =
+ prLockService =
DLockService.create(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME,
getInternalDistributedSystem(), true /* distributed */,
true /* destroyOnDisconnect */, true /* automateFreeResources */);
} catch (IllegalArgumentException e) {
- this.prLockService = DistributedLockService
+ prLockService = DistributedLockService
.getServiceNamed(PartitionedRegionHelper.PARTITION_LOCK_SERVICE_NAME);
- if (this.prLockService == null) {
+ if (prLockService == null) {
throw e; // PARTITION_LOCK_SERVICE_NAME must be illegal!
}
}
}
- return this.prLockService;
+ return prLockService;
}
}
@@ -1949,25 +1914,25 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public DistributedLockService getGatewaySenderLockService() {
- if (this.gatewayLockService == null) {
- synchronized (this.gatewayLockServiceLock) {
- this.stopper.checkCancelInProgress(null);
- if (this.gatewayLockService == null) {
+ if (gatewayLockService == null) {
+ synchronized (gatewayLockServiceLock) {
+ stopper.checkCancelInProgress(null);
+ if (gatewayLockService == null) {
try {
- this.gatewayLockService = DLockService.create(AbstractGatewaySender.LOCK_SERVICE_NAME,
+ gatewayLockService = DLockService.create(AbstractGatewaySender.LOCK_SERVICE_NAME,
getInternalDistributedSystem(), true /* distributed */,
true /* destroyOnDisconnect */, true /* automateFreeResources */);
} catch (IllegalArgumentException e) {
- this.gatewayLockService =
+ gatewayLockService =
DistributedLockService.getServiceNamed(AbstractGatewaySender.LOCK_SERVICE_NAME);
- if (this.gatewayLockService == null) {
+ if (gatewayLockService == null) {
throw e; // AbstractGatewaySender.LOCK_SERVICE_NAME must be illegal!
}
}
}
}
}
- return this.gatewayLockService;
+ return gatewayLockService;
}
/**
@@ -1997,45 +1962,45 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
public HeapEvictor getHeapEvictor() {
- synchronized (this.heapEvictorLock) {
- this.stopper.checkCancelInProgress(null);
- if (this.heapEvictor == null) {
- this.heapEvictor = new HeapEvictor(this);
+ synchronized (heapEvictorLock) {
+ stopper.checkCancelInProgress(null);
+ if (heapEvictor == null) {
+ heapEvictor = new HeapEvictor(this);
}
- return this.heapEvictor;
+ return heapEvictor;
}
}
public OffHeapEvictor getOffHeapEvictor() {
- synchronized (this.offHeapEvictorLock) {
- this.stopper.checkCancelInProgress(null);
- if (this.offHeapEvictor == null) {
- this.offHeapEvictor = new OffHeapEvictor(this);
+ synchronized (offHeapEvictorLock) {
+ stopper.checkCancelInProgress(null);
+ if (offHeapEvictor == null) {
+ offHeapEvictor = new OffHeapEvictor(this);
}
- return this.offHeapEvictor;
+ return offHeapEvictor;
}
}
/** Used by test to inject an evictor */
void setOffHeapEvictor(OffHeapEvictor evictor) {
- this.offHeapEvictor = evictor;
+ offHeapEvictor = evictor;
}
/** Used by test to inject an evictor */
void setHeapEvictor(HeapEvictor evictor) {
- this.heapEvictor = evictor;
+ heapEvictor = evictor;
}
@Override
public PersistentMemberManager getPersistentMemberManager() {
- return this.persistentMemberManager;
+ return persistentMemberManager;
}
@Override
public ClientMetadataService getClientMetadataService() {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
- return this.clientMetadataService;
+ return clientMetadataService;
}
private final boolean DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE = Boolean
@@ -2051,15 +2016,15 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
if (!keepDS && systemFailureCause == null // normal cache close
- && (this.isReconnecting() || this.system.getReconnectedSystem() != null)) {
+ && (isReconnecting() || system.getReconnectedSystem() != null)) {
logger.debug(
"Cache is shutting down distributed system connection. "
+ "isReconnecting={} reconnectedSystem={} keepAlive={} keepDS={}",
- this.isReconnecting(), system.getReconnectedSystem(), keepAlive, keepDS);
+ isReconnecting(), system.getReconnectedSystem(), keepAlive, keepDS);
- this.system.stopReconnectingNoDisconnect();
- if (this.system.getReconnectedSystem() != null) {
- this.system.getReconnectedSystem().disconnect();
+ system.stopReconnectingNoDisconnect();
+ if (system.getReconnectedSystem() != null) {
+ system.getReconnectedSystem().disconnect();
}
return;
}
@@ -2079,23 +2044,23 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
* First close the ManagementService as it uses a lot of infra which will be closed by
* cache.close()
*/
- this.system.handleResourceEvent(ResourceEvent.CACHE_REMOVE, this);
- if (this.resourceEventsListener != null) {
- this.system.removeResourceListener(this.resourceEventsListener);
- this.resourceEventsListener = null;
+ system.handleResourceEvent(ResourceEvent.CACHE_REMOVE, this);
+ if (resourceEventsListener != null) {
+ system.removeResourceListener(resourceEventsListener);
+ resourceEventsListener = null;
}
if (systemFailureCause != null) {
- this.forcedDisconnect = systemFailureCause instanceof ForcedDisconnectException;
- if (this.forcedDisconnect) {
- this.disconnectCause = new ForcedDisconnectException(reason);
+ forcedDisconnect = systemFailureCause instanceof ForcedDisconnectException;
+ if (forcedDisconnect) {
+ disconnectCause = new ForcedDisconnectException(reason);
} else {
- this.disconnectCause = systemFailureCause;
+ disconnectCause = systemFailureCause;
}
}
this.keepAlive = keepAlive;
- this.isClosing = true;
+ isClosing = true;
logger.info("{}: Now closing.", this);
// we don't clear the prID map if there is a system failure. Other
@@ -2106,25 +2071,25 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
TXStateProxy tx = null;
try {
- if (this.transactionManager != null) {
- tx = this.transactionManager.pauseTransaction();
+ if (transactionManager != null) {
+ tx = transactionManager.pauseTransaction();
}
// do this before closing regions
- this.resourceManager.close();
+ resourceManager.close();
try {
- this.resourceAdvisor.close();
+ resourceAdvisor.close();
} catch (CancelException ignore) {
// ignore
}
try {
- this.jmxAdvisor.close();
+ jmxAdvisor.close();
} catch (CancelException ignore) {
// ignore
}
- for (GatewaySender sender : this.allGatewaySenders) {
+ for (GatewaySender sender : allGatewaySenders) {
try {
sender.stop();
GatewaySenderAdvisor advisor = ((AbstractGatewaySender) sender).getSenderAdvisor();
@@ -2140,11 +2105,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
destroyGatewaySenderLockService();
- if (this.eventThreadPool != null) {
+ if (eventThreadPool != null) {
if (isDebugEnabled) {
logger.debug("{}: stopping event thread pool...", this);
}
- this.eventThreadPool.shutdown();
+ eventThreadPool.shutdown();
}
/*
@@ -2153,34 +2118,32 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
* closed!
*/
try {
- this.stopServers();
+ stopServers();
- this.stopServices();
+ stopServices();
httpService.ifPresent(HttpService::stop);
// no need to track PR instances since we won't create any more
// cacheServers or gatewayHubs
- if (this.partitionedRegions != null) {
- if (isDebugEnabled) {
- logger.debug("{}: clearing partitioned regions...", this);
- }
- synchronized (this.partitionedRegions) {
- int prSize = -this.partitionedRegions.size();
- this.partitionedRegions.clear();
- getCachePerfStats().incPartitionedRegions(prSize);
- }
+ if (isDebugEnabled) {
+ logger.debug("{}: clearing partitioned regions...", this);
+ }
+ synchronized (partitionedRegions) {
+ int prSize = -partitionedRegions.size();
+ partitionedRegions.clear();
+ getCachePerfStats().incPartitionedRegions(prSize);
}
prepareDiskStoresForClose();
List<InternalRegion> rootRegionValues;
- synchronized (this.rootRegions) {
- rootRegionValues = new ArrayList<>(this.rootRegions.values());
+ synchronized (rootRegions) {
+ rootRegionValues = new ArrayList<>(rootRegions.values());
}
{
final Operation op;
- if (this.forcedDisconnect) {
+ if (forcedDisconnect) {
op = Operation.FORCED_DISCONNECT;
} else if (isReconnecting()) {
op = Operation.CACHE_RECONNECT;
@@ -2206,10 +2169,9 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
try {
lr.handleCacheClose(op);
} catch (RuntimeException e) {
- if (isDebugEnabled || !this.forcedDisconnect) {
+ if (isDebugEnabled || !forcedDisconnect) {
logger.warn(String.format("%s: error closing region %s",
- new Object[] {this, lr.getFullPath()}),
- e);
+ this, lr.getFullPath()), e);
}
}
}
@@ -2233,14 +2195,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
closeDiskStores();
- this.diskMonitor.close();
+ diskMonitor.close();
// Close the CqService Handle.
try {
if (isDebugEnabled) {
logger.debug("{}: closing CQ service...", this);
}
- this.cqService.close();
+ cqService.close();
} catch (RuntimeException ignore) {
logger.info("Failed to get the CqService, to close during cache close (1).");
}
@@ -2261,13 +2223,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (isDebugEnabled) {
logger.debug("{}: stopping destroyed entries processor...", this);
}
- this.tombstoneService.stop();
+ tombstoneService.stop();
// NOTICE: the CloseCache message is the *last* message you can send!
DistributionManager distributionManager = null;
try {
- distributionManager = this.system.getDistributionManager();
- distributionManager.removeMembershipListener(this.transactionManager);
+ distributionManager = system.getDistributionManager();
+ distributionManager.removeMembershipListener(transactionManager);
} catch (CancelException ignore) {
// distributionManager = null;
}
@@ -2276,8 +2238,9 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (isDebugEnabled) {
logger.debug("{}: sending CloseCache to peers...", this);
}
- Set otherMembers = distributionManager.getOtherDistributionManagerIds();
- ReplyProcessor21 processor = new ReplyProcessor21(this.system, otherMembers);
+ Set<? extends DistributedMember> otherMembers =
+ distributionManager.getOtherDistributionManagerIds();
+ ReplyProcessor21 processor = new ReplyProcessor21(system, otherMembers);
CloseCacheMessage msg = new CloseCacheMessage();
msg.setRecipients(otherMembers);
msg.setProcessorId(processor.getProcessorId());
@@ -2296,7 +2259,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
// NO MORE Distributed Messaging AFTER THIS POINT!!!!
- ClientMetadataService cms = this.clientMetadataService;
+ ClientMetadataService cms = clientMetadataService;
if (cms != null) {
cms.close();
}
@@ -2310,36 +2273,36 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Close the CqService Handle.
try {
- this.cqService.close();
+ cqService.close();
} catch (RuntimeException ignore) {
logger.info("Failed to get the CqService, to close during cache close (2).");
}
- this.cachePerfStats.close();
+ cachePerfStats.close();
TXLockService.destroyServices();
getEventTrackerTask().cancel();
- synchronized (this.ccpTimerMutex) {
- if (this.ccpTimer != null) {
- this.ccpTimer.cancel();
+ synchronized (ccpTimerMutex) {
+ if (ccpTimer != null) {
+ ccpTimer.cancel();
}
}
- this.expirationScheduler.cancel();
+ expirationScheduler.cancel();
// Stop QueryMonitor if running.
- if (this.queryMonitor != null) {
- this.queryMonitor.stopMonitoring();
+ if (queryMonitor != null) {
+ queryMonitor.stopMonitoring();
}
} finally {
// NO DISTRIBUTED MESSAGING CAN BE DONE HERE!
- if (this.transactionManager != null) {
- this.transactionManager.close();
+ if (transactionManager != null) {
+ transactionManager.close();
}
((DynamicRegionFactoryImpl) DynamicRegionFactory.get()).close();
- if (this.transactionManager != null) {
- this.transactionManager.unpauseTransaction(tx);
+ if (transactionManager != null) {
+ transactionManager.unpauseTransaction(tx);
}
TXCommitMessage.getTracker().clearForCacheClose();
}
@@ -2348,8 +2311,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (!keepDS) {
// keepDS is used by ShutdownAll. It will override DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE
- if (!this.DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE) {
- this.system.disconnect();
+ if (!DISABLE_DISCONNECT_DS_ON_CACHE_CLOSE) {
+ system.disconnect();
}
}
TypeRegistry.close();
@@ -2368,7 +2331,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private void stopServices() {
- for (CacheService service : this.services.values()) {
+ for (CacheService service : services.values()) {
try {
service.close();
} catch (Throwable t) {
@@ -2378,14 +2341,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private void closeOffHeapEvictor() {
- OffHeapEvictor evictor = this.offHeapEvictor;
+ OffHeapEvictor evictor = offHeapEvictor;
if (evictor != null) {
evictor.close();
}
}
private void closeHeapEvictor() {
- HeapEvictor evictor = this.heapEvictor;
+ HeapEvictor evictor = heapEvictor;
if (evictor != null) {
evictor.close();
}
@@ -2393,13 +2356,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public boolean isReconnecting() {
- return this.system.isReconnecting();
+ return system.isReconnecting();
}
@Override
public boolean waitUntilReconnected(long time, TimeUnit units) throws InterruptedException {
try {
- boolean systemReconnected = this.system.waitUntilReconnected(time, units);
+ boolean systemReconnected = system.waitUntilReconnected(time, units);
if (!systemReconnected) {
return false;
}
@@ -2412,7 +2375,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void stopReconnecting() {
- this.system.stopReconnecting();
+ system.stopReconnecting();
}
@Override
@@ -2427,7 +2390,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
private void prepareDiskStoresForClose() {
String pdxDSName = TypeRegistry.getPdxDiskStoreName(this);
DiskStoreImpl pdxDiskStore = null;
- for (DiskStoreImpl dsi : this.diskStores.values()) {
+ for (DiskStoreImpl dsi : diskStores.values()) {
if (dsi.getName().equals(pdxDSName)) {
pdxDiskStore = dsi;
} else {
@@ -2446,32 +2409,32 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void addDiskStore(DiskStoreImpl dsi) {
- this.diskStores.put(dsi.getName(), dsi);
+ diskStores.put(dsi.getName(), dsi);
if (!dsi.isOffline()) {
- this.diskMonitor.addDiskStore(dsi);
+ diskMonitor.addDiskStore(dsi);
}
}
@Override
public void removeDiskStore(DiskStoreImpl diskStore) {
- this.diskStores.remove(diskStore.getName());
- this.regionOwnedDiskStores.remove(diskStore.getName());
+ diskStores.remove(diskStore.getName());
+ regionOwnedDiskStores.remove(diskStore.getName());
// Added for M&M
if (!diskStore.getOwnedByRegion())
- this.system.handleResourceEvent(ResourceEvent.DISKSTORE_REMOVE, diskStore);
+ system.handleResourceEvent(ResourceEvent.DISKSTORE_REMOVE, diskStore);
}
@Override
public void addRegionOwnedDiskStore(DiskStoreImpl dsi) {
- this.regionOwnedDiskStores.put(dsi.getName(), dsi);
+ regionOwnedDiskStores.put(dsi.getName(), dsi);
if (!dsi.isOffline()) {
- this.diskMonitor.addDiskStore(dsi);
+ diskMonitor.addDiskStore(dsi);
}
}
@Override
public void closeDiskStores() {
- Iterator<DiskStoreImpl> it = this.diskStores.values().iterator();
+ Iterator<DiskStoreImpl> it = diskStores.values().iterator();
while (it.hasNext()) {
try {
DiskStoreImpl dsi = it.next();
@@ -2480,7 +2443,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
dsi.close();
// Added for M&M
- this.system.handleResourceEvent(ResourceEvent.DISKSTORE_REMOVE, dsi);
+ system.handleResourceEvent(ResourceEvent.DISKSTORE_REMOVE, dsi);
} catch (RuntimeException e) {
logger.fatal("Cache close caught an exception during disk store close", e);
}
@@ -2527,7 +2490,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (name == null) {
name = defaultDiskStoreName;
}
- return this.diskStores.get(name);
+ return diskStores.get(name);
}
/**
@@ -2537,14 +2500,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Collection<DiskStore> listDiskStores() {
- return Collections.unmodifiableCollection(this.diskStores.values());
+ return Collections.unmodifiableCollection(diskStores.values());
}
@Override
public Collection<DiskStore> listDiskStoresIncludingRegionOwned() {
Collection<DiskStore> allDiskStores = new HashSet<>();
- allDiskStores.addAll(this.diskStores.values());
- allDiskStores.addAll(this.regionOwnedDiskStores.values());
+ allDiskStores.addAll(diskStores.values());
+ allDiskStores.addAll(regionOwnedDiskStores.values());
return allDiskStores;
}
@@ -2624,12 +2587,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public DistributedSystem getDistributedSystem() {
- return this.system;
+ return system;
}
@Override
public InternalDistributedSystem getInternalDistributedSystem() {
- return this.system;
+ return system;
}
/**
@@ -2639,24 +2602,24 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public InternalDistributedMember getMyId() {
- return this.system.getDistributedMember();
+ return system.getDistributedMember();
}
@Override
public Set<DistributedMember> getMembers() {
return Collections
- .unmodifiableSet((Set) this.dm.getOtherNormalDistributionManagerIds());
+ .unmodifiableSet(dm.getOtherNormalDistributionManagerIds());
}
@Override
public Set<DistributedMember> getAdminMembers() {
- return (Set) this.dm.getAdminMemberSet();
+ return asDistributedMemberSet(dm.getAdminMemberSet());
}
@SuppressWarnings("unchecked")
private Set<DistributedMember> asDistributedMemberSet(
Set<InternalDistributedMember> internalDistributedMembers) {
- return (Set<DistributedMember>) (Set) internalDistributedMembers;
+ return (Set) internalDistributedMembers;
}
@Override
@@ -2694,32 +2657,32 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public LogWriter getLogger() {
- return this.system.getLogWriter();
+ return system.getLogWriter();
}
@Override
public LogWriter getSecurityLogger() {
- return this.system.getSecurityLogWriter();
+ return system.getSecurityLogWriter();
}
@Override
public LogWriterI18n getLoggerI18n() {
- return this.system.getInternalLogWriter();
+ return system.getInternalLogWriter();
}
@Override
public LogWriterI18n getSecurityLoggerI18n() {
- return this.system.getSecurityInternalLogWriter();
+ return system.getSecurityInternalLogWriter();
}
@Override
public InternalLogWriter getInternalLogWriter() {
- return this.system.getInternalLogWriter();
+ return system.getInternalLogWriter();
}
@Override
public InternalLogWriter getSecurityInternalLogWriter() {
- return this.system.getSecurityInternalLogWriter();
+ return system.getSecurityInternalLogWriter();
}
/**
@@ -2729,17 +2692,17 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public EventTrackerExpiryTask getEventTrackerTask() {
- return this.recordedEventSweeper;
+ return recordedEventSweeper;
}
@Override
public CachePerfStats getCachePerfStats() {
- return this.cachePerfStats;
+ return cachePerfStats;
}
@Override
public String getName() {
- return this.system.getName();
+ return system.getName();
}
/**
@@ -2751,8 +2714,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public List<Properties> getDeclarableProperties(final String className) {
List<Properties> propertiesList = new ArrayList<>();
- synchronized (this.declarablePropertiesMap) {
- for (Entry<Declarable, Properties> entry : this.declarablePropertiesMap.entrySet()) {
+ synchronized (declarablePropertiesMap) {
+ for (Entry<Declarable, Properties> entry : declarablePropertiesMap.entrySet()) {
if (entry.getKey().getClass().getName().equals(className)) {
propertiesList.add(entry.getValue());
}
@@ -2769,7 +2732,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Properties getDeclarableProperties(final Declarable declarable) {
- return this.declarablePropertiesMap.get(declarable);
+ return declarablePropertiesMap.get(declarable);
}
/**
@@ -2779,7 +2742,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public int getUpTime() {
- return (int) (System.currentTimeMillis() - this.creationDate.getTime()) / 1000;
+ return (int) (System.currentTimeMillis() - creationDate.getTime()) / 1000;
}
/**
@@ -2791,8 +2754,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public long cacheTimeMillis() {
- if (this.system != null) {
- return this.system.getClock().cacheTimeMillis();
+ if (system != null) {
+ return system.getClock().cacheTimeMillis();
} else {
return System.currentTimeMillis();
}
@@ -2848,7 +2811,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (!isClient()) {
throw new UnsupportedOperationException();
}
- PoolFactory defaultPoolFactory = this.poolFactory;
+ PoolFactory defaultPoolFactory = poolFactory;
Pool pool = null;
// create the pool if it does not already exist
@@ -2863,7 +2826,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
pool = findFirstCompatiblePool(pools);
if (pool == null) {
// if pool is still null then we will not have a default pool for this ClientCache
- this.defaultPool = null;
+ defaultPool = null;
return;
}
}
@@ -2893,7 +2856,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
pool = defaultPoolFactory.create(poolName);
}
- this.defaultPool = pool;
+ defaultPool = pool;
}
/**
@@ -2935,7 +2898,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
- // TODO: createVMRegion method is too complex for IDE to analyze
+ @SuppressWarnings("unchecked")
+ private static <K, V> Region<K, V> uncheckedRegion(Region region) {
+ return region;
+ }
+
@Override
public <K, V> Region<K, V> createVMRegion(String name, RegionAttributes<K, V> p_attrs,
InternalRegionArguments internalRegionArgs)
@@ -2947,7 +2914,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
throw new IllegalStateException("Regions can not be created in a locator.");
}
}
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
RegionNameValidation.validate(name, internalRegionArgs);
RegionAttributes<K, V> attrs = p_attrs;
attrs = invokeRegionBefore(null, name, attrs, internalRegionArgs);
@@ -2969,8 +2936,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
getCancelCriterion().checkCancelInProgress(null);
Future<InternalRegion> future = null;
- synchronized (this.rootRegions) {
- region = this.rootRegions.get(name);
+ synchronized (rootRegions) {
+ region = rootRegions.get(name);
if (region != null) {
throw new RegionExistsException(region);
}
@@ -2980,7 +2947,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (!isReInitCreate) { // fix bug 33523
String fullPath = Region.SEPARATOR + name;
- future = (Future) this.reinitializingRegions.get(fullPath);
+ future = reinitializingRegions.get(fullPath);
}
if (future == null) {
if (internalRegionArgs.getInternalMetaRegion() != null) {
@@ -3000,7 +2967,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
- this.rootRegions.put(name, region);
+ rootRegions.put(name, region);
if (isReInitCreate) {
regionReinitialized(region);
}
@@ -3052,7 +3019,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
throw e;
} catch (Throwable t) {
SystemFailure.checkFailure();
- this.stopper.checkCancelInProgress(t);
+ stopper.checkCancelInProgress(t);
// bug #44672 - log the failure but don't override the original exception
logger.warn(String.format("Initialization failed for Region %s",
@@ -3062,10 +3029,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
} finally {
// clean up if initialize fails for any reason
setRegionByPath(region.getFullPath(), null);
- synchronized (this.rootRegions) {
- Region rootRegion = this.rootRegions.get(name);
+ synchronized (rootRegions) {
+ Region rootRegion = rootRegions.get(name);
if (rootRegion == region) {
- this.rootRegions.remove(name);
+ rootRegions.remove(name);
}
} // synchronized
}
@@ -3084,44 +3051,50 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Added for M&M . Putting the callback here to avoid creating RegionMBean in case of Exception
if (!region.isInternalRegion()) {
- this.system.handleResourceEvent(ResourceEvent.REGION_CREATE, region);
+ system.handleResourceEvent(ResourceEvent.REGION_CREATE, region);
}
+ return uncheckedRegion(region);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <K, V> RegionAttributes<K, V> uncheckedRegionAttributes(RegionAttributes region) {
return region;
}
@Override
public <K, V> RegionAttributes<K, V> invokeRegionBefore(InternalRegion parent, String name,
RegionAttributes<K, V> attrs, InternalRegionArguments internalRegionArgs) {
- for (RegionListener listener : this.regionListeners) {
+ for (RegionListener listener : regionListeners) {
attrs =
- (RegionAttributes<K, V>) listener.beforeCreate(parent, name, attrs, internalRegionArgs);
+ uncheckedRegionAttributes(listener.beforeCreate(parent, name, attrs, internalRegionArgs));
}
return attrs;
}
@Override
public void invokeRegionAfter(InternalRegion region) {
- for (RegionListener listener : this.regionListeners) {
+ for (RegionListener listener : regionListeners) {
listener.afterCreate(region);
}
}
@Override
public void invokeBeforeDestroyed(InternalRegion region) {
- for (RegionListener listener : this.regionListeners) {
+ for (RegionListener listener : regionListeners) {
listener.beforeDestroyed(region);
}
}
@Override
public void invokeCleanupFailedInitialization(InternalRegion region) {
- for (RegionListener listener : this.regionListeners) {
+ for (RegionListener listener : regionListeners) {
listener.cleanupFailedInitialization(region);
}
}
@Override
+ @SuppressWarnings("unchecked")
public Region getRegion(String path) {
return getRegion(path, false);
}
@@ -3134,8 +3107,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Set<InternalRegion> getAllRegions() {
Set<InternalRegion> result = new HashSet<>();
- synchronized (this.rootRegions) {
- for (Region region : this.rootRegions.values()) {
+ synchronized (rootRegions) {
+ for (Region region : rootRegions.values()) {
if (region instanceof PartitionedRegion) {
PartitionedRegion partitionedRegion = (PartitionedRegion) region;
PartitionedRegionDataStore dataStore = partitionedRegion.getDataStore();
@@ -3159,8 +3132,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Set<InternalRegion> getApplicationRegions() {
Set<InternalRegion> result = new HashSet<>();
- synchronized (this.rootRegions) {
- for (Object region : this.rootRegions.values()) {
+ synchronized (rootRegions) {
+ for (Object region : rootRegions.values()) {
InternalRegion internalRegion = (InternalRegion) region;
if (internalRegion.isInternalRegion()) {
continue; // Skip internal regions
@@ -3172,15 +3145,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
return result;
}
- @SuppressWarnings("unchecked")
@Override
public boolean hasPersistentRegion() {
- synchronized (this.rootRegions) {
- for (InternalRegion region : this.rootRegions.values()) {
+ synchronized (rootRegions) {
+ for (InternalRegion region : rootRegions.values()) {
if (region.getDataPolicy().withPersistence()) {
return true;
}
- for (InternalRegion subRegion : (Set<InternalRegion>) region.basicSubregions(true)) {
+ for (InternalRegion subRegion : region.basicSubregions(true)) {
if (subRegion.getDataPolicy().withPersistence()) {
return true;
}
@@ -3193,9 +3165,9 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void setRegionByPath(String path, InternalRegion r) {
if (r == null) {
- this.pathToRegion.remove(path);
+ pathToRegion.remove(path);
} else {
- this.pathToRegion.put(path, r);
+ pathToRegion.put(path, r);
}
}
@@ -3226,21 +3198,21 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (result != null) {
return result;
}
- return this.pathToRegion.get(path);
+ return pathToRegion.get(path);
}
@Override
public InternalRegion getRegionByPathForProcessing(String path) {
InternalRegion result = getRegionByPath(path);
if (result == null) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT); // go through
// initialization latches
try {
String[] pathParts = parsePath(path);
InternalRegion rootRegion;
- synchronized (this.rootRegions) {
- rootRegion = this.rootRegions.get(pathParts[0]);
+ synchronized (rootRegions) {
+ rootRegion = rootRegions.get(pathParts[0]);
if (rootRegion == null)
return null;
}
@@ -3261,14 +3233,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Region getRegion(String path, boolean returnDestroyedRegion) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
InternalRegion result = getRegionByPath(path);
// Do not waitOnInitialization() for PR
if (result != null) {
result.waitOnInitialization();
if (!returnDestroyedRegion && result.isDestroyed()) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
return null;
} else {
return result;
@@ -3277,17 +3249,17 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
String[] pathParts = parsePath(path);
InternalRegion rootRegion;
- synchronized (this.rootRegions) {
- rootRegion = this.rootRegions.get(pathParts[0]);
+ synchronized (rootRegions) {
+ rootRegion = rootRegions.get(pathParts[0]);
if (rootRegion == null) {
if (logger.isDebugEnabled()) {
logger.debug("GemFireCache.getRegion, no region found for {}", pathParts[0]);
}
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
return null;
}
if (!returnDestroyedRegion && rootRegion.isDestroyed()) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
return null;
}
}
@@ -3301,7 +3273,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
/** Return true if this region is initializing */
@Override
public boolean isGlobalRegionInitializing(String fullPath) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.ANY_INIT); // go through
// initialization latches
try {
@@ -3333,10 +3305,10 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private Set<Region<?, ?>> rootRegions(boolean includePRAdminRegions, boolean waitForInit) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
Set<Region<?, ?>> regions = new HashSet<>();
- synchronized (this.rootRegions) {
- for (InternalRegion region : this.rootRegions.values()) {
+ synchronized (rootRegions) {
+ for (InternalRegion region : rootRegions.values()) {
// If this is an internal meta-region, don't return it to end user
if (region.isSecret() || region.isUsedForMetaRegion()
|| !includePRAdminRegions && (region.isUsedForPartitionedRegionAdmin()
@@ -3377,48 +3349,48 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private boolean isInitialized() {
- return this.isInitialized;
+ return isInitialized;
}
@Override
public boolean isClosed() {
- return this.isClosing;
+ return isClosing;
}
@Override
public int getLockTimeout() {
- return this.lockTimeout;
+ return lockTimeout;
}
@Override
public void setLockTimeout(int seconds) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
- this.lockTimeout = seconds;
+ stopper.checkCancelInProgress(null);
+ lockTimeout = seconds;
}
@Override
public int getLockLease() {
- return this.lockLease;
+ return lockLease;
}
@Override
public void setLockLease(int seconds) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
- this.lockLease = seconds;
+ stopper.checkCancelInProgress(null);
+ lockLease = seconds;
}
@Override
public int getSearchTimeout() {
- return this.searchTimeout;
+ return searchTimeout;
}
@Override
public void setSearchTimeout(int seconds) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
- this.searchTimeout = seconds;
+ stopper.checkCancelInProgress(null);
+ searchTimeout = seconds;
}
@Override
@@ -3429,7 +3401,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void setMessageSyncInterval(int seconds) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
if (seconds < 0) {
throw new IllegalArgumentException(
"The 'messageSyncInterval' property for cache cannot be negative");
@@ -3444,12 +3416,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public InternalRegion getReinitializingRegion(String fullPath) {
- Future future = (Future) this.reinitializingRegions.get(fullPath);
+ Future<InternalRegion> future = reinitializingRegions.get(fullPath);
if (future == null) {
return null;
}
try {
- InternalRegion region = (InternalRegion) future.get();
+ InternalRegion region = future.get();
region.waitOnInitialization();
if (logger.isDebugEnabled()) {
logger.debug("Returning manifested future for: {}", fullPath);
@@ -3475,7 +3447,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void regionReinitializing(String fullPath) {
- Object old = this.reinitializingRegions.putIfAbsent(fullPath, new FutureResult(this.stopper));
+ Object old = reinitializingRegions.putIfAbsent(fullPath, new FutureResult<>(stopper));
if (old != null) {
throw new IllegalStateException(
String.format("Found an existing reinitalizing region named %s",
@@ -3491,13 +3463,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void regionReinitialized(Region region) {
String regionName = region.getFullPath();
- FutureResult future = (FutureResult) this.reinitializingRegions.get(regionName);
+ FutureResult<InternalRegion> future = reinitializingRegions.get(regionName);
if (future == null) {
throw new IllegalStateException(
String.format("Could not find a reinitializing region named %s",
regionName));
}
- future.set(region);
+ future.set((InternalRegion) region);
unregisterReinitializingRegion(regionName);
}
@@ -3508,7 +3480,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void unregisterReinitializingRegion(String fullPath) {
- this.reinitializingRegions.remove(fullPath);
+ reinitializingRegions.remove(fullPath);
}
/**
@@ -3518,7 +3490,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean isCopyOnRead() {
- return this.copyOnRead;
+ return copyOnRead;
}
/**
@@ -3538,7 +3510,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean getCopyOnRead() {
- return this.copyOnRead;
+ return copyOnRead;
}
/**
@@ -3549,11 +3521,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean removeRoot(InternalRegion rootRgn) {
- synchronized (this.rootRegions) {
+ synchronized (rootRegions) {
String regionName = rootRgn.getName();
- InternalRegion found = this.rootRegions.get(regionName);
+ InternalRegion found = rootRegions.get(regionName);
if (found == rootRgn) {
- InternalRegion previous = this.rootRegions.remove(regionName);
+ InternalRegion previous = rootRegions.remove(regionName);
Assert.assertTrue(previous == rootRgn);
return true;
} else
@@ -3605,27 +3577,27 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void addRegionListener(RegionListener regionListener) {
- this.regionListeners.add(regionListener);
+ regionListeners.add(regionListener);
}
@Override
public void removeRegionListener(RegionListener regionListener) {
- this.regionListeners.remove(regionListener);
+ regionListeners.remove(regionListener);
}
@Override
public Set<RegionListener> getRegionListeners() {
- return Collections.unmodifiableSet(this.regionListeners);
+ return Collections.unmodifiableSet(regionListeners);
}
@Override
public <T extends CacheService> T getService(Class<T> clazz) {
- return clazz.cast(this.services.get(clazz));
+ return clazz.cast(services.get(clazz));
}
@Override
public Collection<CacheService> getServices() {
- return Collections.unmodifiableCollection(this.services.values());
+ return Collections.unmodifiableCollection(services.values());
}
/**
@@ -3638,7 +3610,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public CacheTransactionManager getCacheTransactionManager() {
- return this.transactionManager;
+ return transactionManager;
}
/**
@@ -3660,15 +3632,15 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public SystemTimer getCCPTimer() {
- synchronized (this.ccpTimerMutex) {
- if (this.ccpTimer != null) {
- return this.ccpTimer;
+ synchronized (ccpTimerMutex) {
+ if (ccpTimer != null) {
+ return ccpTimer;
}
- this.ccpTimer = new SystemTimer(getDistributedSystem(), true);
- if (this.isClosing) {
- this.ccpTimer.cancel(); // poison it, don't throw.
+ ccpTimer = new SystemTimer(getDistributedSystem(), true);
+ if (isClosing) {
+ ccpTimer.cancel(); // poison it, don't throw.
}
- return this.ccpTimer;
+ return ccpTimer;
}
}
@@ -3689,12 +3661,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void purgeCCPTimer() {
- synchronized (this.ccpTimerMutex) {
- if (this.ccpTimer != null) {
- this.cancelCount++;
- if (this.cancelCount == PURGE_INTERVAL) {
- this.cancelCount = 0;
- this.ccpTimer.timerPurge();
+ synchronized (ccpTimerMutex) {
+ if (ccpTimer != null) {
+ cancelCount++;
+ if (cancelCount == PURGE_INTERVAL) {
+ cancelCount = 0;
+ ccpTimer.timerPurge();
}
}
}
@@ -3709,12 +3681,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public ExpirationScheduler getExpirationScheduler() {
- return this.expirationScheduler;
+ return expirationScheduler;
}
@Override
public TXManagerImpl getTXMgr() {
- return this.transactionManager;
+ return transactionManager;
}
/**
@@ -3725,7 +3697,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Executor getEventThreadPool() {
- return this.eventThreadPool;
+ return eventThreadPool;
}
@Override
@@ -3751,17 +3723,17 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
public void addGatewaySender(GatewaySender sender) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
- synchronized (this.allGatewaySendersLock) {
- if (!this.allGatewaySenders.contains(sender)) {
+ synchronized (allGatewaySendersLock) {
+ if (!allGatewaySenders.contains(sender)) {
new UpdateAttributesProcessor((DistributionAdvisee) sender).distribute(true);
- Set<GatewaySender> newSenders = new HashSet<>(this.allGatewaySenders.size() + 1);
- if (!this.allGatewaySenders.isEmpty()) {
- newSenders.addAll(this.allGatewaySenders);
+ Set<GatewaySender> newSenders = new HashSet<>(allGatewaySenders.size() + 1);
+ if (!allGatewaySenders.isEmpty()) {
+ newSenders.addAll(allGatewaySenders);
}
newSenders.add(sender);
- this.allGatewaySenders = Collections.unmodifiableSet(newSenders);
+ allGatewaySenders = Collections.unmodifiableSet(newSenders);
} else {
throw new IllegalStateException(
String.format("A GatewaySender with id %s is already defined in this cache.",
@@ -3769,7 +3741,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
- synchronized (this.rootRegions) {
+ synchronized (rootRegions) {
Set<InternalRegion> applicationRegions = getApplicationRegions();
for (InternalRegion region : applicationRegions) {
Set<String> senders = region.getAllGatewaySenderIds();
@@ -3790,7 +3762,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
if (!(sender.getRemoteDSId() < 0)) {
- this.system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_CREATE, sender);
+ system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_CREATE, sender);
}
}
@@ -3798,21 +3770,21 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
public void removeGatewaySender(GatewaySender sender) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
- synchronized (this.allGatewaySendersLock) {
- if (this.allGatewaySenders.contains(sender)) {
+ synchronized (allGatewaySendersLock) {
+ if (allGatewaySenders.contains(sender)) {
new UpdateAttributesProcessor((DistributionAdvisee) sender, true).distribute(true);
- Set<GatewaySender> newSenders = new HashSet<>(this.allGatewaySenders.size() - 1);
- if (!this.allGatewaySenders.isEmpty()) {
- newSenders.addAll(this.allGatewaySenders);
+ Set<GatewaySender> newSenders = new HashSet<>(allGatewaySenders.size() - 1);
+ if (!allGatewaySenders.isEmpty()) {
+ newSenders.addAll(allGatewaySenders);
}
newSenders.remove(sender);
- this.allGatewaySenders = Collections.unmodifiableSet(newSenders);
+ allGatewaySenders = Collections.unmodifiableSet(newSenders);
}
}
if (!(sender.getRemoteDSId() < 0)) {
- this.system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_REMOVE, sender);
+ system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_REMOVE, sender);
}
}
@@ -3857,11 +3829,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void addAsyncEventQueue(AsyncEventQueueImpl asyncQueue) {
- this.allAsyncEventQueues.add(asyncQueue);
+ allAsyncEventQueues.add(asyncQueue);
if (!asyncQueue.isMetaQueue()) {
- this.allVisibleAsyncEventQueues.add(asyncQueue);
+ allVisibleAsyncEventQueues.add(asyncQueue);
}
- this.system.handleResourceEvent(ResourceEvent.ASYNCEVENTQUEUE_CREATE, asyncQueue);
+ system.handleResourceEvent(ResourceEvent.ASYNCEVENTQUEUE_CREATE, asyncQueue);
}
/**
@@ -3872,7 +3844,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Set<GatewaySender> getGatewaySenders() {
Set<GatewaySender> senders = new HashSet<>();
- for (GatewaySender sender : this.allGatewaySenders) {
+ for (GatewaySender sender : allGatewaySenders) {
if (!((AbstractGatewaySender) sender).isForInternalUse()) {
senders.add(sender);
}
@@ -3887,12 +3859,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Set<GatewaySender> getAllGatewaySenders() {
- return this.allGatewaySenders;
+ return allGatewaySenders;
}
@Override
public GatewaySender getGatewaySender(String id) {
- for (GatewaySender sender : this.allGatewaySenders) {
+ for (GatewaySender sender : allGatewaySenders) {
if (sender.getId().equals(id)) {
return sender;
}
@@ -3916,12 +3888,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Set<AsyncEventQueue> getAsyncEventQueues(boolean visibleOnly) {
- return visibleOnly ? this.allVisibleAsyncEventQueues : this.allAsyncEventQueues;
+ return visibleOnly ? allVisibleAsyncEventQueues : allAsyncEventQueues;
}
@Override
public AsyncEventQueue getAsyncEventQueue(String id) {
- for (AsyncEventQueue asyncEventQueue : this.allAsyncEventQueues) {
+ for (AsyncEventQueue asyncEventQueue : allAsyncEventQueues) {
if (asyncEventQueue.getId().equals(id)) {
return asyncEventQueue;
}
@@ -3937,32 +3909,32 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
removeGatewaySender(((AsyncEventQueueImpl) asyncQueue).getSender());
}
// using gateway senders lock since async queue uses a gateway sender
- synchronized (this.allGatewaySendersLock) {
- this.allAsyncEventQueues.remove(asyncQueue);
- this.allVisibleAsyncEventQueues.remove(asyncQueue);
+ synchronized (allGatewaySendersLock) {
+ allAsyncEventQueues.remove(asyncQueue);
+ allVisibleAsyncEventQueues.remove(asyncQueue);
}
- this.system.handleResourceEvent(ResourceEvent.ASYNCEVENTQUEUE_REMOVE, asyncQueue);
+ system.handleResourceEvent(ResourceEvent.ASYNCEVENTQUEUE_REMOVE, asyncQueue);
}
/** get the conflict resolver for WAN */
@Override
public GatewayConflictResolver getGatewayConflictResolver() {
- synchronized (this.allGatewayHubsLock) {
- return this.gatewayConflictResolver;
+ synchronized (allGatewayHubsLock) {
+ return gatewayConflictResolver;
}
}
/** set the conflict resolver for WAN */
@Override
public void setGatewayConflictResolver(GatewayConflictResolver resolver) {
- synchronized (this.allGatewayHubsLock) {
- this.gatewayConflictResolver = resolver;
+ synchronized (allGatewayHubsLock) {
+ gatewayConflictResolver = resolver;
}
}
@Override
public List<CacheServer> getCacheServers() {
- return this.unmodifiableAllCacheServers;
+ return unmodifiableAllCacheServers;
}
@Override
@@ -3983,14 +3955,14 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void addPartitionedRegion(PartitionedRegion region) {
- synchronized (this.partitionedRegions) {
+ synchronized (partitionedRegions) {
if (region.isDestroyed()) {
if (logger.isDebugEnabled()) {
logger.debug("GemFireCache#addPartitionedRegion did not add destroyed {}", region);
}
return;
}
- if (this.partitionedRegions.add(region)) {
+ if (partitionedRegions.add(region)) {
getCachePerfStats().incPartitionedRegions(1);
}
}
@@ -4001,8 +3973,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public Set<PartitionedRegion> getPartitionedRegions() {
- synchronized (this.partitionedRegions) {
- return new HashSet<>(this.partitionedRegions);
+ synchronized (partitionedRegions) {
+ return new HashSet<>(partitionedRegions);
}
}
@@ -4025,11 +3997,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
} else {
for (PartitionedRegion pr : prMap.values()) {
String rootName = pr.getRoot().getName();
- Map<String, PartitionedRegion> prSubMap = prTrees.get(rootName);
- if (prSubMap == null) {
- prSubMap = new TreeMap<>();
- prTrees.put(rootName, prSubMap);
- }
+ Map<String, PartitionedRegion> prSubMap =
+ prTrees.computeIfAbsent(rootName, k -> new TreeMap<>());
prSubMap.put(pr.getFullPath(), pr);
}
}
@@ -4039,7 +4008,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
private SortedMap<String, PartitionedRegion> getPartitionedRegionMap() {
SortedMap<String, PartitionedRegion> prMap = new TreeMap<>();
- for (Entry<String, InternalRegion> entry : this.pathToRegion.entrySet()) {
+ for (Entry<String, InternalRegion> entry : pathToRegion.entrySet()) {
String regionName = entry.getKey();
InternalRegion region = entry.getValue();
@@ -4114,7 +4083,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
boolean hasSenders = false;
Set<String> senders = region.getAllGatewaySenderIds();
for (String sender : senders) {
- GatewaySender gatewaySender = this.getGatewaySender(sender);
+ GatewaySender gatewaySender = getGatewaySender(sender);
if (gatewaySender != null && !gatewaySender.isParallel()) {
hasSenders = true;
break;
@@ -4130,8 +4099,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void removePartitionedRegion(PartitionedRegion region) {
- synchronized (this.partitionedRegions) {
- if (this.partitionedRegions.remove(region)) {
+ synchronized (partitionedRegions) {
+ if (partitionedRegions.remove(region)) {
getCachePerfStats().incPartitionedRegions(-1);
}
}
@@ -4140,7 +4109,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void setIsServer(boolean isServer) {
throwIfClient();
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
this.isServer = isServer;
}
@@ -4209,23 +4178,29 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
return null;
}
+ @SuppressWarnings("unchecked")
+ private static <K, V> Map<String, RegionAttributes<K, V>> uncheckedCast(
+ Map<String, RegionAttributes<?, ?>> namedRegionAttributes) {
+ return (Map) namedRegionAttributes;
+ }
+
@Override
public <K, V> RegionAttributes<K, V> getRegionAttributes(String id) {
- return (RegionAttributes<K, V>) this.namedRegionAttributes.get(id);
+ return GemFireCacheImpl.<K, V>uncheckedCast(namedRegionAttributes).get(id);
}
@Override
public <K, V> void setRegionAttributes(String id, RegionAttributes<K, V> attrs) {
if (attrs == null) {
- this.namedRegionAttributes.remove(id);
+ namedRegionAttributes.remove(id);
} else {
- this.namedRegionAttributes.put(id, attrs);
+ namedRegionAttributes.put(id, attrs);
}
}
@Override
- public Map<String, RegionAttributes<?, ?>> listRegionAttributes() {
- return Collections.unmodifiableMap(this.namedRegionAttributes);
+ public <K, V> Map<String, RegionAttributes<K, V>> listRegionAttributes() {
+ return Collections.unmodifiableMap(uncheckedCast(namedRegionAttributes));
}
private static final ThreadLocal<GemFireCacheImpl> xmlCache = new ThreadLocal<>();
@@ -4246,7 +4221,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
if (XML_PARAMETERIZATION_ENABLED) {
char[] buffer = new char[1024];
- reader = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
+ reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.ISO_8859_1));
stringWriter = new StringWriter();
int numChars;
@@ -4257,13 +4232,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
/*
* Now replace all replaceable system properties here using {@code PropertyResolver}
*/
- String replacedXmlString = this.resolver.processUnresolvableString(stringWriter.toString());
+ String replacedXmlString = resolver.processUnresolvableString(stringWriter.toString());
/*
* Turn the string back into the default encoding so that the XML parser can work correctly
* in the presence of an "encoding" attribute in the XML prolog.
*/
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- writer = new OutputStreamWriter(baos, "ISO-8859-1");
+ writer = new OutputStreamWriter(baos, StandardCharsets.ISO_8859_1);
writer.write(replacedXmlString);
writer.flush();
@@ -4306,7 +4281,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
}
- PoolManagerImpl.readyForEvents(this.system, false);
+ PoolManagerImpl.readyForEvents(system, false);
}
private List<File> backupFiles = Collections.emptyList();
@@ -4324,19 +4299,19 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public InternalResourceManager getInternalResourceManager(boolean checkCancellationInProgress) {
if (checkCancellationInProgress) {
- this.stopper.checkCancelInProgress(null);
+ stopper.checkCancelInProgress(null);
}
- return this.resourceManager;
+ return resourceManager;
}
@Override
public void setBackupFiles(List<File> backups) {
- this.backupFiles = backups;
+ backupFiles = backups;
}
@Override
public List<File> getBackupFiles() {
- return Collections.unmodifiableList(this.backupFiles);
+ return Collections.unmodifiableList(backupFiles);
}
@Override
@@ -4358,25 +4333,25 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void registerInterestCompleted() {
// Don't do a cancellation check, it's just a moot point, that's all
- if (GemFireCacheImpl.this.isClosing) {
+ if (isClosing) {
return; // just get out, all of the SimpleWaiters will die of their own accord
}
- int numInProgress = this.registerInterestsInProgress.decrementAndGet();
+ int numInProgress = registerInterestsInProgress.decrementAndGet();
if (logger.isDebugEnabled()) {
logger.debug("registerInterestCompleted: new value = {}", numInProgress);
}
if (numInProgress == 0) {
- synchronized (this.riWaiters) {
+ synchronized (riWaiters) {
// TODO: get rid of double-check
- numInProgress = this.registerInterestsInProgress.get();
+ numInProgress = registerInterestsInProgress.get();
if (numInProgress == 0) { // all clear
if (logger.isDebugEnabled()) {
logger.debug("registerInterestCompleted: Signalling end of register-interest");
}
- for (SimpleWaiter sw : this.riWaiters) {
+ for (SimpleWaiter sw : riWaiters) {
sw.doNotify();
}
- this.riWaiters.clear();
+ riWaiters.clear();
} // all clear
} // synchronized
}
@@ -4385,7 +4360,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void registerInterestStarted() {
// Don't do a cancellation check, it's just a moot point, that's all
- int newVal = this.registerInterestsInProgress.incrementAndGet();
+ int newVal = registerInterestsInProgress.incrementAndGet();
if (logger.isDebugEnabled()) {
logger.debug("registerInterestsStarted: new count = {}", newVal);
}
@@ -4401,18 +4376,18 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// well, so this is just an early out.
getCancelCriterion().checkCancelInProgress(null);
- int count = this.registerInterestsInProgress.get();
+ int count = registerInterestsInProgress.get();
if (count > 0) {
SimpleWaiter simpleWaiter = null;
- synchronized (this.riWaiters) {
+ synchronized (riWaiters) {
// TODO double-check
- count = this.registerInterestsInProgress.get();
+ count = registerInterestsInProgress.get();
if (count > 0) {
if (logger.isDebugEnabled()) {
logger.debug("waitForRegisterInterestsInProgress: count ={}", count);
}
simpleWaiter = new SimpleWaiter();
- this.riWaiters.add(simpleWaiter);
+ riWaiters.add(simpleWaiter);
}
} // synchronized
if (simpleWaiter != null) {
@@ -4429,7 +4404,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public boolean isQueryMonitorDisabledForLowMemory() {
- return this.queryMonitorDisabledForLowMem;
+ return queryMonitorDisabledForLowMem;
}
/**
@@ -4442,7 +4417,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Check to see if monitor is required if ResourceManager critical heap percentage is set
// or whether we override it with the system variable;
boolean monitorRequired =
- !this.queryMonitorDisabledForLowMem && queryMonitorRequiredForResourceManager;
+ !queryMonitorDisabledForLowMem && queryMonitorRequiredForResourceManager;
// Added for DUnit test purpose, which turns-on and off the this.testMaxQueryExecutionTime.
if (!(MAX_QUERY_EXECUTION_TIME > 0 || monitorRequired)) {
// if this.testMaxQueryExecutionTime is set, send the QueryMonitor.
@@ -4452,10 +4427,9 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Return the QueryMonitor service if MAX_QUERY_EXECUTION_TIME is set or it is required by the
// ResourceManager and not overridden by system property.
- boolean needQueryMonitor = MAX_QUERY_EXECUTION_TIME > 0 || monitorRequired;
- if (needQueryMonitor && this.queryMonitor == null) {
- synchronized (this.queryMonitorLock) {
- if (this.queryMonitor == null) {
+ if (queryMonitor == null) {
+ synchronized (queryMonitorLock) {
+ if (queryMonitor == null) {
int maxTime = MAX_QUERY_EXECUTION_TIME;
if (monitorRequired && maxTime < 0) {
@@ -4465,7 +4439,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
maxTime = FIVE_HOURS;
}
- this.queryMonitor =
+ queryMonitor =
new QueryMonitor((ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(
QUERY_MONITOR_THREAD_POOL_SIZE,
(runnable) -> new LoggingThread("QueryMonitor Thread", runnable)),
@@ -4477,7 +4451,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
}
- return this.queryMonitor;
+ return queryMonitor;
}
/**
@@ -4493,7 +4467,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
void doWait() {
synchronized (this) {
- while (!this.notified) {
+ while (!notified) {
getCancelCriterion().checkCancelInProgress(null);
boolean interrupted = Thread.interrupted();
try {
@@ -4511,24 +4485,24 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
void doNotify() {
synchronized (this) {
- this.notified = true;
+ notified = true;
notifyAll();
}
}
}
private void sendAddCacheServerProfileMessage() {
- Set otherMembers = this.dm.getOtherDistributionManagerIds();
+ Set<InternalDistributedMember> otherMembers = dm.getOtherDistributionManagerIds();
AddCacheServerProfileMessage message = new AddCacheServerProfileMessage();
message.operateOnLocalCache(this);
if (!otherMembers.isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug("Sending add cache server profile message to other members.");
}
- ReplyProcessor21 replyProcessor = new ReplyProcessor21(this.dm, otherMembers);
+ ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, otherMembers);
message.setRecipients(otherMembers);
message.processorId = replyProcessor.getProcessorId();
- this.dm.putOutgoing(message);
+ dm.putOutgoing(message);
// Wait for replies.
try {
@@ -4541,29 +4515,23 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
private void sendRemoveCacheServerProfileMessage() {
- Set otherMembers = this.dm.getOtherDistributionManagerIds();
+ Set<InternalDistributedMember> otherMembers = dm.getOtherDistributionManagerIds();
RemoveCacheServerProfileMessage message = new RemoveCacheServerProfileMessage();
message.operateOnLocalCache(this);
// Remove this while loop when we release GEODE 2.0
// This block prevents sending a message to old members that do not know about
// the RemoveCacheServerProfileMessage
- Iterator memberIterator = otherMembers.iterator();
- while (memberIterator.hasNext()) {
- InternalDistributedMember member = (InternalDistributedMember) memberIterator.next();
- if (Version.GEODE_1_5_0.compareTo(member.getVersionObject()) > 0) {
- memberIterator.remove();
- }
- }
+ otherMembers.removeIf(member -> Version.GEODE_1_5_0.compareTo(member.getVersionObject()) > 0);
if (!otherMembers.isEmpty()) {
if (logger.isDebugEnabled()) {
logger.debug("Sending remove cache server profile message to other members.");
}
- ReplyProcessor21 replyProcessor = new ReplyProcessor21(this.dm, otherMembers);
+ ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, otherMembers);
message.setRecipients(otherMembers);
message.processorId = replyProcessor.getProcessorId();
- this.dm.putOutgoing(message);
+ dm.putOutgoing(message);
// Wait for replies.
try {
@@ -4576,7 +4544,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public TXManagerImpl getTxManager() {
- return this.transactionManager;
+ return transactionManager;
}
/**
@@ -4963,52 +4931,52 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void beginDestroy(String path, DistributedRegion region) {
- this.regionsInDestroy.putIfAbsent(path, region);
+ regionsInDestroy.putIfAbsent(path, region);
}
@Override
public void endDestroy(String path, DistributedRegion region) {
- this.regionsInDestroy.remove(path, region);
+ regionsInDestroy.remove(path, region);
}
@Override
public DistributedRegion getRegionInDestroy(String path) {
- return this.regionsInDestroy.get(path);
+ return regionsInDestroy.get(path);
}
@Override
public TombstoneService getTombstoneService() {
- return this.tombstoneService;
+ return tombstoneService;
}
@Override
public TypeRegistry getPdxRegistry() {
- return this.pdxRegistry;
+ return pdxRegistry;
}
@Override
public boolean getPdxReadSerialized() {
- return this.cacheConfig.pdxReadSerialized;
+ return cacheConfig.pdxReadSerialized;
}
@Override
public PdxSerializer getPdxSerializer() {
- return this.cacheConfig.pdxSerializer;
+ return cacheConfig.pdxSerializer;
}
@Override
public String getPdxDiskStore() {
- return this.cacheConfig.pdxDiskStore;
+ return cacheConfig.pdxDiskStore;
}
@Override
public boolean getPdxPersistent() {
- return this.cacheConfig.pdxPersistent;
+ return cacheConfig.pdxPersistent;
}
@Override
public boolean getPdxIgnoreUnreadFields() {
- return this.cacheConfig.pdxIgnoreUnreadFields;
+ return cacheConfig.pdxIgnoreUnreadFields;
}
/**
@@ -5017,7 +4985,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public boolean getPdxReadSerializedByAnyGemFireServices() {
- TypeRegistry pdxRegistry = this.getPdxRegistry();
+ TypeRegistry pdxRegistry = getPdxRegistry();
boolean pdxReadSerializedOverriden = false;
if (pdxRegistry != null) {
pdxReadSerializedOverriden = pdxRegistry.getPdxReadSerializedOverride();
@@ -5029,12 +4997,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public CacheConfig getCacheConfig() {
- return this.cacheConfig;
+ return cacheConfig;
}
@Override
public DistributionManager getDistributionManager() {
- return this.dm;
+ return dm;
}
@Override
@@ -5059,12 +5027,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public ResourceAdvisor getResourceAdvisor() {
- return this.resourceAdvisor;
+ return resourceAdvisor;
}
@Override
public Profile getProfile() {
- return this.resourceAdvisor.createProfile();
+ return resourceAdvisor.createProfile();
}
@Override
@@ -5074,7 +5042,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public InternalDistributedSystem getSystem() {
- return this.system;
+ return system;
}
@Override
@@ -5084,22 +5052,22 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void fillInProfile(Profile profile) {
- this.resourceManager.fillInProfile(profile);
+ resourceManager.fillInProfile(profile);
}
@Override
public int getSerialNumber() {
- return this.serialNumber;
+ return serialNumber;
}
@Override
public TXEntryStateFactory getTXEntryStateFactory() {
- return this.txEntryStateFactory;
+ return txEntryStateFactory;
}
// test hook
public void setPdxSerializer(PdxSerializer serializer) {
- this.cacheConfig.setPdxSerializer(serializer);
+ cacheConfig.setPdxSerializer(serializer);
basicSetPdxSerializer(serializer);
}
@@ -5117,13 +5085,13 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void setReadSerializedForCurrentThread(boolean value) {
PdxInstanceImpl.setPdxReadSerialized(value);
- this.setPdxReadSerializedOverride(value);
+ setPdxReadSerializedOverride(value);
}
// test hook
@Override
public void setReadSerializedForTest(boolean value) {
- this.cacheConfig.setPdxReadSerialized(value);
+ cacheConfig.setPdxReadSerialized(value);
}
@Override
@@ -5140,16 +5108,16 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public void addDeclarableProperties(final Map<Declarable, Properties> mapOfNewDeclarableProps) {
- synchronized (this.declarablePropertiesMap) {
+ synchronized (declarablePropertiesMap) {
for (Entry<Declarable, Properties> newEntry : mapOfNewDeclarableProps.entrySet()) {
// Find and remove a Declarable from the map if an "equal" version is already stored
Class<? extends Declarable> clazz = newEntry.getKey().getClass();
Declarable matchingDeclarable = null;
- for (Entry<Declarable, Properties> oldEntry : this.declarablePropertiesMap.entrySet()) {
+ for (Entry<Declarable, Properties> oldEntry : declarablePropertiesMap.entrySet()) {
BiPredicate<Declarable, Declarable> isKeyIdentifiableAndSameIdPredicate =
- (Declarable oldKey, Declarable newKey) -> Identifiable.class.isInstance(newKey)
+ (Declarable oldKey, Declarable newKey) -> newKey instanceof Identifiable
&& ((Identifiable) oldKey).getId().equals(((Identifiable) newKey).getId());
Supplier<Boolean> isKeyClassSame =
@@ -5164,11 +5132,11 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
}
if (matchingDeclarable != null) {
- this.declarablePropertiesMap.remove(matchingDeclarable);
+ declarablePropertiesMap.remove(matchingDeclarable);
}
// Now add the new/replacement properties to the map
- this.declarablePropertiesMap.put(newEntry.getKey(), newEntry.getValue());
+ declarablePropertiesMap.put(newEntry.getKey(), newEntry.getValue());
}
}
}
@@ -5179,12 +5147,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Declarable getInitializer() {
- return this.initializer;
+ return initializer;
}
@Override
public Properties getInitializerProps() {
- return this.initializerProps;
+ return initializerProps;
}
@Override
@@ -5210,7 +5178,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public JmxManagerAdvisor getJmxManagerAdvisor() {
- return this.jmxAdvisor;
+ return jmxAdvisor;
}
@Override
@@ -5227,12 +5195,12 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public MemoryAllocator getOffHeapStore() {
- return this.getSystem().getOffHeapStore();
+ return getSystem().getOffHeapStore();
}
@Override
public DiskStoreMonitor getDiskStoreMonitor() {
- return this.diskMonitor;
+ return diskMonitor;
}
/**
@@ -5241,35 +5209,29 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
*/
@Override
public ExtensionPoint<Cache> getExtensionPoint() {
- return this.extensionPoint;
+ return extensionPoint;
}
@Override
public CqService getCqService() {
- return this.cqService;
- }
-
- public void addRegionEntrySynchronizationListener(RegionEntrySynchronizationListener listener) {
- this.synchronizationListeners.add(listener);
+ return cqService;
}
- public void removeRegionEntrySynchronizationListener(
- RegionEntrySynchronizationListener listener) {
- this.synchronizationListeners.remove(listener);
+ private void addRegionEntrySynchronizationListener(RegionEntrySynchronizationListener listener) {
+ synchronizationListeners.add(listener);
}
@Override
public void invokeRegionEntrySynchronizationListenersAfterSynchronization(
InternalDistributedMember sender, InternalRegion region,
List<InitialImageOperation.Entry> entriesToSynchronize) {
- for (RegionEntrySynchronizationListener listener : this.synchronizationListeners) {
+ for (RegionEntrySynchronizationListener listener : synchronizationListeners) {
try {
listener.afterSynchronization(sender, region, entriesToSynchronize);
} catch (Throwable t) {
logger.warn(String.format(
"Caught the following exception attempting to synchronize events from member=%s; regionPath=%s; entriesToSynchronize=%s:",
- new Object[] {sender, region.getFullPath(), entriesToSynchronize}),
- t);
+ sender, region.getFullPath(), entriesToSynchronize), t);
}
}
}
@@ -5286,7 +5248,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
// Could not convert pdx to bytes here; it will be tried again later
// and an exception will be thrown there.
}
- } else if (!this.getPdxReadSerialized()) {
+ } else if (!getPdxReadSerialized()) {
result = pdxInstance.getObject();
}
}
@@ -5295,7 +5257,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public Boolean getPdxReadSerializedOverride() {
- TypeRegistry pdxRegistry = this.getPdxRegistry();
+ TypeRegistry pdxRegistry = getPdxRegistry();
if (pdxRegistry != null) {
return pdxRegistry.getPdxReadSerializedOverride();
}
@@ -5304,7 +5266,7 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
@Override
public void setPdxReadSerializedOverride(boolean pdxReadSerialized) {
- TypeRegistry pdxRegistry = this.getPdxRegistry();
+ TypeRegistry pdxRegistry = getPdxRegistry();
if (pdxRegistry != null) {
pdxRegistry.setPdxReadSerializedOverride(pdxReadSerialized);
}
@@ -5337,8 +5299,8 @@ public class GemFireCacheImpl implements InternalCache, InternalClientCache, Has
}
private ThreadsMonitoring getThreadMonitorObj() {
- if (this.dm != null) {
- return this.dm.getThreadMonitoring();
+ if (dm != null) {
+ return dm.getThreadMonitoring();
} else {
return null;
}
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
index 1ec1ca0..47231f7 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/InternalRegion.java
@@ -213,7 +213,7 @@ public interface InternalRegion extends Region, HasCachePerfStats, RegionEntryCo
void waitOnInitialization(StoppableCountDownLatch latch);
- Set basicSubregions(boolean recursive);
+ Set<InternalRegion> basicSubregions(boolean recursive);
boolean isSecret();
@@ -394,7 +394,7 @@ public interface InternalRegion extends Region, HasCachePerfStats, RegionEntryCo
Object getIMSync();
- IndexManager setIndexManager(IndexManager idxMgr);
+ void setIndexManager(IndexManager idxMgr);
RegionTTLExpiryTask getRegionTTLExpiryTask();
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 4411557..5149d50 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
@@ -200,7 +200,6 @@ import org.apache.geode.internal.cache.versions.VersionSource;
import org.apache.geode.internal.cache.versions.VersionStamp;
import org.apache.geode.internal.cache.versions.VersionTag;
import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
-import org.apache.geode.internal.cache.wan.GatewaySenderEventCallbackArgument;
import org.apache.geode.internal.lang.SystemPropertyHelper;
import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.logging.log4j.LogMarker;
@@ -5099,13 +5098,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
Object theCallbackArg = callbackArg;
long startPut = CachePerfStats.getStatTime();
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
- }
- }
@Released
final EntryEventImpl event =
@@ -5175,14 +5167,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
Object theCallbackArg = callbackArg;
long startPut = CachePerfStats.getStatTime();
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
- }
- }
-
@Released
final EntryEventImpl event = entryEventFactory.create(this, Operation.UPDATE, key,
null, theCallbackArg, false,
@@ -5433,20 +5417,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
boolean fromClient, EntryEventImpl clientEvent)
throws TimeoutException, EntryNotFoundException, CacheWriterException {
- Object theCallbackArg = callbackArg;
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
- }
- }
-
// Create an event and put the entry
@Released
final EntryEventImpl event =
entryEventFactory.create(this, Operation.DESTROY, key, null,
- theCallbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
+ callbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
try {
event.setContext(memberId);
@@ -5472,20 +5447,11 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent)
throws TimeoutException, EntryNotFoundException, CacheWriterException {
- Object theCallbackArg = callbackArg;
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- theCallbackArg = new GatewaySenderEventCallbackArgument(theCallbackArg);
- }
- }
-
// Create an event and put the entry
@Released
final EntryEventImpl event =
entryEventFactory.create(this, Operation.INVALIDATE, key, null,
- theCallbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
+ callbackArg, false, memberId.getDistributedMember(), true, clientEvent.getEventId());
try {
event.setContext(memberId);
@@ -8381,14 +8347,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
boolean fromClient, EventID eventId)
throws TimeoutException, EntryExistsException, CacheWriterException {
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
-
RegionEventImpl event = new ClientRegionEventImpl(this, Operation.REGION_DESTROY, callbackArg,
false, client.getDistributedMember(), client, eventId);
@@ -8399,14 +8357,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
boolean fromClient, EventID eventId)
throws TimeoutException, EntryExistsException, CacheWriterException {
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
-
RegionEventImpl event = new ClientRegionEventImpl(this, Operation.REGION_CLEAR, callbackArg,
false, client.getDistributedMember(), client, eventId);
@@ -8792,9 +8742,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
throws TimeoutException, CacheWriterException {
long startPut = CachePerfStats.getStatTime();
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
@Released
final EntryEventImpl event =
@@ -8831,9 +8778,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
Object callbackArg) throws TimeoutException, CacheWriterException {
long startOp = CachePerfStats.getStatTime();
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
@Released
final EntryEventImpl event =
@@ -10621,13 +10565,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
EventID eventId = clientEvent.getEventId();
long startPut = CachePerfStats.getStatTime();
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
@Released
final EntryEventImpl event =
@@ -10704,13 +10641,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
EventID eventId = clientEvent.getEventId();
long startPut = CachePerfStats.getStatTime();
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
@Released
final EntryEventImpl event =
@@ -10765,13 +10695,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
EventID eventId = clientEvent.getEventId();
long startPut = CachePerfStats.getStatTime();
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
@Released
final EntryEventImpl event =
@@ -10830,14 +10753,6 @@ public class LocalRegion extends AbstractRegion implements LoaderHelperFactory,
ClientProxyMembershipID memberId, boolean fromClient, EntryEventImpl clientEvent)
throws TimeoutException, EntryNotFoundException, CacheWriterException {
- if (fromClient) {
- // If this region is also wan-enabled, then wrap that callback arg in a
- // GatewayEventCallbackArgument to store the event id.
- if (isGatewaySenderEnabled()) {
- callbackArg = new GatewaySenderEventCallbackArgument(callbackArg);
- }
- }
-
// Create an event and put the entry
@Released
final EntryEventImpl event =
diff --git a/geode-core/src/main/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListener.java b/geode-core/src/main/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListener.java
index 56a1651..aea0684 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListener.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListener.java
@@ -12,6 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package org.apache.geode.internal.offheap;
import org.apache.geode.OutOfOffHeapMemoryException;
@@ -34,40 +35,37 @@ class DisconnectingOutOfOffHeapMemoryListener implements OutOfOffHeapMemoryListe
@Override
public void close() {
synchronized (lock) {
- this.ids = null; // set null to prevent memory leak after closure!
+ ids = null; // set null to prevent memory leak after closure!
}
}
@Override
public void outOfOffHeapMemory(final OutOfOffHeapMemoryException cause) {
synchronized (lock) {
- if (this.ids == null) {
+ if (ids == null) {
return;
}
if (Boolean.getBoolean(OffHeapStorage.STAY_CONNECTED_ON_OUTOFOFFHEAPMEMORY_PROPERTY)) {
return;
}
- final InternalDistributedSystem dsToDisconnect = this.ids;
- this.ids = null; // set null to prevent memory leak after closure!
+ final InternalDistributedSystem dsToDisconnect = ids;
+ ids = null; // set null to prevent memory leak after closure!
if (dsToDisconnect.getDistributionManager().getRootCause() == null) {
dsToDisconnect.getDistributionManager().setRootCause(cause);
}
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- dsToDisconnect.getLogWriter()
- .info("OffHeapStorage about to invoke disconnect on " + dsToDisconnect);
- dsToDisconnect.disconnect(cause.getMessage(), cause, false);
- }
+ Runnable runnable = () -> {
+ dsToDisconnect.getLogWriter()
+ .info("OffHeapStorage about to invoke disconnect on " + dsToDisconnect);
+ dsToDisconnect.disconnect(cause.getMessage(), false);
};
// invoking disconnect is async because caller may be a DM pool thread which will block until
// DM shutdown times out
- String name = this.getClass().getSimpleName() + "@" + this.hashCode()
+ String name = getClass().getSimpleName() + "@" + hashCode()
+ " Handle OutOfOffHeapMemoryException Thread";
Thread thread = new LoggingThread(name, runnable);
thread.start();
diff --git a/geode-core/src/main/java/org/apache/geode/internal/util/concurrent/FutureResult.java b/geode-core/src/main/java/org/apache/geode/internal/util/concurrent/FutureResult.java
index 9579eeb..45c0f3f 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/util/concurrent/FutureResult.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/util/concurrent/FutureResult.java
@@ -31,78 +31,78 @@ import org.apache.geode.CancelCriterion;
* with a CancellationException.
*
*/
-public class FutureResult implements Future {
+public class FutureResult<V> implements Future<V> {
private final StoppableCountDownLatch latch;
- private Object value;
+ private V value;
private volatile boolean isCancelled = false;
/** Creates a new instance of FutureResult */
public FutureResult(CancelCriterion crit) {
- this.latch = new StoppableCountDownLatch(crit, 1);
+ latch = new StoppableCountDownLatch(crit, 1);
}
/** Creates a new instance of FutureResult with the value available immediately */
- public FutureResult(Object value) {
+ public FutureResult(V value) {
this.value = value;
- this.latch = null;
+ latch = null;
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
- if (this.isCancelled)
+ if (isCancelled)
return false; // already cancelled
- this.isCancelled = true;
- if (this.latch != null)
- this.latch.countDown();
+ isCancelled = true;
+ if (latch != null)
+ latch.countDown();
return true;
}
@Override
- public Object get() throws InterruptedException {
+ public V get() throws InterruptedException {
if (Thread.interrupted())
throw new InterruptedException(); // check in case latch is null
- if (this.isCancelled) {
+ if (isCancelled) {
throw new CancellationException(
"Future was cancelled");
}
- if (this.latch != null)
- this.latch.await();
- if (this.isCancelled) {
+ if (latch != null)
+ latch.await();
+ if (isCancelled) {
throw new CancellationException(
"Future was cancelled");
}
- return this.value;
+ return value;
}
@Override
- public Object get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
+ public V get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
if (Thread.interrupted())
throw new InterruptedException(); // check in case latch is null
- if (this.isCancelled) {
+ if (isCancelled) {
throw new CancellationException(
"Future was cancelled");
}
- if (this.latch != null) {
- if (!this.latch.await(unit.toMillis(timeout))) {
+ if (latch != null) {
+ if (!latch.await(unit.toMillis(timeout))) {
throw new TimeoutException();
}
}
- return this.value;
+ return value;
}
@Override
public boolean isCancelled() {
- return this.isCancelled;
+ return isCancelled;
}
@Override
public boolean isDone() {
- return this.latch == null || this.latch.getCount() == 0L || this.isCancelled;
+ return latch == null || latch.getCount() == 0L || isCancelled;
}
- public void set(Object value) {
+ public void set(V value) {
this.value = value;
- if (this.latch != null)
- this.latch.countDown();
+ if (latch != null)
+ latch.countDown();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
index 69e3757..02749d3 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/offheap/DisconnectingOutOfOffHeapMemoryListenerJUnitTest.java
@@ -12,6 +12,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+
package org.apache.geode.internal.offheap;
import static org.mockito.Mockito.mock;
@@ -66,7 +67,7 @@ public class DisconnectingOutOfOffHeapMemoryListenerJUnitTest {
DisconnectingOutOfOffHeapMemoryListener listener =
new DisconnectingOutOfOffHeapMemoryListener(ids);
listener.outOfOffHeapMemory(ex);
- verify(ids, never()).disconnect(ex.getMessage(), ex, false);
+ verify(ids, never()).disconnect(ex.getMessage(), false);
}
@Test
@@ -75,7 +76,7 @@ public class DisconnectingOutOfOffHeapMemoryListenerJUnitTest {
new DisconnectingOutOfOffHeapMemoryListener(ids);
listener.close();
listener.outOfOffHeapMemory(ex);
- verify(ids, never()).disconnect(ex.getMessage(), ex, false);
+ verify(ids, never()).disconnect(ex.getMessage(), false);
}
@Test
@@ -101,7 +102,7 @@ public class DisconnectingOutOfOffHeapMemoryListenerJUnitTest {
DisconnectingOutOfOffHeapMemoryListener listener =
new DisconnectingOutOfOffHeapMemoryListener(ids);
listener.outOfOffHeapMemory(ex);
- verify(ids, timeout(5000).atLeastOnce()).disconnect(ex.getMessage(), ex, false);
+ verify(ids, timeout(5000).atLeastOnce()).disconnect(ex.getMessage(), false);
verify(lw).info("OffHeapStorage about to invoke disconnect on " + ids);
}