You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/10/26 21:22:47 UTC
[30/52] [partial] incubator-geode git commit: Added Spotless plugin
to enforce formatting standards. Added Google Java Style guide formatter
templates, removed existing formatter templates.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/SystemFailure.java
----------------------------------------------------------------------
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 8acf473..99b0671 100644
--- a/geode-core/src/main/java/org/apache/geode/SystemFailure.java
+++ b/geode-core/src/main/java/org/apache/geode/SystemFailure.java
@@ -1,18 +1,16 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
/**
*
@@ -28,97 +26,76 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
/**
* Catches and responds to JVM failure
* <p>
- * This class represents a catastrophic failure of the system,
- * especially the Java virtual machine. Any class may,
- * at any time, indicate that a system failure has occurred by calling
- * {@link #initiateFailure(Error)} (or, less commonly,
- * {@link #setFailure(Error)}).
+ * This class represents a catastrophic failure of the system, especially the Java virtual machine.
+ * Any class may, at any time, indicate that a system failure has occurred by calling
+ * {@link #initiateFailure(Error)} (or, less commonly, {@link #setFailure(Error)}).
* <p>
- * In practice, the most common type of failure that is likely to be
- * reported by an otherwise healthy JVM is {@link OutOfMemoryError}. However,
- * GemFire will report any occurrence of {@link VirtualMachineError} as
- * a JVM failure.
+ * In practice, the most common type of failure that is likely to be reported by an otherwise
+ * healthy JVM is {@link OutOfMemoryError}. However, GemFire will report any occurrence of
+ * {@link VirtualMachineError} as a JVM failure.
* <p>
- * When a failure is reported, you must assume that the JVM has <em>broken
- * its fundamental execution contract</em> with your application.
- * No programming invariant can be assumed to be true, and your
+ * When a failure is reported, you must assume that the JVM has <em>broken its fundamental execution
+ * contract</em> with your application. No programming invariant can be assumed to be true, and your
* entire application must be regarded as corrupted.
- * <h1>Failure Hooks</h1>
- * GemFire uses this class to disable its distributed system (group
- * communication) and any open caches. It also provides a hook for you
- * to respond to after GemFire disables itself.
- * <h1>Failure WatchDog</h1>
- * When {@link #startThreads()} is called, a "watchdog" {@link Thread} is started that
- * periodically checks to see if system corruption has been reported. When
- * system corruption is detected, this thread proceeds to:
+ * <h1>Failure Hooks</h1> GemFire uses this class to disable its distributed system (group
+ * communication) and any open caches. It also provides a hook for you to respond to after GemFire
+ * disables itself.
+ * <h1>Failure WatchDog</h1> When {@link #startThreads()} is called, a "watchdog" {@link Thread} is
+ * started that periodically checks to see if system corruption has been reported. When system
+ * corruption is detected, this thread proceeds to:
* <p>
* <ol>
- * <li>
- * <em>Close GemFire</em> -- Group communication is ceased (this cache
- * member recuses itself from the distributed system) and the cache
- * is further poisoned (it is pointless to try to cleanly close it at this
- * point.).
+ * <li><em>Close GemFire</em> -- Group communication is ceased (this cache member recuses itself
+ * from the distributed system) and the cache is further poisoned (it is pointless to try to cleanly
+ * close it at this point.).
* <p>
- * After this has successfully ended, we launch a
- * </li>
- * <li>
- * <em>failure action</em>, a user-defined Runnable
- * {@link #setFailureAction(Runnable)}.
- * By default, this Runnable performs nothing. If you feel you need to perform
- * an action before exiting the JVM, this hook gives you a
- * means of attempting some action. Whatever you attempt should be extremely
- * simple, since your Java execution environment has been corrupted.
+ * After this has successfully ended, we launch a</li>
+ * <li><em>failure action</em>, a user-defined Runnable {@link #setFailureAction(Runnable)}. By
+ * default, this Runnable performs nothing. If you feel you need to perform an action before exiting
+ * the JVM, this hook gives you a means of attempting some action. Whatever you attempt should be
+ * extremely simple, since your Java execution environment has been corrupted.
* <p>
- * GemStone recommends that you employ
- * <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html">
- * Java Service Wrapper</a> to detect when your JVM exits and to perform
- * appropriate failure and restart actions.
- * </li>
- * <li>
- * Finally, if the application has granted the watchdog permission to exit the JVM
- * (via {@link #setExitOK(boolean)}), the watchdog calls {@link System#exit(int)} with
- * an argument of 1. If you have not granted this class permission to
- * close the JVM, you are <em>strongly</em> advised to call it in your
- * failure action (in the previous step).
+ * GemStone recommends that you employ
+ * <a href="http://wrapper.tanukisoftware.org/doc/english/introduction.html"> Java Service
+ * Wrapper</a> to detect when your JVM exits and to perform appropriate failure and restart actions.
* </li>
+ * <li>Finally, if the application has granted the watchdog permission to exit the JVM (via
+ * {@link #setExitOK(boolean)}), the watchdog calls {@link System#exit(int)} with an argument of 1.
+ * If you have not granted this class permission to close the JVM, you are <em>strongly</em> advised
+ * to call it in your failure action (in the previous step).</li>
* </ol>
- * <p>
- * Each of these actions will be run exactly once in the above described
- * order. However, if either step throws any type of error ({@link Throwable}),
- * the watchdog will assume that the JVM is still under duress (esp. an
- * {@link OutOfMemoryError}), will wait a bit, and then retry the failed action.
* <p>
- * It bears repeating that you should be very cautious of any Runnables you
- * ask this class to run. By definition the JVM is <em>very sick</em>
- * when failure has been signalled.
+ * Each of these actions will be run exactly once in the above described order. However, if either
+ * step throws any type of error ({@link Throwable}), the watchdog will assume that the JVM is still
+ * under duress (esp. an {@link OutOfMemoryError}), will wait a bit, and then retry the failed
+ * action.
* <p>
- * <h1>Failure Proctor</h1>
- * In addition to the failure watchdog, {@link #startThreads()} creates a second
- * thread (the "proctor") that monitors free memory. It does this by examining
- * {@link Runtime#freeMemory() free memory},
- * {@link Runtime#totalMemory() total memory} and
- * {@link Runtime#maxMemory() maximum memory}. If the amount of available
- * memory stays below a given
- * {@link #setFailureMemoryThreshold(long) threshold}, for
- * more than {@link #WATCHDOG_WAIT} seconds, the watchdog is notified.
+ * It bears repeating that you should be very cautious of any Runnables you ask this class to run.
+ * By definition the JVM is <em>very sick</em> when failure has been signalled.
+ * <p>
+ * <h1>Failure Proctor</h1> In addition to the failure watchdog, {@link #startThreads()} creates a
+ * second thread (the "proctor") that monitors free memory. It does this by examining
+ * {@link Runtime#freeMemory() free memory}, {@link Runtime#totalMemory() total memory} and
+ * {@link Runtime#maxMemory() maximum memory}. If the amount of available memory stays below a given
+ * {@link #setFailureMemoryThreshold(long) threshold}, for more than {@link #WATCHDOG_WAIT} seconds,
+ * the watchdog is notified.
* <p>
* Note that the proctor can be effectively disabled by
- * {@link SystemFailure#setFailureMemoryThreshold(long) setting} the failure memory threshold
- * to a negative value.
+ * {@link SystemFailure#setFailureMemoryThreshold(long) setting} the failure memory threshold to a
+ * negative value.
* <p>
- * The proctor is a second line of defense, attempting to detect
- * OutOfMemoryError conditions in circumstances where nothing alerted the
- * watchdog. For instance, a third-party jar might incorrectly handle this
- * error and leave your virtual machine in a "stuck" state.
+ * The proctor is a second line of defense, attempting to detect OutOfMemoryError conditions in
+ * circumstances where nothing alerted the watchdog. For instance, a third-party jar might
+ * incorrectly handle this error and leave your virtual machine in a "stuck" state.
* <p>
- * Note that the proctor does not relieve you of the obligation to
- * follow the best practices in the next section.
+ * Note that the proctor does not relieve you of the obligation to follow the best practices in the
+ * next section.
* <h1>Best Practices</h1>
- * <h2>Catch and Handle VirtualMachineError</h2>
- * If you feel obliged to catch <em>either</em> {@link Error}, or
- * {@link Throwable}, you <em>must</em>also check for
- * {@link VirtualMachineError} like so:
+ * <h2>Catch and Handle VirtualMachineError</h2> If you feel obliged to catch <em>either</em>
+ * {@link Error}, or {@link Throwable}, you <em>must</em>also check for {@link VirtualMachineError}
+ * like so:
* <p>
+ *
* <pre>
catch (VirtualMachineError err) {
SystemFailure.{@link #initiateFailure(Error) initiateFailure}(err);
@@ -127,17 +104,16 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
throw err;
}
* </pre>
- * <h2>Periodically Check For Errors</h2>
- * Check for serious system errors at
- * appropriate points in your algorithms. You may elect to use
- * the {@link #checkFailure()} utility function, but you are
- * not required to (you could just see if {@link SystemFailure#getFailure()}
- * returns a non-null result).
+ *
+ * <h2>Periodically Check For Errors</h2> Check for serious system errors at appropriate points in
+ * your algorithms. You may elect to use the {@link #checkFailure()} utility function, but you are
+ * not required to (you could just see if {@link SystemFailure#getFailure()} returns a non-null
+ * result).
* <p>
- * A job processing loop is a good candidate, for
- * instance, in org.apache.org.jgroups.protocols.UDP#run(),
- * which implements {@link Thread#run}:
+ * A job processing loop is a good candidate, for instance, in
+ * org.apache.org.jgroups.protocols.UDP#run(), which implements {@link Thread#run}:
* <p>
+ *
* <pre>
for (;;) {
SystemFailure.{@link #checkFailure() checkFailure}();
@@ -145,15 +121,15 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
if (Thread.currentThread().isInterrupted()) break;
...
* </pre>
- * <h2>Create Logging ThreadGroups</h2>
- * If you create any Thread, a best practice is to catch severe errors
- * and signal failure appropriately. One trick to do this is to create a
- * ThreadGroup that handles uncaught exceptions by overriding
- * {@link ThreadGroup#uncaughtException(Thread, Throwable)} and to declare
- * your thread as a member of that {@link ThreadGroup}. This also has a
- * significant side-benefit in that most uncaught exceptions
- * can be detected:
+ *
+ * <h2>Create Logging ThreadGroups</h2> If you create any Thread, a best practice is to catch severe
+ * errors and signal failure appropriately. One trick to do this is to create a ThreadGroup that
+ * handles uncaught exceptions by overriding
+ * {@link ThreadGroup#uncaughtException(Thread, Throwable)} and to declare your thread as a member
+ * of that {@link ThreadGroup}. This also has a significant side-benefit in that most uncaught
+ * exceptions can be detected:
* <p>
+ *
* <pre>
ThreadGroup tg = new ThreadGroup("Worker Threads") {
public void uncaughtException(Thread t, Throwable e) {
@@ -167,56 +143,62 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
}
Thread t = new Thread(myRunnable, tg, "My Thread");
t.start();
- }; * </pre>
+ }; *
+ * </pre>
* <p>
- * <h2>Catches of Error and Throwable Should Check for Failure</h2>
- * Keep in mind that peculiar or flat-out<em>impossible</em> exceptions may
- * ensue after a VirtualMachineError has been thrown <em>anywhere</em> in
- * your virtual machine. Whenever you catch {@link Error} or {@link Throwable},
- * you should also make sure that you aren't dealing with a corrupted JVM:
- * <p>
- * <pre>
- catch (Throwable t) {
- // Whenever you catch Error or Throwable, you must also
- // catch VirtualMachineError (see above). However, there is
- // _still_ a possibility that you are dealing with a cascading
- // error condition, so you also need to check to see if the JVM
- // is still usable:
- SystemFailure.{@link #checkFailure() checkFailure}();
- ...
- }
+ * <h2>Catches of Error and Throwable Should Check for Failure</h2> Keep in mind that peculiar or
+ * flat-out<em>impossible</em> exceptions may ensue after a VirtualMachineError has been thrown
+ * <em>anywhere</em> in your virtual machine. Whenever you catch {@link Error} or {@link Throwable},
+ * you should also make sure that you aren't dealing with a corrupted JVM:
+ * <p>
+ *
+ * <pre>
+ catch (Throwable t) {
+ // Whenever you catch Error or Throwable, you must also
+ // catch VirtualMachineError (see above). However, there is
+ // _still_ a possibility that you are dealing with a cascading
+ // error condition, so you also need to check to see if the JVM
+ // is still usable:
+ SystemFailure.{@link #checkFailure() checkFailure}();
+ ...
+ }
* </pre>
+ *
* @since GemFire 5.1
*/
-@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DM_GC", justification="This class performs System.gc as last ditch effort during out-of-memory condition.")
+@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "DM_GC",
+ justification = "This class performs System.gc as last ditch effort during out-of-memory condition.")
public final class SystemFailure {
/**
- * Time to wait during stopWatchdog and stopProctor. Not final
- * for tests
+ * Time to wait during stopWatchdog and stopProctor. Not final for tests
*/
static int SHUTDOWN_WAIT = 1000;
/**
- * Preallocated error messages\
- * LocalizedStrings may use memory (in the form of an iterator)
- * so we must get the translated messages in advance.
+ * Preallocated error messages\ LocalizedStrings may use memory (in the form of an iterator) so we
+ * must get the translated messages in advance.
**/
- static final String JVM_CORRUPTION = LocalizedStrings.SystemFailure_JVM_CORRUPTION_HAS_BEEN_DETECTED.toLocalizedString();
- static final String CALLING_SYSTEM_EXIT = LocalizedStrings.SystemFailure_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.toLocalizedString();
- public static final String DISTRIBUTION_HALTED_MESSAGE = LocalizedStrings.SystemFailure_DISTRIBUTION_HALTED_DUE_TO_JVM_CORRUPTION.toLocalizedString();
- public static final String DISTRIBUTED_SYSTEM_DISCONNECTED_MESSAGE = LocalizedStrings.SystemFailure_DISTRIBUTED_SYSTEM_DISCONNECTED_DUE_TO_JVM_CORRUPTION.toLocalizedString();
+ static final String JVM_CORRUPTION =
+ LocalizedStrings.SystemFailure_JVM_CORRUPTION_HAS_BEEN_DETECTED.toLocalizedString();
+ static final String CALLING_SYSTEM_EXIT =
+ LocalizedStrings.SystemFailure_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
+ .toLocalizedString();
+ public static final String DISTRIBUTION_HALTED_MESSAGE =
+ LocalizedStrings.SystemFailure_DISTRIBUTION_HALTED_DUE_TO_JVM_CORRUPTION.toLocalizedString();
+ public static final String DISTRIBUTED_SYSTEM_DISCONNECTED_MESSAGE =
+ LocalizedStrings.SystemFailure_DISTRIBUTED_SYSTEM_DISCONNECTED_DUE_TO_JVM_CORRUPTION
+ .toLocalizedString();
/**
* the underlying failure
*
- * This is usually an instance of {@link VirtualMachineError}, but it
- * is not required to be such.
+ * This is usually an instance of {@link VirtualMachineError}, but it is not required to be such.
*
* @see #getFailure()
* @see #initiateFailure(Error)
*/
protected static volatile Error failure = null;
-
+
/**
* user-defined runnable to run last
*
@@ -228,21 +210,20 @@ public final class SystemFailure {
failure.printStackTrace();
}
};
-
+
/**
* @see #setExitOK(boolean)
*/
private static volatile boolean exitOK = false;
-
+
/**
- * If we're going to exit the JVM, I want to be accountable for who
- * told us it was OK.
+ * If we're going to exit the JVM, I want to be accountable for who told us it was OK.
*/
private static volatile Throwable exitExcuse;
-
+
/**
- * Indicate whether it is acceptable to call {@link System#exit(int)} after
- * failure processing has completed.
+ * Indicate whether it is acceptable to call {@link System#exit(int)} after failure processing has
+ * completed.
* <p>
* This may be dynamically modified while the system is running.
*
@@ -254,41 +235,40 @@ public final class SystemFailure {
exitOK = newVal;
if (exitOK) {
exitExcuse = new Throwable("SystemFailure exitOK set");
- }
- else {
+ } else {
exitExcuse = null;
}
return result;
}
-
- //merge42180: Added this method while merging 42180. It should have already be here through different merges or will come later
+
+ // merge42180: Added this method while merging 42180. It should have already be here through
+ // different merges or will come later
/**
- * Returns true if the given Error is a fatal to the JVM and it should be shut
- * down. Code should call {@link #initiateFailure(Error)} or
- * {@link #setFailure(Error)} if this returns true.
+ * Returns true if the given Error is a fatal to the JVM and it should be shut down. Code should
+ * call {@link #initiateFailure(Error)} or {@link #setFailure(Error)} if this returns true.
*/
public static boolean isJVMFailureError(Error err) {
// all VirtualMachineErrors are not fatal to the JVM, in particular
// StackOverflowError is not
return err instanceof OutOfMemoryError || err instanceof UnknownError;
}
+
/**
* Disallow instance creation
*/
private SystemFailure() {
-
+
}
-
+
/**
- * Synchronizes access to state variables, used to notify the watchdog
- * when to run
+ * Synchronizes access to state variables, used to notify the watchdog when to run
*
* @see #notifyWatchDog()
* @see #startProctor()
* @see #startWatchDog()
*/
private static final Object failureSync = new Object();
-
+
/**
* True if we have closed GemFire
*
@@ -301,7 +281,7 @@ public final class SystemFailure {
*
* @see #setFailureAction(Runnable)
*/
- private static volatile boolean failureActionCompleted = false;
+ private static volatile boolean failureActionCompleted = false;
/**
* This is a logging ThreadGroup, created only once.
@@ -319,42 +299,41 @@ public final class SystemFailure {
System.err.println("Internal error in SystemFailure watchdog:" + e);
e.printStackTrace();
}
- };
- }
-
+ };
+ }
+
/**
- * This is the amount of time, in seconds, the watchdog periodically awakens
- * to see if the system has been corrupted.
+ * This is the amount of time, in seconds, the watchdog periodically awakens to see if the system
+ * has been corrupted.
* <p>
- * The watchdog will be explicitly awakened by calls to
- * {@link #setFailure(Error)} or {@link #initiateFailure(Error)}, but
- * it will awaken of its own accord periodically to check for failure even
- * if the above calls do not occur.
+ * The watchdog will be explicitly awakened by calls to {@link #setFailure(Error)} or
+ * {@link #initiateFailure(Error)}, but it will awaken of its own accord periodically to check for
+ * failure even if the above calls do not occur.
* <p>
- * This can be set with the system property
- * <code>gemfire.WATCHDOG_WAIT</code>. The default is 15 sec.
+ * This can be set with the system property <code>gemfire.WATCHDOG_WAIT</code>. The default is 15
+ * sec.
*/
- static public final int WATCHDOG_WAIT = Integer
- .getInteger(DistributionConfig.GEMFIRE_PREFIX + "WATCHDOG_WAIT", 15).intValue();
-
+ static public final int WATCHDOG_WAIT =
+ Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "WATCHDOG_WAIT", 15).intValue();
+
/**
* This is the watchdog thread
*
* @guarded.By {@link #failureSync}
*/
private static Thread watchDog;
-
+
private static volatile boolean isCacheClosing = false;
/**
- * Should be invoked when GemFire cache is being created.
+ * Should be invoked when GemFire cache is being created.
*/
public static void signalCacheCreate() {
isCacheClosing = false;
}
/**
- * Should be invoked when GemFire cache is closing or closed.
+ * Should be invoked when GemFire cache is closing or closed.
*/
public static void signalCacheClose() {
isCacheClosing = true;
@@ -387,7 +366,7 @@ public final class SystemFailure {
watchDog.start();
}
}
-
+
private static void stopWatchDog() {
Thread watchDogSnapshot = null;
synchronized (failureSync) {
@@ -397,7 +376,7 @@ public final class SystemFailure {
watchDogSnapshot = watchDog;
}
}
- if(watchDogSnapshot != null) {
+ if (watchDogSnapshot != null) {
try {
watchDogSnapshot.join(100);
} catch (InterruptedException ignore) {
@@ -411,19 +390,18 @@ public final class SystemFailure {
}
}
}
-
+
/**
* This is the run loop for the watchdog thread.
*/
static protected void runWatchDog() {
-
+
boolean warned = false;
-
+
logFine(WATCHDOG_NAME, "Starting");
try {
basicLoadEmergencyClasses();
- }
- catch (ExceptionInInitializerError e) {
+ } catch (ExceptionInInitializerError e) {
// Uhhh...are we shutting down?
boolean noSurprise = false;
Throwable cause = e.getCause();
@@ -440,11 +418,9 @@ public final class SystemFailure {
}
// In any event, we're toast
return;
- }
- catch (CancelException e) {
+ } catch (CancelException e) {
// ignore this because we are shutting down anyway
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
logWarning(WATCHDOG_NAME, "Unable to initialize watchdog", t);
return;
}
@@ -461,11 +437,10 @@ public final class SystemFailure {
if (stopping) {
return;
}
- logFine(WATCHDOG_NAME, "Waiting for disaster");
+ logFine(WATCHDOG_NAME, "Waiting for disaster");
try {
- failureSync.wait(WATCHDOG_WAIT * 1000);
- }
- catch (InterruptedException e) {
+ failureSync.wait(WATCHDOG_WAIT * 1000);
+ } catch (InterruptedException e) {
// Ignore
}
if (stopping) {
@@ -473,35 +448,34 @@ public final class SystemFailure {
}
}
// Poke nose in the air, take a sniff...
-
+
if (failureActionCompleted) {
// early out, for testing
logInfo(WATCHDOG_NAME, "all actions completed; exiting");
}
if (failure == null) {
- // Tail wag. Go back to sleep.
+ // Tail wag. Go back to sleep.
logFine(WATCHDOG_NAME, "no failure detected");
continue;
}
- // BOW WOW WOW WOW WOW! Corrupted system.
- if (!warned ) {
+ // BOW WOW WOW WOW WOW! Corrupted system.
+ if (!warned) {
warned = logWarning(WATCHDOG_NAME, "failure detected", failure);
}
-
+
// If any of the following fail, we will go back to sleep and
// retry.
if (!gemfireCloseCompleted) {
logInfo(WATCHDOG_NAME, "closing GemFire");
try {
emergencyClose();
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
logWarning(WATCHDOG_NAME, "trouble closing GemFire", t);
continue; // go back to sleep
}
gemfireCloseCompleted = true;
}
-
+
if (!failureActionCompleted) {
// avoid potential race condition setting the runnable
Runnable r = failureAction;
@@ -509,26 +483,24 @@ public final class SystemFailure {
logInfo(WATCHDOG_NAME, "running user's runnable");
try {
r.run();
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
logWarning(WATCHDOG_NAME, "trouble running user's runnable", t);
continue; // go back to sleep
}
}
failureActionCompleted = true;
}
-
+
stopping = true;
stopProctor();
-
+
if (exitOK) {
logWarning(WATCHDOG_NAME,
// No "+" in this long message, we're out of memory!
- CALLING_SYSTEM_EXIT,
- exitExcuse);
-
+ CALLING_SYSTEM_EXIT, exitExcuse);
+
// ATTENTION: there are VERY FEW places in GemFire where it is
- // acceptable to call System.exit. This is one of those
+ // acceptable to call System.exit. This is one of those
// places...
System.exit(1);
}
@@ -537,14 +509,13 @@ public final class SystemFailure {
// Our job here is done
logInfo(WATCHDOG_NAME, "exiting");
return;
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
// We *never* give up. NEVER EVER!
logWarning(WATCHDOG_NAME, "thread encountered a problem: " + t, t);
}
} // for
}
-
+
/**
* Spies on system statistics looking for low memory threshold
*
@@ -556,66 +527,64 @@ public final class SystemFailure {
private static Thread proctor;
/**
- * This mutex controls access to {@link #firstStarveTime} and
- * {@link #minimumMemoryThreshold}.
+ * This mutex controls access to {@link #firstStarveTime} and {@link #minimumMemoryThreshold}.
* <p>
- * I'm hoping that a fat lock is never created here, so that
- * an object allocation isn't necessary to acquire this
- * mutex. You'd have to have A LOT of contention on this mutex
- * in order for a fat lock to be created, which indicates IMHO
- * a serious problem in your applications.
+ * I'm hoping that a fat lock is never created here, so that an object allocation isn't necessary
+ * to acquire this mutex. You'd have to have A LOT of contention on this mutex in order for a fat
+ * lock to be created, which indicates IMHO a serious problem in your applications.
*/
private static final Object memorySync = new Object();
-
+
/**
- * This is the minimum amount of memory that the proctor will
- * tolerate before declaring a system failure.
+ * This is the minimum amount of memory that the proctor will tolerate before declaring a system
+ * failure.
*
* @see #setFailureMemoryThreshold(long)
* @guarded.By {@link #memorySync}
*/
- static long minimumMemoryThreshold = Long.getLong(
- DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.chronic_memory_threshold", 1048576).longValue();
-
+ static long minimumMemoryThreshold =
+ Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.chronic_memory_threshold",
+ 1048576).longValue();
+
/**
- * This is the interval, in seconds, that the proctor
- * thread will awaken and poll system free memory.
+ * This is the interval, in seconds, that the proctor thread will awaken and poll system free
+ * memory.
*
- * The default is 1 sec. This can be set using the system property
+ * The default is 1 sec. This can be set using the system property
* <code>gemfire.SystemFailure.MEMORY_POLL_INTERVAL</code>.
*
* @see #setFailureMemoryThreshold(long)
*/
- static final public long MEMORY_POLL_INTERVAL = Long.getLong(
- DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MEMORY_POLL_INTERVAL", 1).longValue();
-
+ static final public long MEMORY_POLL_INTERVAL =
+ Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MEMORY_POLL_INTERVAL", 1)
+ .longValue();
+
/**
- * This is the maximum amount of time, in seconds, that the proctor thread
- * will tolerate seeing free memory stay below
- * {@link #setFailureMemoryThreshold(long)}, after which point it will
+ * This is the maximum amount of time, in seconds, that the proctor thread will tolerate seeing
+ * free memory stay below {@link #setFailureMemoryThreshold(long)}, after which point it will
* declare a system failure.
*
- * The default is 15 sec. This can be set using the system property
+ * The default is 15 sec. This can be set using the system property
* <code>gemfire.SystemFailure.MEMORY_MAX_WAIT</code>.
*
* @see #setFailureMemoryThreshold(long)
*/
- static final public long MEMORY_MAX_WAIT = Long.getLong(
- DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MEMORY_MAX_WAIT", 15).longValue();
-
+ static final public long MEMORY_MAX_WAIT = Long
+ .getLong(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MEMORY_MAX_WAIT", 15).longValue();
+
/**
- * Flag that determines whether or not we monitor memory on our own.
- * If this flag is set, we will check freeMemory, invoke GC if free memory
- * gets low, and start throwing our own OutOfMemoryException if
+ * Flag that determines whether or not we monitor memory on our own. If this flag is set, we will
+ * check freeMemory, invoke GC if free memory gets low, and start throwing our own
+ * OutOfMemoryException if
*
- * The default is false, so this monitoring is turned off. This monitoring has been found
- * to be unreliable in non-Sun VMs when the VM is under stress or behaves in unpredictable ways.
+ * The default is false, so this monitoring is turned off. This monitoring has been found to be
+ * unreliable in non-Sun VMs when the VM is under stress or behaves in unpredictable ways.
*
* @since GemFire 6.5
*/
- static final public boolean MONITOR_MEMORY = Boolean.getBoolean(
- DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MONITOR_MEMORY");
-
+ static final public boolean MONITOR_MEMORY =
+ Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "SystemFailure.MONITOR_MEMORY");
+
/**
* Start the proctor thread, if it isn't already running.
*
@@ -640,7 +609,7 @@ public final class SystemFailure {
proctor.start();
}
}
-
+
private static void stopProctor() {
Thread proctorSnapshot = null;
synchronized (failureSync) {
@@ -655,41 +624,43 @@ public final class SystemFailure {
}
}
}
-
+
/**
* Symbolic representation of an invalid starve time
*/
static private final long NEVER_STARVED = Long.MAX_VALUE;
-
+
/**
* this is the last time we saw memory starvation
*
* @guarded.By {@link #memorySync}}}
*/
static private long firstStarveTime = NEVER_STARVED;
-
+
/**
- * This is the previous measure of total memory. If it changes,
- * we reset the proctor's starve statistic.
+ * This is the previous measure of total memory. If it changes, we reset the proctor's starve
+ * statistic.
*/
static private long lastTotalMemory = 0;
-
+
/**
- * This is the run loop for the proctor thread (formally known
- * as the "watchcat" (grin)
+ * This is the run loop for the proctor thread (formally known as the "watchcat" (grin)
*/
static protected void runProctor() {
// Note that the javadocs say this can return Long.MAX_VALUE.
// If it does, the proctor will never do its job...
final long maxMemory = Runtime.getRuntime().maxMemory();
-
+
// Allocate this error in advance, since it's too late once
// it's been detected!
- final OutOfMemoryError oome = new OutOfMemoryError(LocalizedStrings.SystemFailure_0_MEMORY_HAS_REMAINED_CHRONICALLY_BELOW_1_BYTES_OUT_OF_A_MAXIMUM_OF_2_FOR_3_SEC.toLocalizedString(new Object[] {PROCTOR_NAME, Long.valueOf(minimumMemoryThreshold), Long.valueOf(maxMemory), Integer.valueOf(WATCHDOG_WAIT)}));
-
+ final OutOfMemoryError oome = new OutOfMemoryError(
+ LocalizedStrings.SystemFailure_0_MEMORY_HAS_REMAINED_CHRONICALLY_BELOW_1_BYTES_OUT_OF_A_MAXIMUM_OF_2_FOR_3_SEC
+ .toLocalizedString(new Object[] {PROCTOR_NAME, Long.valueOf(minimumMemoryThreshold),
+ Long.valueOf(maxMemory), Integer.valueOf(WATCHDOG_WAIT)}));
+
// Catenation, but should be OK when starting up
- logFine(PROCTOR_NAME, "Starting, threshold = " + minimumMemoryThreshold
- + "; max = " + maxMemory);
+ logFine(PROCTOR_NAME,
+ "Starting, threshold = " + minimumMemoryThreshold + "; max = " + maxMemory);
for (;;) {
if (isCacheClosing) {
break;
@@ -699,19 +670,18 @@ public final class SystemFailure {
}
try {
- //*** catnap...
+ // *** catnap...
try {
Thread.sleep(MEMORY_POLL_INTERVAL * 1000);
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
// ignore
}
-
+
if (stopping) {
return;
}
- //*** Twitch ear, take a bath...
+ // *** Twitch ear, take a bath...
if (failureActionCompleted) {
// it's all over, we're late
return;
@@ -721,20 +691,20 @@ public final class SystemFailure {
logFine(PROCTOR_NAME, "Failure has been reported, exiting");
return;
}
-
- if(!MONITOR_MEMORY) {
+
+ if (!MONITOR_MEMORY) {
continue;
}
- //*** Sit up, stretch...
+ // *** Sit up, stretch...
long totalMemory = Runtime.getRuntime().totalMemory();
if (totalMemory < maxMemory) {
// We haven't finished growing the heap, so no worries...yet
if (DEBUG) {
// This message has catenation, we don't want this in
// production code :-)
- logFine(PROCTOR_NAME, "totalMemory (" + totalMemory
- + ") < maxMemory (" + maxMemory + ")");
+ logFine(PROCTOR_NAME,
+ "totalMemory (" + totalMemory + ") < maxMemory (" + maxMemory + ")");
}
firstStarveTime = NEVER_STARVED;
continue;
@@ -747,16 +717,16 @@ public final class SystemFailure {
}
lastTotalMemory = totalMemory; // make a note of this
- //*** Hey, is that the food bowl?
-
+ // *** Hey, is that the food bowl?
+
// At this point, freeMemory really indicates how much
// trouble we're in.
long freeMemory = Runtime.getRuntime().freeMemory();
- if(freeMemory==0) {
+ if (freeMemory == 0) {
/*
- * This is to workaround X bug #41821 in JRockit.
- * Often, Jrockit returns 0 from Runtime.getRuntime().freeMemory()
- * Allocating this one object and calling again seems to workaround the problem.
+ * This is to workaround X bug #41821 in JRockit. Often, Jrockit returns 0 from
+ * Runtime.getRuntime().freeMemory() Allocating this one object and calling again seems to
+ * workaround the problem.
*/
new Object();
freeMemory = Runtime.getRuntime().freeMemory();
@@ -769,7 +739,7 @@ public final class SystemFailure {
curThreshold = minimumMemoryThreshold;
lastStarveTime = firstStarveTime;
}
-
+
if (freeMemory >= curThreshold /* enough memory */
|| curThreshold == 0 /* disabled */) {
// Memory is FINE, reset everything
@@ -778,7 +748,7 @@ public final class SystemFailure {
// production code :-)
logFine(PROCTOR_NAME, "Current free memory is: " + freeMemory);
}
-
+
if (lastStarveTime != NEVER_STARVED) {
logFine(PROCTOR_NAME, "...low memory has self-corrected.");
}
@@ -788,20 +758,19 @@ public final class SystemFailure {
continue;
}
// Memory is low
-
- //*** Leap to feet, nose down, tail switching...
+
+ // *** Leap to feet, nose down, tail switching...
long now = System.currentTimeMillis();
if (lastStarveTime == NEVER_STARVED) {
// first sighting
if (DEBUG) {
// Catenation in this message, don't put in production
- logFine(PROCTOR_NAME, "Noting current memory " + freeMemory
- + " is less than threshold " + curThreshold);
- }
- else {
- logWarning(
- PROCTOR_NAME,
- "Noting that current memory available is less than the currently designated threshold", null);
+ logFine(PROCTOR_NAME,
+ "Noting current memory " + freeMemory + " is less than threshold " + curThreshold);
+ } else {
+ logWarning(PROCTOR_NAME,
+ "Noting that current memory available is less than the currently designated threshold",
+ null);
}
synchronized (memorySync) {
@@ -810,69 +779,62 @@ public final class SystemFailure {
System.gc(); // at least TRY...
continue;
}
-
- //*** squirm, wait for the right moment...wait...wait...
+
+ // *** squirm, wait for the right moment...wait...wait...
if (now - lastStarveTime < MEMORY_MAX_WAIT * 1000) {
// Very recent; problem may correct itself.
if (DEBUG) {
// catenation
- logFine(PROCTOR_NAME, "...memory is still below threshold: "
- + freeMemory);
- }
- else {
- logWarning(
- PROCTOR_NAME,
- "Noting that current memory available is still below currently designated threshold", null);
+ logFine(PROCTOR_NAME, "...memory is still below threshold: " + freeMemory);
+ } else {
+ logWarning(PROCTOR_NAME,
+ "Noting that current memory available is still below currently designated threshold",
+ null);
}
continue;
}
-
- //*** Meow! Meow! MEOWWWW!!!!!
-
+
+ // *** Meow! Meow! MEOWWWW!!!!!
+
// Like any smart cat, let the Dog do all the work.
logWarning(PROCTOR_NAME, "Memory is chronically low; setting failure!", null);
SystemFailure.setFailure(oome);
notifyWatchDog();
return; // we're done!
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
logWarning(PROCTOR_NAME, "thread encountered a problem", t);
// We *never* give up. NEVER EVER!
}
} // for
}
-
+
/**
* Enables some fine logging
*/
static private final boolean DEBUG = false;
-
+
/**
- * If true, we track the progress of emergencyClose
- * on System.err
+ * If true, we track the progress of emergencyClose on System.err
*/
static public final boolean TRACE_CLOSE = false;
-
+
static protected final String WATCHDOG_NAME = "SystemFailure Watchdog";
-
+
static protected final String PROCTOR_NAME = "SystemFailure Proctor";
-
+
/**
* break any potential circularity in {@link #loadEmergencyClasses()}
*/
private static volatile boolean emergencyClassesLoaded = false;
-
+
/**
- * Since it requires object memory to unpack a jar file,
- * make sure this JVM has loaded the classes necessary for
- * closure <em>before</em> it becomes necessary to use them.
+ * Since it requires object memory to unpack a jar file, make sure this JVM has loaded the classes
+ * necessary for closure <em>before</em> it becomes necessary to use them.
* <p>
- * Note that just touching the class in order to load it
- * is usually sufficient, so all an implementation needs
- * to do is to reference the same classes used in
- * {@link #emergencyClose()}. Just make sure to do it while
- * you still have memory to succeed!
+ * Note that just touching the class in order to load it is usually sufficient, so all an
+ * implementation needs to do is to reference the same classes used in {@link #emergencyClose()}.
+ * Just make sure to do it while you still have memory to succeed!
*/
public static void loadEmergencyClasses() {
// This method was called to basically load this class
@@ -881,31 +843,31 @@ public final class SystemFailure {
// call startThreads. The watchdog thread will call basicLoadEmergencyClasses.
startThreads();
}
+
private static void basicLoadEmergencyClasses() {
- if (emergencyClassesLoaded) return;
+ if (emergencyClassesLoaded)
+ return;
emergencyClassesLoaded = true;
SystemFailureTestHook.loadEmergencyClasses(); // bug 50516
GemFireCacheImpl.loadEmergencyClasses();
RemoteGfManagerAgent.loadEmergencyClasses();
}
-
+
/**
* Attempt to close any and all GemFire resources.
*
- * The contract of this method is that it should not
- * acquire any synchronization mutexes nor create any objects.
+ * The contract of this method is that it should not acquire any synchronization mutexes nor
+ * create any objects.
* <p>
- * The former is because the system is in an undefined state and
- * attempting to acquire the mutex may cause a hang.
+ * The former is because the system is in an undefined state and attempting to acquire the mutex
+ * may cause a hang.
* <p>
- * The latter is because the likelihood is that we are invoking
- * this method due to memory exhaustion, so any attempt to create
- * an object will also cause a hang.
+ * The latter is because the likelihood is that we are invoking this method due to memory
+ * exhaustion, so any attempt to create an object will also cause a hang.
* <p>
- * This method is not meant to be called directly (but, well, I
- * guess it could). It is public to document the contract
- * that is implemented by <code>emergencyClose</code> in other
- * parts of the system.
+ * This method is not meant to be called directly (but, well, I guess it could). It is public to
+ * document the contract that is implemented by <code>emergencyClose</code> in other parts of the
+ * system.
*/
public static void emergencyClose() {
// Make the cache (more) useless and inaccessible...
@@ -913,19 +875,19 @@ public final class SystemFailure {
System.err.println("SystemFailure: closing GemFireCache");
}
GemFireCacheImpl.emergencyClose();
-
+
// Arcane strange DS's exist in this class:
- if (TRACE_CLOSE) {
+ 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(); // This will fail if we're out of memory?/
- if (TRACE_CLOSE) {
+ System.gc(); // This will fail if we're out of memory?/
+
+ if (TRACE_CLOSE) {
System.err.println("SystemFailure: end of emergencyClose");
}
}
@@ -935,19 +897,18 @@ public final class SystemFailure {
*
* This method does not return normally.
* <p>
- * Unfortunately, attempting to create a new Throwable at this
- * point may cause the thread to hang (instead of generating
- * another OutOfMemoryError), so we have to make do with whatever
- * Error we have, instead of wrapping it with one pertinent
- * to the current context. See bug 38394.
+ * Unfortunately, attempting to create a new Throwable at this point may cause the thread to hang
+ * (instead of generating another OutOfMemoryError), so we have to make do with whatever Error we
+ * have, instead of wrapping it with one pertinent to the current context. See bug 38394.
*
* @throws Error
*/
static private void throwFailure() throws InternalGemFireError, Error {
// Do not return normally...
- if (failure != null) throw failure;
+ if (failure != null)
+ throw failure;
}
-
+
/**
* Notifies the watchdog thread (assumes that {@link #failure} has been set)
*/
@@ -957,15 +918,15 @@ public final class SystemFailure {
failureSync.notifyAll();
}
}
-
+
/**
- * Utility function to check for failures. If a failure is
- * detected, this methods throws an AssertionFailure.
+ * Utility function to check for failures. If a failure is detected, this methods throws an
+ * AssertionFailure.
*
* @see #initiateFailure(Error)
* @throws InternalGemFireError if the system has been corrupted
- * @throws Error if the system has been corrupted and a thread-specific
- * AssertionError cannot be allocated
+ * @throws Error if the system has been corrupted and a thread-specific AssertionError cannot be
+ * allocated
*/
public static void checkFailure() throws InternalGemFireError, Error {
if (failure == null) {
@@ -976,8 +937,7 @@ public final class SystemFailure {
}
/**
- * Signals that a system failure has occurred and then throws an
- * AssertionError.
+ * Signals that a system failure has occurred and then throws an AssertionError.
*
* @param f the failure to set
* @throws IllegalArgumentException if f is null
@@ -992,52 +952,50 @@ public final class SystemFailure {
/**
* Set the underlying system failure, if not already set.
* <p>
- * This method does not generate an error, and should only be used
- * in circumstances where execution needs to continue, such as when
- * re-implementing {@link ThreadGroup#uncaughtException(Thread, Throwable)}.
+ * This method does not generate an error, and should only be used in circumstances where
+ * execution needs to continue, such as when re-implementing
+ * {@link ThreadGroup#uncaughtException(Thread, Throwable)}.
*
* @param failure the system failure
* @throws IllegalArgumentException if you attempt to set the failure to null
*/
public static void setFailure(Error failure) {
if (failure == null) {
- throw new IllegalArgumentException(LocalizedStrings.SystemFailure_YOU_ARE_NOT_PERMITTED_TO_UNSET_A_SYSTEM_FAILURE.toLocalizedString());
+ throw new IllegalArgumentException(
+ LocalizedStrings.SystemFailure_YOU_ARE_NOT_PERMITTED_TO_UNSET_A_SYSTEM_FAILURE
+ .toLocalizedString());
}
if (SystemFailureTestHook.errorIsExpected(failure)) {
return;
}
// created (OutOfMemoryError), and no stack frames are created
- // (StackOverflowError). There is a slight chance that the
+ // (StackOverflowError). There is a slight chance that the
// very first error may get overwritten, but this avoids the
// potential of object creation via a fat lock
SystemFailure.failure = failure;
notifyWatchDog();
}
-
+
/**
* Returns the catastrophic system failure, if any.
* <p>
- * This is usually (though not necessarily) an instance of
- * {@link VirtualMachineError}.
+ * This is usually (though not necessarily) an instance of {@link VirtualMachineError}.
* <p>
- * A return value of null indicates that no system failure has yet been
- * detected.
+ * A return value of null indicates that no system failure has yet been detected.
* <p>
- * Object synchronization can implicitly require object creation (fat locks
- * in JRockit for instance), so the underlying value is not synchronized
- * (it is a volatile). This means the return value from this call is not
- * necessarily the <em>first</em> failure reported by the JVM.
+ * Object synchronization can implicitly require object creation (fat locks in JRockit for
+ * instance), so the underlying value is not synchronized (it is a volatile). This means the
+ * return value from this call is not necessarily the <em>first</em> failure reported by the JVM.
* <p>
- * Note that even if it <em>were</em> synchronized, it would only be a
- * proximal indicator near the time that the JVM crashed, and may not
- * actually reflect the underlying root cause that generated the failure.
- * For instance, if your JVM is running short of memory, this Throwable is
- * probably an innocent victim and <em>not</em> the actual allocation (or
- * series of allocations) that caused your JVM to exhaust memory.
+ * Note that even if it <em>were</em> synchronized, it would only be a proximal indicator near the
+ * time that the JVM crashed, and may not actually reflect the underlying root cause that
+ * generated the failure. For instance, if your JVM is running short of memory, this Throwable is
+ * probably an innocent victim and <em>not</em> the actual allocation (or series of allocations)
+ * that caused your JVM to exhaust memory.
* <p>
- * If this function returns a non-null value, keep in mind that the JVM is
- * very limited. In particular, any attempt to allocate objects may fail
- * if the original failure was an OutOfMemoryError.
+ * If this function returns a non-null value, keep in mind that the JVM is very limited. In
+ * particular, any attempt to allocate objects may fail if the original failure was an
+ * OutOfMemoryError.
*
* @return the failure, if any
*/
@@ -1046,13 +1004,11 @@ public final class SystemFailure {
}
/**
- * Sets a user-defined action that is run in the event
- * that failure has been detected.
- * <p>
- * This action is run <em>after</em> the GemFire cache has been shut down.
- * If it throws any error, it will be reattempted indefinitely until it
- * succeeds. This action may be dynamically modified while the system
- * is running.
+ * Sets a user-defined action that is run in the event that failure has been detected.
+ * <p>
+ * This action is run <em>after</em> the GemFire cache has been shut down. If it throws any error,
+ * it will be reattempted indefinitely until it succeeds. This action may be dynamically modified
+ * while the system is running.
* <p>
* The default action prints the failure stack trace to System.err.
*
@@ -1067,12 +1023,11 @@ public final class SystemFailure {
}
/**
- * Set the memory threshold under which system failure will be
- * notified.
+ * Set the memory threshold under which system failure will be notified.
*
- * This value may be dynamically modified while the system
- * is running. The default is 1048576 bytes. This can be set using the
- * system property <code>gemfire.SystemFailure.chronic_memory_threshold</code>.
+ * This value may be dynamically modified while the system is running. The default is 1048576
+ * bytes. This can be set using the system property
+ * <code>gemfire.SystemFailure.chronic_memory_threshold</code>.
*
* @param newVal threshold in bytes
* @return the old threshold
@@ -1088,39 +1043,39 @@ public final class SystemFailure {
startProctor(); // just in case
return result;
}
-
-// /**
-// * For use by GemStone Quality Assurance Only
-// *
-// * @deprecated TODO remove this
-// */
-// public static void reset() {
-// System.gc();
-// logWarning("DJP", "do not commit SystemFailure#reset", null);
-// failure = null;
-// failureAction = new Runnable() {
-// public void run() {
-// System.err.println("(SystemFailure) JVM corruption has been detected!");
-// failure.printStackTrace();
-// }
-// };
-// gemfireCloseCompleted = false;
-// failureActionCompleted = false;
-// synchronized (failureSync) {
-// if (watchDog != null) {
-// watchDog.interrupt();
-// }
-// watchDog = null;
-// if (watchCat != null) {
-// watchCat.interrupt();
-// }
-// watchCat = null;
-// }
-//
-// startWatchDog();
-// startWatchCat();
-// }
-
+
+ // /**
+ // * For use by GemStone Quality Assurance Only
+ // *
+ // * @deprecated TODO remove this
+ // */
+ // public static void reset() {
+ // System.gc();
+ // logWarning("DJP", "do not commit SystemFailure#reset", null);
+ // failure = null;
+ // failureAction = new Runnable() {
+ // public void run() {
+ // System.err.println("(SystemFailure) JVM corruption has been detected!");
+ // failure.printStackTrace();
+ // }
+ // };
+ // gemfireCloseCompleted = false;
+ // failureActionCompleted = false;
+ // synchronized (failureSync) {
+ // if (watchDog != null) {
+ // watchDog.interrupt();
+ // }
+ // watchDog = null;
+ // if (watchCat != null) {
+ // watchCat.interrupt();
+ // }
+ // watchCat = null;
+ // }
+ //
+ // startWatchDog();
+ // startWatchCat();
+ // }
+
static private boolean logStdErr(String kind, String name, String s, Throwable t) {
// As far as I can tell, this code path doesn't allocate
// any objects!!!!
@@ -1134,16 +1089,15 @@ public final class SystemFailure {
t.printStackTrace();
}
return true;
- }
- catch (Throwable t2) {
+ } catch (Throwable t2) {
// out of luck
return false;
}
}
-
+
/**
- * Logging can require allocation of objects, so we wrap the
- * logger so that failures are silently ignored.
+ * Logging can require allocation of objects, so we wrap the logger so that failures are silently
+ * ignored.
*
* @param s string to print
* @param t the call stack, if any
@@ -1151,41 +1105,41 @@ public final class SystemFailure {
*/
static protected boolean logWarning(String name, String s, Throwable t) {
return logStdErr("warning", name, s, t);
-// if (PREFER_STDERR) {
-// return logStdErr("warning", name, s, t);
-// }
-// try {
-// log.warning(name + ": " + s, t);
-// return true;
-// }
-// catch (Throwable t2) {
-// return logStdErr("warning", name, s, t);
-// }
+ // if (PREFER_STDERR) {
+ // return logStdErr("warning", name, s, t);
+ // }
+ // try {
+ // log.warning(name + ": " + s, t);
+ // return true;
+ // }
+ // catch (Throwable t2) {
+ // return logStdErr("warning", name, s, t);
+ // }
}
-
+
/**
- * Logging can require allocation of objects, so we wrap the
- * logger so that failures are silently ignored.
+ * Logging can require allocation of objects, so we wrap the logger so that failures are silently
+ * ignored.
*
* @param s string to print
*/
static protected void logInfo(String name, String s) {
logStdErr("info", name, s, null);
-// if (PREFER_STDERR) {
-// logStdErr("info", name, s, null);
-// return;
-// }
-// try {
-// log.info(name + ": " + s);
-// }
-// catch (Throwable t) {
-// logStdErr("info", name, s, t);
-// }
+ // if (PREFER_STDERR) {
+ // logStdErr("info", name, s, null);
+ // return;
+ // }
+ // try {
+ // log.info(name + ": " + s);
+ // }
+ // catch (Throwable t) {
+ // logStdErr("info", name, s, t);
+ // }
}
-
+
/**
- * Logging can require allocation of objects, so we wrap the
- * logger so that failures are silently ignored.
+ * Logging can require allocation of objects, so we wrap the logger so that failures are silently
+ * ignored.
*
* @param s string to print
*/
@@ -1193,34 +1147,34 @@ public final class SystemFailure {
if (DEBUG) {
logStdErr("fine", name, s, null);
}
-// if (DEBUG && PREFER_STDERR) {
-// logStdErr("fine", name, s, null);
-// return;
-// }
-// try {
-// log.fine(name + ": " + s);
-// }
-// catch (Throwable t) {
-// if (DEBUG) {
-// logStdErr("fine", name, s, null);
-// }
-// }
+ // if (DEBUG && PREFER_STDERR) {
+ // logStdErr("fine", name, s, null);
+ // return;
+ // }
+ // try {
+ // log.fine(name + ": " + s);
+ // }
+ // catch (Throwable t) {
+ // if (DEBUG) {
+ // logStdErr("fine", name, s, null);
+ // }
+ // }
}
-
+
private static volatile boolean stopping;
-
+
/**
- * This starts up the watchdog and proctor threads.
- * This method is called when a Cache is created.
+ * This starts up the watchdog and proctor threads. This method is called when a Cache is created.
*/
public static void startThreads() {
stopping = false;
startWatchDog();
startProctor();
}
+
/**
- * This stops the threads that implement this service.
- * This method is called when a Cache is closed.
+ * This stops the threads that implement this service. This method is called when a Cache is
+ * closed.
*/
public static void stopThreads() {
// this method fixes bug 45409
@@ -1228,11 +1182,11 @@ public final class SystemFailure {
stopProctor();
stopWatchDog();
}
-
+
static Thread getWatchDogForTest() {
return watchDog;
}
-
+
static Thread getProctorForTest() {
return proctor;
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/SystemIsRunningException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/SystemIsRunningException.java b/geode-core/src/main/java/org/apache/geode/SystemIsRunningException.java
index 06dd0c7..1a4d2d9 100644
--- a/geode-core/src/main/java/org/apache/geode/SystemIsRunningException.java
+++ b/geode-core/src/main/java/org/apache/geode/SystemIsRunningException.java
@@ -1,34 +1,32 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
/**
- * A <code>SystemIsRunningException</code> is thrown when an operation
- * is attempted that requires that the locator is stopped.
+ * A <code>SystemIsRunningException</code> is thrown when an operation is attempted that requires
+ * that the locator is stopped.
* <p>
- * In some cases this exception may be thrown and the locator will
- * not be running. This will happen if the locator was not stopped
- * cleanly.
- * <p>As of GemFire 5.0 this exception should be named LocatorIsRunningException.
+ * In some cases this exception may be thrown and the locator will not be running. This will happen
+ * if the locator was not stopped cleanly.
+ * <p>
+ * As of GemFire 5.0 this exception should be named LocatorIsRunningException.
*/
public class SystemIsRunningException extends GemFireException {
-private static final long serialVersionUID = 3516268055878767189L;
+ private static final long serialVersionUID = 3516268055878767189L;
- ////////////////////// Constructors //////////////////////
+ ////////////////////// Constructors //////////////////////
/**
* Creates a new <code>SystemIsRunningException</code>.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/ThreadInterruptedException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/ThreadInterruptedException.java b/geode-core/src/main/java/org/apache/geode/ThreadInterruptedException.java
index 373cead..ae341f5 100644
--- a/geode-core/src/main/java/org/apache/geode/ThreadInterruptedException.java
+++ b/geode-core/src/main/java/org/apache/geode/ThreadInterruptedException.java
@@ -1,18 +1,16 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
@@ -22,10 +20,11 @@ package org.apache.geode;
@Deprecated
public final class ThreadInterruptedException extends CancelException {
-private static final long serialVersionUID = 6169940883541267514L;
+ private static final long serialVersionUID = 6169940883541267514L;
+
/**
* Do not create instances of this class
*/
- private ThreadInterruptedException() { }
-
+ private ThreadInterruptedException() {}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/ToDataException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/ToDataException.java b/geode-core/src/main/java/org/apache/geode/ToDataException.java
index e602f3c..a0055a5 100644
--- a/geode-core/src/main/java/org/apache/geode/ToDataException.java
+++ b/geode-core/src/main/java/org/apache/geode/ToDataException.java
@@ -1,41 +1,39 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
/**
- * A <code>ToDataException</code> is thrown during serialization if
- * {@link DataSerializable#toData} throws an exception or if
- * {@link DataSerializer#toData} is called and returns false.
+ * A <code>ToDataException</code> is thrown during serialization if {@link DataSerializable#toData}
+ * throws an exception or if {@link DataSerializer#toData} is called and returns false.
*
* @since GemFire 6.5
*/
public class ToDataException extends SerializationException {
private static final long serialVersionUID = -2329606027453879918L;
+
/**
* Creates a new <code>ToDataException</code> with the given message
*/
public ToDataException(String message) {
- super(message);
+ super(message);
}
+
/**
- * Creates a new <code>ToDataException</code> with the given message
- * and cause.
+ * Creates a new <code>ToDataException</code> with the given message and cause.
*/
public ToDataException(String message, Throwable cause) {
- super(message, cause);
+ super(message, cause);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/UncreatedSystemException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/UncreatedSystemException.java b/geode-core/src/main/java/org/apache/geode/UncreatedSystemException.java
index 685e8fc..2cc94db 100644
--- a/geode-core/src/main/java/org/apache/geode/UncreatedSystemException.java
+++ b/geode-core/src/main/java/org/apache/geode/UncreatedSystemException.java
@@ -1,36 +1,35 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
/**
- * An <code>UncreatedSystemException</code> is thrown when the specified
- * locator's directory or configuration file can not be found.
+ * An <code>UncreatedSystemException</code> is thrown when the specified locator's directory or
+ * configuration file can not be found.
* <p>
* The most likely reasons for this are:
* <ul>
- * <li> The wrong locator directory was given.
- * <li> The locator was deleted or never created.
+ * <li>The wrong locator directory was given.
+ * <li>The locator was deleted or never created.
* </ul>
- * <p>As of GemFire 5.0 this exception should be named UncreatedLocatorException.
+ * <p>
+ * As of GemFire 5.0 this exception should be named UncreatedLocatorException.
*/
public class UncreatedSystemException extends NoSystemException {
-private static final long serialVersionUID = 5424354567878425435L;
+ private static final long serialVersionUID = 5424354567878425435L;
- ////////////////////// Constructors //////////////////////
+ ////////////////////// Constructors //////////////////////
/**
* Creates a new <code>UncreatedSystemException</code>.
@@ -38,11 +37,11 @@ private static final long serialVersionUID = 5424354567878425435L;
public UncreatedSystemException(String message) {
super(message);
}
+
/**
- * Creates a new <code>UncreatedSystemException</code> with the given message
- * and cause.
+ * Creates a new <code>UncreatedSystemException</code> with the given message and cause.
*/
public UncreatedSystemException(String message, Throwable cause) {
- super(message, cause);
+ super(message, cause);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/UnmodifiableException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/UnmodifiableException.java b/geode-core/src/main/java/org/apache/geode/UnmodifiableException.java
index 640629c..4b602e6 100644
--- a/geode-core/src/main/java/org/apache/geode/UnmodifiableException.java
+++ b/geode-core/src/main/java/org/apache/geode/UnmodifiableException.java
@@ -1,31 +1,28 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
/**
- * A <code>UnmodifiableException</code> is thrown when a
- * an attempt is made to modify a GemFire member configuration attribute
- * that can not currently be modified. In most cases the reason it can
- * not be modified is that the member is active.
+ * A <code>UnmodifiableException</code> is thrown when a an attempt is made to modify a GemFire
+ * member configuration attribute that can not currently be modified. In most cases the reason it
+ * can not be modified is that the member is active.
*/
public class UnmodifiableException extends GemFireException {
-private static final long serialVersionUID = -1043243260052395455L;
+ private static final long serialVersionUID = -1043243260052395455L;
- ////////////////////// Constructors //////////////////////
+ ////////////////////// Constructors //////////////////////
/**
* Creates a new <code>UnmodifiableException</code>.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/UnstartedSystemException.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/UnstartedSystemException.java b/geode-core/src/main/java/org/apache/geode/UnstartedSystemException.java
index c390089..438983a 100644
--- a/geode-core/src/main/java/org/apache/geode/UnstartedSystemException.java
+++ b/geode-core/src/main/java/org/apache/geode/UnstartedSystemException.java
@@ -1,37 +1,36 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode;
/**
- * An <code>UnstartedSystemException</code> is thrown when the specified
- * locator exists but is not running or could not be connected to.
+ * An <code>UnstartedSystemException</code> is thrown when the specified locator exists but is not
+ * running or could not be connected to.
* <p>
* The most likely reasons for this are:
* <ul>
- * <li> The locator has not completely started.
- * <li> The locator is stopping.
- * <li> The locator died or was killed.
+ * <li>The locator has not completely started.
+ * <li>The locator is stopping.
+ * <li>The locator died or was killed.
* </ul>
- * <p>As of GemFire 5.0 this exception should be named UnstartedLocatorException.
+ * <p>
+ * As of GemFire 5.0 this exception should be named UnstartedLocatorException.
*/
public class UnstartedSystemException extends NoSystemException {
-private static final long serialVersionUID = -4285897556527521788L;
+ private static final long serialVersionUID = -4285897556527521788L;
- ////////////////////// Constructors //////////////////////
+ ////////////////////// Constructors //////////////////////
/**
* Creates a new <code>UnstartedSystemException</code>.
@@ -39,11 +38,11 @@ private static final long serialVersionUID = -4285897556527521788L;
public UnstartedSystemException(String message) {
super(message);
}
+
/**
- * Creates a new <code>UnstartedSystemException</code> with the given message
- * and cause.
+ * Creates a new <code>UnstartedSystemException</code> with the given message and cause.
*/
public UnstartedSystemException(String message, Throwable cause) {
- super(message, cause);
+ super(message, cause);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/AdminConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/AdminConfig.java b/geode-core/src/main/java/org/apache/geode/admin/AdminConfig.java
index ec5ed73..7a4bd6a 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/AdminConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/AdminConfig.java
@@ -1,18 +1,16 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
*/
package org.apache.geode.admin;
@@ -29,24 +27,23 @@ import java.util.Date;
/**
- * AdminConfig loads/stores the member information list. The list contains
- * all of the members being monitored.
+ * AdminConfig loads/stores the member information list. The list contains all of the members being
+ * monitored.
*
* Config must be of the format:
* <p>
- * <li> Name=What you want displayed as a name for the instance
- * <li> Type=SERVER|CLIENT
- * <li> Host=A valid hostname or IP Address where the instance is
- * running
- * <li> Port=The port you are using to open the monitor port for
- * the instance
- * @deprecated as of 7.0 use the <code><a href="{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code> package instead
+ * <li>Name=What you want displayed as a name for the instance
+ * <li>Type=SERVER|CLIENT
+ * <li>Host=A valid hostname or IP Address where the instance is running
+ * <li>Port=The port you are using to open the monitor port for the instance
+ *
+ * @deprecated as of 7.0 use the <code><a href=
+ * "{@docRoot}/org/apache/geode/management/package-summary.html">management</a></code>
+ * package instead
*/
-public class AdminConfig
-{
+public class AdminConfig {
// Name, Type, Host, Port
- public static Entry[] loadConfig(File file) throws IOException
- {
+ public static Entry[] loadConfig(File file) throws IOException {
// Place all lines into stack
ArrayList entryList = new ArrayList();
@@ -65,17 +62,16 @@ public class AdminConfig
line = line.replace('\t', ' ');
// Skip all empty and comment lines
- if (line.length() != 0 && line.startsWith("#") == false) {
- try {
- entryList.add(new Entry(line));
- } catch (Exception ex) {
- // ignore - drop any lines that are not valid
- }
+ if (line.length() != 0 && line.startsWith("#") == false) {
+ try {
+ entryList.add(new Entry(line));
+ } catch (Exception ex) {
+ // ignore - drop any lines that are not valid
}
- line = fileReader.readLine();
+ }
+ line = fileReader.readLine();
}
- }
- finally {
+ } finally {
if (fileReader != null) {
fileReader.close();
}
@@ -84,20 +80,21 @@ public class AdminConfig
}
}
- return (Entry[])entryList.toArray(new Entry[0]);
+ return (Entry[]) entryList.toArray(new Entry[0]);
}
- public static void storeConfig(File file, AdminConfig.Entry entries[]) throws IOException
- {
+ public static void storeConfig(File file, AdminConfig.Entry entries[]) throws IOException {
FileOutputStream fos = null;
PrintStream ps = null;
try {
fos = new FileOutputStream(file);
ps = new PrintStream(fos);
-
+
// Header
ps.print("#");
- ps.println(LocalizedStrings.AdminConfig_THIS_FILE_IS_GENERATED_BY_ADMINCONSOLE_EDIT_AS_YOU_WISH_BUT_IT_WILL_BE_OVERWRITTEN_IF_IT_IS_MODIFIED_IN_ADMINCONSOLE.toLocalizedString());
+ ps.println(
+ LocalizedStrings.AdminConfig_THIS_FILE_IS_GENERATED_BY_ADMINCONSOLE_EDIT_AS_YOU_WISH_BUT_IT_WILL_BE_OVERWRITTEN_IF_IT_IS_MODIFIED_IN_ADMINCONSOLE
+ .toLocalizedString());
ps.println("#");
ps.println(LocalizedStrings.AdminConfig_MODIFIED_0.toLocalizedString(new Date()));
ps.println("#");
@@ -108,8 +105,7 @@ public class AdminConfig
ps.println(entries[i].toString());
}
ps.flush();
- }
- finally {
+ } finally {
if (ps != null) {
ps.close();
}
@@ -120,27 +116,24 @@ public class AdminConfig
}
- public static class Entry
- {
+ public static class Entry {
public String name;
public String type;
public String host;
public int port;
- public Entry(String line)
- {
- // Split
- String split[] = line.split(",");
+ public Entry(String line) {
+ // Split
+ String split[] = line.split(",");
- // Convert line to parameters
- name = split[0].trim();
- type = split[1].trim();
- host = split[2].trim();
- port = Integer.parseInt(split[3]);
+ // Convert line to parameters
+ name = split[0].trim();
+ type = split[1].trim();
+ host = split[2].trim();
+ port = Integer.parseInt(split[3]);
}
- public Entry(String name, String type, String host, int port)
- {
+ public Entry(String name, String type, String host, int port) {
this.name = name;
this.type = type;
this.host = host;
@@ -148,8 +141,7 @@ public class AdminConfig
}
@Override // GemStoneAddition
- public String toString()
- {
+ public String toString() {
return name + "," + type + "," + host + "," + port;
}
}