Return-Path:
- *
- *
+ *
+ *
+ *
* This class is a refactoring of
- *
- *
+ *
+ *
+ *
* 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
- * AdminDistributedSystem
associated with this
* configuration object.
+ *
* @since GemFire 3.5
*/
-public class DistributedSystemConfigImpl implements DistributedSystemConfig {
+public class DistributedSystemConfigImpl
+ implements DistributedSystemConfig {
private static final Logger logger = LogService.getLogger();
@@ -109,8 +99,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* The admin distributed system object that is configured by this
* config object.
- * @since GemFire 4.0
- */
+ *
+ * @since GemFire 4.0 */
private AdminDistributedSystemImpl system;
/**
@@ -124,14 +114,21 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* Filters out all properties that are unique to the admin
* DistributedSystemConfig
that are not present in the
* internal DistributionConfig
.
+ *
* @since GemFire 4.0
*/
- private static Properties filterOutAdminProperties(Properties props) {
+ private static Properties
+ filterOutAdminProperties(Properties props) {
Properties props2 = new Properties();
- for (Enumeration names = props.propertyNames(); names.hasMoreElements(); ) {
+ for (Enumeration names = props.propertyNames();
+ names.hasMoreElements(); ) {
String name = (String) names.nextElement();
- if (!(ENTITY_CONFIG_XML_FILE_NAME.equals(name) || REFRESH_INTERVAL_NAME.equals(name) || REMOTE_COMMAND_NAME.equals(name))) {
+ if (!(ENTITY_CONFIG_XML_FILE_NAME.equals(name) ||
+ REFRESH_INTERVAL_NAME.equals(name) ||
+ REMOTE_COMMAND_NAME.equals(name)
+ )
+ ) {
String value = props.getProperty(name);
if ((name != null) && (value != null)) {
props2.setProperty(name, value);
@@ -149,7 +146,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* the configuration stored in a DistributedSystem
's
* DistributionConfig
.
*/
- public DistributedSystemConfigImpl(DistributionConfig distConfig, String remoteCommand) {
+ public DistributedSystemConfigImpl(DistributionConfig distConfig,
+ String remoteCommand) {
if (distConfig == null) {
throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_DISTRIBUTIONCONFIG_MUST_NOT_BE_NULL.toLocalizedString());
}
@@ -157,7 +155,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
this.mcastAddress = InetAddressUtil.toString(distConfig.getMcastAddress());
this.mcastPort = distConfig.getMcastPort();
this.locators = distConfig.getLocators();
- this.membershipPortRange = getMembershipPortRangeString(distConfig.getMembershipPortRange());
+ this.membershipPortRange =
+ getMembershipPortRangeString(distConfig.getMembershipPortRange());
this.systemName = distConfig.getName();
@@ -167,7 +166,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
this.sslAuthenticationRequired = distConfig.getClusterSSLRequireAuthentication();
this.logFile = distConfig.getLogFile().getPath();
- this.logLevel = LogWriterImpl.levelToString(distConfig.getLogLevel());
+ this.logLevel =
+ LogWriterImpl.levelToString(distConfig.getLogLevel());
this.logDiskSpaceLimit = distConfig.getLogDiskSpaceLimit();
this.logFileSizeLimit = distConfig.getLogFileSizeLimit();
@@ -186,6 +186,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Zero-argument constructor to be used only by subclasses.
+ *
* @since GemFire 4.0
*/
protected DistributedSystemConfigImpl() {
@@ -204,32 +205,39 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Creates a new DistributedSystemConifgImpl
whose configuration
* is specified by the given Properties
object.
- * @param props The configuration properties specified by the caller
- * @param ignoreGemFirePropsFile whether to skip loading distributed system properties from
- * gemfire.properties file
- *
+ *
+ * @param props
+ * The configuration properties specified by the caller
+ * @param ignoreGemFirePropsFile
+ * whether to skip loading distributed system properties from
+ * gemfire.properties file
+ *
* @since GemFire 6.5
*/
- protected DistributedSystemConfigImpl(Properties props, boolean ignoreGemFirePropsFile) {
- this(new DistributionConfigImpl(filterOutAdminProperties(props), ignoreGemFirePropsFile), DEFAULT_REMOTE_COMMAND);
+ protected DistributedSystemConfigImpl(Properties props,
+ boolean ignoreGemFirePropsFile) {
+ this(new DistributionConfigImpl(
+ filterOutAdminProperties(props), ignoreGemFirePropsFile),
+ DEFAULT_REMOTE_COMMAND);
String remoteCommand = props.getProperty(REMOTE_COMMAND_NAME);
if (remoteCommand != null) {
this.remoteCommand = remoteCommand;
}
- String entityConfigXMLFile = props.getProperty(ENTITY_CONFIG_XML_FILE_NAME);
+ String entityConfigXMLFile =
+ props.getProperty(ENTITY_CONFIG_XML_FILE_NAME);
if (entityConfigXMLFile != null) {
this.entityConfigXMLFile = entityConfigXMLFile;
}
- String refreshInterval = props.getProperty(REFRESH_INTERVAL_NAME);
+ String refreshInterval =
+ props.getProperty(REFRESH_INTERVAL_NAME);
if (refreshInterval != null) {
try {
this.refreshInterval = Integer.parseInt(refreshInterval);
} catch (NumberFormatException nfEx) {
- throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_0_IS_NOT_A_VALID_INTEGER_1.toLocalizedString(new Object[] {
- refreshInterval, REFRESH_INTERVAL_NAME
- }));
+ throw new IllegalArgumentException(
+ LocalizedStrings.DistributedSystemConfigImpl_0_IS_NOT_A_VALID_INTEGER_1.toLocalizedString(new Object[] { refreshInterval, REFRESH_INTERVAL_NAME }));
}
}
}
@@ -240,6 +248,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* Returns the LogWriterI18n
to be used when administering
* the distributed system. Returns null if nothing has been provided via
* setInternalLogWriter
.
+ *
* @since GemFire 4.0
*/
public InternalLogWriter getInternalLogWriter() {
@@ -298,6 +307,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* Marks this config object as "read only". Attempts to modify a
* config object will result in a {@link IllegalStateException}
* being thrown.
+ *
* @since GemFire 4.0
*/
void setDistributedSystem(AdminDistributedSystemImpl system) {
@@ -307,12 +317,14 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Checks to see if this config object is "read only". If it is,
* then an {@link IllegalStateException} is thrown.
+ *
* @since GemFire 4.0
*/
protected void checkReadOnly() {
if (this.system != null) {
- throw new IllegalStateException(LocalizedStrings.DistributedSystemConfigImpl_A_DISTRIBUTEDSYSTEMCONFIG_OBJECT_CANNOT_BE_MODIFIED_AFTER_IT_HAS_BEEN_USED_TO_CREATE_AN_ADMINDISTRIBUTEDSYSTEM
- .toLocalizedString());
+ throw new IllegalStateException(
+ LocalizedStrings.DistributedSystemConfigImpl_A_DISTRIBUTEDSYSTEMCONFIG_OBJECT_CANNOT_BE_MODIFIED_AFTER_IT_HAS_BEEN_USED_TO_CREATE_AN_ADMINDISTRIBUTEDSYSTEM
+ .toLocalizedString());
}
}
@@ -329,6 +341,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Parses the XML configuration file that describes managed
* entities.
+ *
* @throws AdminXmlException If a problem is encountered while parsing the XML file.
*/
private void parseEntityConfigXMLFile() {
@@ -430,6 +443,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Returns the value for membership-port-range
+ *
* @return the value for the Distributed System property membership-port-range
*/
public String getMembershipPortRange() {
@@ -438,8 +452,9 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Sets the Distributed System property membership-port-range
+ *
* @param membershipPortRangeStr the value for membership-port-range given as two numbers separated
- * by a minus sign.
+ * by a minus sign.
*/
public void setMembershipPortRange(String membershipPortRangeStr) {
/*
@@ -457,9 +472,10 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
if (validateMembershipRange(membershipPortRangeStr)) {
this.membershipPortRange = membershipPortRangeStr;
} else {
- throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_INVALID_VALUE_FOR_MEMBERSHIP_PORT_RANGE.toLocalizedString(new Object[] {
- membershipPortRangeStr, MEMBERSHIP_PORT_RANGE_NAME
- }));
+ throw new IllegalArgumentException(
+ LocalizedStrings.DistributedSystemConfigImpl_INVALID_VALUE_FOR_MEMBERSHIP_PORT_RANGE
+ .toLocalizedString(new Object[] { membershipPortRangeStr,
+ MEMBERSHIP_PORT_RANGE_NAME }));
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
@@ -483,9 +499,9 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* Validates the given string - which is expected in the format as two numbers
* separated by a minus sign - in to an integer array of length 2 with first
* element as lower end & second element as upper end of the range.
- * @param membershipPortRange membership-port-range given as two numbers separated by a minus
- * sign.
*
+ * @param membershipPortRange membership-port-range given as two numbers separated by a minus
+ * sign.
* @return true if the membership-port-range string is valid, false otherwise
*/
private boolean validateMembershipRange(String membershipPortRange) {
@@ -497,7 +513,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
range[1] = Integer.parseInt(splitted[1].trim());
//NumberFormatException if any could be thrown
- if (range[0] < 0 || range[0] >= range[1] || range[1] < 0 || range[1] > 65535) {
+ if (range[0] < 0 || range[0] >= range[1] ||
+ range[1] < 0 || range[1] > 65535) {
range = null;
}
}
@@ -510,8 +527,10 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
*/
private static String getMembershipPortRangeString(int[] membershipPortRange) {
String membershipPortRangeString = "";
- if (membershipPortRange != null && membershipPortRange.length == 2) {
- membershipPortRangeString = membershipPortRange[0] + "-" + membershipPortRange[1];
+ if (membershipPortRange != null &&
+ membershipPortRange.length == 2) {
+ membershipPortRangeString = membershipPortRange[0] + "-" +
+ membershipPortRange[1];
}
return membershipPortRangeString;
@@ -675,10 +694,12 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Returns an array of configurations for statically known
* CacheServers
+ *
* @since GemFire 4.0
- */
+ */
public CacheServerConfig[] getCacheServerConfigs() {
- return (CacheServerConfig[]) this.cacheServerConfigs.toArray(new CacheServerConfig[this.cacheServerConfigs.size()]);
+ return (CacheServerConfig[]) this.cacheServerConfigs.toArray(
+ new CacheServerConfig[this.cacheServerConfigs.size()]);
}
public CacheVmConfig[] getCacheVmConfigs() {
@@ -687,6 +708,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Creates the configuration for a CacheServer
+ *
* @since GemFire 4.0
*/
public CacheServerConfig createCacheServerConfig() {
@@ -701,14 +723,14 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Adds the configuration for a CacheServer
+ *
* @since GemFire 4.0
*/
private void addCacheServerConfig(CacheServerConfig managerConfig) {
checkReadOnly();
- if (managerConfig == null) {
+ if (managerConfig == null)
return;
- }
for (Iterator iter = this.cacheServerConfigs.iterator(); iter.hasNext(); ) {
CacheServerConfigImpl impl = (CacheServerConfigImpl) iter.next();
if (impl.equals(managerConfig)) {
@@ -721,6 +743,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Removes the configuration for a CacheServer
+ *
* @since GemFire 4.0
*/
public void removeCacheServerConfig(CacheServerConfig managerConfig) {
@@ -738,15 +761,18 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
*/
public DistributionLocatorConfig[] getDistributionLocatorConfigs() {
if (this.system != null) {
- DistributionLocator[] locators = this.system.getDistributionLocators();
- DistributionLocatorConfig[] configs = new DistributionLocatorConfig[locators.length];
+ DistributionLocator[] locators =
+ this.system.getDistributionLocators();
+ DistributionLocatorConfig[] configs =
+ new DistributionLocatorConfig[locators.length];
for (int i = 0; i < locators.length; i++) {
configs[i] = locators[i].getConfig();
}
return configs;
} else {
- Object[] array = new DistributionLocatorConfig[this.locatorConfigs.size()];
+ Object[] array =
+ new DistributionLocatorConfig[this.locatorConfigs.size()];
return (DistributionLocatorConfig[]) this.locatorConfigs.toArray(array);
}
}
@@ -783,22 +809,22 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
* Validates the bind address. The address may be a host name or IP address,
* but it must not be empty and must be usable for creating an InetAddress.
* Cannot have a leading '/' (which InetAddress.toString() produces).
+ *
* @param bindAddress host name or IP address to validate
*/
public static boolean validateBindAddress(String bindAddress) {
- if (bindAddress == null || bindAddress.length() == 0) {
+ if (bindAddress == null || bindAddress.length() == 0)
return true;
- }
- if (InetAddressUtil.validateHost(bindAddress) == null) {
+ if (InetAddressUtil.validateHost(bindAddress) == null)
return false;
- }
return true;
}
public synchronized void configChanged() {
ConfigListener[] clients = null;
synchronized (this.listeners) {
- clients = (ConfigListener[]) listeners.toArray(new ConfigListener[this.listeners.size()]);
+ clients = (ConfigListener[])
+ listeners.toArray(new ConfigListener[this.listeners.size()]);
}
for (int i = 0; i < clients.length; i++) {
try {
@@ -830,10 +856,14 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
// -------------------------------------------------------------------------
// SSL support...
// -------------------------------------------------------------------------
- private boolean sslEnabled = DistributionConfig.DEFAULT_SSL_ENABLED;
- private String[] sslProtocols = new String[] { DistributionConfig.DEFAULT_SSL_PROTOCOLS };
- private String[] sslCiphers = new String[] { DistributionConfig.DEFAULT_SSL_CIPHERS };
- private boolean sslAuthenticationRequired = DistributionConfig.DEFAULT_SSL_REQUIRE_AUTHENTICATION;
+ private boolean sslEnabled =
+ DistributionConfig.DEFAULT_SSL_ENABLED;
+ private String sslProtocols =
+ DistributionConfig.DEFAULT_SSL_PROTOCOLS;
+ private String sslCiphers =
+ DistributionConfig.DEFAULT_SSL_CIPHERS;
+ private boolean sslAuthenticationRequired =
+ DistributionConfig.DEFAULT_SSL_REQUIRE_AUTHENTICATION;
private Properties sslProperties = new Properties();
public boolean isSSLEnabled() {
@@ -846,21 +876,21 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
configChanged();
}
- public String[] getSSLProtocols() {
+ public String getSSLProtocols() {
return this.sslProtocols;
}
- public void setSSLProtocols(final String[] protocols) {
+ public void setSSLProtocols(String protocols) {
checkReadOnly();
this.sslProtocols = protocols;
configChanged();
}
- public String[] getSSLCiphers() {
+ public String getSSLCiphers() {
return this.sslCiphers;
}
- public void setSSLCiphers(String[] ciphers) {
+ public void setSSLCiphers(String ciphers) {
checkReadOnly();
this.sslCiphers = ciphers;
configChanged();
@@ -903,7 +933,6 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* @return the gfSecurityProperties
- *
* @since GemFire 6.6.3
*/
public Properties getGfSecurityProperties() {
@@ -969,13 +998,14 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
/**
* Makes sure that the mcast port and locators are correct and
* consistent.
+ *
* @throws IllegalArgumentException If configuration is not valid
*/
public void validate() {
- if (this.getMcastPort() < MIN_MCAST_PORT || this.getMcastPort() > MAX_MCAST_PORT) {
- throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_MCASTPORT_MUST_BE_AN_INTEGER_INCLUSIVELY_BETWEEN_0_AND_1.toLocalizedString(new Object[] {
- Integer.valueOf(MIN_MCAST_PORT), Integer.valueOf(MAX_MCAST_PORT)
- }));
+ if (this.getMcastPort() < MIN_MCAST_PORT ||
+ this.getMcastPort() > MAX_MCAST_PORT) {
+ throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_MCASTPORT_MUST_BE_AN_INTEGER_INCLUSIVELY_BETWEEN_0_AND_1
+ .toLocalizedString(new Object[] { Integer.valueOf(MIN_MCAST_PORT), Integer.valueOf(MAX_MCAST_PORT) }));
}
// disabled in 5.1 - multicast and locators can be used together
@@ -987,16 +1017,16 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
LogWriterImpl.levelNameToCode(this.logLevel);
- if (this.logFileSizeLimit < MIN_LOG_FILE_SIZE_LIMIT || this.logFileSizeLimit > MAX_LOG_FILE_SIZE_LIMIT) {
- throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_LOGFILESIZELIMIT_MUST_BE_AN_INTEGER_BETWEEN_0_AND_1.toLocalizedString(new Object[] {
- Integer.valueOf(MIN_LOG_FILE_SIZE_LIMIT), Integer.valueOf(MAX_LOG_FILE_SIZE_LIMIT)
- }));
+ if (this.logFileSizeLimit < MIN_LOG_FILE_SIZE_LIMIT ||
+ this.logFileSizeLimit > MAX_LOG_FILE_SIZE_LIMIT) {
+ throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_LOGFILESIZELIMIT_MUST_BE_AN_INTEGER_BETWEEN_0_AND_1
+ .toLocalizedString(new Object[] { Integer.valueOf(MIN_LOG_FILE_SIZE_LIMIT), Integer.valueOf(MAX_LOG_FILE_SIZE_LIMIT) }));
}
- if (this.logDiskSpaceLimit < MIN_LOG_DISK_SPACE_LIMIT || this.logDiskSpaceLimit > MAX_LOG_DISK_SPACE_LIMIT) {
- throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_LOGDISKSPACELIMIT_MUST_BE_AN_INTEGER_BETWEEN_0_AND_1.toLocalizedString(new Object[] {
- Integer.valueOf(MIN_LOG_DISK_SPACE_LIMIT), Integer.valueOf(MAX_LOG_DISK_SPACE_LIMIT)
- }));
+ if (this.logDiskSpaceLimit < MIN_LOG_DISK_SPACE_LIMIT ||
+ this.logDiskSpaceLimit > MAX_LOG_DISK_SPACE_LIMIT) {
+ throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_LOGDISKSPACELIMIT_MUST_BE_AN_INTEGER_BETWEEN_0_AND_1
+ .toLocalizedString(new Object[] { Integer.valueOf(MIN_LOG_DISK_SPACE_LIMIT), Integer.valueOf(MAX_LOG_DISK_SPACE_LIMIT) }));
}
parseEntityConfigXMLFile();
@@ -1007,12 +1037,14 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
*/
@Override
public Object clone() throws CloneNotSupportedException {
- DistributedSystemConfigImpl other = (DistributedSystemConfigImpl) super.clone();
+ DistributedSystemConfigImpl other =
+ (DistributedSystemConfigImpl) super.clone();
other.system = null;
other.cacheServerConfigs = new HashSet();
other.locatorConfigs = new HashSet();
- DistributionLocatorConfig[] myLocators = this.getDistributionLocatorConfigs();
+ DistributionLocatorConfig[] myLocators =
+ this.getDistributionLocatorConfigs();
for (int i = 0; i < myLocators.length; i++) {
DistributionLocatorConfig locator = myLocators[i];
other.addDistributionLocatorConfig((DistributionLocatorConfig) locator.clone());
@@ -1031,9 +1063,8 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
public String toString() {
StringBuffer buf = new StringBuffer(1000);
String lf = System.getProperty("line.separator");
- if (lf == null) {
+ if (lf == null)
lf = ",";
- }
buf.append("DistributedSystemConfig(");
buf.append(lf);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6ffa6523/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/EnabledManagedEntityController.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/EnabledManagedEntityController.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/EnabledManagedEntityController.java
index 8fee07e..465d7ae 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/EnabledManagedEntityController.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/EnabledManagedEntityController.java
@@ -16,14 +16,6 @@
*/
package com.gemstone.gemfire.admin.internal;
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.logging.log4j.Logger;
-
import com.gemstone.gemfire.admin.AdminDistributedSystem;
import com.gemstone.gemfire.admin.DistributedSystemConfig;
import com.gemstone.gemfire.admin.ManagedEntity;
@@ -34,7 +26,13 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.logging.LogService;
import com.gemstone.gemfire.internal.logging.LoggingThreadGroup;
import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage;
-import com.gemstone.gemfire.management.internal.SSLUtil;
+import org.apache.logging.log4j.Logger;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Properties;
+
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
/**
* Implements the actual administration (starting, stopping, etc.) of
@@ -43,49 +41,43 @@ import com.gemstone.gemfire.management.internal.SSLUtil;
* by the {@link InternalManagedEntity} object. Note that it does not
* use SystemAdmin
to manage "local" entities; it always
* execs the scripts.
- * Systemcontroller
,
* RemoteCommand
, and LocatorRemoteCommand
.
+ *
* @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.
- */
+ /** 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"
+ "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
- */
+ /** Token in command prefix to be replaced with actual HOST */
private static final String HOST = "{HOST}";
- /**
- * Token in command prefix to be replaced with actual execution CMD
- */
+ /** Token in command prefix to be replaced with actual execution CMD */
private static final String CMD = "{CMD}";
////////////////////// 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
- */
+ /** System to which the managed entities belong */
private final AdminDistributedSystem system;
/////////////////////// Constructors ///////////////////////
@@ -96,7 +88,8 @@ class EnabledManagedEntityController implements ManagedEntityController {
*/
EnabledManagedEntityController(AdminDistributedSystem system) {
this.system = system;
- this.threadGroup = LoggingThreadGroup.createThreadGroup("ManagedEntityController threads", logger);
+ this.threadGroup =
+ LoggingThreadGroup.createThreadGroup("ManagedEntityController threads", logger);
}
///////////////////// Instance Methods /////////////////////
@@ -106,41 +99,39 @@ class EnabledManagedEntityController implements ManagedEntityController {
* 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;
}
/**
* 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
- * null
if the executing the command failed.
+ * null
if the executing the command failed.
*/
- protected String execute(String command, InternalManagedEntity entity) {
+ 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());
}
- 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);
@@ -150,11 +141,8 @@ class EnabledManagedEntityController implements ManagedEntityController {
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));
@@ -164,16 +152,12 @@ class EnabledManagedEntityController implements ManagedEntityController {
return output;
}
- /**
- * Returns true if the path ends with a path separator.
- */
+ /** Returns true if the path ends with a path separator. */
private boolean endsWithSeparator(String path) {
return path.endsWith("/") || path.endsWith("\\");
}
- /**
- * Translates the path between Windows and UNIX.
- */
+ /** Translates the path between Windows and UNIX. */
private String getOSPath(String path) {
if (pathIsWindows(path)) {
return path.replace('/', '\\');
@@ -182,17 +166,16 @@ 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.
- */
+ /** 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;
}
@@ -200,10 +183,13 @@ class EnabledManagedEntityController implements ManagedEntityController {
/**
* If the managed entity resides on a remote host, then
* command
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)) {
@@ -217,7 +203,8 @@ 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);
@@ -256,19 +243,23 @@ class EnabledManagedEntityController implements ManagedEntityController {
* $GEMFIRE/bin
taking into account the {@linkplain
* ManagedEntityConfig#getProductDirectory product directory} and the
* platform's file separator.
- * $GEMFIRE/bin
.
+ *
+ * @param executable
+ * The name of the executable that resides in
+ * $GEMFIRE/bin
.
*/
- 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)) {
@@ -276,9 +267,9 @@ class EnabledManagedEntityController implements ManagedEntityController {
}
path += "bin" + File.separator;
}
- // else {
- // path = "";
- // }
+// else {
+// path = "";
+// }
String bat = "";
if (pathIsWindows(path)) {
@@ -293,12 +284,10 @@ class EnabledManagedEntityController implements ManagedEntityController {
*/
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(); ) {
+ for (Iterator iter = sslProps.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
String value = sslProps.getProperty(key);
sb.append(" -J-D" + key + "=" + value);
@@ -310,27 +299,36 @@ class EnabledManagedEntityController implements ManagedEntityController {
/**
* 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, SSLUtil.arrayToSpaceDelimitedString(config.getSSLCiphers()));
- sslProps.setProperty(prefix + CLUSTER_SSL_PROTOCOLS, SSLUtil.arrayToSpaceDelimitedString(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;
}
@@ -339,12 +337,13 @@ 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();
}
@@ -352,12 +351,13 @@ 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,17 +365,22 @@ 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));
}
}
@@ -385,7 +390,8 @@ class EnabledManagedEntityController implements ManagedEntityController {
* members.
*/
public String getLog(DistributionLocatorImpl locator) {
- String command = arrangeRemoteCommand(locator, locator.getLogCommand());
+ String command =
+ arrangeRemoteCommand(locator, locator.getLogCommand());
return execute(command, locator);
}
@@ -393,10 +399,13 @@ class EnabledManagedEntityController implements ManagedEntityController {
* 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/6ffa6523/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlGenerator.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlGenerator.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlGenerator.java
index a2d23a6..e406ba3 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlGenerator.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlGenerator.java
@@ -16,70 +16,40 @@
*/
package com.gemstone.gemfire.admin.internal;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.DTDHandler;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.SAXNotSupportedException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.AttributesImpl;
-
-import com.gemstone.gemfire.admin.AdminDistributedSystem;
-import com.gemstone.gemfire.admin.AdminException;
-import com.gemstone.gemfire.admin.CacheServer;
-import com.gemstone.gemfire.admin.CacheServerConfig;
-import com.gemstone.gemfire.admin.DistributedSystemConfig;
-import com.gemstone.gemfire.admin.DistributionLocator;
-import com.gemstone.gemfire.admin.DistributionLocatorConfig;
-import com.gemstone.gemfire.admin.ManagedEntityConfig;
+import com.gemstone.gemfire.admin.*;
import com.gemstone.gemfire.internal.Assert;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.management.internal.SSLUtil;
-//import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.*;
+//import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+import org.xml.sax.*;
//import org.xml.sax.ext.*;
+import org.xml.sax.helpers.AttributesImpl;
+import java.io.*;
+import java.util.*;
/**
* Generates XML data that represents the managed entities in an
* AdminDistributedSystem
. This class is used mainly for
* testing.
+ *
* @since GemFire 4.0
*/
-public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml implements XMLReader {
+public class ManagedEntityConfigXmlGenerator
+ extends ManagedEntityConfigXml implements XMLReader {
- /**
- * An empty Attributes
- */
+ /** An empty Attributes
*/
private static Attributes EMPTY = new AttributesImpl();
///////////////////////// Instance Fields ////////////////////////
- /**
- * The AdminDistributedSystem
for which we are
- * generating XML
- */
+ /** The AdminDistributedSystem
for which we are
+ * generating XML */
private AdminDistributedSystem system;
- /**
- * The content handler to which SAX events are generated
- */
+ /** The content handler to which SAX events are generated */
private ContentHandler handler;
///////////////////////// Static Methods ////////////////////////
@@ -88,7 +58,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
* Generates an XML representation of all of the managed entities in
* the given AdminDistributedSystem
.
*/
- public static void generate(AdminDistributedSystem system, PrintWriter pw) {
+ public static void generate(AdminDistributedSystem system,
+ PrintWriter pw) {
(new ManagedEntityConfigXmlGenerator(system)).generate(pw);
}
@@ -96,9 +67,10 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
/**
* Creates a new generator for the given
- * AdminDistributedSystem
.
+ * AdminDistributedSystem
.
*/
- private ManagedEntityConfigXmlGenerator(AdminDistributedSystem system) {
+ private ManagedEntityConfigXmlGenerator(AdminDistributedSystem
+ system) {
this.system = system;
}
@@ -143,7 +115,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("", "", ID, "", String.valueOf(this.system.getConfig().getSystemId()));
+ atts.addAttribute("", "", ID, "",
+ String.valueOf(this.system.getConfig().getSystemId()));
handler.startElement("", DISTRIBUTED_SYSTEM, DISTRIBUTED_SYSTEM, atts);
@@ -170,7 +143,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
handler.startElement("", REMOTE_COMMAND, REMOTE_COMMAND, EMPTY);
- handler.characters(remoteCommand.toCharArray(), 0, remoteCommand.length());
+ handler.characters(remoteCommand.toCharArray(), 0,
+ remoteCommand.length());
handler.endElement("", REMOTE_COMMAND, REMOTE_COMMAND);
}
@@ -182,7 +156,7 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
handler.startElement("", LOCATORS, LOCATORS, EMPTY);
generateLocators();
-
+
handler.endElement("", LOCATORS, LOCATORS);
}
@@ -190,7 +164,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
* Generates XML for the distributed system's locators
*/
private void generateLocators() throws SAXException {
- DistributionLocator[] locators = this.system.getDistributionLocators();
+ DistributionLocator[] locators =
+ this.system.getDistributionLocators();
for (int i = 0; i < locators.length; i++) {
generateLocator(locators[i].getConfig());
}
@@ -199,10 +174,12 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
/**
* Generates XML for a locator
*/
- private void generateLocator(DistributionLocatorConfig config) throws SAXException {
-
+ private void generateLocator(DistributionLocatorConfig config)
+ throws SAXException {
+
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("", "", PORT, "", String.valueOf(config.getPort()));
+ atts.addAttribute("", "", PORT, "",
+ String.valueOf(config.getPort()));
handler.startElement("", LOCATOR, LOCATOR, atts);
@@ -214,7 +191,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
/**
* Generates XML for attributes common to all managed entities.
*/
- private void generateEntityConfig(ManagedEntityConfig config) throws SAXException {
+ private void generateEntityConfig(ManagedEntityConfig config)
+ throws SAXException {
String host = config.getHost();
if (host != null) {
@@ -226,21 +204,24 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
String remoteCommand = config.getRemoteCommand();
if (remoteCommand != null) {
handler.startElement("", REMOTE_COMMAND, REMOTE_COMMAND, EMPTY);
- handler.characters(remoteCommand.toCharArray(), 0, remoteCommand.length());
+ handler.characters(remoteCommand.toCharArray(), 0,
+ remoteCommand.length());
handler.endElement("", REMOTE_COMMAND, REMOTE_COMMAND);
}
String workingDirectory = config.getWorkingDirectory();
if (workingDirectory != null) {
handler.startElement("", WORKING_DIRECTORY, WORKING_DIRECTORY, EMPTY);
- handler.characters(workingDirectory.toCharArray(), 0, workingDirectory.length());
+ handler.characters(workingDirectory.toCharArray(), 0,
+ workingDirectory.length());
handler.endElement("", WORKING_DIRECTORY, WORKING_DIRECTORY);
}
String productDirectory = config.getProductDirectory();
if (productDirectory != null) {
handler.startElement("", PRODUCT_DIRECTORY, PRODUCT_DIRECTORY, EMPTY);
- handler.characters(productDirectory.toCharArray(), 0, productDirectory.length());
+ handler.characters(productDirectory.toCharArray(), 0,
+ productDirectory.length());
handler.endElement("", PRODUCT_DIRECTORY, PRODUCT_DIRECTORY);
}
}
@@ -258,30 +239,34 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
}
AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("", "", AUTHENTICATION_REQUIRED, "", String.valueOf(config.isSSLAuthenticationRequired()));
+ atts.addAttribute("", "", AUTHENTICATION_REQUIRED, "",
+ String.valueOf(config.isSSLAuthenticationRequired()));
handler.startElement("", SSL, SSL, atts);
- String protocols = SSLUtil.arrayToSpaceDelimitedString(config.getSSLProtocols());
+ String protocols = config.getSSLProtocols();
if (protocols != null) {
handler.startElement("", PROTOCOLS, PROTOCOLS, EMPTY);
- handler.characters(protocols.toCharArray(), 0, protocols.length());
+ handler.characters(protocols.toCharArray(), 0,
+ protocols.length());
handler.endElement("", PROTOCOLS, PROTOCOLS);
}
- String ciphers = SSLUtil.arrayToSpaceDelimitedString(config.getSSLCiphers());
+ String ciphers = config.getSSLCiphers();
if (ciphers != null) {
handler.startElement("", CIPHERS, CIPHERS, EMPTY);
- handler.characters(ciphers.toCharArray(), 0, ciphers.length());
+ handler.characters(ciphers.toCharArray(), 0,
+ ciphers.length());
handler.endElement("", CIPHERS, CIPHERS);
}
Properties sslProps = config.getSSLProperties();
- for (Iterator iter = sslProps.entrySet().iterator(); iter.hasNext(); ) {
+ for (Iterator iter = sslProps.entrySet().iterator();
+ iter.hasNext(); ) {
Map.Entry entry = (Map.Entry) iter.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
-
+
handler.startElement("", PROPERTY, PROPERTY, EMPTY);
handler.startElement("", KEY, KEY, EMPTY);
@@ -302,7 +287,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
* Generates an XML representation of the
* CacheServer
s in the distributed system.
*/
- private void generateCacheServers() throws SAXException, AdminException {
+ private void generateCacheServers()
+ throws SAXException, AdminException {
CacheServer[] servers = this.system.getCacheServers();
for (int i = 0; i < servers.length; i++) {
@@ -314,7 +300,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
* Generates an XML representation of a
* CacheServerConfig
.
*/
- private void generateCacheServer(CacheServerConfig config) throws SAXException {
+ private void generateCacheServer(CacheServerConfig config)
+ throws SAXException {
handler.startElement("", CACHE_SERVER, CACHE_SERVER, EMPTY);
@@ -323,7 +310,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
String classpath = config.getClassPath();
if (classpath != null) {
handler.startElement("", CLASSPATH, CLASSPATH, EMPTY);
- handler.characters(classpath.toCharArray(), 0, classpath.length());
+ handler.characters(classpath.toCharArray(), 0,
+ classpath.length());
handler.endElement("", CLASSPATH, CLASSPATH);
}
@@ -335,11 +323,11 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
*/
public void setContentHandler(ContentHandler handler) {
this.handler = handler;
- }
+ }
public ContentHandler getContentHandler() {
return this.handler;
- }
+ }
public ErrorHandler getErrorHandler() {
return this;
@@ -347,20 +335,24 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
////////// Inherited methods that don't do anything //////////
- public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ public boolean getFeature(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
return false;
}
- public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ public void setFeature(String name, boolean value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
}
- public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
+ public Object getProperty(String name)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
return null;
}
- public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
+ public void setProperty(String name, Object value)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
}
@@ -371,7 +363,7 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
public EntityResolver getEntityResolver() {
return this;
}
-
+
public void setDTDHandler(DTDHandler handler) {
}
@@ -384,7 +376,8 @@ public class ManagedEntityConfigXmlGenerator extends ManagedEntityConfigXml impl
}
- public void parse(String systemId) throws IOException, SAXException {
+ public void parse(String systemId)
+ throws IOException, SAXException {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6ffa6523/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlParser.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlParser.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlParser.java
index 9ea26c9..58e90e9 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlParser.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXmlParser.java
@@ -16,43 +16,30 @@
*/
package com.gemstone.gemfire.admin.internal;
-import java.io.InputStream;
-import java.util.Stack;
+import com.gemstone.gemfire.admin.*;
+import com.gemstone.gemfire.internal.Assert;
+import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
-
-import com.gemstone.gemfire.admin.AdminXmlException;
-import com.gemstone.gemfire.admin.CacheServerConfig;
-import com.gemstone.gemfire.admin.DistributedSystemConfig;
-import com.gemstone.gemfire.admin.DistributionLocatorConfig;
-import com.gemstone.gemfire.admin.ManagedEntityConfig;
-import com.gemstone.gemfire.internal.Assert;
-import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
-import com.gemstone.gemfire.management.internal.SSLUtil;
+import java.io.*;
+import java.util.*;
/**
* Parses an XML file and configures a {@link DistributedSystemConfig}
* from it.
+ *
* @since GemFire 4.0
*/
-public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml implements ContentHandler {
+public class ManagedEntityConfigXmlParser
+ extends ManagedEntityConfigXml implements ContentHandler {
- /**
- * The DistributedSystemConfig
to be configured
- */
+ /** The DistributedSystemConfig
to be configured */
private DistributedSystemConfig config;
- /**
- * The stack of intermediate values used while parsing
- */
+ /** The stack of intermediate values used while parsing */
private Stack stack = new Stack();
////////////////////// Static Methods //////////////////////
@@ -60,10 +47,14 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
/**
* Parses XML data and from it configures a
* DistributedSystemConfig
.
- * @throws AdminXmlException If an error is encountered while parsing the XML
+ *
+ * @throws AdminXmlException
+ * If an error is encountered while parsing the XML
*/
- public static void parse(InputStream is, DistributedSystemConfig config) {
- ManagedEntityConfigXmlParser handler = new ManagedEntityConfigXmlParser();
+ public static void parse(InputStream is,
+ DistributedSystemConfig config) {
+ ManagedEntityConfigXmlParser handler =
+ new ManagedEntityConfigXmlParser();
handler.config = config;
try {
@@ -96,7 +87,9 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
/**
* Helper method for parsing an integer
- * @throws com.gemstone.gemfire.cache.CacheXmlException If s
is a malformed integer
+ *
+ * @throws com.gemstone.gemfire.cache.CacheXmlException
+ * If s
is a malformed integer
*/
private static int parseInt(String s) {
try {
@@ -109,11 +102,13 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
////////////////////// Instance Methods //////////////////////
- // if (this.system.isMcastEnabled()) {
- // generateMulticast();
- // }
+// if (this.system.isMcastEnabled()) {
+// generateMulticast();
+// }
- public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+ public void startElement(String namespaceURI, String localName,
+ String qName, Attributes atts)
+ throws SAXException {
if (qName.equals(DISTRIBUTED_SYSTEM)) {
startDistributedSystem(atts);
@@ -123,7 +118,7 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
} else if (qName.equals(LOCATORS)) {
startLocators(atts);
-
+
} else if (qName.equals(MULTICAST)) {
startMulticast(atts);
@@ -168,7 +163,9 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
}
- public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+ public void endElement(String namespaceURI, String localName,
+ String qName)
+ throws SAXException {
if (qName.equals(DISTRIBUTED_SYSTEM)) {
endDistributedSystem();
@@ -234,7 +231,7 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
if (id != null) {
this.config.setSystemId(id);
}
-
+
String disable_tcp = atts.getValue(DISABLE_TCP);
if (disable_tcp != null) {
this.config.setDisableTcp(DISABLE_TCP.equalsIgnoreCase("true"));
@@ -247,7 +244,7 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
* When a distributed-system
element is finished
*/
private void endDistributedSystem() {
-
+
}
/**
@@ -256,7 +253,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
* and set its multicast config appropriately.
*/
private void startMulticast(Attributes atts) {
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
String port = atts.getValue(PORT);
config.setMcastPort(parseInt(port));
@@ -298,7 +296,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
((ManagedEntityConfig) top).setRemoteCommand(remoteCommand);
} else {
- String s = "Did not expect a " + top.getClass().getName() + " on top of the stack";
+ String s = "Did not expect a " + top.getClass().getName() +
+ " on top of the stack";
Assert.assertTrue(false, s);
}
}
@@ -314,11 +313,13 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
private void startLocator(Attributes atts) {
String port = atts.getValue(PORT);
- DistributedSystemConfig system = (DistributedSystemConfig) stack.peek();
+ DistributedSystemConfig system =
+ (DistributedSystemConfig) stack.peek();
system.setMcastPort(0);
- DistributionLocatorConfig config = system.createDistributionLocatorConfig();
-
+ DistributionLocatorConfig config =
+ system.createDistributionLocatorConfig();
+
config.setPort(parseInt(port));
stack.push(config);
@@ -364,10 +365,12 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
private void startSSL(Attributes atts) {
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
config.setSSLEnabled(true);
- String authenticationRequired = atts.getValue(AUTHENTICATION_REQUIRED);
+ String authenticationRequired =
+ atts.getValue(AUTHENTICATION_REQUIRED);
config.setSSLAuthenticationRequired(Boolean.valueOf(authenticationRequired).booleanValue());
}
@@ -381,8 +384,9 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
private void endProtocols() {
String protocols = popString();
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
- config.setSSLProtocols(SSLUtil.stringToArray(protocols));
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
+ config.setSSLProtocols(protocols);
}
private void startCiphers(Attributes atts) {
@@ -391,8 +395,9 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
private void endCiphers() {
String ciphers = popString();
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
- config.setSSLCiphers(SSLUtil.stringToArray(ciphers));
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
+ config.setSSLCiphers(ciphers);
}
private void startProperty(Attributes atts) {
@@ -402,7 +407,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
private void endProperty() {
String value = popString();
String key = popString();
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
config.addSSLProperty(key, value);
}
@@ -425,14 +431,15 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
private void startCacheServer(Attributes atts) {
- DistributedSystemConfig config = (DistributedSystemConfig) stack.peek();
- CacheServerConfig server = config.createCacheServerConfig();
+ DistributedSystemConfig config =
+ (DistributedSystemConfig) stack.peek();
+ CacheServerConfig server =
+ config.createCacheServerConfig();
stack.push(server);
}
private void endCacheServer() {
- /* CacheServerConfig server = (CacheServerConfig) */
- stack.pop();
+ /* CacheServerConfig server = (CacheServerConfig) */ stack.pop();
}
private void startClassPath(Attributes atts) {
@@ -466,7 +473,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
* into one big string by using a StringBuffer
. See
* bug 32122.
*/
- public void characters(char[] ch, int start, int length) throws SAXException {
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
Object top = stack.peek();
@@ -484,29 +492,25 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
////////// Inherited methods that don't do anything //////////
- public void setDocumentLocator(Locator locator) {
- }
+ public void setDocumentLocator(Locator locator) { }
- public void startDocument() throws SAXException {
- }
+ public void startDocument() throws SAXException { }
- public void endDocument() throws SAXException {
- }
+ public void endDocument() throws SAXException { }
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- }
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException { }
- public void endPrefixMapping(String prefix) throws SAXException {
- }
+ public void endPrefixMapping(String prefix)
+ throws SAXException { }
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- }
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException { }
- public void processingInstruction(String target, String data) throws SAXException {
- }
+ public void processingInstruction(String target, String data)
+ throws SAXException { }
- public void skippedEntity(String name) throws SAXException {
- }
+ public void skippedEntity(String name) throws SAXException { }
/////////////////////// Inner Classes ///////////////////////
@@ -517,11 +521,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
* is not a DefaultHandler
.
*/
static class DefaultHandlerDelegate extends DefaultHandler {
-
- /**
- * The ManagedEntityConfigXmlParser
that does the
- * real work
- */
+ /** The ManagedEntityConfigXmlParser
that does the
+ * real work */
private ManagedEntityConfigXmlParser handler;
/**
@@ -534,7 +535,9 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
@Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
+ public InputSource resolveEntity(String publicId,
+ String systemId)
+ throws SAXException {
return handler.resolveEntity(publicId, systemId);
}
@@ -554,7 +557,8 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
@Override
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
handler.startPrefixMapping(prefix, uri);
}
@@ -564,27 +568,33 @@ public class ManagedEntityConfigXmlParser extends ManagedEntityConfigXml impleme
}
@Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ public void startElement(String uri, String localName,
+ String qName, Attributes attributes)
+ throws SAXException {
handler.startElement(uri, localName, qName, attributes);
}
@Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
handler.endElement(uri, localName, qName);
}
@Override
- public void characters(char[] ch, int start, int length) throws SAXException {
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
handler.characters(ch, start, length);
}
@Override
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
handler.ignorableWhitespace(ch, start, length);
}
@Override
- public void processingInstruction(String target, String data) throws SAXException {
+ public void processingInstruction(String target, String data)
+ throws SAXException {
handler.processingInstruction(target, data);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6ffa6523/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
index d920265..fa5a1ea 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AdminDistributedSystemJmxImpl.java
@@ -1191,19 +1191,19 @@ public class AdminDistributedSystemJmxImpl
this.getConfig().setSSLEnabled(enabled);
}
- public String[] getSSLProtocols() {
+ public String getSSLProtocols() {
return this.getConfig().getSSLProtocols();
}
- public void setSSLProtocols(final String[] protocols) {
+ public void setSSLProtocols(String protocols) {
this.getConfig().setSSLProtocols(protocols);
}
- public String[] getSSLCiphers() {
+ public String getSSLCiphers() {
return this.getConfig().getSSLCiphers();
}
- public void setSSLCiphers(final String[] ciphers) {
+ public void setSSLCiphers(String ciphers) {
this.getConfig().setSSLCiphers(ciphers);
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/6ffa6523/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AgentConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AgentConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AgentConfigImpl.java
index 72dd46e..6aa8944 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AgentConfigImpl.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/AgentConfigImpl.java
@@ -42,7 +42,6 @@ import com.gemstone.gemfire.admin.jmx.AgentConfig;
import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.util.IOUtils;
-import com.gemstone.gemfire.management.internal.SSLUtil;
/**
* Provides the JMX Agent configuration properties.
@@ -937,8 +936,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl implements Agen
this.httpAuthPassword = validateNonEmptyString(props.getProperty(HTTP_AUTHENTICATION_PASSWORD_NAME), DEFAULT_HTTP_AUTHENTICATION_PASSWORD);
this.sslEnabled = validateBoolean(props.getProperty(CLUSTER_SSL_ENABLED), DEFAULT_SSL_ENABLED);
- this.sslProtocols = validateNonEmptyStringArray(props.getProperty(CLUSTER_SSL_PROTOCOLS), DEFAULT_SSL_PROTOCOLS);
- this.sslCiphers = validateNonEmptyStringArray(props.getProperty(CLUSTER_SSL_CIPHERS), DEFAULT_SSL_CIPHERS);
+ this.sslProtocols = validateNonEmptyString(props.getProperty(CLUSTER_SSL_PROTOCOLS), DEFAULT_SSL_PROTOCOLS);
+ this.sslCiphers = validateNonEmptyString(props.getProperty(CLUSTER_SSL_CIPHERS), DEFAULT_SSL_CIPHERS);
this.sslAuthenticationRequired = validateBoolean(props.getProperty(CLUSTER_SSL_REQUIRE_AUTHENTICATION), DEFAULT_SSL_REQUIRE_AUTHENTICATION);
this.sslProperties = new Properties();
for (int i = 0; true; i++) {
@@ -997,10 +996,6 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl implements Agen
}
}
- private String[] validateNonEmptyStringArray(final String property, final String defaultSslProtocols) {
- return isEmpty(property) ? SSLUtil.stringToArray(defaultSslProtocols) : SSLUtil.stringToArray(property);
- }
-
/**
* Filter all agent configuration attributes out of the given Properties
object.
*