http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemConfigImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemConfigImpl.java index b3e49e8..9f3c6c9 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemConfigImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemConfigImpl.java @@ -16,42 +16,23 @@ */ package com.gemstone.gemfire.admin.internal; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Properties; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.GemFireIOException; -import com.gemstone.gemfire.admin.AdminXmlException; -import com.gemstone.gemfire.admin.CacheServerConfig; -import com.gemstone.gemfire.admin.CacheVmConfig; -import com.gemstone.gemfire.admin.DistributedSystemConfig; -import com.gemstone.gemfire.admin.DistributionLocator; -import com.gemstone.gemfire.admin.DistributionLocatorConfig; +import com.gemstone.gemfire.admin.*; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl; -import com.gemstone.gemfire.internal.Banner; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.InternalLogWriter; -import com.gemstone.gemfire.internal.logging.LocalLogWriter; import com.gemstone.gemfire.internal.logging.LogConfig; import com.gemstone.gemfire.internal.logging.LogService; -import com.gemstone.gemfire.internal.logging.LogWriterFactory; import com.gemstone.gemfire.internal.logging.LogWriterImpl; -import com.gemstone.gemfire.internal.logging.ManagerLogWriter; -import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppender; +import org.apache.logging.log4j.Logger; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.*; + +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.*; /** * An implementation of the configuration object for an @@ -65,11 +46,11 @@ import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppender; * * @since GemFire 3.5 */ -public class DistributedSystemConfigImpl - implements DistributedSystemConfig { +public class DistributedSystemConfigImpl + implements DistributedSystemConfig { private static final Logger logger = LogService.getLogger(); - + private String entityConfigXMLFile = DEFAULT_ENTITY_CONFIG_XML_FILE; private String systemId = DEFAULT_SYSTEM_ID; private String mcastAddress = DEFAULT_MCAST_ADDRESS; @@ -86,7 +67,6 @@ public class DistributedSystemConfigImpl private int memberTimeout = DEFAULT_MEMBER_TIMEOUT; private String membershipPortRange = getMembershipPortRangeString(DEFAULT_MEMBERSHIP_PORT_RANGE); private int tcpPort = DEFAULT_TCP_PORT; - private String logFile = DEFAULT_LOG_FILE; private String logLevel = DEFAULT_LOG_LEVEL; @@ -95,29 +75,39 @@ public class DistributedSystemConfigImpl private int refreshInterval = DEFAULT_REFRESH_INTERVAL; private Properties gfSecurityProperties = new Properties(); - /** Listeners to notify when this DistributedSystemConfig changes */ + /** + * Listeners to notify when this DistributedSystemConfig changes + */ private Set listeners = new HashSet(); - - /** Configs for CacheServers that this system config is aware of */ + + /** + * Configs for CacheServers that this system config is aware of + */ private Set cacheServerConfigs = new HashSet(); - /** Configs for the managed distribution locators in the distributed - * system */ + /** + * Configs for the managed distribution locators in the distributed + * system + */ private Set locatorConfigs = new HashSet(); - - /** The display name of this distributed system */ + + /** + * The display name of this distributed system + */ private String systemName = DEFAULT_NAME; - /** The admin distributed system object that is configured by this - * config object. + /** + * The admin distributed system object that is configured by this + * config object. * * @since GemFire 4.0 */ private AdminDistributedSystemImpl system; - /** The GemFire log writer used by the distributed system */ + /** + * The GemFire log writer used by the distributed system + */ private InternalLogWriter logWriter; - /////////////////////// Static Methods /////////////////////// /** @@ -128,17 +118,17 @@ public class DistributedSystemConfigImpl * @since GemFire 4.0 */ private static Properties - filterOutAdminProperties(Properties props) { + filterOutAdminProperties(Properties props) { Properties props2 = new Properties(); 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) - ) - ) { + REFRESH_INTERVAL_NAME.equals(name) || + REMOTE_COMMAND_NAME.equals(name) + ) + ) { String value = props.getProperty(name); if ((name != null) && (value != null)) { props2.setProperty(name, value); @@ -154,10 +144,10 @@ public class DistributedSystemConfigImpl /** * Creates a new <code>DistributedSystemConfigImpl</code> based on * the configuration stored in a <code>DistributedSystem</code>'s - * <code>DistributionConfig</code>. + * <code>DistributionConfig</code>. */ public DistributedSystemConfigImpl(DistributionConfig distConfig, - String remoteCommand) { + String remoteCommand) { if (distConfig == null) { throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_DISTRIBUTIONCONFIG_MUST_NOT_BE_NULL.toLocalizedString()); } @@ -165,11 +155,11 @@ public class DistributedSystemConfigImpl 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(); - + this.sslEnabled = distConfig.getSSLEnabled(); this.sslCiphers = distConfig.getSSLCiphers(); this.sslProtocols = distConfig.getSSLProtocols(); @@ -177,13 +167,13 @@ public class DistributedSystemConfigImpl this.logFile = distConfig.getLogFile().getPath(); this.logLevel = - LogWriterImpl.levelToString(distConfig.getLogLevel()); + LogWriterImpl.levelToString(distConfig.getLogLevel()); this.logDiskSpaceLimit = distConfig.getLogDiskSpaceLimit(); this.logFileSizeLimit = distConfig.getLogFileSizeLimit(); - + basicSetBindAddress(distConfig.getBindAddress()); this.tcpPort = distConfig.getTcpPort(); - + this.disableTcp = distConfig.getDisableTcp(); this.remoteCommand = remoteCommand; @@ -202,7 +192,7 @@ public class DistributedSystemConfigImpl protected DistributedSystemConfigImpl() { } - + /** * Creates a new <code>DistributedSystemConifgImpl</code> whose * configuration is specified by the given <code>Properties</code> @@ -224,10 +214,10 @@ public class DistributedSystemConfigImpl * * @since GemFire 6.5 */ - protected DistributedSystemConfigImpl(Properties props, - boolean ignoreGemFirePropsFile) { + protected DistributedSystemConfigImpl(Properties props, + boolean ignoreGemFirePropsFile) { this(new DistributionConfigImpl( - filterOutAdminProperties(props), ignoreGemFirePropsFile), + filterOutAdminProperties(props), ignoreGemFirePropsFile), DEFAULT_REMOTE_COMMAND); String remoteCommand = props.getProperty(REMOTE_COMMAND_NAME); if (remoteCommand != null) { @@ -235,18 +225,19 @@ public class DistributedSystemConfigImpl } String entityConfigXMLFile = - props.getProperty(ENTITY_CONFIG_XML_FILE_NAME); + props.getProperty(ENTITY_CONFIG_XML_FILE_NAME); if (entityConfigXMLFile != null) { this.entityConfigXMLFile = entityConfigXMLFile; } String refreshInterval = - props.getProperty(REFRESH_INTERVAL_NAME); + props.getProperty(REFRESH_INTERVAL_NAME); if (refreshInterval != null) { try { - this.refreshInterval = Integer.parseInt(refreshInterval); + 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 })); } } } @@ -275,36 +266,41 @@ public class DistributedSystemConfigImpl // LOG: used only for sharing between IDS, AdminDSImpl and AgentImpl -- to prevent multiple banners, etc. synchronized (this) { this.logWriter = logWriter; - } + } } - + public LogConfig createLogConfig() { return new LogConfig() { - @Override - public int getLogLevel() { - return LogWriterImpl.levelNameToCode(DistributedSystemConfigImpl.this.getLogLevel()); - } - @Override - public File getLogFile() { - return new File(DistributedSystemConfigImpl.this.getLogFile()); - } - @Override - public int getLogFileSizeLimit() { - return DistributedSystemConfigImpl.this.getLogFileSizeLimit(); - } - @Override - public int getLogDiskSpaceLimit() { - return DistributedSystemConfigImpl.this.getLogDiskSpaceLimit(); - } - @Override - public String getName() { - return DistributedSystemConfigImpl.this.getSystemName(); - } - @Override - public String toLoggerString() { - return DistributedSystemConfigImpl.this.toString(); - } - }; + @Override + public int getLogLevel() { + return LogWriterImpl.levelNameToCode(DistributedSystemConfigImpl.this.getLogLevel()); + } + + @Override + public File getLogFile() { + return new File(DistributedSystemConfigImpl.this.getLogFile()); + } + + @Override + public int getLogFileSizeLimit() { + return DistributedSystemConfigImpl.this.getLogFileSizeLimit(); + } + + @Override + public int getLogDiskSpaceLimit() { + return DistributedSystemConfigImpl.this.getLogDiskSpaceLimit(); + } + + @Override + public String getName() { + return DistributedSystemConfigImpl.this.getSystemName(); + } + + @Override + public String toLoggerString() { + return DistributedSystemConfigImpl.this.toString(); + } + }; } /** @@ -326,7 +322,9 @@ public class DistributedSystemConfigImpl */ 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()); } } @@ -344,8 +342,7 @@ public class DistributedSystemConfigImpl * Parses the XML configuration file that describes managed * entities. * - * @throws AdminXmlException - * If a problem is encountered while parsing the XML file. + * @throws AdminXmlException If a problem is encountered while parsing the XML file. */ private void parseEntityConfigXMLFile() { String fileName = this.entityConfigXMLFile; @@ -363,12 +360,10 @@ public class DistributedSystemConfigImpl InputStream is = new FileInputStream(xmlFile); try { ManagedEntityConfigXmlParser.parse(is, this); - } - finally { + } finally { is.close(); } - } - catch (IOException ex) { + } catch (IOException ex) { throw new AdminXmlException(LocalizedStrings.DistributedSystemConfigImpl_WHILE_PARSING_0.toLocalizedString(fileName), ex); } } @@ -382,23 +377,27 @@ public class DistributedSystemConfigImpl this.systemId = systemId; configChanged(); } - - /** Returns the multicast address for the system */ + + /** + * Returns the multicast address for the system + */ public String getMcastAddress() { return this.mcastAddress; } - + public void setMcastAddress(String mcastAddress) { checkReadOnly(); this.mcastAddress = mcastAddress; configChanged(); } - /** Returns the multicast port for the system */ + /** + * Returns the multicast port for the system + */ public int getMcastPort() { return this.mcastPort; } - + public void setMcastPort(int mcastPort) { checkReadOnly(); this.mcastPort = mcastPort; @@ -408,7 +407,7 @@ public class DistributedSystemConfigImpl public int getAckWaitThreshold() { return this.ackWaitThreshold; } - + public void setAckWaitThreshold(int seconds) { checkReadOnly(); this.ackWaitThreshold = seconds; @@ -418,14 +417,16 @@ public class DistributedSystemConfigImpl public int getAckSevereAlertThreshold() { return this.ackSevereAlertThreshold; } - + public void setAckSevereAlertThreshold(int seconds) { checkReadOnly(); this.ackSevereAlertThreshold = seconds; configChanged(); } - /** Returns the comma-delimited list of locators for the system */ + /** + * Returns the comma-delimited list of locators for the system + */ public String getLocators() { return this.locators; } @@ -434,17 +435,16 @@ public class DistributedSystemConfigImpl checkReadOnly(); if (locators == null) { this.locators = ""; - } - else { + } else { this.locators = locators; } configChanged(); } - + /** * Returns the value for membership-port-range - * - * @return the value for the Distributed System property membership-port-range + * + * @return the value for the Distributed System property membership-port-range */ public String getMembershipPortRange() { return this.membershipPortRange; @@ -452,10 +452,9 @@ public class DistributedSystemConfigImpl /** * 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. + * + * @param membershipPortRangeStr the value for membership-port-range given as two numbers separated + * by a minus sign. */ public void setMembershipPortRange(String membershipPortRangeStr) { /* @@ -475,8 +474,8 @@ public class DistributedSystemConfigImpl } else { throw new IllegalArgumentException( LocalizedStrings.DistributedSystemConfigImpl_INVALID_VALUE_FOR_MEMBERSHIP_PORT_RANGE - .toLocalizedString(new Object[] {membershipPortRangeStr, - MEMBERSHIP_PORT_RANGE_NAME})); + .toLocalizedString(new Object[] { membershipPortRangeStr, + MEMBERSHIP_PORT_RANGE_NAME })); } } catch (Exception e) { if (logger.isDebugEnabled()) { @@ -485,13 +484,13 @@ public class DistributedSystemConfigImpl } } } - + public void setTcpPort(int port) { checkReadOnly(); this.tcpPort = port; configChanged(); } - + public int getTcpPort() { return this.tcpPort; } @@ -500,10 +499,9 @@ public class DistributedSystemConfigImpl * 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) { @@ -514,27 +512,27 @@ public class DistributedSystemConfigImpl range[0] = Integer.parseInt(splitted[0].trim()); range[1] = Integer.parseInt(splitted[1].trim()); //NumberFormatException if any could be thrown - - if (range[0] < 0 || range[0] >= range[1] || + + if (range[0] < 0 || range[0] >= range[1] || range[1] < 0 || range[1] > 65535) { range = null; } } return range != null; - } - + } + /** * @return the String representation of membershipPortRange with lower & upper - * limits of the port range separated by '-' e.g. 1-65535 + * limits of the port range separated by '-' e.g. 1-65535 */ private static String getMembershipPortRangeString(int[] membershipPortRange) { String membershipPortRangeString = ""; - if (membershipPortRange != null && + if (membershipPortRange != null && membershipPortRange.length == 2) { - membershipPortRangeString = membershipPortRange[0] + "-" + - membershipPortRange[1]; + membershipPortRangeString = membershipPortRange[0] + "-" + + membershipPortRange[1]; } - + return membershipPortRangeString; } @@ -547,7 +545,7 @@ public class DistributedSystemConfigImpl basicSetBindAddress(bindAddress); configChanged(); } - + public String getServerBindAddress() { return this.serverBindAddress; } @@ -557,11 +555,11 @@ public class DistributedSystemConfigImpl basicSetServerBindAddress(bindAddress); configChanged(); } - + public boolean getDisableTcp() { return this.disableTcp; } - + public void setDisableTcp(boolean flag) { checkReadOnly(); disableTcp = flag; @@ -573,20 +571,25 @@ public class DistributedSystemConfigImpl this.enableNetworkPartitionDetection = newValue; configChanged(); } + public boolean getEnableNetworkPartitionDetection() { return this.enableNetworkPartitionDetection; } + public void setDisableAutoReconnect(boolean newValue) { checkReadOnly(); this.disableAutoReconnect = newValue; configChanged(); } + public boolean getDisableAutoReconnect() { return this.disableAutoReconnect; } + public int getMemberTimeout() { - return this.memberTimeout; + return this.memberTimeout; } + public void setMemberTimeout(int value) { checkReadOnly(); this.memberTimeout = value; @@ -599,19 +602,21 @@ public class DistributedSystemConfigImpl } this.bindAddress = bindAddress; } - + private void basicSetServerBindAddress(String bindAddress) { if (!validateBindAddress(bindAddress)) { throw new IllegalArgumentException(LocalizedStrings.DistributedSystemConfigImpl_INVALID_BIND_ADDRESS_0.toLocalizedString(bindAddress)); } this.serverBindAddress = bindAddress; } - - /** Returns the remote command setting to use for remote administration */ + + /** + * Returns the remote command setting to use for remote administration + */ public String getRemoteCommand() { return this.remoteCommand; } - + /** * Sets the remote command for this config object. This attribute * may be modified after this config object has been used to create @@ -624,10 +629,11 @@ public class DistributedSystemConfigImpl this.remoteCommand = remoteCommand; configChanged(); } - - private static final boolean ALLOW_ALL_REMOTE_COMMANDS = Boolean.getBoolean("gemfire.admin.ALLOW_ALL_REMOTE_COMMANDS"); + + private static final boolean ALLOW_ALL_REMOTE_COMMANDS = Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "admin.ALLOW_ALL_REMOTE_COMMANDS"); private static final String[] LEGAL_REMOTE_COMMANDS = { "rsh", "ssh" }; private static final String ILLEGAL_REMOTE_COMMAND_RSH_OR_SSH = "Allowed remote commands include \"rsh {HOST} {CMD}\" or \"ssh {HOST} {CMD}\" with valid rsh or ssh switches. Invalid: "; + private final void checkRemoteCommand(final String remoteCommand) { if (remoteCommand == null || remoteCommand.isEmpty()) { return; @@ -636,9 +642,9 @@ public class DistributedSystemConfigImpl if (!command.contains("{host}") || !command.contains("{cmd}")) { throw new IllegalArgumentException(ILLEGAL_REMOTE_COMMAND_RSH_OR_SSH + remoteCommand); } - + final StringTokenizer tokenizer = new StringTokenizer(command, " "); - final ArrayList<String> array = new ArrayList<String>(); + final ArrayList<String> array = new ArrayList<String>(); for (int i = 0; tokenizer.hasMoreTokens(); i++) { String string = tokenizer.nextToken(); if (i == 0) { @@ -647,7 +653,7 @@ public class DistributedSystemConfigImpl for (int j = 0; j < LEGAL_REMOTE_COMMANDS.length; j++) { if (string.contains(LEGAL_REMOTE_COMMANDS[j])) { // verify command is at end of string - if (!(string.endsWith(LEGAL_REMOTE_COMMANDS[j]) || string.endsWith(LEGAL_REMOTE_COMMANDS[j]+".exe"))) { + if (!(string.endsWith(LEGAL_REMOTE_COMMANDS[j]) || string.endsWith(LEGAL_REMOTE_COMMANDS[j] + ".exe"))) { throw new IllegalArgumentException(ILLEGAL_REMOTE_COMMAND_RSH_OR_SSH + remoteCommand); } found = true; @@ -659,13 +665,13 @@ public class DistributedSystemConfigImpl } else { final boolean isSwitch = string.startsWith("-"); final boolean isHostOrCmd = string.equals("{host}") || string.equals("{cmd}"); - + // additional elements must be switches or values-for-switches or {host} or user@{host} or {cmd} if (!isSwitch && !isHostOrCmd) { - final String previous = (array == null || array.isEmpty()) ? null : array.get(array.size()-1); + final String previous = (array == null || array.isEmpty()) ? null : array.get(array.size() - 1); final boolean isValueForSwitch = previous != null && previous.startsWith("-"); final boolean isHostWithUser = string.contains("@") && string.endsWith("{host}"); - + if (!(isValueForSwitch || isHostWithUser)) { throw new IllegalArgumentException(ILLEGAL_REMOTE_COMMAND_RSH_OR_SSH + remoteCommand); } @@ -674,18 +680,18 @@ public class DistributedSystemConfigImpl array.add(string); } } - - public String getSystemName() { - return this.systemName; - } - - public void setSystemName(final String systemName) { - checkReadOnly(); - this.systemName = systemName; + + public String getSystemName() { + return this.systemName; + } + + public void setSystemName(final String systemName) { + checkReadOnly(); + this.systemName = systemName; configChanged(); - } - - /** + } + + /** * Returns an array of configurations for statically known * CacheServers * @@ -695,12 +701,12 @@ public class DistributedSystemConfigImpl return (CacheServerConfig[]) this.cacheServerConfigs.toArray( new CacheServerConfig[this.cacheServerConfigs.size()]); } + public CacheVmConfig[] getCacheVmConfigs() { return (CacheVmConfig[]) this.cacheServerConfigs.toArray(new CacheVmConfig[this.cacheServerConfigs.size()]); } - - - /** + + /** * Creates the configuration for a CacheServer * * @since GemFire 4.0 @@ -710,11 +716,12 @@ public class DistributedSystemConfigImpl addCacheServerConfig(config); return config; } + public CacheVmConfig createCacheVmConfig() { - return (CacheVmConfig)createCacheServerConfig(); + return (CacheVmConfig) createCacheServerConfig(); } - - /** + + /** * Adds the configuration for a CacheServer * * @since GemFire 4.0 @@ -722,8 +729,9 @@ public class DistributedSystemConfigImpl private void addCacheServerConfig(CacheServerConfig managerConfig) { checkReadOnly(); - if (managerConfig == null) return; - for (Iterator iter = this.cacheServerConfigs.iterator(); iter.hasNext();) { + if (managerConfig == null) + return; + for (Iterator iter = this.cacheServerConfigs.iterator(); iter.hasNext(); ) { CacheServerConfigImpl impl = (CacheServerConfigImpl) iter.next(); if (impl.equals(managerConfig)) { return; @@ -732,30 +740,31 @@ public class DistributedSystemConfigImpl this.cacheServerConfigs.add(managerConfig); configChanged(); } - - /** + + /** * Removes the configuration for a CacheServer * * @since GemFire 4.0 */ public void removeCacheServerConfig(CacheServerConfig managerConfig) { - removeCacheVmConfig((CacheVmConfig)managerConfig); + removeCacheVmConfig((CacheVmConfig) managerConfig); } + public void removeCacheVmConfig(CacheVmConfig managerConfig) { checkReadOnly(); this.cacheServerConfigs.remove(managerConfig); configChanged(); } - /** + /** * Returns the configurations of all managed distribution locators */ public DistributionLocatorConfig[] getDistributionLocatorConfigs() { if (this.system != null) { DistributionLocator[] locators = - this.system.getDistributionLocators(); + this.system.getDistributionLocators(); DistributionLocatorConfig[] configs = - new DistributionLocatorConfig[locators.length]; + new DistributionLocatorConfig[locators.length]; for (int i = 0; i < locators.length; i++) { configs[i] = locators[i].getConfig(); } @@ -763,27 +772,31 @@ public class DistributedSystemConfigImpl } else { Object[] array = - new DistributionLocatorConfig[this.locatorConfigs.size()]; + new DistributionLocatorConfig[this.locatorConfigs.size()]; return (DistributionLocatorConfig[]) this.locatorConfigs.toArray(array); } } - - /** Creates the configuration for a DistributionLocator */ + + /** + * Creates the configuration for a DistributionLocator + */ public DistributionLocatorConfig createDistributionLocatorConfig() { checkReadOnly(); DistributionLocatorConfig config = new DistributionLocatorConfigImpl(); addDistributionLocatorConfig(config); return config; } - - /** Adds the configuration for a DistributionLocator */ + + /** + * Adds the configuration for a DistributionLocator + */ private void addDistributionLocatorConfig(DistributionLocatorConfig config) { checkReadOnly(); this.locatorConfigs.add(config); configChanged(); } - - /** + + /** * Removes the configuration for a DistributionLocator */ public void removeDistributionLocatorConfig(DistributionLocatorConfig config) { @@ -792,7 +805,7 @@ public class DistributedSystemConfigImpl configChanged(); } - /** + /** * 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). @@ -800,15 +813,17 @@ public class DistributedSystemConfigImpl * @param bindAddress host name or IP address to validate */ public static boolean validateBindAddress(String bindAddress) { - if (bindAddress == null || bindAddress.length() == 0) return true; - if (InetAddressUtil.validateHost(bindAddress) == null) return false; + if (bindAddress == null || bindAddress.length() == 0) + return true; + if (InetAddressUtil.validateHost(bindAddress) == null) + return false; return true; } - + public synchronized void configChanged() { ConfigListener[] clients = null; - synchronized(this.listeners) { - clients = (ConfigListener[]) + synchronized (this.listeners) { + clients = (ConfigListener[]) listeners.toArray(new ConfigListener[this.listeners.size()]); } for (int i = 0; i < clients.length; i++) { @@ -819,66 +834,78 @@ public class DistributedSystemConfigImpl } } } - - /** Registers listener for notification of changes in this config. */ + + /** + * Registers listener for notification of changes in this config. + */ public void addListener(ConfigListener listener) { - synchronized(this.listeners) { + synchronized (this.listeners) { this.listeners.add(listener); } } - - /** Removes previously registered listener of this config. */ + + /** + * Removes previously registered listener of this config. + */ public void removeListener(ConfigListener listener) { - synchronized(this.listeners) { + synchronized (this.listeners) { this.listeners.remove(listener); } } - + // ------------------------------------------------------------------------- // SSL support... // ------------------------------------------------------------------------- - private boolean sslEnabled = + private boolean sslEnabled = DistributionConfig.DEFAULT_SSL_ENABLED; - private String sslProtocols = + private String sslProtocols = DistributionConfig.DEFAULT_SSL_PROTOCOLS; - private String sslCiphers = + private String sslCiphers = DistributionConfig.DEFAULT_SSL_CIPHERS; - private boolean sslAuthenticationRequired = + private boolean sslAuthenticationRequired = DistributionConfig.DEFAULT_SSL_REQUIRE_AUTHENTICATION; private Properties sslProperties = new Properties(); - + public boolean isSSLEnabled() { return this.sslEnabled; } + public void setSSLEnabled(boolean enabled) { checkReadOnly(); this.sslEnabled = enabled; configChanged(); } + public String getSSLProtocols() { return this.sslProtocols; } + public void setSSLProtocols(String protocols) { checkReadOnly(); this.sslProtocols = protocols; configChanged(); } + public String getSSLCiphers() { return this.sslCiphers; } + public void setSSLCiphers(String ciphers) { checkReadOnly(); this.sslCiphers = ciphers; configChanged(); } + public boolean isSSLAuthenticationRequired() { return this.sslAuthenticationRequired; } + public void setSSLAuthenticationRequired(boolean authRequired) { checkReadOnly(); this.sslAuthenticationRequired = authRequired; configChanged(); } + public Properties getSSLProperties() { return this.sslProperties; } @@ -891,7 +918,7 @@ public class DistributedSystemConfigImpl } configChanged(); } - + public void addSSLProperty(String key, String value) { checkReadOnly(); this.sslProperties.put(key, value); @@ -903,10 +930,8 @@ public class DistributedSystemConfigImpl this.sslProperties.remove(key); configChanged(); } - + /** - * - * * @return the gfSecurityProperties * @since GemFire 6.6.3 */ @@ -970,18 +995,17 @@ public class DistributedSystemConfigImpl configChanged(); } - /** * Makes sure that the mcast port and locators are correct and * consistent. * - * @throws IllegalArgumentException - * If configuration is not valid + * @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)})); + 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 @@ -993,14 +1017,16 @@ public class DistributedSystemConfigImpl LogWriterImpl.levelNameToCode(this.logLevel); - if (this.logFileSizeLimit < MIN_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)})); + 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 || + 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)})); + 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(); @@ -1012,13 +1038,13 @@ public class DistributedSystemConfigImpl @Override public Object clone() throws CloneNotSupportedException { DistributedSystemConfigImpl other = - (DistributedSystemConfigImpl) super.clone(); + (DistributedSystemConfigImpl) super.clone(); other.system = null; other.cacheServerConfigs = new HashSet(); other.locatorConfigs = new HashSet(); DistributionLocatorConfig[] myLocators = - this.getDistributionLocatorConfigs(); + this.getDistributionLocatorConfigs(); for (int i = 0; i < myLocators.length; i++) { DistributionLocatorConfig locator = myLocators[i]; other.addDistributionLocatorConfig((DistributionLocatorConfig) locator.clone()); @@ -1032,69 +1058,70 @@ public class DistributedSystemConfigImpl return other; } - + @Override public String toString() { StringBuffer buf = new StringBuffer(1000); String lf = System.getProperty("line.separator"); - if (lf == null) lf = ","; - + if (lf == null) + lf = ","; + buf.append("DistributedSystemConfig("); buf.append(lf); buf.append(" system-name="); buf.append(String.valueOf(this.systemName)); buf.append(lf); - buf.append(" "+MCAST_ADDRESS_NAME+"="); + buf.append(" " + MCAST_ADDRESS + "="); buf.append(String.valueOf(this.mcastAddress)); buf.append(lf); - buf.append(" "+MCAST_PORT_NAME+"="); + buf.append(" " + MCAST_PORT + "="); buf.append(String.valueOf(this.mcastPort)); buf.append(lf); - buf.append(" "+LOCATORS_NAME+"="); + buf.append(" " + LOCATORS + "="); buf.append(String.valueOf(this.locators)); buf.append(lf); - buf.append(" "+MEMBERSHIP_PORT_RANGE_NAME+"="); + buf.append(" " + MEMBERSHIP_PORT_RANGE_NAME + "="); buf.append(getMembershipPortRange()); buf.append(lf); - buf.append(" "+BIND_ADDRESS_NAME+"="); + buf.append(" " + BIND_ADDRESS + "="); buf.append(String.valueOf(this.bindAddress)); buf.append(lf); - buf.append(" "+TCP_PORT_NAME+"="+this.tcpPort); + buf.append(" " + TCP_PORT + "=" + this.tcpPort); buf.append(lf); - buf.append(" "+DistributionConfig.DISABLE_TCP_NAME+"="); + buf.append(" " + DistributionConfig.DISABLE_TCP_NAME + "="); buf.append(String.valueOf(this.disableTcp)); buf.append(lf); - buf.append(" "+DistributionConfig.DISABLE_AUTO_RECONNECT_NAME+"="); + buf.append(" " + DistributionConfig.DISABLE_AUTO_RECONNECT_NAME + "="); buf.append(String.valueOf(this.disableAutoReconnect)); buf.append(lf); - buf.append(" "+REMOTE_COMMAND_NAME+"="); + buf.append(" " + REMOTE_COMMAND_NAME + "="); buf.append(String.valueOf(this.remoteCommand)); buf.append(lf); - buf.append(" "+SSL_ENABLED_NAME+"="); + buf.append(" " + SSL_ENABLED_NAME + "="); buf.append(String.valueOf(this.sslEnabled)); buf.append(lf); - buf.append(" "+SSL_CIPHERS_NAME+"="); + buf.append(" " + SSL_CIPHERS_NAME + "="); buf.append(String.valueOf(this.sslCiphers)); buf.append(lf); - buf.append(" "+SSL_PROTOCOLS_NAME+"="); + buf.append(" " + SSL_PROTOCOLS_NAME + "="); buf.append(String.valueOf(this.sslProtocols)); buf.append(lf); - buf.append(" "+SSL_REQUIRE_AUTHENTICATION_NAME+"="); + buf.append(" " + SSL_REQUIRE_AUTHENTICATION_NAME + "="); buf.append(String.valueOf(this.sslAuthenticationRequired)); buf.append(lf); - buf.append(" "+LOG_FILE_NAME+"="); + buf.append(" " + LOG_FILE_NAME + "="); buf.append(String.valueOf(this.logFile)); buf.append(lf); - buf.append(" "+LOG_LEVEL_NAME+"="); + buf.append(" " + LOG_LEVEL_NAME + "="); buf.append(String.valueOf(this.logLevel)); buf.append(lf); - buf.append(" "+LOG_DISK_SPACE_LIMIT_NAME+"="); + buf.append(" " + LOG_DISK_SPACE_LIMIT_NAME + "="); buf.append(String.valueOf(this.logDiskSpaceLimit)); buf.append(lf); - buf.append(" "+LOG_FILE_SIZE_LIMIT_NAME+"="); + buf.append(" " + LOG_FILE_SIZE_LIMIT_NAME + "="); buf.append(String.valueOf(this.logFileSizeLimit)); buf.append(lf); - buf.append(" "+REFRESH_INTERVAL_NAME+"="); + buf.append(" " + REFRESH_INTERVAL_NAME + "="); buf.append(String.valueOf(this.refreshInterval)); buf.append(")"); return buf.toString();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemHealthEvaluator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemHealthEvaluator.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemHealthEvaluator.java index 013f0c2..33989a8 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemHealthEvaluator.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributedSystemHealthEvaluator.java @@ -17,15 +17,16 @@ package com.gemstone.gemfire.admin.internal; import com.gemstone.gemfire.admin.DistributedSystemHealthConfig; -import com.gemstone.gemfire.distributed.internal.DistributionManager; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.DM; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; +import com.gemstone.gemfire.distributed.internal.DistributionManager; import com.gemstone.gemfire.distributed.internal.MembershipListener; -import java.util.*; - -import com.gemstone.gemfire.distributed.internal.membership.*; +import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; +import java.util.List; +import java.util.Set; + /** * Contains the logic for evaluating the health of an entire GemFire * distributed system according to the thresholds provided in a {@link http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorConfigImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorConfigImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorConfigImpl.java index 9abfd57..818e45f 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorConfigImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorConfigImpl.java @@ -19,12 +19,13 @@ package com.gemstone.gemfire.admin.internal; import com.gemstone.gemfire.admin.DistributionLocator; import com.gemstone.gemfire.admin.DistributionLocatorConfig; import com.gemstone.gemfire.distributed.internal.InternalLocator; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import java.net.InetAddress; import java.util.Properties; +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.MCAST_PORT; + /** * Provides an implementation of * <code>DistributionLocatorConfig</code>. @@ -104,7 +105,7 @@ public class DistributionLocatorConfigImpl this.bindAddress = null; this.locator = null; this.dsProperties = new java.util.Properties(); - this.dsProperties.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); + this.dsProperties.setProperty(MCAST_PORT, "0"); } ///////////////////// Instance Methods ///////////////////// http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorImpl.java index 58952c2..bda1b59 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/DistributionLocatorImpl.java @@ -17,26 +17,22 @@ package com.gemstone.gemfire.admin.internal; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.admin.AdminDistributedSystem; import com.gemstone.gemfire.admin.DistributionLocator; import com.gemstone.gemfire.admin.DistributionLocatorConfig; import com.gemstone.gemfire.admin.ManagedEntityConfig; import com.gemstone.gemfire.distributed.internal.DM; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.admin.remote.DistributionLocatorId; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; +import org.apache.logging.log4j.Logger; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.*; /** * Default administrative implementation of a DistributionLocator. @@ -44,37 +40,47 @@ import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; * @since GemFire 3.5 */ public class DistributionLocatorImpl - implements DistributionLocator, InternalManagedEntity { - + implements DistributionLocator, InternalManagedEntity { + private static final Logger logger = LogService.getLogger(); - - /** How many new <code>DistributionLocator</code>s have been created? */ + + /** + * How many new <code>DistributionLocator</code>s have been created? + */ private static int newLocators = 0; //////////////////// Instance Fields //////////////////// - /** The configuration object for this locator */ + /** + * The configuration object for this locator + */ private final DistributionLocatorConfigImpl config; - /** The id of this distribution locator */ + /** + * The id of this distribution locator + */ private final String id; - - /** Used to control the actual DistributionLocator service */ + + /** + * Used to control the actual DistributionLocator service + */ private ManagedEntityController controller; - /** The system that this locator is a part of */ + /** + * The system that this locator is a part of + */ private AdminDistributedSystemImpl system; // ------------------------------------------------------------------------- // constructor(s)... // ------------------------------------------------------------------------- - + /** * Constructs new instance of <code>DistributionLocatorImpl</code> * that is a member of the given distributed system. */ public DistributionLocatorImpl(DistributionLocatorConfig config, - AdminDistributedSystemImpl system) { + AdminDistributedSystemImpl system) { this.config = (DistributionLocatorConfigImpl) config; this.config.validate(); this.config.setManagedEntity(this); @@ -82,14 +88,14 @@ public class DistributionLocatorImpl this.controller = system.getEntityController(); this.system = system; } - + // ------------------------------------------------------------------------- // Attribute accessors/mutators... // ------------------------------------------------------------------------- - - public String getId() { - return this.id; - } + + public String getId() { + return this.id; + } public String getNewId() { synchronized (DistributionLocatorImpl.class) { @@ -124,16 +130,17 @@ public class DistributionLocatorImpl // ------------------------------------------------------------------------- // Operations... // ------------------------------------------------------------------------- - + /** * Polls to determine whether or not this managed entity has * started. */ - public boolean waitToStart(long timeout) - throws InterruptedException { + public boolean waitToStart(long timeout) + throws InterruptedException { + + if (Thread.interrupted()) + throw new InterruptedException(); - if (Thread.interrupted()) throw new InterruptedException(); - long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < timeout) { if (this.isRunning()) { @@ -145,7 +152,7 @@ public class DistributionLocatorImpl } logger.info(LocalizedMessage.create( - LocalizedStrings.DistributionLocatorImpl_DONE_WAITING_FOR_LOCATOR)); + LocalizedStrings.DistributionLocatorImpl_DONE_WAITING_FOR_LOCATOR)); return this.isRunning(); } @@ -153,11 +160,12 @@ public class DistributionLocatorImpl * Polls to determine whether or not this managed entity has * stopped. */ - public boolean waitToStop(long timeout) - throws InterruptedException { + public boolean waitToStop(long timeout) + throws InterruptedException { + + if (Thread.interrupted()) + throw new InterruptedException(); - if (Thread.interrupted()) throw new InterruptedException(); - long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < timeout) { if (!this.isRunning()) { @@ -172,24 +180,23 @@ public class DistributionLocatorImpl } public boolean isRunning() { - DM dm = ((AdminDistributedSystemImpl)getDistributedSystem()).getDistributionManager(); - if(dm == null) { + DM dm = ((AdminDistributedSystemImpl) getDistributedSystem()).getDistributionManager(); + if (dm == null) { try { return this.controller.isRunning(this); - } - catch (IllegalStateException e) { + } catch (IllegalStateException e) { return false; } } - + String host = getConfig().getHost(); int port = getConfig().getPort(); String bindAddress = getConfig().getBindAddress(); - + boolean found = false; Map<InternalDistributedMember, Collection<String>> hostedLocators = dm.getAllHostedLocators(); - for (Iterator<InternalDistributedMember> memberIter = hostedLocators.keySet().iterator(); memberIter.hasNext();) { - for (Iterator<String> locatorIter = hostedLocators.get(memberIter.next()).iterator(); locatorIter.hasNext();) { + for (Iterator<InternalDistributedMember> memberIter = hostedLocators.keySet().iterator(); memberIter.hasNext(); ) { + for (Iterator<String> locatorIter = hostedLocators.get(memberIter.next()).iterator(); locatorIter.hasNext(); ) { DistributionLocatorId locator = new DistributionLocatorId(locatorIter.next()); found = found || locator.getHost().getHostAddress().equals(host); found = found || locator.getHost().getHostName().equals(host); @@ -200,8 +207,7 @@ public class DistributionLocatorImpl if (!found) { found = locator.getHost().getHostAddress().equals(inetAddr.getHostAddress()); } - } - catch (UnknownHostException e) { + } catch (UnknownHostException e) { // try config host as if it is an IP address instead of host name } } @@ -217,32 +223,32 @@ public class DistributionLocatorImpl } return found; } - + public void start() { this.config.validate(); this.controller.start(this); this.config.setLocator(this); this.system.updateLocatorsString(); } - + public void stop() { this.controller.stop(this); this.config.setLocator(null); } - + public String getLog() { return this.controller.getLog(this); } - - /** - * Returns a string representation of the object. - * - * @return a string representation of the object - */ + + /** + * Returns a string representation of the object. + * + * @return a string representation of the object + */ @Override - public String toString() { - return "DistributionLocator " + getId(); - } + public String toString() { + return "DistributionLocator " + getId(); + } //////////////////////// Command execution //////////////////////// @@ -264,8 +270,8 @@ public class DistributionLocatorImpl Properties props = config.getDistributedSystemProperties(); Enumeration en = props.propertyNames(); while (en.hasMoreElements()) { - String pn = (String)en.nextElement(); - sb.append(" -Dgemfire." + pn + "=" + props.getProperty(pn)); + String pn = (String) en.nextElement(); + sb.append(" -D" + DistributionConfig.GEMFIRE_PREFIX + "" + pn + "=" + props.getProperty(pn)); } String bindAddress = this.getConfig().getBindAddress(); @@ -276,7 +282,7 @@ public class DistributionLocatorImpl sb.append(" "); String sslArgs = - this.controller.buildSSLArguments(this.system.getConfig()); + this.controller.buildSSLArguments(this.system.getConfig()); if (sslArgs != null) { sb.append(sslArgs); } @@ -300,7 +306,7 @@ public class DistributionLocatorImpl sb.append(" "); String sslArgs = - this.controller.buildSSLArguments(this.system.getConfig()); + this.controller.buildSSLArguments(this.system.getConfig()); if (sslArgs != null) { sb.append(sslArgs); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/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 536ffb1..ab39935 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,12 +16,6 @@ */ package com.gemstone.gemfire.admin.internal; -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; @@ -32,6 +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 org.apache.logging.log4j.Logger; + +import java.io.File; +import java.util.Iterator; +import java.util.Properties; + +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.MCAST_PORT; /** * Implements the actual administration (starting, stopping, etc.) of @@ -314,7 +315,7 @@ class EnabledManagedEntityController implements ManagedEntityController { Properties sslProps = (Properties) config.getSSLProperties().clone(); // add ssl-enabled, etc... sslProps.setProperty(prefix + - DistributionConfig.MCAST_PORT_NAME, + MCAST_PORT, "0"); sslProps.setProperty(prefix + DistributionConfig.SSL_ENABLED_NAME, http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXml.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXml.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXml.java index 321bce6..fdfd86d 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXml.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedEntityConfigXml.java @@ -16,11 +16,12 @@ */ package com.gemstone.gemfire.admin.internal; +import com.gemstone.gemfire.distributed.SystemConfigurationProperties; import com.gemstone.gemfire.internal.ClassPathLoader; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; - import org.xml.sax.*; -import java.io.*; + +import java.io.InputStream; /** * The abstract superclass of classes that convert XML into a {@link @@ -57,7 +58,7 @@ abstract class ManagedEntityConfigXml implements EntityResolver, ErrorHandler { public static final String REMOTE_COMMAND = "remote-command"; /** The name of the <code>locators</code> element. */ - public static final String LOCATORS = "locators"; + public static final String LOCATORS = SystemConfigurationProperties.LOCATORS; /** The name of the <code>ssl</code> element. */ public static final String SSL = "ssl"; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedSystemMemberImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedSystemMemberImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedSystemMemberImpl.java index 678ae8e..7b01a62 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedSystemMemberImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/ManagedSystemMemberImpl.java @@ -19,9 +19,10 @@ package com.gemstone.gemfire.admin.internal; import com.gemstone.gemfire.admin.AdminException; import com.gemstone.gemfire.admin.ConfigurationParameter; import com.gemstone.gemfire.admin.ManagedEntityConfig; -import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.admin.GemFireVM; +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.LOCATORS; + /** * A <code>SystemMember</code> that is also managed (or manageable) by * the admin API. @@ -238,7 +239,7 @@ public abstract class ManagedSystemMemberImpl extends SystemMemberImpl String value = param.getValueAsString(); if (value != null && !value.equals("")) { - if (name.equals(DistributionConfig.LOCATORS_NAME)) { + if (name.equals(LOCATORS)) { // Use the new locator syntax so that is plays nicely with // rsh. See bug 32306. String locator = value; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/SystemMemberImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/SystemMemberImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/SystemMemberImpl.java index 3584e58..5bd8e5b 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/SystemMemberImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/internal/SystemMemberImpl.java @@ -16,27 +16,9 @@ */ package com.gemstone.gemfire.admin.internal; -import java.net.InetAddress; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.admin.AdminDistributedSystem; -import com.gemstone.gemfire.admin.AdminException; -import com.gemstone.gemfire.admin.CacheDoesNotExistException; -import com.gemstone.gemfire.admin.ConfigurationParameter; -import com.gemstone.gemfire.admin.RuntimeAdminException; -import com.gemstone.gemfire.admin.StatisticResource; -import com.gemstone.gemfire.admin.SystemMemberCache; -import com.gemstone.gemfire.admin.SystemMemberType; +import com.gemstone.gemfire.admin.*; import com.gemstone.gemfire.distributed.DistributedMember; import com.gemstone.gemfire.distributed.Role; import com.gemstone.gemfire.distributed.internal.DistributionConfig; @@ -48,6 +30,10 @@ import com.gemstone.gemfire.internal.admin.GemFireVM; import com.gemstone.gemfire.internal.admin.StatResource; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; +import org.apache.logging.log4j.Logger; + +import java.net.InetAddress; +import java.util.*; /** * Member of a GemFire system. http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/AgentConfig.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/AgentConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/AgentConfig.java index 1f1e187..9bb4c25 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/AgentConfig.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/AgentConfig.java @@ -17,6 +17,7 @@ package com.gemstone.gemfire.admin.jmx; import com.gemstone.gemfire.admin.DistributedSystemConfig; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; //import com.gemstone.gemfire.admin.internal.InetAddressUtil; /** @@ -278,8 +279,7 @@ import com.gemstone.gemfire.admin.DistributedSystemConfig; public interface AgentConfig extends DistributedSystemConfig { /** The prefix for JMX Agent configuration system properties */ - public static final String SYSTEM_PROPERTY_PREFIX = - "gemfire.agent."; + public static final String SYSTEM_PROPERTY_PREFIX = DistributionConfig.GEMFIRE_PREFIX + "agent."; /** The default "propertyFile" value */ public static final String DEFAULT_PROPERTY_FILE = "agent.properties"; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/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 858ed71..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 @@ -16,83 +16,35 @@ */ package com.gemstone.gemfire.admin.jmx.internal; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.TimerTask; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.management.MBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.Notification; -import javax.management.ObjectName; -import javax.management.RuntimeMBeanException; -import javax.management.RuntimeOperationsException; -import javax.management.modelmbean.ModelMBean; -import javax.management.openmbean.CompositeData; -import javax.management.openmbean.CompositeDataSupport; -import javax.management.openmbean.CompositeType; -import javax.management.openmbean.OpenDataException; -import javax.management.openmbean.OpenType; -import javax.management.openmbean.SimpleType; -import javax.management.openmbean.TabularData; -import javax.management.openmbean.TabularDataSupport; -import javax.management.openmbean.TabularType; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.admin.AdminException; -import com.gemstone.gemfire.admin.CacheServer; -import com.gemstone.gemfire.admin.CacheServerConfig; -import com.gemstone.gemfire.admin.CacheVm; -import com.gemstone.gemfire.admin.CacheVmConfig; -import com.gemstone.gemfire.admin.DistributedSystemConfig; -import com.gemstone.gemfire.admin.DistributionLocator; -import com.gemstone.gemfire.admin.DistributionLocatorConfig; -import com.gemstone.gemfire.admin.GemFireHealth; -import com.gemstone.gemfire.admin.SystemMember; -import com.gemstone.gemfire.admin.SystemMemberCacheEvent; -import com.gemstone.gemfire.admin.SystemMemberCacheListener; -import com.gemstone.gemfire.admin.SystemMemberRegionEvent; -import com.gemstone.gemfire.admin.SystemMemberType; +import com.gemstone.gemfire.admin.*; import com.gemstone.gemfire.admin.internal.AdminDistributedSystemImpl; import com.gemstone.gemfire.admin.internal.CacheServerConfigImpl; import com.gemstone.gemfire.admin.internal.DistributionLocatorImpl; import com.gemstone.gemfire.cache.persistence.PersistentID; import com.gemstone.gemfire.distributed.DistributedMember; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.internal.Assert; import com.gemstone.gemfire.internal.admin.Alert; -import com.gemstone.gemfire.internal.admin.ApplicationVM; -import com.gemstone.gemfire.internal.admin.ClientMembershipMessage; -import com.gemstone.gemfire.internal.admin.GemFireVM; -import com.gemstone.gemfire.internal.admin.GfManagerAgent; -import com.gemstone.gemfire.internal.admin.StatAlert; -import com.gemstone.gemfire.internal.admin.StatAlertDefinition; +import com.gemstone.gemfire.internal.admin.*; import com.gemstone.gemfire.internal.admin.remote.UpdateAlertDefinitionMessage; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.InternalLogWriter; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; +import org.apache.logging.log4j.Logger; + +import javax.management.*; +import javax.management.modelmbean.ModelMBean; +import javax.management.openmbean.*; +import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; /** * Provides MBean support for managing a GemFire distributed system. @@ -341,23 +293,23 @@ public class AdminDistributedSystemJmxImpl // ------------------------------------------------------------------------- /** Notification type for indicating system member joined */ - public static final String NOTIF_MEMBER_JOINED = - "gemfire.distributedsystem.member.joined"; + public static final String NOTIF_MEMBER_JOINED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.member.joined"; /** Notification type for indicating system member left */ - public static final String NOTIF_MEMBER_LEFT = - "gemfire.distributedsystem.member.left"; + public static final String NOTIF_MEMBER_LEFT = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.member.left"; /** Notification type for indicating system member crashed */ - public static final String NOTIF_MEMBER_CRASHED = - "gemfire.distributedsystem.member.crashed"; + public static final String NOTIF_MEMBER_CRASHED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.member.crashed"; /** Notification type for sending GemFire alerts as JMX notifications */ - public static final String NOTIF_ALERT = - "gemfire.distributedsystem.alert"; + public static final String NOTIF_ALERT = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.alert"; /** Notification type for sending GemFire StatAlerts as JMX notifications */ - public static final String NOTIF_STAT_ALERT = - "gemfire.distributedsystem.statalert"; + public static final String NOTIF_STAT_ALERT = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.statalert"; /** Notification type for indicating abnormal disconnection from the distributed system */ - public static final String NOTIF_ADMIN_SYSTEM_DISCONNECT = - "gemfire.distributedsystem.disconnect"; + public static final String NOTIF_ADMIN_SYSTEM_DISCONNECT = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.disconnect"; private static final String EML_SUBJ_PRFX_GFE_ALERT = "[GemFire Alert] ";
