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:35 UTC
[21/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/internal/EnabledManagedEntityController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/EnabledManagedEntityController.java b/geode-core/src/main/java/org/apache/geode/admin/internal/EnabledManagedEntityController.java
index 20871d8..59e8386 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/EnabledManagedEntityController.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/EnabledManagedEntityController.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.internal;
@@ -35,35 +33,28 @@ import java.util.Properties;
import static org.apache.geode.distributed.ConfigurationProperties.*;
/**
- * Implements the actual administration (starting, stopping, etc.) of
- * GemFire {@link ManagedEntity}s. It {@link Runtime#exec(java.lang.String) executes}
- * commands to administer the entities based on information provided
- * by the {@link InternalManagedEntity} object. Note that it does not
- * use <code>SystemAdmin</code> to manage "local" entities; it always
- * execs the scripts.
+ * Implements the actual administration (starting, stopping, etc.) of GemFire
+ * {@link ManagedEntity}s. It {@link Runtime#exec(java.lang.String) executes} commands to administer
+ * the entities based on information provided by the {@link InternalManagedEntity} object. Note that
+ * it does not use <code>SystemAdmin</code> to manage "local" entities; it always execs the scripts.
*
* <P>
*
- * This class is a refactoring of <code>Systemcontroller</code>,
- * <code>RemoteCommand</code>, and <code>LocatorRemoteCommand</code>.
+ * This class is a refactoring of <code>Systemcontroller</code>, <code>RemoteCommand</code>, and
+ * <code>LocatorRemoteCommand</code>.
*
* @since GemFire 4.0
*/
class EnabledManagedEntityController implements ManagedEntityController {
private static final Logger logger = LogService.getLogger();
-// /** A lock to ensure that only entity is managed at a time. See bug
-// * 31374. */
-// private static Object startStopLock = new Object();
+ // /** A lock to ensure that only entity is managed at a time. See bug
+ // * 31374. */
+ // private static Object startStopLock = new Object();
/** Known strings found in output indicating error. */
- private static final String[] ERROR_OUTPUTS = new String[] {
- "No such file or directory",
- "The system cannot find the file specified.",
- "Access is denied.",
- "cannot open",
- "ERROR"
- };
+ private static final String[] ERROR_OUTPUTS = new String[] {"No such file or directory",
+ "The system cannot find the file specified.", "Access is denied.", "cannot open", "ERROR"};
/** Token in command prefix to be replaced with actual HOST */
private static final String HOST = "{HOST}";
@@ -71,39 +62,41 @@ class EnabledManagedEntityController implements ManagedEntityController {
/** Token in command prefix to be replaced with actual execution CMD */
private static final String CMD = "{CMD}";
- ////////////////////// Instance Fields //////////////////////
+ ////////////////////// Instance Fields //////////////////////
- /** The thread group in which threads launched by this system
- * controller reside. */
+ /**
+ * The thread group in which threads launched by this system controller reside.
+ */
private final ThreadGroup threadGroup;
/** System to which the managed entities belong */
private final AdminDistributedSystem system;
- /////////////////////// Constructors ///////////////////////
+ /////////////////////// Constructors ///////////////////////
/**
- * Creates a new <code>ManagedEntityController</code> for entities
- * in the given distributed system.
+ * Creates a new <code>ManagedEntityController</code> for entities in the given distributed
+ * system.
*/
EnabledManagedEntityController(AdminDistributedSystem system) {
this.system = system;
this.threadGroup =
- LoggingThreadGroup.createThreadGroup("ManagedEntityController threads", logger);
+ LoggingThreadGroup.createThreadGroup("ManagedEntityController threads", logger);
}
- ///////////////////// Instance Methods /////////////////////
+ ///////////////////// Instance Methods /////////////////////
/**
- * Returns <code>true</code> if the <code>output</code> string
- * contains a known error message.
+ * Returns <code>true</code> if the <code>output</code> string contains a known error message.
*/
private boolean outputIsError(String output) {
- if (output == null) return false;
+ if (output == null)
+ return false;
boolean error = false;
for (int i = 0; i < ERROR_OUTPUTS.length; i++) {
error = output.indexOf(ERROR_OUTPUTS[i]) > -1;
- if (error) return error;
+ if (error)
+ return error;
}
return error;
}
@@ -111,41 +104,47 @@ class EnabledManagedEntityController implements ManagedEntityController {
/**
* Executes a command using {@link Runtime#exec(java.lang.String)}.
*
- * @param command
- * The full command to remotely execute
+ * @param command The full command to remotely execute
*
- * @return Output from the command that was executed or
- * <code>null</code> if the executing the command failed.
+ * @return Output from the command that was executed or <code>null</code> if the executing the
+ * command failed.
*/
- protected String execute(String command,
- InternalManagedEntity entity) {
- /* TODO: this is getting ugly... clients of this method really need to
- have the ability to do their own parsing/checking of 'output' */
+ protected String execute(String command, InternalManagedEntity entity) {
+ /*
+ * TODO: this is getting ugly... clients of this method really need to have the ability to do
+ * their own parsing/checking of 'output'
+ */
if (command == null || command.length() == 0) {
- throw new IllegalArgumentException(LocalizedStrings.ManagedEntityController_EXECUTION_COMMAND_IS_EMPTY.toLocalizedString());
+ throw new IllegalArgumentException(
+ LocalizedStrings.ManagedEntityController_EXECUTION_COMMAND_IS_EMPTY.toLocalizedString());
}
- File workingDir =
- new File(entity.getEntityConfig().getWorkingDirectory());
- logger.info(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_EXECUTING_REMOTE_COMMAND_0_IN_DIRECTORY_1, new Object[] {command, workingDir}));
+ File workingDir = new File(entity.getEntityConfig().getWorkingDirectory());
+ logger.info(LocalizedMessage.create(
+ LocalizedStrings.ManagedEntityController_EXECUTING_REMOTE_COMMAND_0_IN_DIRECTORY_1,
+ new Object[] {command, workingDir}));
Process p = null;
try {
- p = Runtime.getRuntime().exec(command, null /* env */,
- workingDir);
+ p = Runtime.getRuntime().exec(command, null /* env */, workingDir);
} catch (java.io.IOException e) {
- logger.fatal(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_WHILE_EXECUTING_0, command), e);
+ logger.fatal(LocalizedMessage
+ .create(LocalizedStrings.ManagedEntityController_WHILE_EXECUTING_0, command), e);
return null;
}
final ProcessOutputReader pos = new ProcessOutputReader(p);
int retCode = pos.getExitCode();
final String output = pos.getOutput();
- logger.info(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_RESULT_OF_EXECUTING_0_IS_1, new Object[] {command, Integer.valueOf(retCode)}));
- logger.info(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_OUTPUT_OF_0_IS_1, new Object[] {command, output}));
+ logger.info(
+ LocalizedMessage.create(LocalizedStrings.ManagedEntityController_RESULT_OF_EXECUTING_0_IS_1,
+ new Object[] {command, Integer.valueOf(retCode)}));
+ logger.info(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_OUTPUT_OF_0_IS_1,
+ new Object[] {command, output}));
if (retCode != 0 || outputIsError(output)) {
- logger.warn(LocalizedMessage.create(LocalizedStrings.ManagedEntityController_REMOTE_EXECUTION_OF_0_FAILED, command));
+ logger.warn(LocalizedMessage
+ .create(LocalizedStrings.ManagedEntityController_REMOTE_EXECUTION_OF_0_FAILED, command));
return null;
}
@@ -166,30 +165,27 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
}
-// /** Returns true if the path is on Windows. */
-// private boolean pathIsWindows(File path) {
-// return pathIsWindows(path.toString());
-// }
+ // /** Returns true if the path is on Windows. */
+ // private boolean pathIsWindows(File path) {
+ // return pathIsWindows(path.toString());
+ // }
/** Returns true if the path is on Windows. */
private boolean pathIsWindows(String path) {
if (path != null && path.length() > 1) {
- return (Character.isLetter(path.charAt(0)) && path.charAt(1) == ':') ||
- (path.startsWith("//") || path.startsWith("\\\\"));
+ return (Character.isLetter(path.charAt(0)) && path.charAt(1) == ':')
+ || (path.startsWith("//") || path.startsWith("\\\\"));
}
return false;
}
/**
- * If the managed entity resides on a remote host, then
- * <code>command</code> is munged to take the remote command into account.
+ * If the managed entity resides on a remote host, then <code>command</code> is munged to take the
+ * remote command into account.
*
- * @throws IllegalStateException
- * If a remote command is required, but one has not been
- * specified.
+ * @throws IllegalStateException If a remote command is required, but one has not been specified.
*/
- private String arrangeRemoteCommand(InternalManagedEntity entity,
- String cmd) {
+ private String arrangeRemoteCommand(InternalManagedEntity entity, String cmd) {
String host = entity.getEntityConfig().getHost();
if (InetAddressUtil.isLocalHost(host)) {
@@ -203,8 +199,9 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
if (prefix == null || prefix.length() <= 0) {
- throw new IllegalStateException(LocalizedStrings.ManagedEntityController_A_REMOTE_COMMAND_MUST_BE_SPECIFIED_TO_OPERATE_ON_A_MANAGED_ENTITY_ON_HOST_0
- .toLocalizedString(host));
+ throw new IllegalStateException(
+ LocalizedStrings.ManagedEntityController_A_REMOTE_COMMAND_MUST_BE_SPECIFIED_TO_OPERATE_ON_A_MANAGED_ENTITY_ON_HOST_0
+ .toLocalizedString(host));
}
int hostIdx = prefix.indexOf(HOST);
@@ -222,7 +219,7 @@ class EnabledManagedEntityController implements ManagedEntityController {
end = prefix.substring(hostIdx + HOST.length());
}
prefix = start + host + end;
- cmdIdx = prefix.indexOf(CMD); //recalculate;
+ cmdIdx = prefix.indexOf(CMD); // recalculate;
}
if (cmdIdx >= 0) {
@@ -239,27 +236,22 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
/**
- * Returns the full path to the executable in
- * <code>$GEMFIRE/bin</code> taking into account the {@linkplain
- * ManagedEntityConfig#getProductDirectory product directory} and the
- * platform's file separator.
+ * Returns the full path to the executable in <code>$GEMFIRE/bin</code> taking into account the
+ * {@linkplain ManagedEntityConfig#getProductDirectory product directory} and the platform's file
+ * separator.
*
* <P>
*
- * Note: we should probably do a better job of determine whether or
- * not the machine on which the entity runs is Windows or Linux.
+ * Note: we should probably do a better job of determine whether or not the machine on which the
+ * entity runs is Windows or Linux.
*
- * @param executable
- * The name of the executable that resides in
- * <code>$GEMFIRE/bin</code>.
+ * @param executable The name of the executable that resides in <code>$GEMFIRE/bin</code>.
*/
- public String getProductExecutable(InternalManagedEntity entity,
- String executable) {
- String productDirectory =
- entity.getEntityConfig().getProductDirectory();
+ public String getProductExecutable(InternalManagedEntity entity, String executable) {
+ String productDirectory = entity.getEntityConfig().getProductDirectory();
String path = null;
File productDir = new File(productDirectory);
-// if (productDir != null) (cannot be null)
+ // if (productDir != null) (cannot be null)
{
path = productDir.getPath();
if (!endsWithSeparator(path)) {
@@ -267,9 +259,9 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
path += "bin" + File.separator;
}
-// else {
-// path = "";
-// }
+ // else {
+ // path = "";
+ // }
String bat = "";
if (pathIsWindows(path)) {
@@ -279,12 +271,13 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
/**
- * Builds optional SSL command-line arguments. Returns null if SSL is not
- * enabled for the distributed system.
+ * Builds optional SSL command-line arguments. Returns null if SSL is not enabled for the
+ * distributed system.
*/
public String buildSSLArguments(DistributedSystemConfig config) {
Properties sslProps = buildSSLProperties(config, true);
- if (sslProps == null) return null;
+ if (sslProps == null)
+ return null;
StringBuffer sb = new StringBuffer();
for (Iterator iter = sslProps.keySet().iterator(); iter.hasNext();) {
@@ -297,38 +290,28 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
/**
- * Builds optional SSL properties for DistributionLocator. Returns null if SSL
- * is not enabled for the distributed system.
+ * Builds optional SSL properties for DistributionLocator. Returns null if SSL is not enabled for
+ * the distributed system.
*
- * @param forCommandLine
- * true indicates that
- * {@link DistributionConfig#GEMFIRE_PREFIX} should be
- * prepended so the argument will become -Dgemfire.xxxx
+ * @param forCommandLine true indicates that {@link DistributionConfig#GEMFIRE_PREFIX} should be
+ * prepended so the argument will become -Dgemfire.xxxx
*/
- private Properties buildSSLProperties(DistributedSystemConfig config,
- boolean forCommandLine) {
- if (!config.isSSLEnabled()) return null;
+ private Properties buildSSLProperties(DistributedSystemConfig config, boolean forCommandLine) {
+ if (!config.isSSLEnabled())
+ return null;
String prefix = "";
- if (forCommandLine) prefix = DistributionConfig.GEMFIRE_PREFIX;
+ if (forCommandLine)
+ prefix = DistributionConfig.GEMFIRE_PREFIX;
Properties sslProps = (Properties) config.getSSLProperties().clone();
// add ssl-enabled, etc...
- sslProps.setProperty(prefix +
- MCAST_PORT,
- "0");
- sslProps.setProperty(prefix +
- CLUSTER_SSL_ENABLED,
- String.valueOf(config.isSSLEnabled()));
- sslProps.setProperty(prefix +
- CLUSTER_SSL_CIPHERS,
- config.getSSLCiphers());
- sslProps.setProperty(prefix +
- CLUSTER_SSL_PROTOCOLS,
- config.getSSLProtocols());
- sslProps.setProperty(prefix +
- CLUSTER_SSL_REQUIRE_AUTHENTICATION,
- String.valueOf(config.isSSLAuthenticationRequired()));
+ sslProps.setProperty(prefix + MCAST_PORT, "0");
+ sslProps.setProperty(prefix + CLUSTER_SSL_ENABLED, String.valueOf(config.isSSLEnabled()));
+ sslProps.setProperty(prefix + CLUSTER_SSL_CIPHERS, config.getSSLCiphers());
+ sslProps.setProperty(prefix + CLUSTER_SSL_PROTOCOLS, config.getSSLProtocols());
+ sslProps.setProperty(prefix + CLUSTER_SSL_REQUIRE_AUTHENTICATION,
+ String.valueOf(config.isSSLAuthenticationRequired()));
return sslProps;
}
@@ -337,13 +320,12 @@ class EnabledManagedEntityController implements ManagedEntityController {
* Starts a managed entity.
*/
public void start(final InternalManagedEntity entity) {
- final String command =
- arrangeRemoteCommand(entity, entity.getStartCommand());
+ final String command = arrangeRemoteCommand(entity, entity.getStartCommand());
Thread start = new Thread(this.threadGroup, new Runnable() {
- public void run() {
- execute(command, entity);
- }
- }, "Start " + entity.getEntityType());
+ public void run() {
+ execute(command, entity);
+ }
+ }, "Start " + entity.getEntityType());
start.start();
}
@@ -351,13 +333,12 @@ class EnabledManagedEntityController implements ManagedEntityController {
* Stops a managed entity.
*/
public void stop(final InternalManagedEntity entity) {
- final String command =
- arrangeRemoteCommand(entity, entity.getStopCommand());
+ final String command = arrangeRemoteCommand(entity, entity.getStopCommand());
Thread stop = new Thread(this.threadGroup, new Runnable() {
- public void run() {
- execute(command, entity);
- }
- }, "Stop " + entity.getEntityType());
+ public void run() {
+ execute(command, entity);
+ }
+ }, "Stop " + entity.getEntityType());
stop.start();
}
@@ -365,47 +346,40 @@ class EnabledManagedEntityController implements ManagedEntityController {
* Returns whether or not a managed entity is running
*/
public boolean isRunning(InternalManagedEntity entity) {
- final String command =
- arrangeRemoteCommand(entity, entity.getIsRunningCommand());
+ final String command = arrangeRemoteCommand(entity, entity.getIsRunningCommand());
String output = execute(command, entity);
- if (output == null ||
- (output.indexOf("stop" /* "ing" "ped" */) != -1) ||
- (output.indexOf("killed") != -1) ||
- (output.indexOf("starting") != -1)) {
+ if (output == null || (output.indexOf("stop" /* "ing" "ped" */) != -1)
+ || (output.indexOf("killed") != -1) || (output.indexOf("starting") != -1)) {
return false;
} else if (output.indexOf("running") != -1) {
return true;
} else {
- throw new IllegalStateException(LocalizedStrings.ManagedEntityController_COULD_NOT_DETERMINE_IF_MANAGED_ENTITY_WAS_RUNNING_0
- .toLocalizedString(output));
+ throw new IllegalStateException(
+ LocalizedStrings.ManagedEntityController_COULD_NOT_DETERMINE_IF_MANAGED_ENTITY_WAS_RUNNING_0
+ .toLocalizedString(output));
}
}
/**
- * Returns the contents of a locator's log file. Other APIs are
- * used to get the log file of managed entities that are also system
- * members.
+ * Returns the contents of a locator's log file. Other APIs are used to get the log file of
+ * managed entities that are also system members.
*/
public String getLog(DistributionLocatorImpl locator) {
- String command =
- arrangeRemoteCommand(locator, locator.getLogCommand());
+ String command = arrangeRemoteCommand(locator, locator.getLogCommand());
return execute(command, locator);
}
/**
- * Returns the contents of the given directory using the given
- * managed entity to determine the host and remote command.
+ * Returns the contents of the given directory using the given managed entity to determine the
+ * host and remote command.
*/
- private String listDirectory(InternalManagedEntity entity,
- String dir) {
+ private String listDirectory(InternalManagedEntity entity, String dir) {
ManagedEntityConfig config = entity.getEntityConfig();
- String listFile =
- pathIsWindows(config.getProductDirectory()) ? "dir " : "ls ";
- String command =
- arrangeRemoteCommand(entity, listFile + dir);
+ String listFile = pathIsWindows(config.getProductDirectory()) ? "dir " : "ls ";
+ String command = arrangeRemoteCommand(entity, listFile + dir);
return execute(command, entity);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupRequest.java b/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupRequest.java
index 2de4b08..25abd7e 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupRequest.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.internal;
@@ -47,30 +45,31 @@ import org.apache.geode.internal.logging.LogService;
import org.apache.geode.internal.logging.log4j.LocalizedMessage;
/**
- * A request send from an admin VM to all of the peers to indicate
- * that that should complete the backup operation.
+ * A request send from an admin VM to all of the peers to indicate that that should complete the
+ * backup operation.
*
*
*/
-public class FinishBackupRequest extends CliLegacyMessage {
+public class FinishBackupRequest extends CliLegacyMessage {
private static final Logger logger = LogService.getLogger();
-
+
private File targetDir;
private File baselineDir;
private boolean abort;
-
+
public FinishBackupRequest() {
super();
}
- public FinishBackupRequest(File targetDir,File baselineDir, boolean abort) {
+ public FinishBackupRequest(File targetDir, File baselineDir, boolean abort) {
this.targetDir = targetDir;
this.baselineDir = baselineDir;
this.abort = abort;
}
-
- public static Map<DistributedMember, Set<PersistentID>> send(DM dm, Set recipients, File targetDir, File baselineDir, boolean abort) {
- FinishBackupRequest request = new FinishBackupRequest(targetDir,baselineDir, abort);
+
+ public static Map<DistributedMember, Set<PersistentID>> send(DM dm, Set recipients,
+ File targetDir, File baselineDir, boolean abort) {
+ FinishBackupRequest request = new FinishBackupRequest(targetDir, baselineDir, abort);
request.setRecipients(recipients);
FinishBackupReplyProcessor replyProcessor = new FinishBackupReplyProcessor(dm, recipients);
@@ -79,40 +78,41 @@ public class FinishBackupRequest extends CliLegacyMessage {
try {
replyProcessor.waitForReplies();
} catch (ReplyException e) {
- if(!(e.getCause() instanceof CancelException)) {
+ if (!(e.getCause() instanceof CancelException)) {
throw e;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
- AdminResponse response = request.createResponse((DistributionManager)dm);
+ AdminResponse response = request.createResponse((DistributionManager) dm);
response.setSender(dm.getDistributionManagerId());
replyProcessor.process(response);
return replyProcessor.results;
}
-
+
@Override
protected AdminResponse createResponse(DistributionManager dm) {
GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
HashSet<PersistentID> persistentIds;
- if(cache == null || cache.getBackupManager() == null) {
+ if (cache == null || cache.getBackupManager() == null) {
persistentIds = new HashSet<PersistentID>();
} else {
try {
persistentIds = cache.getBackupManager().finishBackup(targetDir, baselineDir, abort);
} catch (IOException e) {
- logger.error(LocalizedMessage.create(LocalizedStrings.CliLegacyMessage_ERROR, this.getClass()), e);
+ logger.error(
+ LocalizedMessage.create(LocalizedStrings.CliLegacyMessage_ERROR, this.getClass()), e);
return AdminFailureResponse.create(dm, getSender(), e);
}
}
-
+
return new FinishBackupResponse(this.getSender(), persistentIds);
}
public int getDSFID() {
return FINISH_BACKUP_REQUEST;
}
-
+
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
super.fromData(in);
@@ -130,42 +130,44 @@ public class FinishBackupRequest extends CliLegacyMessage {
}
private static class FinishBackupReplyProcessor extends AdminMultipleReplyProcessor {
- Map<DistributedMember, Set<PersistentID>> results = Collections.synchronizedMap(new HashMap<DistributedMember, Set<PersistentID>>());
+ Map<DistributedMember, Set<PersistentID>> results =
+ Collections.synchronizedMap(new HashMap<DistributedMember, Set<PersistentID>>());
+
public FinishBackupReplyProcessor(DM dm, Collection initMembers) {
super(dm, initMembers);
}
-
+
@Override
protected boolean stopBecauseOfExceptions() {
return false;
}
-
-
+
+
@Override
protected int getAckWaitThreshold() {
- //Disable the 15 second warning if the backup is taking a long time
+ // Disable the 15 second warning if the backup is taking a long time
return 0;
}
@Override
public long getAckSevereAlertThresholdMS() {
- //Don't log severe alerts for backups either
+ // Don't log severe alerts for backups either
return Long.MAX_VALUE;
}
@Override
protected void process(DistributionMessage msg, boolean warn) {
- if(msg instanceof FinishBackupResponse) {
+ if (msg instanceof FinishBackupResponse) {
final HashSet<PersistentID> persistentIds = ((FinishBackupResponse) msg).getPersistentIds();
- if(persistentIds != null && !persistentIds.isEmpty()) {
+ if (persistentIds != null && !persistentIds.isEmpty()) {
results.put(msg.getSender(), persistentIds);
}
}
super.process(msg, warn);
}
-
-
+
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupResponse.java b/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupResponse.java
index d3595ef..ab032b7 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupResponse.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/FinishBackupResponse.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.internal;
@@ -27,25 +25,25 @@ import org.apache.geode.distributed.internal.membership.InternalDistributedMembe
import org.apache.geode.internal.admin.remote.AdminResponse;
/**
- * The reply for a {@link FinishBackupRequest}. The
- * reply contains the persistent ids of the disk stores
- * that were backed up on this member.
+ * The reply for a {@link FinishBackupRequest}. The reply contains the persistent ids of the disk
+ * stores that were backed up on this member.
*
*
*/
public class FinishBackupResponse extends AdminResponse {
-
+
private HashSet<PersistentID> persistentIds;
-
+
public FinishBackupResponse() {
super();
}
- public FinishBackupResponse(InternalDistributedMember sender, HashSet<PersistentID> persistentIds) {
+ public FinishBackupResponse(InternalDistributedMember sender,
+ HashSet<PersistentID> persistentIds) {
this.setRecipient(sender);
this.persistentIds = persistentIds;
}
-
+
public HashSet<PersistentID> getPersistentIds() {
return persistentIds;
}
@@ -70,7 +68,7 @@ public class FinishBackupResponse extends AdminResponse {
public int getDSFID() {
return FINISH_BACKUP_RESPONSE;
}
-
+
@Override
public String toString() {
return getClass().getName() + ": " + persistentIds;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java
index 2232377..ff6dd9d 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskRequest.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.internal;
@@ -32,19 +30,18 @@ import org.apache.geode.internal.cache.DiskStoreImpl;
import org.apache.geode.internal.cache.GemFireCacheImpl;
/**
- * A request to from an admin VM to all non admin members
- * to start a backup. In the prepare phase of the backup,
- * the members will suspend bucket destroys to make sure
- * buckets aren't missed during the backup.
+ * A request to from an admin VM to all non admin members to start a backup. In the prepare phase of
+ * the backup, the members will suspend bucket destroys to make sure buckets aren't missed during
+ * the backup.
*
*
*/
-public class FlushToDiskRequest extends CliLegacyMessage {
-
+public class FlushToDiskRequest extends CliLegacyMessage {
+
public FlushToDiskRequest() {
-
+
}
-
+
public static void send(DM dm, Set recipients) {
FlushToDiskRequest request = new FlushToDiskRequest();
request.setRecipients(recipients);
@@ -55,40 +52,40 @@ public class FlushToDiskRequest extends CliLegacyMessage {
try {
replyProcessor.waitForReplies();
} catch (ReplyException e) {
- if(!(e.getCause() instanceof CancelException)) {
+ if (!(e.getCause() instanceof CancelException)) {
throw e;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
- AdminResponse response = request.createResponse((DistributionManager)dm);
+ AdminResponse response = request.createResponse((DistributionManager) dm);
response.setSender(dm.getDistributionManagerId());
replyProcessor.process(response);
}
-
+
@Override
protected AdminResponse createResponse(DistributionManager dm) {
GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
HashSet<PersistentID> persistentIds;
- if(cache != null) {
+ if (cache != null) {
Collection<DiskStoreImpl> diskStores = cache.listDiskStoresIncludingRegionOwned();
- for(DiskStoreImpl store : diskStores) {
+ for (DiskStoreImpl store : diskStores) {
store.flush();
}
}
-
+
return new FlushToDiskResponse(this.getSender());
}
public int getDSFID() {
return FLUSH_TO_DISK_REQUEST;
}
-
+
private static class FlushToDiskProcessor extends AdminMultipleReplyProcessor {
public FlushToDiskProcessor(DM dm, Collection initMembers) {
super(dm, initMembers);
}
-
+
@Override
protected boolean stopBecauseOfExceptions() {
return false;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskResponse.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskResponse.java b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskResponse.java
index 622abd3..5461ebb 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskResponse.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/FlushToDiskResponse.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.internal;
@@ -33,11 +31,11 @@ public class FlushToDiskResponse extends AdminResponse {
public FlushToDiskResponse(InternalDistributedMember sender) {
this.setRecipient(sender);
}
-
+
public int getDSFID() {
return FLUSH_TO_DISK_RESPONSE;
}
-
+
@Override
public String toString() {
return getClass().getName();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthConfigImpl.java
index 754b0fb..4bf0305 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthConfigImpl.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.internal;
@@ -28,35 +26,32 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
*
* @since GemFire 3.5
*/
-public class GemFireHealthConfigImpl
- extends CacheHealthConfigImpl
- implements GemFireHealthConfig {
+public class GemFireHealthConfigImpl extends CacheHealthConfigImpl implements GemFireHealthConfig {
private static final long serialVersionUID = -6797673296902808018L;
/** The name of the host to which this configuration applies. */
private String hostName;
- /** The number of seconds to wait between evaluating the health of
- * GemFire. */
+ /**
+ * The number of seconds to wait between evaluating the health of GemFire.
+ */
private int interval = DEFAULT_HEALTH_EVALUATION_INTERVAL;
- //////////////////////// Constructors ////////////////////////
+ //////////////////////// Constructors ////////////////////////
/**
- * Creates a new <code>GemFireHealthConfigImpl</code> that applies
- * to the host with the given name.
+ * Creates a new <code>GemFireHealthConfigImpl</code> that applies to the host with the given
+ * name.
*
- * @param hostName
- * The name of the host to which this configuration applies.
- * If <code>null</code>, then this is the "default"
- * configuration.
+ * @param hostName The name of the host to which this configuration applies. If <code>null</code>,
+ * then this is the "default" configuration.
*/
public GemFireHealthConfigImpl(String hostName) {
this.hostName = hostName;
}
- /////////////////////// Instance Methods ///////////////////////
+ /////////////////////// Instance Methods ///////////////////////
public String getHostName() {
return this.hostName;
@@ -73,10 +68,12 @@ public class GemFireHealthConfigImpl
@Override
public String toString() {
if (this.hostName == null) {
- return LocalizedStrings.GemFireHealthConfigImpl_DEFAULT_GEMFIRE_HEALTH_CONFIGURATION.toLocalizedString();
+ return LocalizedStrings.GemFireHealthConfigImpl_DEFAULT_GEMFIRE_HEALTH_CONFIGURATION
+ .toLocalizedString();
} else {
- return LocalizedStrings.GemFireHealthConfigImpl_GEMFIRE_HEALTH_CONFIGURATION_FOR_HOST_0.toLocalizedString(this.hostName);
+ return LocalizedStrings.GemFireHealthConfigImpl_GEMFIRE_HEALTH_CONFIGURATION_FOR_HOST_0
+ .toLocalizedString(this.hostName);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthEvaluator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthEvaluator.java b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthEvaluator.java
index f07cb2c..1573ca7 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthEvaluator.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthEvaluator.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.internal;
@@ -30,14 +28,13 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.internal.logging.LogService;
/**
- * Evaluates the health of various GemFire components in the VM
- * according to a {@link GemFireHealthConfig}.
+ * Evaluates the health of various GemFire components in the VM according to a
+ * {@link GemFireHealthConfig}.
*
* <P>
*
- * Note that evaluators never reside in the administration VM, they
- * only in member VMs. They are not <code>Serializable</code> and
- * aren't meant to be.
+ * Note that evaluators never reside in the administration VM, they only in member VMs. They are not
+ * <code>Serializable</code> and aren't meant to be.
*
* @see MemberHealthEvaluator
* @see CacheHealthEvaluator
@@ -48,7 +45,7 @@ import org.apache.geode.internal.logging.LogService;
public class GemFireHealthEvaluator {
private static final Logger logger = LogService.getLogger();
-
+
/** Determines how the health of GemFire is determined */
private GemFireHealthConfig config;
@@ -58,29 +55,28 @@ public class GemFireHealthEvaluator {
/** Evaluates the health of the Cache hosted in this VM */
private CacheHealthEvaluator cacheHealth;
- /** The most recent <code>OKAY_HEALTH</code> diagnoses of the
- * GemFire system */
+ /**
+ * The most recent <code>OKAY_HEALTH</code> diagnoses of the GemFire system
+ */
private List okayDiagnoses;
- /** The most recent <code>POOR_HEALTH</code> diagnoses of the
- * GemFire system */
+ /**
+ * The most recent <code>POOR_HEALTH</code> diagnoses of the GemFire system
+ */
private List poorDiagnoses;
- /////////////////////// Constructors ///////////////////////
+ /////////////////////// Constructors ///////////////////////
/**
* Creates a new <code>GemFireHealthEvaluator</code>
*
- * @param config
- * The configuration that determines whether or GemFire is
- * healthy
- * @param dm
- * The distribution manager
+ * @param config The configuration that determines whether or GemFire is healthy
+ * @param dm The distribution manager
*/
- public GemFireHealthEvaluator(GemFireHealthConfig config,
- DistributionManager dm) {
+ public GemFireHealthEvaluator(GemFireHealthConfig config, DistributionManager dm) {
if (config == null) {
- throw new NullPointerException(LocalizedStrings.GemFireHealthEvaluator_NULL_GEMFIREHEALTHCONFIG.toLocalizedString());
+ throw new NullPointerException(
+ LocalizedStrings.GemFireHealthEvaluator_NULL_GEMFIREHEALTHCONFIG.toLocalizedString());
}
this.config = config;
@@ -90,13 +86,13 @@ public class GemFireHealthEvaluator {
this.poorDiagnoses = new ArrayList();
}
- ////////////////////// Instance Methods //////////////////////
+ ////////////////////// Instance Methods //////////////////////
/**
* Evaluates the health of the GemFire components in this VM.
*
- * @return The aggregate health code (such as {@link
- * GemFireHealth#OKAY_HEALTH}) of the GemFire components.
+ * @return The aggregate health code (such as {@link GemFireHealth#OKAY_HEALTH}) of the GemFire
+ * components.
*/
public GemFireHealth.Health evaluate() {
List status = new ArrayList();
@@ -107,9 +103,9 @@ public class GemFireHealthEvaluator {
this.okayDiagnoses.clear();
this.poorDiagnoses.clear();
- for (Iterator iter = status.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = status.iterator(); iter.hasNext();) {
AbstractHealthEvaluator.HealthStatus health =
- (AbstractHealthEvaluator.HealthStatus) iter.next();
+ (AbstractHealthEvaluator.HealthStatus) iter.next();
if (overallHealth == GemFireHealth.GOOD_HEALTH) {
if ((health.getHealthCode() != GemFireHealth.GOOD_HEALTH)) {
overallHealth = health.getHealthCode();
@@ -137,10 +133,9 @@ public class GemFireHealthEvaluator {
}
/**
- * Returns detailed information explaining the current health status.
- * Each array element is a different cause for the current status.
- * An empty array will be returned if the current status is {@link
- * GemFireHealth#GOOD_HEALTH}.
+ * Returns detailed information explaining the current health status. Each array element is a
+ * different cause for the current status. An empty array will be returned if the current status
+ * is {@link GemFireHealth#GOOD_HEALTH}.
*/
public String[] getDiagnosis(GemFireHealth.Health healthCode) {
if (healthCode == GemFireHealth.GOOD_HEALTH) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthImpl.java
index f944482..efeee66 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/GemFireHealthImpl.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.internal;
@@ -27,17 +25,14 @@ import java.net.UnknownHostException;
import java.util.*;
/**
- * Provides the implementation of the <code>GemFireHealth</code>
- * administration API. This class is responsible for {@linkplain
- * GemFireVM#addHealthListener sending} the {@link
- * GemFireHealthConfig}s to the remote member VM in which the health
- * is calcualted.
+ * Provides the implementation of the <code>GemFireHealth</code> administration API. This class is
+ * responsible for {@linkplain GemFireVM#addHealthListener sending} the {@link GemFireHealthConfig}s
+ * to the remote member VM in which the health is calcualted.
*
*
* @since GemFire 3.5
*/
-public class GemFireHealthImpl
- implements GemFireHealth, JoinLeaveListener, HealthListener {
+public class GemFireHealthImpl implements GemFireHealth, JoinLeaveListener, HealthListener {
/** The distributed system whose health is being monitored */
private final GfManagerAgent agent;
@@ -45,12 +40,15 @@ public class GemFireHealthImpl
/** The default configuration for checking GemFire health */
protected GemFireHealthConfig defaultConfig;
- /** Maps the name of a host to its <code>GemFireHealthConfig</code>.
- * Note that the mappings are created lazily. */
+ /**
+ * Maps the name of a host to its <code>GemFireHealthConfig</code>. Note that the mappings are
+ * created lazily.
+ */
private final Map hostConfigs;
- /** Maps the name of a host to all of the members
- * (<code>GemFireVM</code>s) that run on that host. */
+ /**
+ * Maps the name of a host to all of the members (<code>GemFireVM</code>s) that run on that host.
+ */
private final Map hostMembers;
/** The members that are known to be in {@link #OKAY_HEALTH}. */
@@ -65,28 +63,29 @@ public class GemFireHealthImpl
/** Is this GemFireHealthImpl closed? */
private boolean isClosed;
- /** The configuration specifying how the health of the distributed
- * system should be computed. */
+ /**
+ * The configuration specifying how the health of the distributed system should be computed.
+ */
protected volatile DistributedSystemHealthConfig dsHealthConfig;
/** Monitors the health of the entire distributed system */
private DistributedSystemHealthMonitor dsHealthMonitor = null;
- /** The distributed system whose health is monitored by this
- * <Code>GemFireHealth</code>. */
+ /**
+ * The distributed system whose health is monitored by this <Code>GemFireHealth</code>.
+ */
private final AdminDistributedSystem system;
-
- /////////////////////// Constructors ///////////////////////
+
+ /////////////////////// Constructors ///////////////////////
/**
- * Creates a new <code>GemFireHealthImpl</code> that monitors the
- * health of member of the given distributed system.
+ * Creates a new <code>GemFireHealthImpl</code> that monitors the health of member of the given
+ * distributed system.
*/
- protected GemFireHealthImpl(GfManagerAgent agent,
- AdminDistributedSystem system) {
-// agent.getDM().getLogger().info("Creating GemFireHealthImpl",
-// new Exception("Stack trace"));
+ protected GemFireHealthImpl(GfManagerAgent agent, AdminDistributedSystem system) {
+ // agent.getDM().getLogger().info("Creating GemFireHealthImpl",
+ // new Exception("Stack trace"));
this.agent = agent;
this.system = system;
@@ -120,58 +119,53 @@ public class GemFireHealthImpl
sb.append("; diagnosis=" + getDiagnosis());
return sb.toString();
}
- ////////////////////// Instance Methods //////////////////////
+ ////////////////////// Instance Methods //////////////////////
/**
- * Returns the <code>DistributedSystem</code> whose health this
- * <code>GemFireHealth</code> monitors.
+ * Returns the <code>DistributedSystem</code> whose health this <code>GemFireHealth</code>
+ * monitors.
*/
public AdminDistributedSystem getDistributedSystem() {
return this.system;
}
/**
- * A "template factory" method for creating a
- * <code>DistributedSystemHealthConfig</code>. It can be overridden
- * by subclasses to produce instances of different
+ * A "template factory" method for creating a <code>DistributedSystemHealthConfig</code>. It can
+ * be overridden by subclasses to produce instances of different
* <code>DistributedSystemHealthConfig</code> implementations.
*/
- protected DistributedSystemHealthConfig
- createDistributedSystemHealthConfig() {
+ protected DistributedSystemHealthConfig createDistributedSystemHealthConfig() {
return new DistributedSystemHealthConfigImpl();
}
/**
- * A "template factory" method for creating a
- * <code>GemFireHealthConfig</code>. It can be overridden by
- * subclasses to produce instances of different
- * <code>GemFireHealthConfig</code> implementations.
+ * A "template factory" method for creating a <code>GemFireHealthConfig</code>. It can be
+ * overridden by subclasses to produce instances of different <code>GemFireHealthConfig</code>
+ * implementations.
*
- * @param hostName
- * The host whose health we are configuring
+ * @param hostName The host whose health we are configuring
*/
- protected GemFireHealthConfig
- createGemFireHealthConfig(String hostName) {
+ protected GemFireHealthConfig createGemFireHealthConfig(String hostName) {
return new GemFireHealthConfigImpl(hostName);
}
/**
- * Throws an {@link IllegalStateException} if this
- * <code>GemFireHealthImpl</code> is closed.
+ * Throws an {@link IllegalStateException} if this <code>GemFireHealthImpl</code> is closed.
*/
private void checkClosed() {
if (this.isClosed) {
- throw new IllegalStateException(LocalizedStrings.GemFireHealthImpl_CANNOT_ACCESS_A_CLOSED_GEMFIREHEALTH_INSTANCE.toLocalizedString());
+ throw new IllegalStateException(
+ LocalizedStrings.GemFireHealthImpl_CANNOT_ACCESS_A_CLOSED_GEMFIREHEALTH_INSTANCE
+ .toLocalizedString());
}
}
/**
- * Returns the overall health of GemFire. Note that this method
- * does not contact any of the member VMs. Instead, it relies on
- * the members to alert it of changes in its health via a {@link
- * HealthListener}.
+ * Returns the overall health of GemFire. Note that this method does not contact any of the member
+ * VMs. Instead, it relies on the members to alert it of changes in its health via a
+ * {@link HealthListener}.
*/
public GemFireHealth.Health getHealth() {
checkClosed();
@@ -179,8 +173,8 @@ public class GemFireHealthImpl
}
/**
- * Resets the overall health to be {@link #GOOD_HEALTH}. It also
- * resets the health in the member VMs.
+ * Resets the overall health to be {@link #GOOD_HEALTH}. It also resets the health in the member
+ * VMs.
*
* @see GemFireVM#resetHealthStatus
*/
@@ -192,10 +186,9 @@ public class GemFireHealthImpl
this.poorHealth.clear();
synchronized (this) {
- for (Iterator iter = hostMembers.values().iterator();
- iter.hasNext(); ) {
+ for (Iterator iter = hostMembers.values().iterator(); iter.hasNext();) {
List members = (List) iter.next();
- for (Iterator iter2 = members.iterator(); iter2.hasNext(); ) {
+ for (Iterator iter2 = members.iterator(); iter2.hasNext();) {
GemFireVM member = (GemFireVM) iter2.next();
member.resetHealthStatus();
}
@@ -204,8 +197,7 @@ public class GemFireHealthImpl
}
/**
- * Aggregates the diagnoses from all members of the distributed
- * system.
+ * Aggregates the diagnoses from all members of the distributed system.
*/
public String getDiagnosis() {
checkClosed();
@@ -213,13 +205,11 @@ public class GemFireHealthImpl
StringBuffer sb = new StringBuffer();
synchronized (this) {
- for (Iterator iter = hostMembers.values().iterator();
- iter.hasNext(); ) {
+ for (Iterator iter = hostMembers.values().iterator(); iter.hasNext();) {
List members = (List) iter.next();
- for (Iterator iter2 = members.iterator(); iter2.hasNext(); ) {
+ for (Iterator iter2 = members.iterator(); iter2.hasNext();) {
GemFireVM member = (GemFireVM) iter2.next();
- String[] diagnoses =
- member.getHealthDiagnosis(this.overallHealth);
+ String[] diagnoses = member.getHealthDiagnosis(this.overallHealth);
for (int i = 0; i < diagnoses.length; i++) {
sb.append(diagnoses[i]).append("\n");;
}
@@ -233,8 +223,7 @@ public class GemFireHealthImpl
/**
* Starts a new {@link DistributedSystemHealthMonitor}
*/
- public void setDistributedSystemHealthConfig(DistributedSystemHealthConfig
- config) {
+ public void setDistributedSystemHealthConfig(DistributedSystemHealthConfig config) {
synchronized (this.hostConfigs) {
// If too many threads are changing the health config, then we
// will might get an OutOfMemoryError trying to start a new
@@ -247,17 +236,14 @@ public class GemFireHealthImpl
this.dsHealthConfig = config;
DistributedSystemHealthEvaluator eval =
- new DistributedSystemHealthEvaluator(config, this.agent.getDM());
- int interval =
- this.getDefaultGemFireHealthConfig().getHealthEvaluationInterval();
- this.dsHealthMonitor =
- new DistributedSystemHealthMonitor(eval, this, interval);
+ new DistributedSystemHealthEvaluator(config, this.agent.getDM());
+ int interval = this.getDefaultGemFireHealthConfig().getHealthEvaluationInterval();
+ this.dsHealthMonitor = new DistributedSystemHealthMonitor(eval, this, interval);
this.dsHealthMonitor.start();
}
}
- public DistributedSystemHealthConfig
- getDistributedSystemHealthConfig() {
+ public DistributedSystemHealthConfig getDistributedSystemHealthConfig() {
checkClosed();
return this.dsHealthConfig;
@@ -272,25 +258,25 @@ public class GemFireHealthImpl
checkClosed();
if (config.getHostName() != null) {
- throw new IllegalArgumentException(LocalizedStrings.GemFireHealthImpl_THE_GEMFIREHEALTHCONFIG_FOR_FOR_0_CANNOT_SERVE_AS_THE_DEFAULT_HEALTH_CONFIG.toLocalizedString(config.getHostName()));
+ throw new IllegalArgumentException(
+ LocalizedStrings.GemFireHealthImpl_THE_GEMFIREHEALTHCONFIG_FOR_FOR_0_CANNOT_SERVE_AS_THE_DEFAULT_HEALTH_CONFIG
+ .toLocalizedString(config.getHostName()));
}
this.defaultConfig = config;
synchronized (this) {
- for (Iterator iter = this.hostMembers.entrySet().iterator();
- iter.hasNext(); ) {
+ for (Iterator iter = this.hostMembers.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
InetAddress hostIpAddress = (InetAddress) entry.getKey();
List members = (List) entry.getValue();
- GemFireHealthConfig hostConfig =
- (GemFireHealthConfig) hostConfigs.get(hostIpAddress);
+ GemFireHealthConfig hostConfig = (GemFireHealthConfig) hostConfigs.get(hostIpAddress);
if (hostConfig == null) {
hostConfig = config;
}
- for (Iterator iter2 = members.iterator(); iter2.hasNext(); ) {
+ for (Iterator iter2 = members.iterator(); iter2.hasNext();) {
GemFireVM member = (GemFireVM) iter2.next();
Assert.assertTrue(member.getHost().equals(hostIpAddress));
member.addHealthListener(this, hostConfig);
@@ -299,7 +285,7 @@ public class GemFireHealthImpl
}
// We only need to do this if the health monitoring interval has
- // change. This is probably not the most efficient way of doing
+ // change. This is probably not the most efficient way of doing
// things.
if (this.dsHealthConfig != null) {
setDistributedSystemHealthConfig(this.dsHealthConfig);
@@ -309,14 +295,11 @@ public class GemFireHealthImpl
/**
* Returns the GemFireHealthConfig object for the given host name.
*
- * @param hostName
- * host name for which the GemFire Health Config is needed
+ * @param hostName host name for which the GemFire Health Config is needed
*
- * @throws IllegalArgumentException
- * if host with given name could not be found
+ * @throws IllegalArgumentException if host with given name could not be found
*/
- public synchronized GemFireHealthConfig
- getGemFireHealthConfig(String hostName){
+ public synchronized GemFireHealthConfig getGemFireHealthConfig(String hostName) {
checkClosed();
@@ -326,11 +309,11 @@ public class GemFireHealthImpl
} catch (UnknownHostException e) {
throw new IllegalArgumentException(
LocalizedStrings.GemFireHealthImpl_COULD_NOT_FIND_A_HOST_WITH_NAME_0
- .toLocalizedString(hostName), e);
+ .toLocalizedString(hostName),
+ e);
}
-
- GemFireHealthConfig config =
- (GemFireHealthConfig) this.hostConfigs.get(hostIpAddress);
+
+ GemFireHealthConfig config = (GemFireHealthConfig) this.hostConfigs.get(hostIpAddress);
if (config == null) {
config = createGemFireHealthConfig(hostName);
this.hostConfigs.put(hostIpAddress, config);
@@ -342,18 +325,14 @@ public class GemFireHealthImpl
/**
* Sets the GemFireHealthConfig object for the given host name.
*
- * @param hostName
- * host name for which the GemFire Health Config is needed
- * @param config
- * GemFireHealthConfig object to set
+ * @param hostName host name for which the GemFire Health Config is needed
+ * @param config GemFireHealthConfig object to set
*
- * @throws IllegalArgumentException
- * if (1) given host name & the host name in the given config do not
- * match OR (2) host with given name could not be found OR (3) there
- * are no GemFire components running on the given host
+ * @throws IllegalArgumentException if (1) given host name & the host name in the given config do
+ * not match OR (2) host with given name could not be found OR (3) there are no GemFire
+ * components running on the given host
*/
- public void setGemFireHealthConfig(String hostName,
- GemFireHealthConfig config) {
+ public void setGemFireHealthConfig(String hostName, GemFireHealthConfig config) {
checkClosed();
synchronized (this) {
@@ -378,9 +357,10 @@ public class GemFireHealthImpl
} catch (UnknownHostException e) {
throw new IllegalArgumentException(
LocalizedStrings.GemFireHealthImpl_COULD_NOT_FIND_A_HOST_WITH_NAME_0
- .toLocalizedString(hostName), e);
+ .toLocalizedString(hostName),
+ e);
}
-
+
List members = (List) this.hostMembers.get(hostIpAddress);
if (members == null || members.isEmpty()) {
throw new IllegalArgumentException(
@@ -388,7 +368,7 @@ public class GemFireHealthImpl
.toLocalizedString(hostName));
}
- for (Iterator iter = members.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = members.iterator(); iter.hasNext();) {
GemFireVM member = (GemFireVM) iter.next();
member.addHealthListener(this, config);
}
@@ -396,14 +376,14 @@ public class GemFireHealthImpl
}
/**
- * Tells the members of the distributed system that we are no longer
- * interested in monitoring their health.
+ * Tells the members of the distributed system that we are no longer interested in monitoring
+ * their health.
*
* @see GemFireVM#removeHealthListener
*/
- public void close(){
+ public void close() {
this.agent.removeJoinLeaveListener(this);
-
+
synchronized (this) {
if (this.isClosed) {
return;
@@ -417,10 +397,9 @@ public class GemFireHealthImpl
}
try {
- for (Iterator iter = hostMembers.values().iterator();
- iter.hasNext(); ) {
+ for (Iterator iter = hostMembers.values().iterator(); iter.hasNext();) {
List members = (List) iter.next();
- for (Iterator iter2 = members.iterator(); iter2.hasNext(); ) {
+ for (Iterator iter2 = members.iterator(); iter2.hasNext();) {
GemFireVM member = (GemFireVM) iter2.next();
member.removeHealthListener();
}
@@ -454,14 +433,12 @@ public class GemFireHealthImpl
}
- public synchronized void nodeJoined(GfManagerAgent source,
- GemFireVM joined) {
+ public synchronized void nodeJoined(GfManagerAgent source, GemFireVM joined) {
noteNewMember(joined);
InetAddress hostIpAddress = joined.getHost();
- GemFireHealthConfig config =
- (GemFireHealthConfig) this.hostConfigs.get(hostIpAddress);
+ GemFireHealthConfig config = (GemFireHealthConfig) this.hostConfigs.get(hostIpAddress);
if (config == null) {
config = this.getDefaultGemFireHealthConfig();
}
@@ -471,8 +448,7 @@ public class GemFireHealthImpl
/**
* Makes note of the newly-left member
*/
- public synchronized void nodeLeft(GfManagerAgent source,
- GemFireVM left) {
+ public synchronized void nodeLeft(GfManagerAgent source, GemFireVM left) {
InetAddress hostIpAddress = left.getHost();
List members = (List) this.hostMembers.get(hostIpAddress);
if (members != null) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/InetAddressUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/InetAddressUtil.java b/geode-core/src/main/java/org/apache/geode/admin/internal/InetAddressUtil.java
index 698a627..17d1535 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/InetAddressUtil.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/InetAddressUtil.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.internal;
@@ -31,31 +29,30 @@ import org.apache.geode.internal.logging.LogService;
/**
- * Provides static utilities for manipulating, validating, and converting
- * InetAddresses and host strings.
+ * Provides static utilities for manipulating, validating, and converting InetAddresses and host
+ * strings.
*
- * @since GemFire 3.5
+ * @since GemFire 3.5
*/
@Deprecated
public class InetAddressUtil {
-
+
private static final Logger logger = LogService.getLogger();
-
- /** InetAddress instance representing the local host */
+
+ /** InetAddress instance representing the local host */
public static final InetAddress LOCALHOST = createLocalHost();
-
- public static final String LOOPBACK_ADDRESS =
- SocketCreator.preferIPv6Addresses() ? "::1" : "127.0.0.1";
-
- public static final InetAddress LOOPBACK =
- InetAddressUtil.toInetAddress(LOOPBACK_ADDRESS);
-
+
+ public static final String LOOPBACK_ADDRESS =
+ SocketCreator.preferIPv6Addresses() ? "::1" : "127.0.0.1";
+
+ public static final InetAddress LOOPBACK = InetAddressUtil.toInetAddress(LOOPBACK_ADDRESS);
+
/** Disallows InetAddressUtil instantiation. */
private InetAddressUtil() {}
- /**
- * Returns a string version of InetAddress which can be converted back to an
- * InetAddress later. Essentially any leading slash is trimmed.
+ /**
+ * Returns a string version of InetAddress which can be converted back to an InetAddress later.
+ * Essentially any leading slash is trimmed.
*
* @param val the InetAddress or String to return a formatted string of
* @return string version the InetAddress minus any leading slash
@@ -71,16 +68,15 @@ public class InetAddressUtil {
return trimLeadingSlash(val.toString());
}
}
-
- /**
- * Converts the string host to an instance of InetAddress. Returns null if
- * the string is empty. Fails Assertion if the conversion would result in
- * <code>java.lang.UnknownHostException</code>.
+
+ /**
+ * Converts the string host to an instance of InetAddress. Returns null if the string is empty.
+ * Fails Assertion if the conversion would result in <code>java.lang.UnknownHostException</code>.
* <p>
* Any leading slashes on host will be ignored.
*
- * @param host string version the InetAddress
- * @return the host converted to InetAddress instance
+ * @param host string version the InetAddress
+ * @return the host converted to InetAddress instance
*/
public static InetAddress toInetAddress(String host) {
if (host == null || host.length() == 0) {
@@ -89,8 +85,7 @@ public class InetAddressUtil {
try {
if (host.indexOf("/") > -1) {
return InetAddress.getByName(host.substring(host.indexOf("/") + 1));
- }
- else {
+ } else {
return InetAddress.getByName(host);
}
} catch (java.net.UnknownHostException e) {
@@ -100,10 +95,10 @@ public class InetAddressUtil {
}
}
- /**
- * Creates an InetAddress representing the local host. The checked exception
- * <code>java.lang.UnknownHostException</code> is captured and results in
- * an Assertion failure instead.
+ /**
+ * Creates an InetAddress representing the local host. The checked exception
+ * <code>java.lang.UnknownHostException</code> is captured and results in an Assertion failure
+ * instead.
*
* @return InetAddress instance representing the local host
*/
@@ -117,24 +112,24 @@ public class InetAddressUtil {
}
}
- /**
- * Validates the host by making sure it can successfully be used to get an
- * instance of InetAddress. If the host string is null, empty or would result
- * in <code>java.lang.UnknownHostException</code> then null is returned.
+ /**
+ * Validates the host by making sure it can successfully be used to get an instance of
+ * InetAddress. If the host string is null, empty or would result in
+ * <code>java.lang.UnknownHostException</code> then null is returned.
* <p>
* Any leading slashes on host will be ignored.
*
- * @param host string version the InetAddress
- * @return the host converted to InetAddress instance
+ * @param host string version the InetAddress
+ * @return the host converted to InetAddress instance
*/
public static String validateHost(String host) {
if (host == null || host.length() == 0) {
- return null;
+ return null;
}
try {
InetAddress.getByName(trimLeadingSlash(host));
return host;
- } catch (java.net.UnknownHostException e) {
+ } catch (java.net.UnknownHostException e) {
logStackTrace(e);
return null;
}
@@ -145,45 +140,45 @@ public class InetAddressUtil {
if (host instanceof InetAddress) {
if (LOCALHOST.equals(host)) {
return true;
- }
- else {
-// InetAddress hostAddr = (InetAddress)host;
+ } else {
+ // InetAddress hostAddr = (InetAddress)host;
try {
- Enumeration en=NetworkInterface.getNetworkInterfaces();
- while(en.hasMoreElements()) {
- NetworkInterface i=(NetworkInterface)en.nextElement();
- for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) {
- InetAddress addr=(InetAddress)en2.nextElement();
+ Enumeration en = NetworkInterface.getNetworkInterfaces();
+ while (en.hasMoreElements()) {
+ NetworkInterface i = (NetworkInterface) en.nextElement();
+ for (Enumeration en2 = i.getInetAddresses(); en2.hasMoreElements();) {
+ InetAddress addr = (InetAddress) en2.nextElement();
if (host.equals(addr)) {
return true;
}
}
}
return false;
- }
- catch (SocketException e) {
- throw new GemFireIOException(LocalizedStrings.InetAddressUtil_UNABLE_TO_QUERY_NETWORK_INTERFACE.toLocalizedString(), e);
+ } catch (SocketException e) {
+ throw new GemFireIOException(
+ LocalizedStrings.InetAddressUtil_UNABLE_TO_QUERY_NETWORK_INTERFACE
+ .toLocalizedString(),
+ e);
}
}
- }
- else {
+ } else {
return isLocalHost(InetAddressUtil.toInetAddress(host.toString()));
}
}
-
+
/** Returns true if host matches the LOOPBACK (127.0.0.1). */
public static boolean isLoopback(Object host) {
if (host instanceof InetAddress) {
return LOOPBACK.equals(host);
- }
- else {
+ } else {
return isLoopback(InetAddressUtil.toInetAddress(host.toString()));
}
}
-
+
/** Returns a version of the value after removing any leading slashes */
private static String trimLeadingSlash(String value) {
- if (value == null) return "";
+ if (value == null)
+ return "";
while (value.indexOf("/") > -1) {
value = value.substring(value.indexOf("/") + 1);
}
@@ -191,19 +186,16 @@ public class InetAddressUtil {
}
/**
- * Logs the stack trace for the given Throwable if logger is initialized else
- * prints the stack trace using System.out. If logged the logs are logged at
- * WARNING level.
+ * Logs the stack trace for the given Throwable if logger is initialized else prints the stack
+ * trace using System.out. If logged the logs are logged at WARNING level.
*
- * @param throwable
- * Throwable to log stack trace for
+ * @param throwable Throwable to log stack trace for
*/
private static void logStackTrace(Throwable throwable) {
- AdminDistributedSystemImpl adminDS =
- AdminDistributedSystemImpl.getConnectedInstance();
+ AdminDistributedSystemImpl adminDS = AdminDistributedSystemImpl.getConnectedInstance();
logger.warn(throwable.getMessage(), throwable);
- }
-
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/admin/internal/InternalManagedEntity.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/InternalManagedEntity.java b/geode-core/src/main/java/org/apache/geode/admin/internal/InternalManagedEntity.java
index d963a21..6211aea 100644
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/InternalManagedEntity.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/InternalManagedEntity.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.internal;
@@ -21,9 +19,8 @@ import org.apache.geode.admin.ManagedEntity;
import org.apache.geode.admin.ManagedEntityConfig;
/**
- * Provides internal-only functionality that is expected of all
- * <code>ManagedEntity<code>s. This functionality is used by the
- * {@link ManagedEntityController} to manage the entity.
+ * Provides internal-only functionality that is expected of all <code>ManagedEntity<code>s. This
+ * functionality is used by the {@link ManagedEntityController} to manage the entity.
*
* @since GemFire 4.0
*/
@@ -44,57 +41,51 @@ public interface InternalManagedEntity extends ManagedEntity {
/** A managed entity is running (is started) */
public static final int RUNNING = 14;
- ////////////////////// Instance Methods //////////////////////
+ ////////////////////// Instance Methods //////////////////////
/**
- * Returns the <code>ManagedEntityConfig</code> for this
- * <code>ManagedEntity</code>.
+ * Returns the <code>ManagedEntityConfig</code> for this <code>ManagedEntity</code>.
*/
public ManagedEntityConfig getEntityConfig();
/**
- * Returns a brief description (such as "locator") of this managed
- * entity.
+ * Returns a brief description (such as "locator") of this managed entity.
*/
public String getEntityType();
/**
- * Returns the (local) command to execute in order to start this
- * managed entity. The command includes the full path to the
- * executable (include <code>$GEMFIRE/bin</code>) and any
- * command-line arguments. It does not take the {@linkplain
- * ManagedEntityConfig#getRemoteCommand remote command} into account.
+ * Returns the (local) command to execute in order to start this managed entity. The command
+ * includes the full path to the executable (include <code>$GEMFIRE/bin</code>) and any
+ * command-line arguments. It does not take the {@linkplain ManagedEntityConfig#getRemoteCommand
+ * remote command} into account.
*/
public String getStartCommand();
/**
- * Returns the (local) command to execute in order to stop this
- * managed entity.
+ * Returns the (local) command to execute in order to stop this managed entity.
*/
public String getStopCommand();
/**
- * Returns the (local) command to execute in order to determine
- * whether or not this managed entity is runing.
+ * Returns the (local) command to execute in order to determine whether or not this managed entity
+ * is runing.
*/
public String getIsRunningCommand();
/**
- * Returns a descriptive, one-word, unique id for a newly-created
- * <code>ManagedEntity</code>. This ensures that we do not have
- * collisions in the ids of entities.
+ * Returns a descriptive, one-word, unique id for a newly-created <code>ManagedEntity</code>. This
+ * ensures that we do not have collisions in the ids of entities.
*/
public String getNewId();
/**
- * Returns the distributed system to which this managed entity
- * belongs.
+ * Returns the distributed system to which this managed entity belongs.
*/
public AdminDistributedSystem getDistributedSystem();
/**
- * Sets the state of this managed entity and informs threads that
- * are waiting for a state change. See bug 32455.
+ * Sets the state of this managed entity and informs threads that are waiting for a state change.
+ * See bug 32455.
*
* @return The previous state of this managed entity.
*