http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/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 b5e850d..5aaa184 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 @@ -35,6 +35,8 @@ import java.util.Iterator; import java.util.Properties; import java.util.StringTokenizer; +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.*; + /** * Provides the JMX Agent configuration properties. * <p> @@ -49,52 +51,76 @@ import java.util.StringTokenizer; * @since GemFire 3.5 (in which it was named AgentConfig) */ public class AgentConfigImpl extends DistributedSystemConfigImpl - implements AgentConfig { + implements AgentConfig { // ------------------------------------------------------------------------- // Static class variable(s) // ------------------------------------------------------------------------- - /** Command-line arg to enable agent debugging */ + /** + * Command-line arg to enable agent debugging + */ public static final String AGENT_DEBUG = "agent-debug"; - /** The name of the "propertyFile" property. May specify as cmd-line arg */ + /** + * The name of the "propertyFile" property. May specify as cmd-line arg + */ public static final String PROPERTY_FILE_NAME = "property-file"; - /** The name of the "gfAgentPropertyFile" property, can be specified as System Property */ - public static final String AGENT_PROPSFILE_PROPERTY_NAME = "gfAgentPropertyFile"; + /** + * The name of the "gfAgentPropertyFile" property, can be specified as System Property + */ + public static final String AGENT_PROPSFILE_PROPERTY_NAME = "gfAgentPropertyFile"; // ------------------------------------------------------------------------- // DistributionLocator properties... // ------------------------------------------------------------------------- - /** The name of the "locator.host-" property */ + /** + * The name of the "locator.host-" property + */ public static final String LOCATOR_HOST_NAME = "locator.host-"; - /** The name of the "locator.port-" property */ + /** + * The name of the "locator.port-" property + */ public static final String LOCATOR_PORT_NAME = "locator.port-"; - /** The name of the "locator.product-directory-" property */ + /** + * The name of the "locator.product-directory-" property + */ public static final String LOCATOR_PRODUCT_DIRECTORY_NAME = "locator.product-directory-"; - /** The name of the "locator.working-directory-" property */ + /** + * The name of the "locator.working-directory-" property + */ public static final String LOCATOR_WORKING_DIRECTORY_NAME = "locator.working-directory-"; - /** The name of the "locator.remote-command-" property */ + /** + * The name of the "locator.remote-command-" property + */ public static final String LOCATOR_REMOTE_COMMAND = "locator.remote-command-"; - /** The name of the "locator.bind-address-" property */ + /** + * The name of the "locator.bind-address-" property + */ public static final String LOCATOR_BIND_ADDRESS = "locator.bind-address-"; - /** the properties used in configuring a locator's distributed system */ + /** + * the properties used in configuring a locator's distributed system + */ public static final String LOCATOR_DS_PROPERTIES = "locator.ds-properties"; - /** The default log file for stand-alone JMX agents */ + /** + * The default log file for stand-alone JMX agents + */ /*package scope*/ static final String DEFAULT_LOG_FILE = "agent.log"; - /** The default startup log file to be used by agent launcher */ + /** + * The default startup log file to be used by agent launcher + */ /*package scope*/ static final String DEFAULT_STARTUP_LOG_FILE = "start_agent.log"; @@ -132,48 +158,47 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl Properties props = new Properties(); props.setProperty(AUTO_CONNECT_NAME, - String.valueOf(DEFAULT_AUTO_CONNECT)); + String.valueOf(DEFAULT_AUTO_CONNECT)); props.setProperty(HTTP_ENABLED_NAME, - String.valueOf(DEFAULT_HTTP_ENABLED)); + String.valueOf(DEFAULT_HTTP_ENABLED)); props.setProperty(HTTP_BIND_ADDRESS_NAME, - String.valueOf(DEFAULT_HTTP_BIND_ADDRESS)); + String.valueOf(DEFAULT_HTTP_BIND_ADDRESS)); props.setProperty(HTTP_PORT_NAME, - String.valueOf(DEFAULT_HTTP_PORT)); + String.valueOf(DEFAULT_HTTP_PORT)); props.setProperty(HTTP_AUTHENTICATION_ENABLED_NAME, - String.valueOf(DEFAULT_HTTP_AUTHENTICATION_ENABLED)); + String.valueOf(DEFAULT_HTTP_AUTHENTICATION_ENABLED)); props.setProperty(HTTP_AUTHENTICATION_USER_NAME, - String.valueOf(DEFAULT_HTTP_AUTHENTICATION_USER)); + String.valueOf(DEFAULT_HTTP_AUTHENTICATION_USER)); props.setProperty(HTTP_AUTHENTICATION_PASSWORD_NAME, - String.valueOf(DEFAULT_HTTP_AUTHENTICATION_PASSWORD)); + String.valueOf(DEFAULT_HTTP_AUTHENTICATION_PASSWORD)); props.setProperty(RMI_ENABLED_NAME, - String.valueOf(DEFAULT_RMI_ENABLED)); + String.valueOf(DEFAULT_RMI_ENABLED)); props.setProperty(RMI_REGISTRY_ENABLED_NAME, - String.valueOf(DEFAULT_RMI_REGISTRY_ENABLED)); + String.valueOf(DEFAULT_RMI_REGISTRY_ENABLED)); props.setProperty(RMI_BIND_ADDRESS_NAME, - String.valueOf(DEFAULT_RMI_BIND_ADDRESS)); + String.valueOf(DEFAULT_RMI_BIND_ADDRESS)); props.setProperty(RMI_PORT_NAME, - String.valueOf(DEFAULT_RMI_PORT)); + String.valueOf(DEFAULT_RMI_PORT)); props.setProperty(RMI_SERVER_PORT_NAME, - String.valueOf(DEFAULT_RMI_SERVER_PORT)); + String.valueOf(DEFAULT_RMI_SERVER_PORT)); props.setProperty(SNMP_ENABLED_NAME, - String.valueOf(DEFAULT_SNMP_ENABLED)); + String.valueOf(DEFAULT_SNMP_ENABLED)); props.setProperty(SNMP_DIRECTORY_NAME, - String.valueOf(DEFAULT_SNMP_DIRECTORY)); + String.valueOf(DEFAULT_SNMP_DIRECTORY)); props.setProperty(AGENT_SSL_ENABLED_NAME, - String.valueOf(DEFAULT_AGENT_SSL_ENABLED)); + String.valueOf(DEFAULT_AGENT_SSL_ENABLED)); props.setProperty(AGENT_SSL_PROTOCOLS_NAME, - String.valueOf(DEFAULT_AGENT_SSL_PROTOCOLS)); + String.valueOf(DEFAULT_AGENT_SSL_PROTOCOLS)); props.setProperty(AGENT_SSL_CIPHERS_NAME, - String.valueOf(DEFAULT_AGENT_SSL_CIPHERS)); + String.valueOf(DEFAULT_AGENT_SSL_CIPHERS)); props.setProperty(AGENT_SSL_REQUIRE_AUTHENTICATION_NAME, - String.valueOf(DEFAULT_AGENT_SSL_REQUIRE_AUTHENTICATION)); + String.valueOf(DEFAULT_AGENT_SSL_REQUIRE_AUTHENTICATION)); props.setProperty(HTTP_SSL_REQUIRE_AUTHENTICATION_NAME, - String.valueOf(DEFAULT_HTTP_SSL_REQUIRE_AUTHENTICATION)); - + String.valueOf(DEFAULT_HTTP_SSL_REQUIRE_AUTHENTICATION)); return props; } @@ -277,16 +302,16 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl props.setProperty(ENTITY_CONFIG_XML_FILE_NAME, String.valueOf(DEFAULT_ENTITY_CONFIG_XML_FILE)); - props.setProperty(MCAST_PORT_NAME, + props.setProperty(MCAST_PORT, String.valueOf(DEFAULT_MCAST_PORT)); - props.setProperty(MCAST_ADDRESS_NAME, + props.setProperty(MCAST_ADDRESS, String.valueOf(DEFAULT_MCAST_ADDRESS)); - props.setProperty(LOCATORS_NAME, + props.setProperty(LOCATORS, String.valueOf(DEFAULT_LOCATORS)); - props.setProperty(BIND_ADDRESS_NAME, + props.setProperty(BIND_ADDRESS, String.valueOf(DEFAULT_BIND_ADDRESS)); props.setProperty(REMOTE_COMMAND_NAME, @@ -315,19 +340,29 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl // Member variable(s) // ------------------------------------------------------------------------- - /** Does agent automatically connect to the distributed system? */ + /** + * Does agent automatically connect to the distributed system? + */ private boolean autoConnect; - /** True if Agent adaptors should use SSL */ + /** + * True if Agent adaptors should use SSL + */ private boolean agentSSLEnabled; - /** The SSL Protocols that the Agent adaptors will use */ + /** + * The SSL Protocols that the Agent adaptors will use + */ private String agentSSLProtocols; - /** The SSL Ciphers that the Agent adaptors will use */ + /** + * The SSL Ciphers that the Agent adaptors will use + */ private String agentSSLCiphers; - /** True if Agent adaptors require authentication when SSL is enabled */ + /** + * True if Agent adaptors require authentication when SSL is enabled + */ private boolean agentSSLRequireAuth; /** @@ -337,61 +372,99 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl */ private boolean httpSSLRequireAuth; - /** True if HttpAdaptor authentication is enabled */ + /** + * True if HttpAdaptor authentication is enabled + */ private boolean httpAuthEnabled; - /** The login user for HttpAdaptor authentication */ + /** + * The login user for HttpAdaptor authentication + */ private String httpAuthUser; - /** The login password for HttpAdaptor authentication */ + /** + * The login password for HttpAdaptor authentication + */ private String httpAuthPassword; - /** True if the HttpAdaptor is enabled */ + /** + * True if the HttpAdaptor is enabled + */ private boolean httpEnabled; - /** The port for the MX4J HttpAdatper */ + /** + * The port for the MX4J HttpAdatper + */ private int httpPort; - /** The host for the MX4J HttpAdatper */ + /** + * The host for the MX4J HttpAdatper + */ private String httpBindAddress; - /** True if the RMIConnectorServer is enabled */ + /** + * True if the RMIConnectorServer is enabled + */ private boolean rmiEnabled; - /** True if the Agent is to create its own RMI registry */ + /** + * True if the Agent is to create its own RMI registry + */ private boolean rmiRegistryEnabled; - /** The host for the MX4J RMIConnectorServer */ + /** + * The host for the MX4J RMIConnectorServer + */ private String rmiBindAddress; - /** The port for the RMI Registry created by the Agent */ + /** + * The port for the RMI Registry created by the Agent + */ private int rmiPort; - /** The port for the MX4J RMIConnectorServer */ + /** + * The port for the MX4J RMIConnectorServer + */ private int rmiServerPort; - /** True if the SnmpAdaptor is enabled */ + /** + * True if the SnmpAdaptor is enabled + */ private boolean snmpEnabled; - /** The bind address for sockets used by the SNMP adapter */ + /** + * The bind address for sockets used by the SNMP adapter + */ private String snmpBindAddress; - /** Path to the directory containing the SNMP Adaptor and its sub-dirs */ + /** + * Path to the directory containing the SNMP Adaptor and its sub-dirs + */ private String snmpDirectory; - /** Is Email notification enabled */ + /** + * Is Email notification enabled + */ private boolean isEmailNotificationEnabled; - /** Email notification from: emailID */ + /** + * Email notification from: emailID + */ private String emailNotificationFrom; - /** The host name of the mail server to be used for email communication. */ + /** + * The host name of the mail server to be used for email communication. + */ private String emailNotificationHostName; - /** Email notification to: emailIDs list */ + /** + * Email notification to: emailIDs list + */ private String emailNotificationToList; - /** State Save File Name */ + /** + * State Save File Name + */ private String stateSaveFile; /** @@ -400,11 +473,15 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl */ private URL url; - /** Original command line arguments */ + /** + * Original command line arguments + */ private String[] originalCmdLineArgs = null; - /** The <code>Agent</code> that is configured by this - * <code>AgentConfigImpl</code> */ + /** + * The <code>Agent</code> that is configured by this + * <code>AgentConfigImpl</code> + */ private Agent agent; // ------------------------------------------------------------------------- @@ -424,7 +501,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl * are used to create a set of non-default properties for initializing this * AgentConfig. * - * @param args array of non-default configuration arguments + * @param args array of non-default configuration arguments */ public AgentConfigImpl(String[] args) { this(toProperties(args)); @@ -435,7 +512,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl * Creates a new <code>AgentConfig</code> with the given non-default * configuration properties. * - * @param props overriding non-default configuration properties + * @param props overriding non-default configuration properties */ public AgentConfigImpl(Properties props) { // for admin bug #40434 @@ -450,7 +527,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl /** * Constructs new instance of AgentConfig using the specified property file. * - * @param propFile the file to load configuration properties from + * @param propFile the file to load configuration properties from */ public AgentConfigImpl(File propFile) { // Initialize default values @@ -462,12 +539,10 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl FileInputStream in = new FileInputStream(propFile); props.load(in); in.close(); - } - catch (java.io.IOException e) { + } catch (java.io.IOException e) { throw new GemFireIOException(LocalizedStrings.AgentConfigImpl_FAILED_READING_0.toLocalizedString(propFile), e); } - } - else { + } else { throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_SPECIFIED_PROPERTIES_FILE_DOES_NOT_EXIST_0.toLocalizedString(propFile)); } @@ -493,7 +568,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl @Override protected void checkReadOnly() { if (this.agent != null) { - throw new IllegalStateException(LocalizedStrings.AgentConfigImpl_AN_AGENTCONFIG_OBJECT_CANNOT_BE_MODIFIED_AFTER_IT_HAS_BEEN_USED_TO_CREATE_AN_AGENT.toLocalizedString()); + throw new IllegalStateException( + LocalizedStrings.AgentConfigImpl_AN_AGENTCONFIG_OBJECT_CANNOT_BE_MODIFIED_AFTER_IT_HAS_BEEN_USED_TO_CREATE_AN_AGENT.toLocalizedString()); } super.checkReadOnly(); @@ -516,7 +592,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return LocalizedStrings.AgentConfigImpl_USING_DEFAULT_CONFIGURATION_BECAUSE_PROPERTY_FILE_WAS_FOUND.toLocalizedString(); } else { return LocalizedStrings.AgentConfigImpl_CONFIGURATION_LOADED_FROM_0 - .toLocalizedString(this.url); + .toLocalizedString(this.url); } } @@ -531,7 +607,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl if (!f.isAbsolute()) { // save to <cwd>/propertyFile f = new File(System.getProperty("user.dir"), - retrievePropertyFile()); + retrievePropertyFile()); } } else { f = new File(this.url.getFile()); @@ -553,7 +629,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl pw.println(LocalizedStrings.AgentConfigImpl_AGENT_CONFIGURATION.toLocalizedString()); Enumeration e = p.propertyNames(); while (e.hasMoreElements()) { - String pn = (String)e.nextElement(); + String pn = (String) e.nextElement(); String pv = p.getProperty(pn); pw.println(" " + pn + " = " + pv); } @@ -571,14 +647,11 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return toProperties(false /* include DS properties */); } - /** * Converts the contents of this config to a property instance. * - * @param includeDSProperties - * Should distributed system properties be included in the - * <code>Properties</code> object? See bug 32682. - * + * @param includeDSProperties Should distributed system properties be included in the + * <code>Properties</code> object? See bug 32682. * @return contents of this config as java.util.Properties */ public Properties toProperties(boolean includeDSProperties) { @@ -630,17 +703,17 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl Properties sslProps = getSSLProperties(); if (sslProps.size() > 0) { int sequence = 0; - 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); - props.setProperty("ssl-property-" + sequence, key+"="+OBFUSCATED_STRING); + props.setProperty("ssl-property-" + sequence, key + "=" + OBFUSCATED_STRING); sequence++; } } if (this.getDistributionLocatorConfigs().length > 0) { DistributionLocatorConfig[] configs = - this.getDistributionLocatorConfigs(); + this.getDistributionLocatorConfigs(); for (int i = 0; i < configs.length; i++) { DistributionLocatorConfig locator = configs[i]; props.setProperty(LOCATOR_HOST_NAME + i, toString(LOCATOR_HOST_NAME, locator.getHost())); @@ -649,21 +722,21 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl props.setProperty(LOCATOR_WORKING_DIRECTORY_NAME + i, toString(LOCATOR_WORKING_DIRECTORY_NAME, locator.getWorkingDirectory())); props.setProperty(LOCATOR_REMOTE_COMMAND + i, toString(LOCATOR_REMOTE_COMMAND, locator.getRemoteCommand())); props.setProperty(LOCATOR_BIND_ADDRESS + i, toString(LOCATOR_BIND_ADDRESS, locator.getBindAddress())); -// props.setProperty(LOCATOR_DS_PROPERTIES + i, -// getdsPropertiesString(locator)); + // props.setProperty(LOCATOR_DS_PROPERTIES + i, + // getdsPropertiesString(locator)); } } if (includeDSProperties) { props.setProperty(ENTITY_CONFIG_XML_FILE_NAME, toString(ENTITY_CONFIG_XML_FILE_NAME, getEntityConfigXMLFile())); // This could be different each time agent is started -// props.setProperty(SYSTEM_ID_NAME, toString(getSystemId())); - props.setProperty(MCAST_PORT_NAME, toString(MCAST_PORT_NAME, getMcastPort())); - props.setProperty(MCAST_ADDRESS_NAME, toString(MCAST_ADDRESS_NAME, getMcastAddress())); - props.setProperty(LOCATORS_NAME, toString(LOCATORS_NAME, getLocators())); + // props.setProperty(SYSTEM_ID_NAME, toString(getSystemId())); + props.setProperty(MCAST_PORT, toString(MCAST_PORT, getMcastPort())); + props.setProperty(MCAST_ADDRESS, toString(MCAST_ADDRESS, getMcastAddress())); + props.setProperty(LOCATORS, toString(LOCATORS, getLocators())); props.setProperty(MEMBERSHIP_PORT_RANGE_NAME, getMembershipPortRange()); - props.setProperty(TCP_PORT_NAME, ""+getTcpPort()); - props.setProperty(BIND_ADDRESS_NAME, toString(BIND_ADDRESS_NAME, getBindAddress())); + props.setProperty(TCP_PORT, "" + getTcpPort()); + props.setProperty(BIND_ADDRESS, toString(BIND_ADDRESS, getBindAddress())); props.setProperty(REMOTE_COMMAND_NAME, toString(REMOTE_COMMAND_NAME, getRemoteCommand())); props.setProperty(LOG_FILE_NAME, toString(LOG_FILE_NAME, getLogFile())); props.setProperty(LOG_LEVEL_NAME, toString(LOG_LEVEL_NAME, getLogLevel())); @@ -861,7 +934,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl /** * Returns the port of the RMI Connector Server. - * + * <p> * See <a href="#rmi-server-port">description</a> above. * * @return the value set for rmi-server-port @@ -1011,38 +1084,42 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl DEFAULT_SSL_REQUIRE_AUTHENTICATION); this.sslProperties = new Properties(); for (int i = 0; true; i++) { - String key = "ssl-property-"+i; + String key = "ssl-property-" + i; String value = props.getProperty(key); - if (value == null) break; + if (value == null) + break; StringTokenizer st = new StringTokenizer(value, "="); - if (!st.hasMoreTokens()) break; + if (!st.hasMoreTokens()) + break; String propKey = st.nextToken(); - if (!st.hasMoreTokens()) break; + if (!st.hasMoreTokens()) + break; String propValue = st.nextToken(); this.sslProperties.put(propKey, propValue); } this.isEmailNotificationEnabled = validateBoolean(props.getProperty( - AgentConfig.EMAIL_NOTIFICATIONS_ENABLED_NAME), - DEFAULT_EMAIL_NOTIFICATIONS_ENABLED); - this.emailNotificationHostName= validateNonEmptyString(props.getProperty( - AgentConfig.EMAIL_NOTIFICATIONS_HOST_NAME), - DEFAULT_EMAIL_HOST); - this.emailNotificationFrom= validateNonEmptyString(props.getProperty( - AgentConfig.EMAIL_NOTIFICATIONS_FROM_NAME), - DEFAULT_EMAIL_FROM); - this.emailNotificationToList= validateNonEmptyString(props.getProperty( - AgentConfig.EMAIL_NOTIFICATIONS_TO_LIST_NAME), - DEFAULT_EMAIL_TO_LIST); + AgentConfig.EMAIL_NOTIFICATIONS_ENABLED_NAME), + DEFAULT_EMAIL_NOTIFICATIONS_ENABLED); + this.emailNotificationHostName = validateNonEmptyString(props.getProperty( + AgentConfig.EMAIL_NOTIFICATIONS_HOST_NAME), + DEFAULT_EMAIL_HOST); + this.emailNotificationFrom = validateNonEmptyString(props.getProperty( + AgentConfig.EMAIL_NOTIFICATIONS_FROM_NAME), + DEFAULT_EMAIL_FROM); + this.emailNotificationToList = validateNonEmptyString(props.getProperty( + AgentConfig.EMAIL_NOTIFICATIONS_TO_LIST_NAME), + DEFAULT_EMAIL_TO_LIST); this.stateSaveFile = validateNonEmptyString(props.getProperty( - AgentConfig.STATE_SAVE_FILE_NAME), - DEFAULT_STATE_SAVE_FILE); + AgentConfig.STATE_SAVE_FILE_NAME), + DEFAULT_STATE_SAVE_FILE); try { for (int i = 0; true; i++) { String hostProp = props.getProperty(LOCATOR_HOST_NAME + i); - if (isEmpty(hostProp)) break; + if (isEmpty(hostProp)) + break; String host = hostProp; int port = Integer.parseInt( props.getProperty(LOCATOR_PORT_NAME + i)); @@ -1056,7 +1133,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl props.getProperty(LOCATOR_BIND_ADDRESS + i); DistributionLocatorConfig config = - this.createDistributionLocatorConfig(); + this.createDistributionLocatorConfig(); config.setHost(host); config.setPort(port); config.setBindAddress(bindAddr); @@ -1077,6 +1154,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl /** * Filter all agent configuration attributes out of the given <code>Properties</code> object. * <p/> + * * @param props the <code>Properties</code> object of filter agent configuration attributes out of. * @see AgentConfigImpl#_getPropertyDescription(String) */ @@ -1101,12 +1179,12 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl * Appends the log-file property to the Properties object if set of properties does not already define the * log-file property or the gemfire.agent.log-file property. * <p/> + * * @param props the <code>Properties</code> to append the log-file property to if the property does not exist. */ private static void appendLogFileProperty(final Properties props) { if (!(props.containsKey(DistributedSystemConfig.LOG_FILE_NAME) - || props.containsKey(SYSTEM_PROPERTY_PREFIX + DistributedSystemConfig.LOG_FILE_NAME))) - { + || props.containsKey(SYSTEM_PROPERTY_PREFIX + DistributedSystemConfig.LOG_FILE_NAME))) { props.put(DistributedSystemConfig.LOG_FILE_NAME, DEFAULT_LOG_FILE); } } @@ -1116,6 +1194,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl * Properties. If the supplied property overrides the property in the * property-file, then property-file value is ignored. System Properties always * override the supplied properties + * * @return appendedProps Properties appened to from the property-file if any */ private static Properties appendOptionalPropertyFileProperties(final Properties props) { @@ -1141,12 +1220,10 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl appendedProps.setProperty(key.toString(), agentPropertyFileProperties.getProperty(key.toString())); } } - } - catch (IOException e) { + } catch (IOException e) { throw new GemFireIOException(LocalizedStrings.AgentConfigImpl_FAILED_READING_0.toLocalizedString( - url.toString()), e); - } - finally { + url.toString()), e); + } finally { IOUtils.close(in); } } @@ -1168,9 +1245,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl /** * Returns a description of the given agent config property * - * @throws IllegalArgumentException - * If <code>prop</code> is not a recognized agent - * configuration property + * @throws IllegalArgumentException If <code>prop</code> is not a recognized agent + * configuration property */ public static String getPropertyDescription(String prop) { if (prop.equals(LOG_FILE_NAME)) { @@ -1182,21 +1258,22 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } else if (prop.equals(LOG_DISK_SPACE_LIMIT_NAME)) { return LocalizedStrings.AgentConfigImpl_LIMIT_IN_MEGABYTES_OF_HOW_MUCH_DISK_SPACE_CAN_BE_CONSUMED_BY_OLD_INACTIVE_LOG_FILES.toLocalizedString(); } else if (prop.equals(LOG_FILE_SIZE_LIMIT_NAME)) { - return LocalizedStrings.AgentConfigImpl_LIMIT_IN_MEGABYTES_OF_HOW_LARGE_THE_CURRENT_STATISTIC_ARCHIVE_FILE_CAN_GROW_BEFORE_IT_IS_CLOSED_AND_ARCHIVAL_ROLLS_ON_TO_A_NEW_FILE.toLocalizedString(); - } else if (prop.equals(MCAST_PORT_NAME)) { + return LocalizedStrings.AgentConfigImpl_LIMIT_IN_MEGABYTES_OF_HOW_LARGE_THE_CURRENT_STATISTIC_ARCHIVE_FILE_CAN_GROW_BEFORE_IT_IS_CLOSED_AND_ARCHIVAL_ROLLS_ON_TO_A_NEW_FILE + .toLocalizedString(); + } else if (prop.equals(MCAST_PORT)) { return LocalizedStrings.AgentConfigImpl_MULTICAST_PORT_USED_TO_CONNECT_TO_DISTRIBUTED_SYSTEM.toLocalizedString(); - } else if (prop.equals(MCAST_ADDRESS_NAME)) { + } else if (prop.equals(MCAST_ADDRESS)) { return LocalizedStrings.AgentConfigImpl_MULTICAST_ADDRESS_USED_TO_CONNECT_TO_DISTRIBUTED_SYSTEM.toLocalizedString(); - } else if (prop.equals(BIND_ADDRESS_NAME)) { + } else if (prop.equals(BIND_ADDRESS)) { return LocalizedStrings.AgentConfigImpl_IP_ADDRESS_OF_THE_AGENTS_DISTRIBUTED_SYSTEM.toLocalizedString(); - } else if (prop.equals(TCP_PORT_NAME)) { + } else if (prop.equals(TCP_PORT)) { return LocalizedStrings.AgentConfigImpl_TCP_PORT.toLocalizedString(); - } else if (prop.equals(LOCATORS_NAME)) { + } else if (prop.equals(LOCATORS)) { return LocalizedStrings.AgentConfigImpl_ADDRESSES_OF_THE_LOCATORS_OF_THE_DISTRIBUTED_SYSTEM.toLocalizedString(); } else if (prop.equals(MEMBERSHIP_PORT_RANGE_NAME)) { - return LocalizedStrings.AgentConfigImpl_ALLOWED_RANGE_OF_UDP_PORTS_TO_FORM_UNIQUE_MEMBERSHIP_ID.toLocalizedString(); -// } else if (prop.equals(SYSTEM_ID_NAME)) { -// return "The id of the distributed system"; + return LocalizedStrings.AgentConfigImpl_ALLOWED_RANGE_OF_UDP_PORTS_TO_FORM_UNIQUE_MEMBERSHIP_ID.toLocalizedString(); + // } else if (prop.equals(SYSTEM_ID_NAME)) { + // return "The id of the distributed system"; } else if (prop.equals(ENTITY_CONFIG_XML_FILE_NAME)) { return LocalizedStrings.AgentConfigImpl_XML_CONFIGURATION_FILE_FOR_MANAGED_ENTITIES.toLocalizedString(); } else if (prop.equals(REFRESH_INTERVAL_NAME)) { @@ -1231,8 +1308,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl if (prop.equals(AUTO_CONNECT_NAME)) { return LocalizedStrings.AgentConfigImpl_WILL_THE_AGENT_AUTOMATICALLY_CONNECT_TO_THE_DISTRIBUTED_SYSTEM.toLocalizedString(); -// } else if (prop.equals(SYSTEM_NAME_NAME)) { -// return "The logical name of the distributed system"; + // } else if (prop.equals(SYSTEM_NAME_NAME)) { + // return "The logical name of the distributed system"; } else if (prop.equals(HTTP_ENABLED_NAME)) { return LocalizedStrings.AgentConfigImpl_WILL_THE_AGENT_START_THE_HTTP_JMX_ADAPTER.toLocalizedString(); @@ -1316,19 +1393,19 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return LocalizedStrings.AgentConfigImpl_PROPERTIES_FOR_CONFIGURING_A_LOCATORS_DISTRIBUTED_SYSTEM.toLocalizedString(); } else if (prop.equals(EMAIL_NOTIFICATIONS_ENABLED_NAME)) { - return LocalizedStrings.AgentConfigImpl_IDENTIFY_IF_EMAIL_NOTIFICATIONS_ARE_ENABLED_OR_NOT.toLocalizedString(); + return LocalizedStrings.AgentConfigImpl_IDENTIFY_IF_EMAIL_NOTIFICATIONS_ARE_ENABLED_OR_NOT.toLocalizedString(); } else if (prop.equals(EMAIL_NOTIFICATIONS_FROM_NAME)) { - return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_EMAIL_ADDRESS_USING_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); + return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_EMAIL_ADDRESS_USING_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); } else if (prop.equals(EMAIL_NOTIFICATIONS_HOST_NAME)) { - return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_EMAIL_SERVER_HOST_USING_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); + return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_EMAIL_SERVER_HOST_USING_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); } else if (prop.equals(EMAIL_NOTIFICATIONS_TO_LIST_NAME)) { - return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_COMMA_SEPARATED_EMAIL_ADDRESSES_LIST_TO_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); + return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_COMMA_SEPARATED_EMAIL_ADDRESSES_LIST_TO_WHICH_EMAIL_NOTIFICATIONS_ARE_SENT.toLocalizedString(); } else if (prop.equals(STATE_SAVE_FILE_NAME)) { - return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_NAME_OF_THE_FILE_TO_BE_USED_FOR_SAVING_AGENT_STATE.toLocalizedString(); + return LocalizedStrings.AgentConfigImpl_IDENTIFY_THE_NAME_OF_THE_FILE_TO_BE_USED_FOR_SAVING_AGENT_STATE.toLocalizedString(); } else { return null; @@ -1349,14 +1426,12 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl if (args[i].startsWith("-J")) { int eq = args[i].indexOf("="); String key = args[i].substring(2, eq); - String value = args[i].substring(eq+1); + String value = args[i].substring(eq + 1); System.setProperty(key, value); - } - - else if (args[i].indexOf(AGENT_DEBUG) > 0) { + } else if (args[i].indexOf(AGENT_DEBUG) > 0) { int eq = args[i].indexOf("="); String key = args[i].substring(2, eq); - String value = args[i].substring(eq+1); + String value = args[i].substring(eq + 1); System.setProperty(key, value); } @@ -1364,7 +1439,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl else if (args[i].indexOf("=") > 0) { int eq = args[i].indexOf("="); String key = args[i].substring(0, eq); - String value = args[i].substring(eq+1); + String value = args[i].substring(eq + 1); props.setProperty(key, value); } } @@ -1372,7 +1447,9 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return props; } - /** Returns the original command-line arguments. */ + /** + * Returns the original command-line arguments. + */ public String[] getOriginalArgs() { return this.originalCmdLineArgs; } @@ -1381,43 +1458,51 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl // Validation methods for configuration options // ------------------------------------------------------------------------- - /** + /** * 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 */ @Override public void validate() { super.validate(); if (this.httpPort < 0 || this.httpPort > MAX_HTTP_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {HTTP_PORT_NAME, Integer.valueOf(MIN_HTTP_PORT), Integer.valueOf(MAX_HTTP_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { HTTP_PORT_NAME, Integer.valueOf(MIN_HTTP_PORT), Integer.valueOf(MAX_HTTP_PORT) })); } if (this.rmiPort < 0 || this.rmiPort > MAX_RMI_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {RMI_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { RMI_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT) })); } if (this.rmiServerPort < 0 || this.rmiServerPort > MAX_RMI_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {RMI_SERVER_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { RMI_SERVER_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT) })); } } - /** Returns defaultValue if value is empty. */ + /** + * Returns defaultValue if value is empty. + */ private String validateNonEmptyString(String value, - String defaultValue) { + String defaultValue) { return isEmpty(value) ? defaultValue : value; } - /** Validates that systemHost can be used for an InetAddress. */ + /** + * Validates that systemHost can be used for an InetAddress. + */ private String validateSystemHost(String systemHost) { return InetAddressUtil.validateHost(systemHost); } - /** Returns null if productDir is empty; else converts it to File. */ + /** + * Returns null if productDir is empty; else converts it to File. + */ private String validateProductDirectory(String productDir) { if (isEmpty(productDir)) { return null; @@ -1425,9 +1510,12 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return productDir; } - /** Returns true if value parses as true; null value returns defaultValue. */ + /** + * Returns true if value parses as true; null value returns defaultValue. + */ private boolean validateBoolean(String value, boolean defaultValue) { - if (isEmpty(value)) return defaultValue; + if (isEmpty(value)) + return defaultValue; return Boolean.valueOf(value).booleanValue(); } @@ -1446,6 +1534,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl return validateHttpPort(Integer.parseInt(val)); } } + /** * Validates that httpPort is either zero or within the {@link * com.gemstone.gemfire.admin.jmx.AgentConfig#MIN_HTTP_PORT} and {@link @@ -1453,7 +1542,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl */ private int validateHttpPort(int val) { if (val < 0 || val > MAX_HTTP_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {HTTP_PORT_NAME, Integer.valueOf(MIN_HTTP_PORT), Integer.valueOf(MAX_HTTP_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { HTTP_PORT_NAME, Integer.valueOf(MIN_HTTP_PORT), Integer.valueOf(MAX_HTTP_PORT) })); } return val; } @@ -1468,8 +1558,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl String value = InetAddressUtil.validateHost(val); if (value == null) { return DEFAULT_HTTP_BIND_ADDRESS; - } - else { + } else { return value; } } @@ -1496,21 +1585,20 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl String value = InetAddressUtil.validateHost(val); if (value == null) { return DEFAULT_SNMP_BIND_ADDRESS; - } - else { + } else { return value; } } -// /** -// * Validates that snmpBindAddress is not null and then returns the string form of it. -// */ -// private String validateSnmpBindAddress(InetAddress snmpBindAddress) { -// if (snmpBindAddress == null) { -// throw new IllegalArgumentException("SnmpBindAddress must not be null"); -// } -// return toString(snmpBindAddress); -// } + // /** + // * Validates that snmpBindAddress is not null and then returns the string form of it. + // */ + // private String validateSnmpBindAddress(InetAddress snmpBindAddress) { + // if (snmpBindAddress == null) { + // throw new IllegalArgumentException("SnmpBindAddress must not be null"); + // } + // return toString(snmpBindAddress); + // } /** * SnmpDirectory must be specified if SNMP is enabled. This directory must @@ -1551,7 +1639,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl */ private int validateRmiPort(int val) { if (val < MIN_RMI_PORT || val > MAX_RMI_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {RMI_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { RMI_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT) })); } return val; } @@ -1577,7 +1666,8 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl */ private int validateRmiServerPort(int val) { if (val < MIN_RMI_PORT || val > MAX_RMI_PORT) { - throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2.toLocalizedString(new Object[] {RMI_SERVER_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT)})); + throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_0_MUST_BE_ZERO_OR_AN_INTEGER_BETWEEN_1_AND_2 + .toLocalizedString(new Object[] { RMI_SERVER_PORT_NAME, Integer.valueOf(MIN_RMI_PORT), Integer.valueOf(MAX_RMI_PORT) })); } return val; } @@ -1592,22 +1682,23 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl String value = InetAddressUtil.validateHost(val); if (value == null) { return DEFAULT_RMI_BIND_ADDRESS; - } - else { + } else { return value; } } -// /** -// * Validates that rmiBindAddress is not null and then returns the string form of it. -// */ -// private String validateRmiBindAddress(InetAddress rmiBindAddress) { -// if (rmiBindAddress == null) { -// throw new IllegalArgumentException("RmiBindAddress must not be null"); -// } -// return toString(rmiBindAddress); -// } - - /** Validates working directory is not null or empty. */ + // /** + // * Validates that rmiBindAddress is not null and then returns the string form of it. + // */ + // private String validateRmiBindAddress(InetAddress rmiBindAddress) { + // if (rmiBindAddress == null) { + // throw new IllegalArgumentException("RmiBindAddress must not be null"); + // } + // return toString(rmiBindAddress); + // } + + /** + * Validates working directory is not null or empty. + */ private File validateWorkingDirectory(String workingDir) { if (isEmpty(workingDir)) { throw new IllegalArgumentException(LocalizedStrings.AgentConfigImpl_LOCATOR_WORKINGDIRECTORY_MUST_NOT_BE_NULL.toLocalizedString()); @@ -1633,7 +1724,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl * Only the first file found will be used. * * @return a <code>URL</code> that names the property file; - * otherwise Null if no property file was found. + * otherwise Null if no property file was found. */ public static URL getPropertyFileURL(final String propFileLocation) { File propFile = new File(propFileLocation); @@ -1644,8 +1735,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl try { return propFile.toURI().toURL(); - } - catch (java.net.MalformedURLException ignore) { + } catch (java.net.MalformedURLException ignore) { } } @@ -1658,8 +1748,7 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl try { return propFile.toURI().toURL(); - } - catch (java.net.MalformedURLException ignore) { + } catch (java.net.MalformedURLException ignore) { } } } @@ -1689,17 +1778,18 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } return true; } - + /** * Returns string representation of the specified object with special * handling for InetAddress. * - * @param obj the object to convert to string + * @param obj the object to convert to string * @return string representation of the specified object */ private static String toString(String attName, java.lang.Object obj) { if (okToDisplayPropertyValue(attName)) { - if (obj == null) return ""; + if (obj == null) + return ""; if (obj instanceof InetAddress) { return InetAddressUtil.toString(obj); } @@ -1709,7 +1799,9 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } } - /** Returns string representation of the int. */ + /** + * Returns string representation of the int. + */ private static String toString(String attName, int num) { if (okToDisplayPropertyValue(attName)) { return String.valueOf(num); @@ -1718,7 +1810,9 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } } - /** Returns string representation of the boolean value. */ + /** + * Returns string representation of the boolean value. + */ private static String toString(String attName, boolean v) { if (okToDisplayPropertyValue(attName)) { return String.valueOf(v); @@ -1727,7 +1821,9 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } } - /** Returns true if the string is null or empty. */ + /** + * Returns true if the string is null or empty. + */ public static boolean isEmpty(String string) { return string == null || string.length() == 0; } @@ -1745,42 +1841,51 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl public boolean isSSLEnabled() { return this.sslEnabled; } + @Override public void setSSLEnabled(boolean enabled) { this.sslEnabled = enabled; configChanged(); } + @Override public String getSSLProtocols() { return this.sslProtocols; } + @Override public void setSSLProtocols(String protocols) { this.sslProtocols = protocols; configChanged(); } + @Override public String getSSLCiphers() { return this.sslCiphers; } + @Override public void setSSLCiphers(String ciphers) { this.sslCiphers = ciphers; configChanged(); } + @Override public boolean isSSLAuthenticationRequired() { return this.sslAuthenticationRequired; } + @Override public void setSSLAuthenticationRequired(boolean authRequired) { this.sslAuthenticationRequired = authRequired; configChanged(); } + @Override public Properties getSSLProperties() { return this.sslProperties; } + @Override public void setSSLProperties(Properties sslProperties) { this.sslProperties = sslProperties; @@ -1791,50 +1896,50 @@ public class AgentConfigImpl extends DistributedSystemConfigImpl } public String getStateSaveFile() { - return this.stateSaveFile; + return this.stateSaveFile; } public void setStateSaveFile(String file) { - checkReadOnly(); - this.stateSaveFile = file; - configChanged(); + checkReadOnly(); + this.stateSaveFile = file; + configChanged(); } public boolean isEmailNotificationEnabled() { - return this.isEmailNotificationEnabled; + return this.isEmailNotificationEnabled; } public void setEmailNotificationEnabled(boolean enabled) { - checkReadOnly(); - this.isEmailNotificationEnabled = enabled; - configChanged(); + checkReadOnly(); + this.isEmailNotificationEnabled = enabled; + configChanged(); } public String getEmailNotificationFrom() { - return this.emailNotificationFrom; + return this.emailNotificationFrom; } public void setEmailNotificationFrom(String emailID) { - this.emailNotificationFrom = emailID; - configChanged(); + this.emailNotificationFrom = emailID; + configChanged(); } public String getEmailNotificationHost() { - return this.emailNotificationHostName; + return this.emailNotificationHostName; } public void setEmailNotificationHost(String hostName) { - this.emailNotificationHostName = hostName; - configChanged(); + this.emailNotificationHostName = hostName; + configChanged(); } public String getEmailNotificationToList() { - return this.emailNotificationToList; + return this.emailNotificationToList; } public void setEmailNotificationToList(String emailIDs) { - this.emailNotificationToList = emailIDs; - configChanged(); + this.emailNotificationToList = emailIDs; + configChanged(); } @Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MX4JServerSocketFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MX4JServerSocketFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MX4JServerSocketFactory.java index 3badf0f..649038e 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MX4JServerSocketFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MX4JServerSocketFactory.java @@ -16,17 +16,16 @@ */ package com.gemstone.gemfire.admin.jmx.internal; -import java.io.IOException; -import java.net.ServerSocket; -import java.util.Properties; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.admin.DistributedSystemConfig; import com.gemstone.gemfire.admin.internal.InetAddressUtil; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.SocketCreator; import com.gemstone.gemfire.internal.logging.LogService; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Properties; /** * Creates <code>ServerSockets</code> for JMX adaptors. http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MemberInfoWithStatsMBean.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MemberInfoWithStatsMBean.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MemberInfoWithStatsMBean.java index 646c8d5..2667ec7 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MemberInfoWithStatsMBean.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/MemberInfoWithStatsMBean.java @@ -16,51 +16,7 @@ */ package com.gemstone.gemfire.admin.jmx.internal; -import java.net.InetAddress; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.concurrent.atomic.AtomicLong; - -import javax.management.InstanceNotFoundException; -import javax.management.ListenerNotFoundException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanOperationInfo; -import javax.management.MBeanParameterInfo; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.Notification; -import javax.management.NotificationBroadcasterSupport; -import javax.management.NotificationEmitter; -import javax.management.NotificationFilter; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.management.OperationsException; -import javax.management.ReflectionException; - -import org.apache.logging.log4j.Logger; - -import mx4j.AbstractDynamicMBean; - -import com.gemstone.gemfire.admin.AdminDistributedSystem; -import com.gemstone.gemfire.admin.AdminException; -import com.gemstone.gemfire.admin.CacheVm; -import com.gemstone.gemfire.admin.ConfigurationParameter; -import com.gemstone.gemfire.admin.GemFireMemberStatus; -import com.gemstone.gemfire.admin.RegionSubRegionSnapshot; -import com.gemstone.gemfire.admin.StatisticResource; -import com.gemstone.gemfire.admin.SystemMember; -import com.gemstone.gemfire.admin.SystemMemberCacheServer; +import com.gemstone.gemfire.admin.*; import com.gemstone.gemfire.admin.jmx.Agent; import com.gemstone.gemfire.cache.InterestPolicy; import com.gemstone.gemfire.cache.SubscriptionAttributes; @@ -70,6 +26,14 @@ import com.gemstone.gemfire.internal.admin.remote.ClientHealthStats; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; +import mx4j.AbstractDynamicMBean; +import org.apache.logging.log4j.Logger; + +import javax.management.*; +import java.net.InetAddress; +import java.text.MessageFormat; +import java.util.*; +import java.util.concurrent.atomic.AtomicLong; /** * This class uses the JMX Attributes/Operations that use (return/throw) @@ -591,48 +555,48 @@ public class MemberInfoWithStatsMBean extends AbstractDynamicMBean // private static final String GATEWAYHUB_COUNT = "gemfire.gatewayhubcount.int"; // private static final String CLIENT_COUNT = "gemfire.clientcount.int"; - private static final String MEMBER_ID = "gemfire.member.id.string"; - private static final String MEMBER_NAME = "gemfire.member.name.string"; - private static final String MEMBER_HOST = "gemfire.member.host.string"; - private static final String MEMBER_PORT = "gemfire.member.port.int"; - private static final String MEMBER_UPTIME = "gemfire.member.uptime.long"; - private static final String MEMBER_CLIENTS = "gemfire.member.clients.map"; - private static final String MEMBER_REGIONS = "gemfire.member.regions.map"; - private static final String MEMBER_TYPE = "gemfire.member.type.string"; - private static final String IS_SERVER = "gemfire.member.isserver.boolean"; - private static final String IS_GATEWAY = "gemfire.member.isgateway.boolean"; + private static final String MEMBER_ID = DistributionConfig.GEMFIRE_PREFIX + "member.id.string"; + private static final String MEMBER_NAME = DistributionConfig.GEMFIRE_PREFIX + "member.name.string"; + private static final String MEMBER_HOST = DistributionConfig.GEMFIRE_PREFIX + "member.host.string"; + private static final String MEMBER_PORT = DistributionConfig.GEMFIRE_PREFIX + "member.port.int"; + private static final String MEMBER_UPTIME = DistributionConfig.GEMFIRE_PREFIX + "member.uptime.long"; + private static final String MEMBER_CLIENTS = DistributionConfig.GEMFIRE_PREFIX + "member.clients.map"; + private static final String MEMBER_REGIONS = DistributionConfig.GEMFIRE_PREFIX + "member.regions.map"; + private static final String MEMBER_TYPE = DistributionConfig.GEMFIRE_PREFIX + "member.type.string"; + private static final String IS_SERVER = DistributionConfig.GEMFIRE_PREFIX + "member.isserver.boolean"; + private static final String IS_GATEWAY = DistributionConfig.GEMFIRE_PREFIX + "member.isgateway.boolean"; - private static final String MEMBER_STATSAMPLING_ENABLED = "gemfire.member.config.statsamplingenabled.boolean"; - private static final String MEMBER_TIME_STATS_ENABLED = "gemfire.member.config.timestatsenabled.boolean"; - - private static final String STATS_PROCESSCPUTIME = "gemfire.member.stat.processcputime.long"; - private static final String STATS_CPUS = "gemfire.member.stat.cpus.int"; - private static final String STATS_USEDMEMORY = "gemfire.member.stat.usedmemory.long"; - private static final String STATS_MAXMEMORY = "gemfire.member.stat.maxmemory.long"; - private static final String STATS_GETS = "gemfire.member.stat.gets.int"; - private static final String STATS_GETTIME = "gemfire.member.stat.gettime.long"; - private static final String STATS_PUTS = "gemfire.member.stat.puts.int"; - private static final String STATS_PUTTIME = "gemfire.member.stat.puttime.long"; - - private static final String REGION_NAME = "gemfire.region.name.string"; - private static final String REGION_PATH = "gemfire.region.path.string"; - private static final String REGION_SCOPE = "gemfire.region.scope.string"; - private static final String REGION_DATAPOLICY = "gemfire.region.datapolicy.string"; - private static final String REGION_INTERESTPOLICY = "gemfire.region.interestpolicy.string"; - private static final String REGION_ENTRYCOUNT = "gemfire.region.entrycount.int"; - private static final String REGION_DISKATTRS = "gemfire.region.diskattrs.string"; + private static final String MEMBER_STATSAMPLING_ENABLED = DistributionConfig.GEMFIRE_PREFIX + "member.config.statsamplingenabled.boolean"; + private static final String MEMBER_TIME_STATS_ENABLED = DistributionConfig.GEMFIRE_PREFIX + "member.config.timestatsenabled.boolean"; + + private static final String STATS_PROCESSCPUTIME = DistributionConfig.GEMFIRE_PREFIX + "member.stat.processcputime.long"; + private static final String STATS_CPUS = DistributionConfig.GEMFIRE_PREFIX + "member.stat.cpus.int"; + private static final String STATS_USEDMEMORY = DistributionConfig.GEMFIRE_PREFIX + "member.stat.usedmemory.long"; + private static final String STATS_MAXMEMORY = DistributionConfig.GEMFIRE_PREFIX + "member.stat.maxmemory.long"; + private static final String STATS_GETS = DistributionConfig.GEMFIRE_PREFIX + "member.stat.gets.int"; + private static final String STATS_GETTIME = DistributionConfig.GEMFIRE_PREFIX + "member.stat.gettime.long"; + private static final String STATS_PUTS = DistributionConfig.GEMFIRE_PREFIX + "member.stat.puts.int"; + private static final String STATS_PUTTIME = DistributionConfig.GEMFIRE_PREFIX + "member.stat.puttime.long"; + + private static final String REGION_NAME = DistributionConfig.GEMFIRE_PREFIX + "region.name.string"; + private static final String REGION_PATH = DistributionConfig.GEMFIRE_PREFIX + "region.path.string"; + private static final String REGION_SCOPE = DistributionConfig.GEMFIRE_PREFIX + "region.scope.string"; + private static final String REGION_DATAPOLICY = DistributionConfig.GEMFIRE_PREFIX + "region.datapolicy.string"; + private static final String REGION_INTERESTPOLICY = DistributionConfig.GEMFIRE_PREFIX + "region.interestpolicy.string"; + private static final String REGION_ENTRYCOUNT = DistributionConfig.GEMFIRE_PREFIX + "region.entrycount.int"; + private static final String REGION_DISKATTRS = DistributionConfig.GEMFIRE_PREFIX + "region.diskattrs.string"; - private static final String CLIENT_ID = "gemfire.client.id.string"; - private static final String CLIENT_NAME = "gemfire.client.name.string"; - private static final String CLIENT_HOST = "gemfire.client.host.string"; - private static final String CLIENT_QUEUESIZE = "gemfire.client.queuesize.int"; - private static final String CLIENT_STATS_GETS = "gemfire.client.stats.gets.int"; - private static final String CLIENT_STATS_PUTS = "gemfire.client.stats.puts.int"; - private static final String CLIENT_STATS_CACHEMISSES = "gemfire.client.stats.cachemisses.int"; - private static final String CLIENT_STATS_CPUUSAGE = "gemfire.client.stats.cpuusage.long"; - private static final String CLIENT_STATS_CPUS = "gemfire.client.stats.cpus.int"; - private static final String CLIENT_STATS_UPDATETIME = "gemfire.client.stats.updatetime.long"; - private static final String CLIENT_STATS_THREADS = "gemfire.client.stats.threads.int"; + private static final String CLIENT_ID = DistributionConfig.GEMFIRE_PREFIX + "client.id.string"; + private static final String CLIENT_NAME = DistributionConfig.GEMFIRE_PREFIX + "client.name.string"; + private static final String CLIENT_HOST = DistributionConfig.GEMFIRE_PREFIX + "client.host.string"; + private static final String CLIENT_QUEUESIZE = DistributionConfig.GEMFIRE_PREFIX + "client.queuesize.int"; + private static final String CLIENT_STATS_GETS = DistributionConfig.GEMFIRE_PREFIX + "client.stats.gets.int"; + private static final String CLIENT_STATS_PUTS = DistributionConfig.GEMFIRE_PREFIX + "client.stats.puts.int"; + private static final String CLIENT_STATS_CACHEMISSES = DistributionConfig.GEMFIRE_PREFIX + "client.stats.cachemisses.int"; + private static final String CLIENT_STATS_CPUUSAGE = DistributionConfig.GEMFIRE_PREFIX + "client.stats.cpuusage.long"; + private static final String CLIENT_STATS_CPUS = DistributionConfig.GEMFIRE_PREFIX + "client.stats.cpus.int"; + private static final String CLIENT_STATS_UPDATETIME = DistributionConfig.GEMFIRE_PREFIX + "client.stats.updatetime.long"; + private static final String CLIENT_STATS_THREADS = DistributionConfig.GEMFIRE_PREFIX + "client.stats.threads.int"; /** * http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/SystemMemberJmx.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/SystemMemberJmx.java b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/SystemMemberJmx.java index aa06cc6..c57bf85 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/SystemMemberJmx.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/admin/jmx/internal/SystemMemberJmx.java @@ -16,33 +16,20 @@ */ package com.gemstone.gemfire.admin.jmx.internal; -import java.util.concurrent.atomic.AtomicInteger; - -import javax.management.MBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.Notification; -import javax.management.NotificationListener; -import javax.management.ObjectName; -import javax.management.RuntimeOperationsException; -import javax.naming.OperationNotSupportedException; - -import org.apache.commons.modeler.ManagedBean; -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.admin.AdminException; -import com.gemstone.gemfire.admin.ConfigurationParameter; -import com.gemstone.gemfire.admin.OperationCancelledException; -import com.gemstone.gemfire.admin.StatisticResource; -import com.gemstone.gemfire.admin.SystemMember; -import com.gemstone.gemfire.admin.SystemMemberCache; -import com.gemstone.gemfire.admin.SystemMemberCacheEvent; -import com.gemstone.gemfire.admin.SystemMemberRegionEvent; +import com.gemstone.gemfire.admin.*; import com.gemstone.gemfire.cache.Operation; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.internal.admin.ClientMembershipMessage; 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.commons.modeler.ManagedBean; +import org.apache.logging.log4j.Logger; + +import javax.management.*; +import javax.naming.OperationNotSupportedException; +import java.util.concurrent.atomic.AtomicInteger; /** * Defines methods that all <code>SystemMember</code> MBeans should @@ -56,38 +43,38 @@ public interface SystemMemberJmx * Notification type for indicating a cache got created on a member of this * distributed system. */ - public static final String NOTIF_CACHE_CREATED = - "gemfire.distributedsystem.cache.created"; + public static final String NOTIF_CACHE_CREATED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.created"; /** * Notification type for indicating a cache is closed on a member of this * distributed system. */ - public static final String NOTIF_CACHE_CLOSED = - "gemfire.distributedsystem.cache.closed"; + public static final String NOTIF_CACHE_CLOSED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.closed"; /** * Notification type for indicating a region is created in a cache on a member * of this distributed system. */ - public static final String NOTIF_REGION_CREATED = - "gemfire.distributedsystem.cache.region.created"; + public static final String NOTIF_REGION_CREATED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.region.created"; /** * Notification type for indicating a region was removed from a cache on a * member of this distributed system. */ - public static final String NOTIF_REGION_LOST = - "gemfire.distributedsystem.cache.region.lost"; + public static final String NOTIF_REGION_LOST = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.region.lost"; /** Notification type for indicating client joined */ - public static final String NOTIF_CLIENT_JOINED = - "gemfire.distributedsystem.cache.client.joined"; + public static final String NOTIF_CLIENT_JOINED = + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.client.joined"; /** Notification type for indicating client left */ public static final String NOTIF_CLIENT_LEFT = - "gemfire.distributedsystem.cache.client.left"; + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.client.left"; /** Notification type for indicating client crashed */ public static final String NOTIF_CLIENT_CRASHED = - "gemfire.distributedsystem.cache.client.crashed"; + DistributionConfig.GEMFIRE_PREFIX + "distributedsystem.cache.client.crashed"; /** * Gets the interval in seconds between config refreshes http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java index 1654b1a..620c79f 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/DiskStoreFactory.java @@ -16,6 +16,7 @@ */ package com.gemstone.gemfire.cache; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import java.io.File; @@ -60,7 +61,8 @@ public interface DiskStoreFactory * The default maximum oplog file size in megabytes. * <p>Current value: <code>1024</code> which is one gigabyte. */ - public static final long DEFAULT_MAX_OPLOG_SIZE = Long.getLong("gemfire.DEFAULT_MAX_OPLOG_SIZE", 1024L).longValue(); // 1024 == 1 GB; // sys prop used by dunit and junit + public static final long DEFAULT_MAX_OPLOG_SIZE = Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "DEFAULT_MAX_OPLOG_SIZE", 1024L) + .longValue(); // 1024 == 1 GB; // sys prop used by dunit and junit /** * The default time interval in milliseconds. http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientCacheFactory.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientCacheFactory.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientCacheFactory.java index 5b035a5..3cbfff8 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientCacheFactory.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/ClientCacheFactory.java @@ -17,8 +17,6 @@ package com.gemstone.gemfire.cache.client; -import java.util.Properties; - import com.gemstone.gemfire.cache.CacheClosedException; import com.gemstone.gemfire.cache.Region; import com.gemstone.gemfire.cache.server.CacheServer; @@ -27,9 +25,13 @@ import com.gemstone.gemfire.internal.GemFireVersion; import com.gemstone.gemfire.internal.cache.CacheConfig; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; -import com.gemstone.gemfire.internal.jndi.JNDIInvoker; -import com.gemstone.gemfire.pdx.PdxSerializer; import com.gemstone.gemfire.pdx.PdxInstance; +import com.gemstone.gemfire.pdx.PdxSerializer; + +import java.util.Properties; + +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.LOCATORS; +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.MCAST_PORT; /** Factory class used to create the singleton {@link ClientCache client cache} and connect to one or more GemFire Cache Servers. If the application wants to connect to GemFire as a peer it should use {@link com.gemstone.gemfire.cache.CacheFactory} instead. @@ -194,7 +196,7 @@ public class ClientCacheFactory { GemFireCacheImpl instance = GemFireCacheImpl.getInstance(); { - String propValue = this.dsProps.getProperty("mcast-port"); + String propValue = this.dsProps.getProperty(MCAST_PORT); if (propValue != null) { int mcastPort = Integer.parseInt(propValue); if (mcastPort != 0) { @@ -203,13 +205,13 @@ public class ClientCacheFactory { } } { - String propValue = this.dsProps.getProperty("locators"); + String propValue = this.dsProps.getProperty(LOCATORS); if (propValue != null && !propValue.equals("")) { throw new IllegalStateException("On a client cache the locators property must be set to an empty string or not set. It was set to \"" + propValue + "\"."); } } - this.dsProps.setProperty("mcast-port", "0"); - this.dsProps.setProperty("locators", ""); + this.dsProps.setProperty(MCAST_PORT, "0"); + this.dsProps.setProperty(LOCATORS, ""); DistributedSystem system = DistributedSystem.connect(this.dsProps); if (instance != null && !instance.isClosed()) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AuthenticateUserOp.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AuthenticateUserOp.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AuthenticateUserOp.java index 135b7df..b85e17a 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AuthenticateUserOp.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/AuthenticateUserOp.java @@ -19,10 +19,6 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.util.Properties; - import com.gemstone.gemfire.DataSerializer; import com.gemstone.gemfire.InternalGemFireError; import com.gemstone.gemfire.cache.client.ServerOperationException; @@ -45,6 +41,10 @@ import com.gemstone.gemfire.security.AuthenticationFailedException; import com.gemstone.gemfire.security.AuthenticationRequiredException; import com.gemstone.gemfire.security.NotAuthorizedException; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.util.Properties; + /** * Authenticates this client (or a user) on a server. This op ideally should get * executed once-per-server. http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java index 8e05175..6e255c4 100755 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ClientMetadataService.java @@ -16,28 +16,9 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArraySet; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.EntryOperation; -import com.gemstone.gemfire.cache.FixedPartitionResolver; -import com.gemstone.gemfire.cache.Operation; -import com.gemstone.gemfire.cache.PartitionResolver; -import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.cache.BucketServerLocation66; import com.gemstone.gemfire.internal.cache.EntryOperationImpl; @@ -45,6 +26,11 @@ import com.gemstone.gemfire.internal.cache.LocalRegion; import com.gemstone.gemfire.internal.cache.PartitionedRegionHelper; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; +import org.apache.logging.log4j.Logger; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.CopyOnWriteArraySet; /** * Maintains {@link ClientPartitionAdvisor} for Partitioned Regions on servers @@ -63,7 +49,7 @@ public final class ClientMetadataService { private final Set<String> nonPRs = new HashSet<String>(); - private boolean HONOUR_SERVER_GROUP_IN_PR_SINGLE_HOP = Boolean.getBoolean("gemfire.PoolImpl.honourServerGroupsInPRSingleHop"); + private boolean HONOUR_SERVER_GROUP_IN_PR_SINGLE_HOP = Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.honourServerGroupsInPRSingleHop"); public static final int SIZE_BYTES_ARRAY_RECEIVED = 2; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionFactoryImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionFactoryImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionFactoryImpl.java index 6533b50..c1700d4 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionFactoryImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ConnectionFactoryImpl.java @@ -16,19 +16,12 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.ScheduledExecutorService; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.cache.GatewayConfigurationException; import com.gemstone.gemfire.cache.client.ServerRefusedConnectionException; import com.gemstone.gemfire.cache.client.internal.ServerBlackList.FailureTracker; import com.gemstone.gemfire.cache.wan.GatewaySender; -import com.gemstone.gemfire.distributed.DistributedSystem; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem; import com.gemstone.gemfire.distributed.internal.ServerLocation; @@ -41,6 +34,11 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; import com.gemstone.gemfire.security.GemFireSecurityException; +import org.apache.logging.log4j.Logger; + +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ScheduledExecutorService; /** * Creates connections, using a connection source to determine http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ExplicitConnectionSourceImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ExplicitConnectionSourceImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ExplicitConnectionSourceImpl.java index d8fc9b6..26aadf8 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ExplicitConnectionSourceImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/ExplicitConnectionSourceImpl.java @@ -16,21 +16,16 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.apache.logging.log4j.Logger; - +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID; import com.gemstone.gemfire.internal.cache.tier.sockets.ServerQueueStatus; import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.security.GemFireSecurityException; +import org.apache.logging.log4j.Logger; + +import java.net.InetSocketAddress; +import java.util.*; /** * A connection source where the list of endpoints is specified explicitly. @@ -55,7 +50,7 @@ public class ExplicitConnectionSourceImpl implements ConnectionSource { * the endpoints list */ private boolean DISABLE_SHUFFLING = Boolean - .getBoolean("gemfire.bridge.disableShufflingOfEndpoints"); + .getBoolean(DistributionConfig.GEMFIRE_PREFIX + "bridge.disableShufflingOfEndpoints"); public ExplicitConnectionSourceImpl(List/*<InetSocketAddress>*/contacts) { ArrayList serverList = new ArrayList(contacts.size()); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/OpExecutorImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/OpExecutorImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/OpExecutorImpl.java index 8410dbd..bbec12f 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/OpExecutorImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/OpExecutorImpl.java @@ -16,36 +16,12 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.io.EOFException; -import java.io.IOException; -import java.io.NotSerializableException; -import java.net.ConnectException; -import java.net.SocketException; -import java.net.SocketTimeoutException; -import java.nio.BufferUnderflowException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.logging.log4j.Logger; - -import com.gemstone.gemfire.CancelCriterion; -import com.gemstone.gemfire.CancelException; -import com.gemstone.gemfire.CopyException; -import com.gemstone.gemfire.GemFireException; -import com.gemstone.gemfire.GemFireIOException; -import com.gemstone.gemfire.SerializationException; +import com.gemstone.gemfire.*; import com.gemstone.gemfire.cache.CacheRuntimeException; import com.gemstone.gemfire.cache.RegionDestroyedException; import com.gemstone.gemfire.cache.SynchronizationCommitConflictException; import com.gemstone.gemfire.cache.TransactionException; -import com.gemstone.gemfire.cache.client.NoAvailableServersException; -import com.gemstone.gemfire.cache.client.ServerConnectivityException; -import com.gemstone.gemfire.cache.client.ServerOperationException; -import com.gemstone.gemfire.cache.client.ServerRefusedConnectionException; -import com.gemstone.gemfire.cache.client.SubscriptionNotEnabledException; +import com.gemstone.gemfire.cache.client.*; import com.gemstone.gemfire.cache.client.internal.ExecuteFunctionOp.ExecuteFunctionOpImpl; import com.gemstone.gemfire.cache.client.internal.ExecuteRegionFunctionOp.ExecuteRegionFunctionOpImpl; import com.gemstone.gemfire.cache.client.internal.QueueManager.QueueConnections; @@ -53,6 +29,7 @@ import com.gemstone.gemfire.cache.client.internal.pooling.ConnectionDestroyedExc import com.gemstone.gemfire.cache.client.internal.pooling.ConnectionManager; import com.gemstone.gemfire.cache.execute.FunctionException; import com.gemstone.gemfire.cache.execute.FunctionInvocationTargetException; +import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.cache.PoolManagerImpl; import com.gemstone.gemfire.internal.cache.PutAllPartialResultException; @@ -66,6 +43,16 @@ import com.gemstone.gemfire.internal.logging.LogService; import com.gemstone.gemfire.internal.logging.log4j.LogMarker; import com.gemstone.gemfire.security.AuthenticationRequiredException; import com.gemstone.gemfire.security.GemFireSecurityException; +import org.apache.logging.log4j.Logger; + +import java.io.EOFException; +import java.io.IOException; +import java.io.NotSerializableException; +import java.net.ConnectException; +import java.net.SocketException; +import java.net.SocketTimeoutException; +import java.nio.BufferUnderflowException; +import java.util.*; /** * Called from the client and execute client to server @@ -75,9 +62,9 @@ import com.gemstone.gemfire.security.GemFireSecurityException; */ public class OpExecutorImpl implements ExecutablePool { private static final Logger logger = LogService.getLogger(); - - private static final boolean TRY_SERVERS_ONCE = Boolean.getBoolean("gemfire.PoolImpl.TRY_SERVERS_ONCE"); - private static final int TX_RETRY_ATTEMPT = Integer.getInteger("gemfire.txRetryAttempt", 500); + + private static final boolean TRY_SERVERS_ONCE = Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.TRY_SERVERS_ONCE"); + private static final int TX_RETRY_ATTEMPT = Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "txRetryAttempt", 500); private final ConnectionManager connectionManager; private final int retryAttempts; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70612010/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java index 3579769..44465d8 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/cache/client/internal/PoolImpl.java @@ -16,33 +16,11 @@ */ package com.gemstone.gemfire.cache.client.internal; -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.logging.log4j.Logger; - import com.gemstone.gemfire.CancelCriterion; import com.gemstone.gemfire.CancelException; import com.gemstone.gemfire.StatisticsFactory; import com.gemstone.gemfire.SystemFailure; -import com.gemstone.gemfire.cache.Cache; -import com.gemstone.gemfire.cache.CacheClosedException; -import com.gemstone.gemfire.cache.CacheFactory; -import com.gemstone.gemfire.cache.NoSubscriptionServersAvailableException; -import com.gemstone.gemfire.cache.Region; -import com.gemstone.gemfire.cache.RegionService; +import com.gemstone.gemfire.cache.*; import com.gemstone.gemfire.cache.client.Pool; import com.gemstone.gemfire.cache.client.ServerConnectivityException; import com.gemstone.gemfire.cache.client.SubscriptionNotEnabledException; @@ -58,18 +36,25 @@ import com.gemstone.gemfire.distributed.internal.ServerLocation; import com.gemstone.gemfire.internal.DummyStatisticsFactory; import com.gemstone.gemfire.internal.ScheduledThreadPoolExecutorWithKeepAlive; import com.gemstone.gemfire.internal.admin.ClientStatsManager; -import com.gemstone.gemfire.internal.cache.EventID; -import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; -import com.gemstone.gemfire.internal.cache.InternalCache; -import com.gemstone.gemfire.internal.cache.PoolFactoryImpl; -import com.gemstone.gemfire.internal.cache.PoolManagerImpl; -import com.gemstone.gemfire.internal.cache.PoolStats; +import com.gemstone.gemfire.internal.cache.*; import com.gemstone.gemfire.internal.cache.tier.sockets.AcceptorImpl; import com.gemstone.gemfire.internal.cache.tier.sockets.ClientProxyMembershipID; 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 java.net.InetSocketAddress; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static com.gemstone.gemfire.distributed.SystemConfigurationProperties.LOCATORS; /** * Manages the client side of client to server connections @@ -78,14 +63,17 @@ import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessage; * @since GemFire 5.7 */ public class PoolImpl implements InternalPool { - public static final String ON_DISCONNECT_CLEAR_PDXTYPEIDS = "gemfire.ON_DISCONNECT_CLEAR_PDXTYPEIDS"; + public static final String ON_DISCONNECT_CLEAR_PDXTYPEIDS = DistributionConfig.GEMFIRE_PREFIX + "ON_DISCONNECT_CLEAR_PDXTYPEIDS"; private static final Logger logger = LogService.getLogger(); - - public static final int HANDSHAKE_TIMEOUT = Long.getLong("gemfire.PoolImpl.HANDSHAKE_TIMEOUT", AcceptorImpl.DEFAULT_HANDSHAKE_TIMEOUT_MS).intValue(); - public static final long SHUTDOWN_TIMEOUT = Long.getLong("gemfire.PoolImpl.SHUTDOWN_TIMEOUT", 30000).longValue(); - public static final int BACKGROUND_TASK_POOL_SIZE = Integer.getInteger("gemfire.PoolImpl.BACKGROUND_TASK_POOL_SIZE", 20).intValue(); - public static final int BACKGROUND_TASK_POOL_KEEP_ALIVE = Integer.getInteger("gemfire.PoolImpl.BACKGROUND_TASK_POOL_KEEP_ALIVE", 1000).intValue(); + + public static final int HANDSHAKE_TIMEOUT = Long + .getLong(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.HANDSHAKE_TIMEOUT", AcceptorImpl.DEFAULT_HANDSHAKE_TIMEOUT_MS).intValue(); + public static final long SHUTDOWN_TIMEOUT = Long.getLong(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.SHUTDOWN_TIMEOUT", 30000).longValue(); + public static final int BACKGROUND_TASK_POOL_SIZE = Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.BACKGROUND_TASK_POOL_SIZE", 20) + .intValue(); + public static final int BACKGROUND_TASK_POOL_KEEP_ALIVE = Integer + .getInteger(DistributionConfig.GEMFIRE_PREFIX + "PoolImpl.BACKGROUND_TASK_POOL_KEEP_ALIVE", 1000).intValue(); //For durable client tests only. Connection Sources read this flag //and return an empty list of servers. public volatile static boolean TEST_DURABLE_IS_NET_DOWN = false; @@ -213,9 +201,9 @@ public class PoolImpl implements InternalPool { } this.dsys = ds; this.cancelCriterion = new Stopper(); - if(Boolean.getBoolean("gemfire.SPECIAL_DURABLE")) { - ClientProxyMembershipID.setPoolName(name); - this.proxyId = ClientProxyMembershipID.getNewProxyMembership(ds); + if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "SPECIAL_DURABLE")) { + ClientProxyMembershipID.setPoolName(name); + this.proxyId = ClientProxyMembershipID.getNewProxyMembership(ds); ClientProxyMembershipID.setPoolName(null); } else { this.proxyId = ClientProxyMembershipID.getNewProxyMembership(ds); @@ -466,7 +454,7 @@ public class PoolImpl implements InternalPool { public void destroy(boolean keepAlive) { int cnt = getAttachCount(); this.keepAlive = keepAlive; - boolean SPECIAL_DURABLE = Boolean.getBoolean("gemfire.SPECIAL_DURABLE"); + boolean SPECIAL_DURABLE = Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "SPECIAL_DURABLE"); if (cnt > 0) { //special case to allow closing durable client pool under the keep alive flag //closing regions prior to closing pool can cause them to unregister interest @@ -680,7 +668,7 @@ public class PoolImpl implements InternalPool { } if (!getLocators().equals(other.getLocators())) { throw new RuntimeException( - LocalizedStrings.PoolImpl_0_ARE_DIFFERENT.toLocalizedString("locators")); + LocalizedStrings.PoolImpl_0_ARE_DIFFERENT.toLocalizedString(LOCATORS)); } if (!getServers().equals(other.getServers())) { throw new RuntimeException(
