You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2016/10/28 21:40:28 UTC
[14/98] [abbrv] [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/admin/jmx/internal/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java
index b87792d..6a1bd63 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.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.jmx.internal;
@@ -55,18 +53,19 @@ import org.apache.geode.internal.util.IOUtils;
import org.apache.geode.internal.util.JavaCommandBuilder;
/**
- * A command line utility inspired by the <code>CacheServerLauncher</code> that is responsible for administering
- * a stand-along GemFire JMX {@link Agent}.
+ * A command line utility inspired by the <code>CacheServerLauncher</code> that is responsible for
+ * administering a stand-along GemFire JMX {@link Agent}.
* <p/>
+ *
* @since GemFire 3.5
*/
public class AgentLauncher {
private static final Logger logger = LogService.getLogger();
-
+
/** Should the launch command be printed? */
- public static final boolean PRINT_LAUNCH_COMMAND = Boolean.getBoolean(AgentLauncher.class.getSimpleName()
- + ".PRINT_LAUNCH_COMMAND");
+ public static final boolean PRINT_LAUNCH_COMMAND =
+ Boolean.getBoolean(AgentLauncher.class.getSimpleName() + ".PRINT_LAUNCH_COMMAND");
/* constants used to define state */
static final int SHUTDOWN = 0;
@@ -79,7 +78,10 @@ public class AgentLauncher {
/** Agent configuration options */
static final String AGENT_PROPS = "agent-props";
- /** A flag to indicate if the current log file should be kept. Used only when 'start' is used to fork off the 'server' */
+ /**
+ * A flag to indicate if the current log file should be kept. Used only when 'start' is used to
+ * fork off the 'server'
+ */
static final String APPENDTO_LOG_FILE = "appendto-log-file";
/** optional and additional classpath entries */
@@ -107,10 +109,11 @@ public class AgentLauncher {
private final String statusFileName;
/**
- * Instantiates an AgentLauncher for execution and control of the GemFire JMX Agent process. This constructor is
- * package private to prevent direct instantiation or subclassing by classes outside this package, but does allow
- * the class to be tested as needed.
+ * Instantiates an AgentLauncher for execution and control of the GemFire JMX Agent process. This
+ * constructor is package private to prevent direct instantiation or subclassing by classes
+ * outside this package, but does allow the class to be tested as needed.
* <p/>
+ *
* @param basename base name for the application to be launched
*/
AgentLauncher(final String basename) {
@@ -135,15 +138,17 @@ public class AgentLauncher {
SortedMap<String, String> map = new TreeMap<String, String>();
int maxLength = 0;
- for (Iterator<Object> iter = props.keySet().iterator(); iter.hasNext(); ) {
+ for (Iterator<Object> iter = props.keySet().iterator(); iter.hasNext();) {
String prop = (String) iter.next();
int length = prop.length();
if (length > maxLength) {
maxLength = length;
}
- map.put(prop, AgentConfigImpl.getPropertyDescription(prop) +
- " (" + LocalizedStrings.AgentLauncher_DEFAULT.toLocalizedString() + " \"" + props.getProperty(prop) + "\")");
+ map.put(prop,
+ AgentConfigImpl.getPropertyDescription(prop) + " ("
+ + LocalizedStrings.AgentLauncher_DEFAULT.toLocalizedString() + " \""
+ + props.getProperty(prop) + "\")");
}
Iterator<Entry<String, String>> entries = map.entrySet().iterator();
@@ -175,8 +180,8 @@ public class AgentLauncher {
}
/**
- * Returns a map that maps the name of the start options to its value on the command line. If no value is
- * specified on the command line, a default one is provided.
+ * Returns a map that maps the name of the start options to its value on the command line. If no
+ * value is specified on the command line, a default one is provided.
*/
protected Map<String, Object> getStartOptions(final String[] args) throws Exception {
final Map<String, Object> options = new HashMap<String, Object>();
@@ -193,21 +198,18 @@ public class AgentLauncher {
for (final String arg : args) {
if (arg.startsWith("-classpath=")) {
options.put(CLASSPATH, arg.substring("-classpath=".length()));
- }
- else if (arg.startsWith("-dir=")) {
+ } else if (arg.startsWith("-dir=")) {
final File workingDirectory = processDirOption(options, arg.substring("-dir=".length()));
System.setProperty(AgentConfigImpl.AGENT_PROPSFILE_PROPERTY_NAME,
- new File(workingDirectory, AgentConfig.DEFAULT_PROPERTY_FILE).getPath());
- }
- else if (arg.startsWith("-J")) {
+ new File(workingDirectory, AgentConfig.DEFAULT_PROPERTY_FILE).getPath());
+ } else if (arg.startsWith("-J")) {
vmArgs.add(arg.substring(2));
- }
- else if (arg.contains("=")) {
+ } else if (arg.contains("=")) {
final int index = arg.indexOf("=");
final String prop = arg.substring(0, index);
final String value = arg.substring(index + 1);
- // if appendto-log-file is set, put it in options; it is not set as an agent prop
+ // if appendto-log-file is set, put it in options; it is not set as an agent prop
if (prop.equals(APPENDTO_LOG_FILE)) {
options.put(APPENDTO_LOG_FILE, value);
continue;
@@ -216,16 +218,21 @@ public class AgentLauncher {
// verify the property is valid
AgentConfigImpl.getPropertyDescription(prop);
- // Note, the gfAgentPropertyFile System property is ultimately read in the constructor of the AgentImpl class
- // in order to make any properties defined in this file not only accessible to the DistributedSystem but to
+ // Note, the gfAgentPropertyFile System property is ultimately read in the constructor of
+ // the AgentImpl class
+ // in order to make any properties defined in this file not only accessible to the
+ // DistributedSystem but to
// the GemFire Agent as well.
if (AgentConfigImpl.PROPERTY_FILE_NAME.equals(prop)) {
System.setProperty(AgentConfigImpl.AGENT_PROPSFILE_PROPERTY_NAME, value);
}
- // The Agent properties file (specified with the command-line key=value) is used to pass configuration settings
- // to the GemFire DistributedSystem. A property file can be passed using the property-file command-line switch
- // is a large number of properties are specified, or the properties maybe individually specified on the
+ // The Agent properties file (specified with the command-line key=value) is used to pass
+ // configuration settings
+ // to the GemFire DistributedSystem. A property file can be passed using the property-file
+ // command-line switch
+ // is a large number of properties are specified, or the properties maybe individually
+ // specified on the
// command-line as property=value arguments.
agentProps.setProperty(prop, value);
}
@@ -235,21 +242,24 @@ public class AgentLauncher {
}
/**
- * After parsing the command line arguments, spawn the Java VM that will host the GemFire JMX Agent.
+ * After parsing the command line arguments, spawn the Java VM that will host the GemFire JMX
+ * Agent.
*/
public void start(final String[] args) throws Exception {
final Map<String, Object> options = getStartOptions(args);
workingDirectory = IOUtils.tryGetCanonicalFileElseGetAbsoluteFile((File) options.get(DIR));
- // verify that any GemFire JMX Agent process has been properly shutdown and delete any remaining status files...
+ // verify that any GemFire JMX Agent process has been properly shutdown and delete any remaining
+ // status files...
verifyAndClearStatus();
// start the GemFire JMX Agent process...
runCommandLine(options, buildCommandLine(options));
// wait for the GemFire JMX Agent process to complete startup and begin running...
- // it is also possible the Agent process may fail to start, so this should not wait indefinitely unless
+ // it is also possible the Agent process may fail to start, so this should not wait indefinitely
+ // unless
// the status file was not successfully written to
pollAgentUntilRunning();
@@ -260,15 +270,16 @@ public class AgentLauncher {
final Status status = getStatus();
if (status != null && status.state != SHUTDOWN) {
- throw new IllegalStateException(LocalizedStrings.AgentLauncher_JMX_AGENT_EXISTS_BUT_WAS_NOT_SHUTDOWN.toLocalizedString());
+ throw new IllegalStateException(
+ LocalizedStrings.AgentLauncher_JMX_AGENT_EXISTS_BUT_WAS_NOT_SHUTDOWN.toLocalizedString());
}
deleteStatus();
}
private String[] buildCommandLine(final Map<String, Object> options) {
- final List<String> commands = JavaCommandBuilder.buildCommand(AgentLauncher.class.getName(), (String) options.get(CLASSPATH), null,
- (List<String>) options.get(VMARGS));
+ final List<String> commands = JavaCommandBuilder.buildCommand(AgentLauncher.class.getName(),
+ (String) options.get(CLASSPATH), null, (List<String>) options.get(VMARGS));
commands.add("server");
commands.add("-dir=" + workingDirectory);
@@ -293,14 +304,16 @@ public class AgentLauncher {
}
}
- private int runCommandLine(final Map<String, Object> options, final String[] commandLine) throws IOException {
- // initialize the startup log starting with a fresh log file (where all startup messages are printed)
- final File startLogFile = IOUtils.tryGetCanonicalFileElseGetAbsoluteFile(
- new File(workingDirectory, startLogFileName));
+ private int runCommandLine(final Map<String, Object> options, final String[] commandLine)
+ throws IOException {
+ // initialize the startup log starting with a fresh log file (where all startup messages are
+ // printed)
+ final File startLogFile = IOUtils
+ .tryGetCanonicalFileElseGetAbsoluteFile(new File(workingDirectory, startLogFileName));
if (startLogFile.exists() && !startLogFile.delete()) {
- throw new IOException(LocalizedStrings.AgentLauncher_UNABLE_TO_DELETE_FILE_0.toLocalizedString(
- startLogFile.getAbsolutePath()));
+ throw new IOException(LocalizedStrings.AgentLauncher_UNABLE_TO_DELETE_FILE_0
+ .toLocalizedString(startLogFile.getAbsolutePath()));
}
Map<String, String> env = new HashMap<String, String>();
@@ -311,7 +324,8 @@ public class AgentLauncher {
final int pid = OSProcess.bgexec(commandLine, workingDirectory, startLogFile, false, env);
- System.out.println(LocalizedStrings.AgentLauncher_STARTING_JMX_AGENT_WITH_PID_0.toLocalizedString(pid));
+ System.out.println(
+ LocalizedStrings.AgentLauncher_STARTING_JMX_AGENT_WITH_PID_0.toLocalizedString(pid));
return pid;
}
@@ -319,10 +333,13 @@ public class AgentLauncher {
private void pollAgentUntilRunning() throws Exception {
Status status = spinReadStatus();
- // TODO this loop could recurse indefinitely if the GemFire JMX Agent's state never changes from STARTING
- // to something else (like RUNNING), which could happen if server process fails to startup correctly
+ // TODO this loop could recurse indefinitely if the GemFire JMX Agent's state never changes from
+ // STARTING
+ // to something else (like RUNNING), which could happen if server process fails to startup
+ // correctly
// and did not or could not write to the status file!
- // TODO should we really allow the InterruptedException from the Thread.sleep call to break this loop (yeah, I
+ // TODO should we really allow the InterruptedException from the Thread.sleep call to break this
+ // loop (yeah, I
// think so given the fact this could loop indefinitely)?
while (status != null && status.state == STARTING) {
Thread.sleep(500);
@@ -332,8 +349,7 @@ public class AgentLauncher {
if (status == null) {
// TODO throw a more appropriate Exception here!
throw new Exception(LocalizedStrings.AgentLauncher_NO_AVAILABLE_STATUS.toLocalizedString());
- }
- else {
+ } else {
System.out.println(status);
}
}
@@ -370,21 +386,23 @@ public class AgentLauncher {
}
// LOG:TODO: redirectOutput called here
- OSProcess.redirectOutput(new File(config.getLogFile())); // redirect output to the configured log file
+ OSProcess.redirectOutput(new File(config.getLogFile())); // redirect output to the configured
+ // log file
return AgentFactory.getAgent(config);
}
private ThreadGroup createAgentProcessThreadGroup() {
return new ThreadGroup(LocalizedStrings.AgentLauncher_STARTING_AGENT.toLocalizedString()) {
- @Override
- public void uncaughtException(final Thread t, final Throwable e) {
- if (e instanceof VirtualMachineError) {
- SystemFailure.setFailure((VirtualMachineError) e);
- }
- setServerError(LocalizedStrings.AgentLauncher_UNCAUGHT_EXCEPTION_IN_THREAD_0.toLocalizedString(t.getName()), e);
+ @Override
+ public void uncaughtException(final Thread t, final Throwable e) {
+ if (e instanceof VirtualMachineError) {
+ SystemFailure.setFailure((VirtualMachineError) e);
}
- };
+ setServerError(LocalizedStrings.AgentLauncher_UNCAUGHT_EXCEPTION_IN_THREAD_0
+ .toLocalizedString(t.getName()), e);
+ }
+ };
}
private Thread createAgentProcessThread(final ThreadGroup group, final Agent agent) {
@@ -397,18 +415,17 @@ public class AgentLauncher {
try {
agent.start();
writeStatus(createStatus(AgentLauncher.this.basename, RUNNING, OSProcess.getId()));
- }
- catch (IOException e) {
+ } catch (IOException e) {
e.printStackTrace();
- }
- catch (GemFireException e) {
+ } catch (GemFireException e) {
e.printStackTrace();
handleGemFireException(e);
}
}
private void handleGemFireException(final GemFireException e) {
- String message = LocalizedStrings.AgentLauncher_SERVER_FAILED_TO_START_0.toLocalizedString(e.getMessage());
+ String message = LocalizedStrings.AgentLauncher_SERVER_FAILED_TO_START_0
+ .toLocalizedString(e.getMessage());
if (e.getCause() != null) {
if (e.getCause().getCause() != null) {
@@ -427,9 +444,9 @@ public class AgentLauncher {
*/
private void setServerError(final String message, final Throwable cause) {
try {
- writeStatus(createStatus(this.basename, SHUTDOWN_PENDING_AFTER_FAILED_STARTUP, OSProcess.getId(), message, cause));
- }
- catch (Exception e) {
+ writeStatus(createStatus(this.basename, SHUTDOWN_PENDING_AFTER_FAILED_STARTUP,
+ OSProcess.getId(), message, cause));
+ } catch (Exception e) {
logger.fatal(e.getMessage(), e);
System.exit(1);
}
@@ -450,9 +467,8 @@ public class AgentLauncher {
}
/**
- * Extracts configuration information for stopping a agent based on the
- * contents of the command line. This method can also be used with getting
- * the status of a agent.
+ * Extracts configuration information for stopping a agent based on the contents of the command
+ * line. This method can also be used with getting the status of a agent.
*/
protected Map<String, Object> getStopOptions(final String[] args) throws Exception {
final Map<String, Object> options = new HashMap<String, Object>();
@@ -462,12 +478,11 @@ public class AgentLauncher {
for (final String arg : args) {
if (arg.equals("stop") || arg.equals("status")) {
// expected
- }
- else if (arg.startsWith("-dir=")) {
+ } else if (arg.startsWith("-dir=")) {
processDirOption(options, arg.substring("-dir=".length()));
- }
- else {
- throw new Exception(LocalizedStrings.AgentLauncher_UNKNOWN_ARGUMENT_0.toLocalizedString(arg));
+ } else {
+ throw new Exception(
+ LocalizedStrings.AgentLauncher_UNKNOWN_ARGUMENT_0.toLocalizedString(arg));
}
}
@@ -494,18 +509,19 @@ public class AgentLauncher {
pollAgentForShutdown();
if (isStatus(SHUTDOWN)) {
- System.out.println(LocalizedStrings.AgentLauncher_0_HAS_STOPPED.toLocalizedString(this.basename));
+ System.out
+ .println(LocalizedStrings.AgentLauncher_0_HAS_STOPPED.toLocalizedString(this.basename));
deleteStatus();
exitStatus = 0;
+ } else {
+ System.out
+ .println(LocalizedStrings.AgentLauncher_TIMEOUT_WAITING_FOR_0_TO_SHUTDOWN_STATUS_IS_1
+ .toLocalizedString(this.basename, status));
}
- else {
- System.out.println(LocalizedStrings.AgentLauncher_TIMEOUT_WAITING_FOR_0_TO_SHUTDOWN_STATUS_IS_1
- .toLocalizedString(this.basename, status));
- }
- }
- else {
- System.out.println(LocalizedStrings.AgentLauncher_THE_SPECIFIED_WORKING_DIRECTORY_0_CONTAINS_NO_STATUS_FILE
- .toLocalizedString(workingDirectory));
+ } else {
+ System.out.println(
+ LocalizedStrings.AgentLauncher_THE_SPECIFIED_WORKING_DIRECTORY_0_CONTAINS_NO_STATUS_FILE
+ .toLocalizedString(workingDirectory));
}
System.exit(exitStatus);
@@ -526,7 +542,8 @@ public class AgentLauncher {
* Prints the status of the GemFire JMX Agent running in the configured working directory.
*/
public void status(final String[] args) throws Exception {
- this.workingDirectory = IOUtils.tryGetCanonicalFileElseGetAbsoluteFile((File) getStopOptions(args).get(DIR));
+ this.workingDirectory =
+ IOUtils.tryGetCanonicalFileElseGetAbsoluteFile((File) getStopOptions(args).get(DIR));
System.out.println(getStatus());
System.exit(0);
}
@@ -539,24 +556,30 @@ public class AgentLauncher {
if (new File(workingDirectory, statusFileName).exists()) {
status = spinReadStatus();
- }
- else {
- status = createStatus(this.basename, SHUTDOWN, 0, LocalizedStrings.AgentLauncher_0_IS_NOT_RUNNING_IN_SPECIFIED_WORKING_DIRECTORY_1
- .toLocalizedString(this.basename, this.workingDirectory), null);
+ } else {
+ status = createStatus(this.basename, SHUTDOWN, 0,
+ LocalizedStrings.AgentLauncher_0_IS_NOT_RUNNING_IN_SPECIFIED_WORKING_DIRECTORY_1
+ .toLocalizedString(this.basename, this.workingDirectory),
+ null);
}
return status;
}
/**
- * Determines if the Status.state is one of the specified states in the given array of states. Note, the status
- * of the Agent, as indicated in the .agent.ser status file, should never have a written value of UNKNOWN.
+ * Determines if the Status.state is one of the specified states in the given array of states.
+ * Note, the status of the Agent, as indicated in the .agent.ser status file, should never have a
+ * written value of UNKNOWN.
* <p/>
- * @param states an array of possible acceptable states satisfying the condition of the Agent's status.
- * @return a boolean value indicating whether the Agent's status satisfies one of the specified states.
+ *
+ * @param states an array of possible acceptable states satisfying the condition of the Agent's
+ * status.
+ * @return a boolean value indicating whether the Agent's status satisfies one of the specified
+ * states.
*/
private boolean isStatus(final Integer... states) {
- return (this.status != null && Arrays.asList(defaultToUnknownStateIfNull(states)).contains(this.status.state));
+ return (this.status != null
+ && Arrays.asList(defaultToUnknownStateIfNull(states)).contains(this.status.state));
}
/**
@@ -571,12 +594,15 @@ public class AgentLauncher {
}
/**
- * Reads the GemFire JMX Agent's status from the status file (.agent.ser) in it's working directory.
+ * Reads the GemFire JMX Agent's status from the status file (.agent.ser) in it's working
+ * directory.
* <p/>
- * @return a Status object containing the state persisted to the .agent.ser file in the working directory
- * and representing the status of the Agent
+ *
+ * @return a Status object containing the state persisted to the .agent.ser file in the working
+ * directory and representing the status of the Agent
* @throws IOException if the status file was unable to be read.
- * @throws RuntimeException if the class of the object written to the .agent.ser file is not of type Status.
+ * @throws RuntimeException if the class of the object written to the .agent.ser file is not of
+ * type Status.
*/
protected Status readStatus() throws IOException {
FileInputStream fileIn = null;
@@ -587,22 +613,22 @@ public class AgentLauncher {
objectIn = new ObjectInputStream(fileIn);
this.status = (Status) objectIn.readObject();
return this.status;
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException(e);
- }
- finally {
+ } finally {
IOUtils.close(objectIn);
IOUtils.close(fileIn);
}
}
/**
- * A wrapper method for the readStatus method to make one last check for the GemFire JMX Agent process if running
- * with the native libraries.
- * @return the Status object as returned from readStatus unless running in native mode and a determination is made
- * such that the Agent process is not running.
- * @throws IOException if the state of the Agent process could not be read from the .agent.ser status file.
+ * A wrapper method for the readStatus method to make one last check for the GemFire JMX Agent
+ * process if running with the native libraries.
+ *
+ * @return the Status object as returned from readStatus unless running in native mode and a
+ * determination is made such that the Agent process is not running.
+ * @throws IOException if the state of the Agent process could not be read from the .agent.ser
+ * status file.
* @see #readStatus()
*/
protected Status nativeReadStatus() throws IOException {
@@ -617,11 +643,12 @@ public class AgentLauncher {
}
/**
- * Reads the JMX Agent's status from the .agent.ser status file. If the status file cannot be read due
- * to I/O problems, the method will keep attempting to read the file for up to 20 seconds.
+ * Reads the JMX Agent's status from the .agent.ser status file. If the status file cannot be read
+ * due to I/O problems, the method will keep attempting to read the file for up to 20 seconds.
* <p/>
- * @return the Status of the GemFire JMX Agent as determined by the .agent.ser status file, or natively
- * based on the presence/absence of the Agent process.
+ *
+ * @return the Status of the GemFire JMX Agent as determined by the .agent.ser status file, or
+ * natively based on the presence/absence of the Agent process.
*/
protected Status spinReadStatus() {
Status status = null;
@@ -632,15 +659,15 @@ public class AgentLauncher {
while (status == null && clock < endTime) {
try {
status = nativeReadStatus();
- }
- catch (Exception ignore) {
+ } catch (Exception ignore) {
// see bug 31575
// see bug 36998
- // try again after a short delay... the status file might have been read prematurely before it existed
- // or while the server was trying to write to it resulting in a possible EOFException, or other IOException.
+ // try again after a short delay... the status file might have been read prematurely before
+ // it existed
+ // or while the server was trying to write to it resulting in a possible EOFException, or
+ // other IOException.
pause(500);
- }
- finally {
+ } finally {
clock = System.currentTimeMillis();
}
}
@@ -649,9 +676,10 @@ public class AgentLauncher {
}
/**
- * Sets the status of the GemFire JMX Agent by serializing a <code>Status</code> object to a status file
- * in the Agent's working directory.
+ * Sets the status of the GemFire JMX Agent by serializing a <code>Status</code> object to a
+ * status file in the Agent's working directory.
* <p/>
+ *
* @param status the Status object representing the state of the Agent process to persist to disk.
* @return the written Status object.
* @throws IOException if the Status could not be successfully persisted to disk.
@@ -667,8 +695,7 @@ public class AgentLauncher {
objectOut.flush();
this.status = status;
return this.status;
- }
- finally {
+ } finally {
IOUtils.close(objectOut);
IOUtils.close(fileOut);
}
@@ -678,7 +705,8 @@ public class AgentLauncher {
return createStatus(basename, state, pid, null, null);
}
- protected static Status createStatus(final String basename, final int state, final int pid, final String msg, final Throwable t) {
+ protected static Status createStatus(final String basename, final int state, final int pid,
+ final String msg, final Throwable t) {
final Status status = new Status(basename);
status.state = state;
status.pid = pid;
@@ -693,26 +721,27 @@ public class AgentLauncher {
}
protected static Integer[] defaultToUnknownStateIfNull(final Integer... states) {
- return (states != null ? states : new Integer[] { UNKNOWN });
+ return (states != null ? states : new Integer[] {UNKNOWN});
}
protected static boolean pause(final int milliseconds) {
try {
Thread.sleep(milliseconds);
return true;
- }
- catch (InterruptedException e) {
+ } catch (InterruptedException e) {
Thread.currentThread().interrupt();
return false;
}
}
- protected static File processDirOption(final Map<String, Object> options, final String dirValue) throws FileNotFoundException {
+ protected static File processDirOption(final Map<String, Object> options, final String dirValue)
+ throws FileNotFoundException {
final File workingDirectory = new File(dirValue);
if (!workingDirectory.exists()) {
- throw new FileNotFoundException(LocalizedStrings.AgentLauncher_THE_INPUT_WORKING_DIRECTORY_DOES_NOT_EXIST_0
- .toLocalizedString(dirValue));
+ throw new FileNotFoundException(
+ LocalizedStrings.AgentLauncher_THE_INPUT_WORKING_DIRECTORY_DOES_NOT_EXIST_0
+ .toLocalizedString(dirValue));
}
options.put(DIR, workingDirectory);
@@ -723,6 +752,7 @@ public class AgentLauncher {
/**
* Prints usage information for the AgentLauncher to the command line.
* <p/>
+ *
* @param message a String to output to the command line indicating the user error.
*/
private static void usage(final String message) {
@@ -732,7 +762,7 @@ public class AgentLauncher {
out.println("agent start [-J<vmarg>]* [-dir=<dir>] [prop=value]*");
out.println(LocalizedStrings.AgentLauncher_STARTS_THE_GEMFIRE_JMX_AGENT.toLocalizedString());
- out.println("\t" + LocalizedStrings.AgentLauncher_VMARG.toLocalizedString() );
+ out.println("\t" + LocalizedStrings.AgentLauncher_VMARG.toLocalizedString());
out.println("\t" + LocalizedStrings.AgentLauncher_DIR.toLocalizedString());
out.println("\t" + LocalizedStrings.AgentLauncher_PROP.toLocalizedString());
out.println("\t" + LocalizedStrings.AgentLauncher_SEE_HELP_CONFIG.toLocalizedString());
@@ -743,7 +773,9 @@ public class AgentLauncher {
out.println("\t" + LocalizedStrings.AgentLauncher_DIR.toLocalizedString());
out.println("");
out.println("agent status [-dir=<dir>]");
- out.println(LocalizedStrings.AgentLauncher_REPORTS_THE_STATUS_AND_THE_PROCESS_ID_OF_A_GEMFIRE_JMX_AGENT.toLocalizedString());
+ out.println(
+ LocalizedStrings.AgentLauncher_REPORTS_THE_STATUS_AND_THE_PROCESS_ID_OF_A_GEMFIRE_JMX_AGENT
+ .toLocalizedString());
out.println("\t" + LocalizedStrings.AgentLauncher_DIR.toLocalizedString());
out.println();
@@ -751,15 +783,17 @@ public class AgentLauncher {
}
/**
- * Bootstrap method to launch the GemFire JMX Agent process to monitor and manage a GemFire Distributed System/Cache.
- * Main will read the arguments passed on the command line and dispatch the command to the appropriate handler.
+ * Bootstrap method to launch the GemFire JMX Agent process to monitor and manage a GemFire
+ * Distributed System/Cache. Main will read the arguments passed on the command line and dispatch
+ * the command to the appropriate handler.
*/
public static void main(final String[] args) {
if (args.length < 1) {
usage(LocalizedStrings.AgentLauncher_MISSING_COMMAND.toLocalizedString());
}
- // TODO is this only needed on 'agent server'? 'agent {start|stop|status}' technically do no run any GemFire Cache
+ // TODO is this only needed on 'agent server'? 'agent {start|stop|status}' technically do no run
+ // any GemFire Cache
// or DS code inside the current process.
SystemFailure.loadEmergencyClasses();
@@ -770,50 +804,45 @@ public class AgentLauncher {
if (command.equalsIgnoreCase("start")) {
launcher.start(args);
- }
- else if (command.equalsIgnoreCase("server")) {
+ } else if (command.equalsIgnoreCase("server")) {
launcher.server(args);
- }
- else if (command.equalsIgnoreCase("stop")) {
+ } else if (command.equalsIgnoreCase("stop")) {
launcher.stop(args);
- }
- else if (command.equalsIgnoreCase("status")) {
+ } else if (command.equalsIgnoreCase("status")) {
launcher.status(args);
- }
- else if (command.toLowerCase().matches("-{0,2}help")) {
+ } else if (command.toLowerCase().matches("-{0,2}help")) {
if (args.length > 1) {
final String topic = args[1];
if (topic.equals("config")) {
launcher.configHelp();
- }
- else {
+ } else {
usage(LocalizedStrings.AgentLauncher_NO_HELP_AVAILABLE_FOR_0.toLocalizedString(topic));
}
}
usage(LocalizedStrings.AgentLauncher_AGENT_HELP.toLocalizedString());
- }
- else {
+ } else {
usage(LocalizedStrings.AgentLauncher_UNKNOWN_COMMAND_0.toLocalizedString(command));
}
- }
- catch (VirtualMachineError e) {
+ } catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
- }
- catch (Throwable t) {
+ } catch (Throwable t) {
SystemFailure.checkFailure();
t.printStackTrace();
- System.err.println(LocalizedStrings.AgentLauncher_ERROR_0.toLocalizedString(t.getLocalizedMessage()));
+ System.err.println(
+ LocalizedStrings.AgentLauncher_ERROR_0.toLocalizedString(t.getLocalizedMessage()));
System.exit(1);
}
}
/**
- * A class representing the current state of the GemFire JMX Agent process. Instances of this class are serialized
- * to a {@linkplain #statusFileName file} on disk in the specified working directory {@linkplain #workingDirectory}.
+ * A class representing the current state of the GemFire JMX Agent process. Instances of this
+ * class are serialized to a {@linkplain #statusFileName file} on disk in the specified working
+ * directory {@linkplain #workingDirectory}.
* <p/>
+ *
* @see #SHUTDOWN
* @see #STARTING
* @see #RUNNING
@@ -844,9 +873,9 @@ public class AgentLauncher {
if (pid == Integer.MIN_VALUE && state == SHUTDOWN && msg != null) {
buffer.append(msg);
- }
- else {
- buffer.append(LocalizedStrings.AgentLauncher_0_PID_1_STATUS.toLocalizedString(this.baseName, pid));
+ } else {
+ buffer.append(
+ LocalizedStrings.AgentLauncher_0_PID_1_STATUS.toLocalizedString(this.baseName, pid));
switch (state) {
case SHUTDOWN:
@@ -862,7 +891,8 @@ public class AgentLauncher {
buffer.append(LocalizedStrings.AgentLauncher_SHUTDOWN_PENDING.toLocalizedString());
break;
case SHUTDOWN_PENDING_AFTER_FAILED_STARTUP:
- buffer.append(LocalizedStrings.AgentLauncher_SHUTDOWN_PENDING_AFTER_FAILED_STARTUP.toLocalizedString());
+ buffer.append(LocalizedStrings.AgentLauncher_SHUTDOWN_PENDING_AFTER_FAILED_STARTUP
+ .toLocalizedString());
break;
default:
buffer.append(LocalizedStrings.AgentLauncher_UNKNOWN.toLocalizedString());
@@ -872,12 +902,12 @@ public class AgentLauncher {
if (exception != null) {
if (msg != null) {
buffer.append("\n").append(msg).append(" - ");
- }
- else {
+ } else {
buffer.append("\n " + LocalizedStrings.AgentLauncher_EXCEPTION_IN_0_1
- .toLocalizedString(this.baseName, exception.getMessage()) + " - ");
+ .toLocalizedString(this.baseName, exception.getMessage()) + " - ");
}
- buffer.append(LocalizedStrings.AgentLauncher_SEE_LOG_FILE_FOR_DETAILS.toLocalizedString());
+ buffer
+ .append(LocalizedStrings.AgentLauncher_SEE_LOG_FILE_FOR_DETAILS.toLocalizedString());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/CacheServerJmxImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/CacheServerJmxImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/CacheServerJmxImpl.java
index e08f3a5..5e6202d 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/CacheServerJmxImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/CacheServerJmxImpl.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.jmx.internal;
@@ -51,19 +49,17 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.internal.logging.LogService;
/**
- * MBean representation of a {@link
- * org.apache.geode.admin.CacheVm}.
+ * MBean representation of a {@link org.apache.geode.admin.CacheVm}.
*
* @since GemFire 4.0
*/
public class CacheServerJmxImpl extends CacheServerImpl
- implements ManagedResource, CacheVmConfig, CacheServerConfig, SystemMemberJmx {
+ implements ManagedResource, CacheVmConfig, CacheServerConfig, SystemMemberJmx {
private static final Logger logger = LogService.getLogger();
-
- /**
- * Interval in seconds between refreshes. Value less than one results in no
- * refreshing
+
+ /**
+ * Interval in seconds between refreshes. Value less than one results in no refreshing
*/
private int refreshInterval = 0;
@@ -78,73 +74,66 @@ public class CacheServerJmxImpl extends CacheServerImpl
/** Reference to the cache MBean representing a Cache in the Cache VM Member */
private SystemMemberCacheJmxImpl managedSystemMemberCache;
-
+
/** collection to collect all the resources created for this member */
- private Map<StatResource, StatisticResourceJmxImpl> managedStatisticsResourcesMap = new HashMap<StatResource, StatisticResourceJmxImpl>();
+ private Map<StatResource, StatisticResourceJmxImpl> managedStatisticsResourcesMap =
+ new HashMap<StatResource, StatisticResourceJmxImpl>();
- ////////////////////// Constructors //////////////////////
+ ////////////////////// Constructors //////////////////////
/**
- * Creates a new <code>CacheServerJmxImpl</code> for an existing
- * cache server.
+ * Creates a new <code>CacheServerJmxImpl</code> for an existing cache server.
*/
- CacheServerJmxImpl(AdminDistributedSystemJmxImpl system,
- GemFireVM vm)
- throws AdminException {
+ CacheServerJmxImpl(AdminDistributedSystemJmxImpl system, GemFireVM vm) throws AdminException {
super(system, vm);
initializeMBean();
}
/**
- * Creates a new <code>CacheServerJmxImpl</code> for an
- * newly-created cache server.
+ * Creates a new <code>CacheServerJmxImpl</code> for an newly-created cache server.
*/
- CacheServerJmxImpl(AdminDistributedSystemJmxImpl system,
- CacheVmConfig config)
- throws AdminException {
+ CacheServerJmxImpl(AdminDistributedSystemJmxImpl system, CacheVmConfig config)
+ throws AdminException {
super(system, config);
initializeMBean();
}
- ////////////////////// Instance Methods //////////////////////
+ ////////////////////// Instance Methods //////////////////////
- /**
+ /**
* Creates and registers the MBean to manage this resource
*/
- private void initializeMBean()
- throws AdminException {
- //initialize Managed Resources for stats & cache first.
-// initializeManagedResources();
-
- this.mbeanName = new StringBuffer("GemFire.CacheVm:")
- .append("id=")
- .append(MBeanUtil.makeCompliantMBeanNameProperty(getId()))
- .append(",type=")
- .append(MBeanUtil.makeCompliantMBeanNameProperty(getType().getName()))
- .toString();
-
- this.objectName = MBeanUtil.createMBean(this,
- addDynamicAttributes(MBeanUtil.lookupManagedBean(this)));
+ private void initializeMBean() throws AdminException {
+ // initialize Managed Resources for stats & cache first.
+ // initializeManagedResources();
+
+ this.mbeanName = new StringBuffer("GemFire.CacheVm:").append("id=")
+ .append(MBeanUtil.makeCompliantMBeanNameProperty(getId())).append(",type=")
+ .append(MBeanUtil.makeCompliantMBeanNameProperty(getType().getName())).toString();
+
+ this.objectName =
+ MBeanUtil.createMBean(this, addDynamicAttributes(MBeanUtil.lookupManagedBean(this)));
// Refresh Interval
- AdminDistributedSystemJmxImpl sysJmx = (AdminDistributedSystemJmxImpl)system;
- if (sysJmx.getRefreshInterval()>0)
+ AdminDistributedSystemJmxImpl sysJmx = (AdminDistributedSystemJmxImpl) system;
+ if (sysJmx.getRefreshInterval() > 0)
this.refreshInterval = sysJmx.getRefreshInterval();
}
public String getMBeanName() {
return this.mbeanName;
}
-
+
public ModelMBean getModelMBean() {
return this.modelMBean;
}
+
public void setModelMBean(ModelMBean modelMBean) {
this.modelMBean = modelMBean;
}
-
+
public ObjectName getObjectName() {
return this.objectName;
}
@@ -152,18 +141,17 @@ public class CacheServerJmxImpl extends CacheServerImpl
public ManagedResourceType getManagedResourceType() {
return ManagedResourceType.CACHE_VM;
}
-
+
/**
- * Un-registers all the statistics & cache managed resource created for this
- * member. After un-registering the resource MBean instances, clears
- * managedStatisticsResourcesMap collection & sets managedSystemMemberCache
- * to null.
+ * Un-registers all the statistics & cache managed resource created for this member. After
+ * un-registering the resource MBean instances, clears managedStatisticsResourcesMap collection &
+ * sets managedSystemMemberCache to null.
*
- * Creates ConfigurationParameterJmxImpl, StatisticResourceJmxImpl and
- * SystemMemberCacheJmxImpl. But cleans up only StatisticResourceJmxImpl and
- * SystemMemberCacheJmxImpl which are of type ManagedResource.
+ * Creates ConfigurationParameterJmxImpl, StatisticResourceJmxImpl and SystemMemberCacheJmxImpl.
+ * But cleans up only StatisticResourceJmxImpl and SystemMemberCacheJmxImpl which are of type
+ * ManagedResource.
*/
- public void cleanupResource() {
+ public void cleanupResource() {
synchronized (this.managedStatisticsResourcesMap) {
ConfigurationParameter[] names = getConfiguration();
if (names != null) {
@@ -173,21 +161,22 @@ public class CacheServerJmxImpl extends CacheServerImpl
}
}
this.parms.clear();
-
- Collection<StatisticResourceJmxImpl> statisticResources = managedStatisticsResourcesMap.values();
-
+
+ Collection<StatisticResourceJmxImpl> statisticResources =
+ managedStatisticsResourcesMap.values();
+
for (StatisticResourceJmxImpl statisticResource : statisticResources) {
MBeanUtil.unregisterMBean(statisticResource);
}
-
+
this.managedStatisticsResourcesMap.clear();
}
-
+
MBeanUtil.unregisterMBean(this.managedSystemMemberCache);
this.managedSystemMemberCache = null;
}
- /////////////////////// Configuration ///////////////////////
+ /////////////////////// Configuration ///////////////////////
@Override
public String getHost() {
@@ -252,9 +241,9 @@ public class CacheServerJmxImpl extends CacheServerImpl
}
// -------------------------------------------------------------------------
- // MBean attribute accessors/mutators
+ // MBean attribute accessors/mutators
// -------------------------------------------------------------------------
-
+
/**
* Gets the interval in seconds between config refreshes
*
@@ -263,14 +252,13 @@ public class CacheServerJmxImpl extends CacheServerImpl
public int getRefreshInterval() {
return this.refreshInterval;
}
-
- /**
- * Sets interval in seconds between cache config refreshes; zero or less turns
- * off auto refreshing. Manual refreshing has no effect on when the next
- * scheduled refresh will occur.
+
+ /**
+ * Sets interval in seconds between cache config refreshes; zero or less turns off auto
+ * refreshing. Manual refreshing has no effect on when the next scheduled refresh will occur.
*
- * @param refreshInterval the new refresh interval in seconds
- */
+ * @param refreshInterval the new refresh interval in seconds
+ */
public void _setRefreshInterval(int refreshInterval) {
boolean isRegistered = MBeanUtil.isRefreshNotificationRegistered(this,
RefreshNotificationType.SYSTEM_MEMBER_CONFIG);
@@ -282,31 +270,29 @@ public class CacheServerJmxImpl extends CacheServerImpl
}
/**
- * RefreshInterval is now set only through the AdminDistributedSystem property
- * refreshInterval. Attempt to set refreshInterval on CacheServerJmx MBean
- * would result in an OperationNotSupportedException Auto-refresh is enabled
- * on demand when a call to refreshConfig is made
+ * RefreshInterval is now set only through the AdminDistributedSystem property refreshInterval.
+ * Attempt to set refreshInterval on CacheServerJmx MBean would result in an
+ * OperationNotSupportedException Auto-refresh is enabled on demand when a call to refreshConfig
+ * is made
*
- * @param refreshInterval
- * the new refresh interval in seconds
+ * @param refreshInterval the new refresh interval in seconds
* @deprecated since 6.0 use DistributedSystemConfig.refreshInterval instead
*/
@Deprecated
- public void setRefreshInterval(int refreshInterval)
- throws OperationNotSupportedException {
+ public void setRefreshInterval(int refreshInterval) throws OperationNotSupportedException {
throw new OperationNotSupportedException(
- LocalizedStrings.MANAGED_RESOURCE_REFRESH_INTERVAL_CANT_BE_SET_DIRECTLY.toLocalizedString());
- }
-
+ LocalizedStrings.MANAGED_RESOURCE_REFRESH_INTERVAL_CANT_BE_SET_DIRECTLY
+ .toLocalizedString());
+ }
+
// -------------------------------------------------------------------------
- // MBean Operations
+ // MBean Operations
// -------------------------------------------------------------------------
- public void refreshConfig()
- throws org.apache.geode.admin.AdminException {
- // 1st call to refreshConfig would trigger
+ public void refreshConfig() throws org.apache.geode.admin.AdminException {
+ // 1st call to refreshConfig would trigger
// the auto-refresh if an interval is set
- if (this.refreshInterval>0) {
+ if (this.refreshInterval > 0) {
this._setRefreshInterval(this.refreshInterval);
}
@@ -316,82 +302,78 @@ public class CacheServerJmxImpl extends CacheServerImpl
/**
* Initializes Cache & Statistics managed resources.
*
- * @throws AdminException
- * if initialization of managed resources fails
+ * @throws AdminException if initialization of managed resources fails
*/
-// private void initializeManagedResources() throws AdminException {
-// try {
-// manageCache();
-// } catch (MalformedObjectNameException e) {
-// throw new AdminException(LocalizedStrings.SystemMemberJmxImpl_EXCEPTION_OCCURRED_WHILE_INITIALIZING_0_MBEANS_FOR_1.toLocalizedString(
-// new Object[] {"Cache", getId()}),
-// e);
-// } catch (AdminException ae) {
-// if (LocalizedStrings.SystemMemberJmx_THIS_SYSTEM_MEMBER_DOES_NOT_HAVE_A_CACHE.toLocalizedString().equals(ae.getMessage())) {
-// //ignore this exception for a cache-less peer
-// } else {
-// throw ae;
-// }
-// }
-// try {
-// manageStats();
-// } catch (MalformedObjectNameException e) {
-// throw new AdminException(LocalizedStrings.SystemMemberJmxImpl_EXCEPTION_OCCURRED_WHILE_INITIALIZING_0_MBEANS_FOR_1.toLocalizedString(
-// new Object[] {"Statistics", getId()}),
-// e);
-// }
-// }
-
- /**
+ // private void initializeManagedResources() throws AdminException {
+ // try {
+ // manageCache();
+ // } catch (MalformedObjectNameException e) {
+ // throw new
+ // AdminException(LocalizedStrings.SystemMemberJmxImpl_EXCEPTION_OCCURRED_WHILE_INITIALIZING_0_MBEANS_FOR_1.toLocalizedString(
+ // new Object[] {"Cache", getId()}),
+ // e);
+ // } catch (AdminException ae) {
+ // if
+ // (LocalizedStrings.SystemMemberJmx_THIS_SYSTEM_MEMBER_DOES_NOT_HAVE_A_CACHE.toLocalizedString().equals(ae.getMessage()))
+ // {
+ // //ignore this exception for a cache-less peer
+ // } else {
+ // throw ae;
+ // }
+ // }
+ // try {
+ // manageStats();
+ // } catch (MalformedObjectNameException e) {
+ // throw new
+ // AdminException(LocalizedStrings.SystemMemberJmxImpl_EXCEPTION_OCCURRED_WHILE_INITIALIZING_0_MBEANS_FOR_1.toLocalizedString(
+ // new Object[] {"Statistics", getId()}),
+ // e);
+ // }
+ // }
+
+ /**
* Gets this member's cache.
*
* @return array of ObjectName for this member's cache
*/
- public ObjectName manageCache()
- throws AdminException, MalformedObjectNameException {
+ public ObjectName manageCache() throws AdminException, MalformedObjectNameException {
return Helper.manageCache(this);
}
- /**
+ /**
* Gets all active StatisticResources for this manager.
*
* @return array of ObjectName instances
*/
- public ObjectName[] manageStats()
- throws AdminException, MalformedObjectNameException {
+ public ObjectName[] manageStats() throws AdminException, MalformedObjectNameException {
return Helper.manageStats(this);
}
- /**
- * Gets the active StatisticResources for this manager, based on the
- * typeName as the key
+ /**
+ * Gets the active StatisticResources for this manager, based on the typeName as the key
*
* @return ObjectName of StatisticResourceJMX instance
*/
- public ObjectName[] manageStat(String statisticsTypeName)
- throws AdminException, MalformedObjectNameException {
-
+ public ObjectName[] manageStat(String statisticsTypeName)
+ throws AdminException, MalformedObjectNameException {
+
return Helper.manageStat(this, statisticsTypeName);
}
// -------------------------------------------------------------------------
- // JMX Notification listener
+ // JMX Notification listener
// -------------------------------------------------------------------------
/**
- * Handles notification to refresh. Reacts by refreshing the values of this
- * GemFireManager's ConfigurationParamaters. Any other notification is
- * ignored. Given notification is handled only if there is any JMX client
- * connected to the system.
+ * Handles notification to refresh. Reacts by refreshing the values of this GemFireManager's
+ * ConfigurationParamaters. Any other notification is ignored. Given notification is handled only
+ * if there is any JMX client connected to the system.
*
- * @param notification
- * the JMX notification being received
- * @param hb
- * handback object is unused
+ * @param notification the JMX notification being received
+ * @param hb handback object is unused
*/
public void handleNotification(Notification notification, Object hb) {
- AdminDistributedSystemJmxImpl systemJmx =
- (AdminDistributedSystemJmxImpl) this.system;
+ AdminDistributedSystemJmxImpl systemJmx = (AdminDistributedSystemJmxImpl) this.system;
if (!systemJmx.isRmiClientCountZero()) {
Helper.handleNotification(this, notification, hb);
@@ -399,51 +381,44 @@ public class CacheServerJmxImpl extends CacheServerImpl
}
// -------------------------------------------------------------------------
- // Template methods overriden from superclass...
+ // Template methods overriden from superclass...
// -------------------------------------------------------------------------
-
+
/**
- * Template method for creating instance of ConfigurationParameter.
- * Overridden to return ConfigurationParameterJmxImpl.
+ * Template method for creating instance of ConfigurationParameter. Overridden to return
+ * ConfigurationParameterJmxImpl.
*/
@Override
- protected ConfigurationParameter createConfigurationParameter(String name,
- String description,
- Object value,
- Class type,
- boolean userModifiable) {
- return new ConfigurationParameterJmxImpl(
- name, description, value, type, userModifiable);
+ protected ConfigurationParameter createConfigurationParameter(String name, String description,
+ Object value, Class type, boolean userModifiable) {
+ return new ConfigurationParameterJmxImpl(name, description, value, type, userModifiable);
}
-
+
/**
- * Override createStatisticResource by instantiating StatisticResourceJmxImpl
- * if it was not created earlier otherwise returns the same instance.
+ * Override createStatisticResource by instantiating StatisticResourceJmxImpl if it was not
+ * created earlier otherwise returns the same instance.
*
- * @param stat
- * StatResource reference for which this JMX resource is to be created
+ * @param stat StatResource reference for which this JMX resource is to be created
* @return StatisticResourceJmxImpl - JMX Implementation of StatisticResource
- * @throws AdminException
- * if constructing StatisticResourceJmxImpl instance fails
+ * @throws AdminException if constructing StatisticResourceJmxImpl instance fails
*/
@Override
protected StatisticResource createStatisticResource(StatResource stat)
- throws org.apache.geode.admin.AdminException {
+ throws org.apache.geode.admin.AdminException {
StatisticResourceJmxImpl managedStatisticResource = null;
-
+
synchronized (this.managedStatisticsResourcesMap) {
- /*
- * Ensuring that a single instance of Statistic Resource is created per
- * StatResource.
+ /*
+ * Ensuring that a single instance of Statistic Resource is created per StatResource.
*/
StatisticResourceJmxImpl statisticResourceJmxImpl = managedStatisticsResourcesMap.get(stat);
if (statisticResourceJmxImpl != null) {
managedStatisticResource = statisticResourceJmxImpl;
} else {
managedStatisticResource = new StatisticResourceJmxImpl(stat, this);
- managedStatisticResource.getStatistics();//inits timer
+ managedStatisticResource.getStatistics();// inits timer
managedStatisticsResourcesMap.put(stat, managedStatisticResource);
}
}
@@ -451,88 +426,81 @@ public class CacheServerJmxImpl extends CacheServerImpl
}
/**
- * Override createSystemMemberCache by instantiating SystemMemberCacheJmxImpl
- * if it was not created earlier.
+ * Override createSystemMemberCache by instantiating SystemMemberCacheJmxImpl if it was not
+ * created earlier.
*
- * @param vm
- * GemFireVM reference for which this JMX resource is to be created
+ * @param vm GemFireVM reference for which this JMX resource is to be created
* @return SystemMemberCacheJmxImpl - JMX Implementation of SystemMemberCache
- * @throws AdminException
- * if constructing SystemMemberCacheJmxImpl instance fails
+ * @throws AdminException if constructing SystemMemberCacheJmxImpl instance fails
*/
@Override
protected SystemMemberCache createSystemMemberCache(GemFireVM vm)
- throws org.apache.geode.admin.AdminException {
+ throws org.apache.geode.admin.AdminException {
if (managedSystemMemberCache == null) {
managedSystemMemberCache = new SystemMemberCacheJmxImpl(vm);
}
return managedSystemMemberCache;
}
-
+
// -------------------------------------------------------------------------
- // Create MBean attributes for each ConfigurationParameter
+ // Create MBean attributes for each ConfigurationParameter
// -------------------------------------------------------------------------
-
+
/**
* Add MBean attribute definitions for each ConfigurationParameter.
*
* @param managed the mbean definition to add attributes to
- * @return a new instance of ManagedBean copied from <code>managed</code> but
- * with the new attributes added
+ * @return a new instance of ManagedBean copied from <code>managed</code> but with the new
+ * attributes added
*/
- public ManagedBean addDynamicAttributes(ManagedBean managed)
- throws org.apache.geode.admin.AdminException {
+ public ManagedBean addDynamicAttributes(ManagedBean managed)
+ throws org.apache.geode.admin.AdminException {
return Helper.addDynamicAttributes(this, managed);
}
/**
- * Cleans up Managed Resources created for the client that was connected to
- * the server represented by this class.
+ * Cleans up Managed Resources created for the client that was connected to the server represented
+ * by this class.
*
- * @param clientId
- * id of the client to be removed
- * @return List of ManagedResources associated with the client of given client
- * id
+ * @param clientId id of the client to be removed
+ * @return List of ManagedResources associated with the client of given client id
*/
/*
- * This clean up is for the clients. The clients are started with a loner DM.
- * Hence the clientId is not supposed to contain '/' as per
- * InternalDistributedMember.toString().
+ * This clean up is for the clients. The clients are started with a loner DM. Hence the clientId
+ * is not supposed to contain '/' as per InternalDistributedMember.toString().
*/
public List<ManagedResource> cleanupBridgeClientResources(String clientId) {
List<ManagedResource> returnedResources = new ArrayList<ManagedResource>();
- String compatibleId = "id_"+MBeanUtil.makeCompliantMBeanNameProperty(clientId);
+ String compatibleId = "id_" + MBeanUtil.makeCompliantMBeanNameProperty(clientId);
synchronized (this.managedStatisticsResourcesMap) {
- Set<Entry<StatResource, StatisticResourceJmxImpl>> entrySet = this.managedStatisticsResourcesMap.entrySet();
-
- for (Iterator<Entry<StatResource, StatisticResourceJmxImpl>> it = entrySet.iterator(); it.hasNext();) {
+ Set<Entry<StatResource, StatisticResourceJmxImpl>> entrySet =
+ this.managedStatisticsResourcesMap.entrySet();
+
+ for (Iterator<Entry<StatResource, StatisticResourceJmxImpl>> it = entrySet.iterator(); it
+ .hasNext();) {
Entry<StatResource, StatisticResourceJmxImpl> entry = it.next();
StatisticResourceJmxImpl resource = entry.getValue();
if (resource.getMBeanName().contains(compatibleId)) {
- it.remove(); //remove matching entry
+ it.remove(); // remove matching entry
returnedResources.add(resource);
}
}
}
return returnedResources;
}
-
+
/**
* Implementation handles client membership changes.
*
- * @param clientId
- * id of the client for whom membership change happened
- * @param eventType
- * membership change type; one of
- * {@link ClientMembershipMessage#JOINED},
- * {@link ClientMembershipMessage#LEFT},
- * {@link ClientMembershipMessage#CRASHED}
+ * @param clientId id of the client for whom membership change happened
+ * @param eventType membership change type; one of {@link ClientMembershipMessage#JOINED},
+ * {@link ClientMembershipMessage#LEFT}, {@link ClientMembershipMessage#CRASHED}
*/
public void handleClientMembership(String clientId, int eventType) {
- String notifType = null;
+ String notifType = null;
List<ManagedResource> cleanedUp = null;
-
+
if (eventType == ClientMembershipMessage.LEFT) {
notifType = NOTIF_CLIENT_LEFT;
cleanedUp = cleanupBridgeClientResources(clientId);
@@ -542,98 +510,79 @@ public class CacheServerJmxImpl extends CacheServerImpl
} else if (eventType == ClientMembershipMessage.JOINED) {
notifType = NOTIF_CLIENT_JOINED;
}
-
+
if (cleanedUp != null) {
for (ManagedResource resource : cleanedUp) {
MBeanUtil.unregisterMBean(resource);
}
}
- Helper.sendNotification(this,
- new Notification(notifType, this.modelMBean,
- Helper.getNextNotificationSequenceNumber(),
- clientId));
+ Helper.sendNotification(this, new Notification(notifType, this.modelMBean,
+ Helper.getNextNotificationSequenceNumber(), clientId));
}
-
+
/**
- * Implementation handles creation of cache by extracting the details from the
- * given event object and sending the
- * {@link SystemMemberJmx#NOTIF_CACHE_CREATED} notification to the connected
- * JMX Clients.
+ * Implementation handles creation of cache by extracting the details from the given event object
+ * and sending the {@link SystemMemberJmx#NOTIF_CACHE_CREATED} notification to the connected JMX
+ * Clients.
*
- * @param event
- * event object corresponding to the creation of the cache
+ * @param event event object corresponding to the creation of the cache
*/
public void handleCacheCreate(SystemMemberCacheEvent event) {
- Helper.sendNotification(this,
- new Notification(NOTIF_CACHE_CREATED, this.modelMBean,
- Helper.getNextNotificationSequenceNumber(),
- Helper.getCacheEventDetails(event)));
- }
+ Helper.sendNotification(this, new Notification(NOTIF_CACHE_CREATED, this.modelMBean,
+ Helper.getNextNotificationSequenceNumber(), Helper.getCacheEventDetails(event)));
+ }
/**
- * Implementation handles closure of cache by extracting the details from the
- * given event object and sending the
- * {@link SystemMemberJmx#NOTIF_CACHE_CLOSED} notification to the connected
- * JMX Clients.
+ * Implementation handles closure of cache by extracting the details from the given event object
+ * and sending the {@link SystemMemberJmx#NOTIF_CACHE_CLOSED} notification to the connected JMX
+ * Clients.
*
- * @param event
- * event object corresponding to the closure of the cache
+ * @param event event object corresponding to the closure of the cache
*/
public void handleCacheClose(SystemMemberCacheEvent event) {
- Helper.sendNotification(this,
- new Notification(NOTIF_CACHE_CLOSED, this.modelMBean,
- Helper.getNextNotificationSequenceNumber(),
- Helper.getCacheEventDetails(event)));
+ Helper.sendNotification(this, new Notification(NOTIF_CACHE_CLOSED, this.modelMBean,
+ Helper.getNextNotificationSequenceNumber(), Helper.getCacheEventDetails(event)));
}
/**
- * Implementation handles creation of region by extracting the details from
- * the given event object and sending the
- * {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected
- * JMX Clients. Region Path is set as User Data in Notification.
+ * Implementation handles creation of region by extracting the details from the given event object
+ * and sending the {@link SystemMemberJmx#NOTIF_REGION_CREATED} notification to the connected JMX
+ * Clients. Region Path is set as User Data in Notification.
*
- * @param event
- * event object corresponding to the creation of a region
+ * @param event event object corresponding to the creation of a region
*/
public void handleRegionCreate(SystemMemberRegionEvent event) {
- Notification notification = new Notification(NOTIF_REGION_CREATED,
- this.modelMBean,
- Helper.getNextNotificationSequenceNumber(),
- Helper.getRegionEventDetails(event));
-
+ Notification notification = new Notification(NOTIF_REGION_CREATED, this.modelMBean,
+ Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));
+
notification.setUserData(event.getRegionPath());
Helper.sendNotification(this, notification);
}
/**
- * Implementation should handle loss of region by extracting the details from
- * the given event object and sending the
- * {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected
- * JMX Clients. Region Path is set as User Data in Notification. Additionally,
- * it also clears the ManagedResources created for the region that is lost.
+ * Implementation should handle loss of region by extracting the details from the given event
+ * object and sending the {@link SystemMemberJmx#NOTIF_REGION_LOST} notification to the connected
+ * JMX Clients. Region Path is set as User Data in Notification. Additionally, it also clears the
+ * ManagedResources created for the region that is lost.
*
- * @param event
- * event object corresponding to the loss of a region
+ * @param event event object corresponding to the loss of a region
*/
public void handleRegionLoss(SystemMemberRegionEvent event) {
SystemMemberCacheJmxImpl cacheResource = this.managedSystemMemberCache;
-
+
if (cacheResource != null) {
- ManagedResource cleanedUp =
- cacheResource.cleanupRegionResources(event.getRegionPath());
-
+ ManagedResource cleanedUp = cacheResource.cleanupRegionResources(event.getRegionPath());
+
if (cleanedUp != null) {
MBeanUtil.unregisterMBean(cleanedUp);
}
}
- Notification notification = new Notification(NOTIF_REGION_LOST,
- this.modelMBean,
- Helper.getNextNotificationSequenceNumber(),
- Helper.getRegionEventDetails(event));
-
+ Notification notification = new Notification(NOTIF_REGION_LOST, this.modelMBean,
+ Helper.getNextNotificationSequenceNumber(), Helper.getRegionEventDetails(event));
+
notification.setUserData(event.getRegionPath());
Helper.sendNotification(this, notification);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigAttributeInfo.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigAttributeInfo.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigAttributeInfo.java
index 9f7f940..3273ccc 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigAttributeInfo.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigAttributeInfo.java
@@ -1,75 +1,65 @@
/*
- * 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.jmx.internal;
-//import org.apache.geode.admin.ConfigurationParameter;
+// import org.apache.geode.admin.ConfigurationParameter;
import org.apache.geode.internal.Assert;
import javax.management.Descriptor;
import javax.management.modelmbean.DescriptorSupport;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
-/**
- * Subclass of AttributeInfo with {@link
- * org.apache.geode.admin.ConfigurationParameter} added for use as the
- * {@link javax.management.modelmbean.ModelMBeanAttributeInfo} descriptor's
+/**
+ * Subclass of AttributeInfo with {@link org.apache.geode.admin.ConfigurationParameter} added for
+ * use as the {@link javax.management.modelmbean.ModelMBeanAttributeInfo} descriptor's
* <i>targetObject</i> value.
*
- * @since GemFire 3.5
+ * @since GemFire 3.5
*
*/
class ConfigAttributeInfo extends org.apache.commons.modeler.AttributeInfo {
private static final long serialVersionUID = -1918437700841687078L;
-
+
private final ConfigurationParameterJmxImpl config;
-
+
public ConfigAttributeInfo(ConfigurationParameterJmxImpl config) {
super();
this.config = config;
}
-
+
public ConfigurationParameterJmxImpl getConfig() {
return this.config;
}
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
- Descriptor desc = new DescriptorSupport(
- new String[] {
- "name=" + this.displayName,
- "descriptorType=attribute",
- "currencyTimeLimit=-1", // always stale
- "displayName=" + this.displayName,
- "getMethod=getJmxValue",
- "setMethod=setJmxValue"
- });
-
+ Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
+ "descriptorType=attribute", "currencyTimeLimit=-1", // always stale
+ "displayName=" + this.displayName, "getMethod=getJmxValue", "setMethod=setJmxValue"});
+
Assert.assertTrue(this.config != null, "Config target object is null!");
desc.setField("targetObject", this.config);
- ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
- this.displayName, // name
- this.type, // type
+ ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
+ this.type, // type
this.description, // description
- this.readable, // isReadable
- this.writeable, // isWritable
- this.is, // isIs
+ this.readable, // isReadable
+ this.writeable, // isWritable
+ this.is, // isIs
desc);
-
+
return info;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigurationParameterJmxImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigurationParameterJmxImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigurationParameterJmxImpl.java
index a318eb5..f9add13 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigurationParameterJmxImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/ConfigurationParameterJmxImpl.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.jmx.internal;
@@ -29,49 +27,46 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
/**
* Provides MBean support for managing accessing a ConfigurationParameter.
* <p>
- * Implements java.io.Serializable because several MBeans have attributes of
- * type ConfigurationParameter. This means that calls to getMBeanInfo which
- * may be serialized for remote clients will be broken unless those attributes
- * support serialization.
+ * Implements java.io.Serializable because several MBeans have attributes of type
+ * ConfigurationParameter. This means that calls to getMBeanInfo which may be serialized for remote
+ * clients will be broken unless those attributes support serialization.
* <p>
- * TODO: refactor to implement ConfigurationParameter and delegate to
- * ConfigurationParameterImpl. Wrap all delegate calls w/ e.printStackTrace()
- * since the HttpAdaptor devours them
+ * TODO: refactor to implement ConfigurationParameter and delegate to ConfigurationParameterImpl.
+ * Wrap all delegate calls w/ e.printStackTrace() since the HttpAdaptor devours them
*
- * @since GemFire 3.5
+ * @since GemFire 3.5
*
*/
public class ConfigurationParameterJmxImpl
-extends org.apache.geode.admin.internal.ConfigurationParameterImpl
-implements Serializable {
+ extends org.apache.geode.admin.internal.ConfigurationParameterImpl implements Serializable {
private static final long serialVersionUID = -7822171853906772375L;
private boolean deserialized = false;
-
+
// -------------------------------------------------------------------------
- // Constructor(s)
+ // Constructor(s)
// -------------------------------------------------------------------------
-
- protected ConfigurationParameterJmxImpl(String name,
- String description,
- Object value,
- Class type,
- boolean userModifiable) {
+
+ protected ConfigurationParameterJmxImpl(String name, String description, Object value, Class type,
+ boolean userModifiable) {
super(name, description, value, type, userModifiable);
}
-
- protected ConfigurationParameterJmxImpl(String name,
- Object value) {
+
+ protected ConfigurationParameterJmxImpl(String name, Object value) {
super(name, value);
}
-
+
/** Constructor to allow serialization */
- protected ConfigurationParameterJmxImpl() { super(); }
-
+ protected ConfigurationParameterJmxImpl() {
+ super();
+ }
+
@Override
public void setValue(Object value) throws UnmodifiableConfigurationException {
if (deserialized) {
- throw new UnsupportedOperationException(LocalizedStrings.ConfigurationParameterJmxImpl_REMOTE_MUTATION_OF_CONFIGURATIONPARAMETER_IS_CURRENTLY_UNSUPPORTED.toLocalizedString());
+ throw new UnsupportedOperationException(
+ LocalizedStrings.ConfigurationParameterJmxImpl_REMOTE_MUTATION_OF_CONFIGURATIONPARAMETER_IS_CURRENTLY_UNSUPPORTED
+ .toLocalizedString());
}
try {
super.setValue(value);
@@ -83,12 +78,12 @@ implements Serializable {
throw e;
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
- // If this ever returns, rethrow the error. We're poisoned
+ // If this ever returns, rethrow the error. We're poisoned
// now, so don't let this thread continue.
throw err;
} catch (java.lang.Error e) {
// Whenever you catch Error or Throwable, you must also
- // catch VirtualMachineError (see above). However, there is
+ // 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:
@@ -97,73 +92,72 @@ implements Serializable {
throw e;
}
}
-
+
// -------------------------------------------------------------------------
- // HACK
+ // HACK
// -------------------------------------------------------------------------
public void setJmxValue(Integer value) throws UnmodifiableConfigurationException {
setValue(value);
}
+
public void setJmxValue(String value) throws UnmodifiableConfigurationException {
setValue(value);
}
+
public void setJmxValue(java.io.File value) throws UnmodifiableConfigurationException {
setValue(value);
}
+
public void setJmxValue(Boolean value) throws UnmodifiableConfigurationException {
setValue(value);
}
-
+
public Class getJmxValueType() {
if (isInetAddress() || isFile() || isOctal()) {
return java.lang.String.class;
}
return getValueType();
}
-
+
public Object getJmxValue() {
if (isInetAddress() || isFile() || isOctal()) {
return getValueAsString();
}
return getValue();
}
-
- /**
- * Override writeObject which is used in serialization. This class is
- * serialized when JMX client acquires MBeanInfo for ConfigurationParameter
- * MBean. Super class is not serializable.
+
+ /**
+ * Override writeObject which is used in serialization. This class is serialized when JMX client
+ * acquires MBeanInfo for ConfigurationParameter MBean. Super class is not serializable.
*/
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException {
out.writeObject(this.name);
out.writeObject(this.description);
out.writeObject(this.value);
out.writeObject(this.type);
out.writeBoolean(this.userModifiable);
}
-
- /**
- * Override readObject which is used in serialization. Customize
- * serialization of this exception to avoid escape of InternalRole
- * which is not Serializable.
+
+ /**
+ * Override readObject which is used in serialization. Customize serialization of this exception
+ * to avoid escape of InternalRole which is not Serializable.
*/
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
+ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
String inName = (String) in.readObject();
String inDescription = (String) in.readObject();
Object inValue = in.readObject();
Class inClass = (Class) in.readObject();
boolean inUserModifiable = in.readBoolean();
-
+
Assert.assertTrue(inName != null);
Assert.assertTrue(inDescription != null);
Assert.assertTrue(inValue != null);
Assert.assertTrue(inClass != null);
-
+
this.deserialized = true;
this.name = inName;
setInternalState(inDescription, inValue, inClass, inUserModifiable);
}
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/DistributedSystemHealthConfigJmxImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/DistributedSystemHealthConfigJmxImpl.java b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/DistributedSystemHealthConfigJmxImpl.java
index 18c3fd5..54d3072 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/DistributedSystemHealthConfigJmxImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/jmx/internal/DistributedSystemHealthConfigJmxImpl.java
@@ -1,42 +1,38 @@
/*
- * 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.jmx.internal;
import org.apache.geode.admin.*;
import org.apache.geode.admin.internal.*;
-//import org.apache.geode.internal.admin.*;
+// import org.apache.geode.internal.admin.*;
import javax.management.*;
import javax.management.modelmbean.*;
-//import org.apache.commons.modeler.ManagedBean;
+// import org.apache.commons.modeler.ManagedBean;
/**
- * The JMX "managed resource" that represents the configuration for
- * the health of a distributed system. Basically, it provides the
- * behavior of <code>DistributedSystemHealthConfigImpl</code>, but
- * does some JMX stuff like registering beans with the agent.
+ * The JMX "managed resource" that represents the configuration for the health of a distributed
+ * system. Basically, it provides the behavior of <code>DistributedSystemHealthConfigImpl</code>,
+ * but does some JMX stuff like registering beans with the agent.
*
* @see GemFireHealthJmxImpl#createDistributedSystemHealthConfig
*
*
* @since GemFire 3.5
*/
-public class DistributedSystemHealthConfigJmxImpl
- extends DistributedSystemHealthConfigImpl
- implements ManagedResource {
+public class DistributedSystemHealthConfigJmxImpl extends DistributedSystemHealthConfigImpl
+ implements ManagedResource {
/** The <code>GemFireHealth</code> that we help configure */
private GemFireHealth health;
@@ -50,31 +46,27 @@ public class DistributedSystemHealthConfigJmxImpl
/** The JMX object name of the MBean for this managed resource */
private final ObjectName objectName;
- /////////////////////// Constructors ///////////////////////
+ /////////////////////// Constructors ///////////////////////
/**
- * Creates a new <code>DistributedSystemHealthCOnfigJmxImpl</code>
- * that configures the health of the distributed system monitored by
- * <code>health</code>.
+ * Creates a new <code>DistributedSystemHealthCOnfigJmxImpl</code> that configures the health of
+ * the distributed system monitored by <code>health</code>.
*/
- DistributedSystemHealthConfigJmxImpl(GemFireHealthJmxImpl health)
- throws AdminException {
+ DistributedSystemHealthConfigJmxImpl(GemFireHealthJmxImpl health) throws AdminException {
super();
this.health = health;
- this.mbeanName = new StringBuffer()
- .append(MBEAN_NAME_PREFIX)
- .append("DistributedSystemHealthConfig,id=")
- .append(MBeanUtil.makeCompliantMBeanNameProperty(health.getDistributedSystem().getId()))
- .toString();
+ this.mbeanName =
+ new StringBuffer().append(MBEAN_NAME_PREFIX).append("DistributedSystemHealthConfig,id=")
+ .append(MBeanUtil.makeCompliantMBeanNameProperty(health.getDistributedSystem().getId()))
+ .toString();
this.objectName = MBeanUtil.createMBean(this);
}
- ////////////////////// Instance Methods //////////////////////
+ ////////////////////// Instance Methods //////////////////////
/**
- * Applies the changes made to this config back to the health
- * monitor.
+ * Applies the changes made to this config back to the health monitor.
*
* @see GemFireHealth#setDistributedSystemHealthConfig
*/
@@ -85,7 +77,7 @@ public class DistributedSystemHealthConfigJmxImpl
public String getMBeanName() {
return this.mbeanName;
}
-
+
public ModelMBean getModelMBean() {
return this.modelMBean;
}