You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2016/02/18 00:10:39 UTC
[04/33] incubator-geode git commit: GEODE-913: refactor
AbstractDistributionConfig
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
index 190a137..fc2fca7 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfigImpl.java
@@ -17,21 +17,6 @@
package com.gemstone.gemfire.distributed.internal;
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
import com.gemstone.gemfire.GemFireConfigException;
import com.gemstone.gemfire.GemFireIOException;
import com.gemstone.gemfire.distributed.DistributedSystem;
@@ -41,6 +26,14 @@ import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
import com.gemstone.gemfire.internal.process.ProcessLauncherContext;
import com.gemstone.gemfire.memcached.GemFireMemcachedServer;
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.*;
+
/**
* Provides an implementation of <code>DistributionConfig</code> that
* knows how to read the configuration file.
@@ -1544,8 +1537,7 @@ public class DistributionConfigImpl
}
public void setHttpServicePort(int value) {
- minMaxCheck(HTTP_SERVICE_PORT_NAME, value, 0, 65535);
- this.httpServicePort = value;
+ this.httpServicePort = (Integer)checkAttribute(HTTP_SERVICE_PORT_NAME, value);
}
public String getHttpServiceBindAddress() {
@@ -1553,8 +1545,7 @@ public class DistributionConfigImpl
}
public void setHttpServiceBindAddress(String value) {
- checkHttpServiceBindAddress(value);
- this.httpServiceBindAddress = value;
+ this.httpServiceBindAddress = (String)checkAttribute(HTTP_SERVICE_BIND_ADDRESS_NAME, value);
}
public boolean getStartDevRestApi(){
@@ -1566,8 +1557,7 @@ public class DistributionConfigImpl
}
public void setUserCommandPackages(String value) {
- checkUserCommandPackages(value);
- this.userCommandPackages = value;
+ this.userCommandPackages = (String)checkAttribute(USER_COMMAND_PACKAGES, value);
}
public boolean getDeltaPropagation() {
@@ -1575,44 +1565,35 @@ public class DistributionConfigImpl
}
public void setDeltaPropagation(boolean value) {
- checkDeltaPropagationModifiable();
- this.deltaPropagation = value;
+ this.deltaPropagation = (Boolean)checkAttribute(DELTA_PROPAGATION_PROP_NAME, value);
}
public void setName(String value) {
- checkName(value);
if (value == null) {
value = DEFAULT_NAME;
}
- this.name = value;
+ this.name = (String)checkAttribute(NAME_NAME, value);
}
public void setTcpPort(int value) {
- checkTcpPort(value);
- this.tcpPort = value;
+ this.tcpPort = (Integer)checkAttribute(TCP_PORT_NAME, value);
}
public void setMcastPort(int value) {
- checkMcastPort(value);
- this.mcastPort = value;
+ this.mcastPort = (Integer)checkAttribute(MCAST_PORT_NAME, value);
}
public void setMcastTtl(int value) {
- checkMcastTtl(value);
- this.mcastTtl = value;
+ this.mcastTtl = (Integer)checkAttribute(MCAST_TTL_NAME, value);
}
public void setSocketLeaseTime(int value) {
- checkSocketLeaseTime(value);
- this.socketLeaseTime = value;
+ this.socketLeaseTime = (Integer)checkAttribute(SOCKET_LEASE_TIME_NAME, value);
}
public void setSocketBufferSize(int value) {
- checkSocketBufferSize(value);
- this.socketBufferSize = value;
+ this.socketBufferSize = (Integer)checkAttribute(SOCKET_BUFFER_SIZE_NAME, value);
}
public void setConserveSockets(boolean value) {
- checkConserveSockets(value);
- this.conserveSockets = value;
+ this.conserveSockets = (Boolean)checkAttribute(CONSERVE_SOCKETS_NAME, value);
}
public void setRoles(String value) {
- checkRoles(value);
- this.roles = value;
+ this.roles = (String)checkAttribute(ROLES_NAME, value);
}
public void setMaxWaitTimeForReconnect(int value){
@@ -1624,23 +1605,19 @@ public class DistributionConfigImpl
}
public void setMcastAddress(InetAddress value) {
- checkMcastAddress(value);
- this.mcastAddress = value;
+ this.mcastAddress = (InetAddress)checkAttribute(MCAST_ADDRESS_NAME, value);
}
public void setBindAddress(String value) {
- checkBindAddress(value);
- this.bindAddress = value;
+ this.bindAddress = (String)checkAttribute(BIND_ADDRESS_NAME, value);
}
public void setServerBindAddress(String value) {
- checkServerBindAddress(value);
- this.serverBindAddress = value;
+ this.serverBindAddress = (String)checkAttribute(SERVER_BIND_ADDRESS_NAME, value);
}
public void setLocators(String value) {
- value = checkLocators(value);
if (value == null) {
value = DEFAULT_LOCATORS;
}
- this.locators = value;
+ this.locators = (String)checkAttribute(LOCATORS_NAME, value);
}
public void setLocatorWaitTime(int value) {
@@ -1652,16 +1629,13 @@ public class DistributionConfigImpl
}
public void setDeployWorkingDir(File value) {
- checkDeployWorkingDir(value);
- this.deployWorkingDir = value;
+ this.deployWorkingDir = (File)checkAttribute(DEPLOY_WORKING_DIR, value);
}
public void setLogFile(File value) {
- checkLogFile(value);
- this.logFile = value;
+ this.logFile = (File)checkAttribute(LOG_FILE_NAME, value);
}
public void setLogLevel(int value) {
- checkLogLevel(value);
- this.logLevel = value;
+ this.logLevel = (Integer)checkAttribute(LOG_LEVEL_NAME, value);
}
/**
* the locator startup code must be able to modify the locator log file in order
@@ -1700,17 +1674,16 @@ public class DistributionConfigImpl
}
}
else {
- checkStartLocator(value);
+ value = (String)checkAttribute(START_LOCATOR_NAME, value);
}
}
this.startLocator = value;
}
public void setStatisticSamplingEnabled(boolean value) {
- checkStatisticSamplingEnabled(value);
- this.statisticSamplingEnabled = value;
+ this.statisticSamplingEnabled = (Boolean)checkAttribute(STATISTIC_SAMPLING_ENABLED_NAME, value);
}
public void setStatisticSampleRate(int value) {
- checkStatisticSampleRate(value);
+ value = (Integer)checkAttribute(STATISTIC_SAMPLE_RATE_NAME, value);
if (value < DEFAULT_STATISTIC_SAMPLE_RATE) {
// fix 48228
InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance();
@@ -1722,110 +1695,94 @@ public class DistributionConfigImpl
this.statisticSampleRate = value;
}
public void setStatisticArchiveFile(File value) {
- checkStatisticArchiveFile(value);
if (value == null) {
value = new File("");
}
- this.statisticArchiveFile = value;
+ this.statisticArchiveFile = (File)checkAttribute(STATISTIC_ARCHIVE_FILE_NAME, value);
}
public void setCacheXmlFile(File value) {
- checkCacheXmlFile(value);
- this.cacheXmlFile = value;
+ this.cacheXmlFile = (File)checkAttribute(CACHE_XML_FILE_NAME, value);
}
public void setAckWaitThreshold(int value) {
- checkAckWaitThreshold(value);
- this.ackWaitThreshold = value;
+ this.ackWaitThreshold = (Integer)checkAttribute(ACK_WAIT_THRESHOLD_NAME, value);
}
public void setAckSevereAlertThreshold(int value) {
- checkAckSevereAlertThreshold(value);
- this.ackForceDisconnectThreshold = value;
+ this.ackForceDisconnectThreshold = (Integer)checkAttribute(ACK_SEVERE_ALERT_THRESHOLD_NAME, value);
}
public int getArchiveDiskSpaceLimit() {
return this.archiveDiskSpaceLimit;
}
public void setArchiveDiskSpaceLimit(int value) {
- checkArchiveDiskSpaceLimit(value);
- this.archiveDiskSpaceLimit = value;
+ this.archiveDiskSpaceLimit = (Integer)checkAttribute(ARCHIVE_DISK_SPACE_LIMIT_NAME, value);
}
public int getArchiveFileSizeLimit() {
return this.archiveFileSizeLimit;
}
public void setArchiveFileSizeLimit(int value) {
- checkArchiveFileSizeLimit(value);
- this.archiveFileSizeLimit = value;
+ this.archiveFileSizeLimit = (Integer)checkAttribute(ARCHIVE_FILE_SIZE_LIMIT_NAME, value);
}
public int getLogDiskSpaceLimit() {
return this.logDiskSpaceLimit;
}
public void setLogDiskSpaceLimit(int value) {
- checkLogDiskSpaceLimit(value);
- this.logDiskSpaceLimit = value;
+ this.logDiskSpaceLimit = (Integer)checkAttribute(LOG_DISK_SPACE_LIMIT_NAME, value);
}
public int getLogFileSizeLimit() {
return this.logFileSizeLimit;
}
public void setLogFileSizeLimit(int value) {
- checkLogFileSizeLimit(value);
- this.logFileSizeLimit = value;
+ this.logFileSizeLimit = (Integer)checkAttribute(LOG_FILE_SIZE_LIMIT_NAME, value);
}
public void setSSLEnabled( boolean value ) {
- checkSSLEnabled( value ? Boolean.TRUE : Boolean.FALSE );
- this.sslEnabled = value;
+ this.sslEnabled = (Boolean)checkAttribute(SSL_ENABLED_NAME, value);
}
public void setSSLProtocols( String value ) {
- checkSSLProtocols( value );
- this.sslProtocols = value;
+ this.sslProtocols = (String)checkAttribute(SSL_PROTOCOLS_NAME, value);
}
public void setSSLCiphers( String value ) {
- checkSSLCiphers( value );
- this.sslCiphers = value;
+ this.sslCiphers = (String)checkAttribute(SSL_CIPHERS_NAME, value);
}
public void setSSLRequireAuthentication( boolean value ){
- checkSSLRequireAuthentication( value ? Boolean.TRUE : Boolean.FALSE );
- this.sslRequireAuthentication = value;
+ this.sslRequireAuthentication = (Boolean)checkAttribute(SSL_REQUIRE_AUTHENTICATION_NAME, value);
}
public void setClusterSSLEnabled( boolean value ) {
- checkClusterSSLEnabled( value ? Boolean.TRUE : Boolean.FALSE );
- this.clusterSSLEnabled = value;
+ this.clusterSSLEnabled = (Boolean)checkAttribute(CLUSTER_SSL_ENABLED_NAME, value);
}
public void setClusterSSLProtocols( String value ) {
- checkClusterSSLProtocols( value );
- this.clusterSSLProtocols = value;
+ this.clusterSSLProtocols = (String)checkAttribute(CLUSTER_SSL_PROTOCOLS_NAME, value);
}
public void setClusterSSLCiphers( String value ) {
- checkClusterSSLCiphers( value );
- this.clusterSSLCiphers = value;
+ this.clusterSSLCiphers = (String)checkAttribute(CLUSTER_SSL_CIPHERS_NAME, value);
}
public void setClusterSSLRequireAuthentication( boolean value ){
- checkClusterSSLRequireAuthentication( value ? Boolean.TRUE : Boolean.FALSE );
- this.clusterSSLRequireAuthentication = value;
+ this.clusterSSLRequireAuthentication = (Boolean)checkAttribute(CLUSTER_SSL_REQUIRE_AUTHENTICATION_NAME, value);
}
public void setClusterSSLKeyStore( String value ) {
- checkClusterSSLKeyStore( value );
+ value = (String)checkAttribute(CLUSTER_SSL_KEYSTORE_NAME, value);
this.getClusterSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_NAME, value);
this.clusterSSLKeyStore = value;
}
public void setClusterSSLKeyStoreType( String value ) {
- checkClusterSSLKeyStoreType( value );
+ value = (String)checkAttribute(CLUSTER_SSL_KEYSTORE_TYPE_NAME, value);
this.getClusterSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_TYPE_NAME, value);
this.clusterSSLKeyStoreType = value;
}
public void setClusterSSLKeyStorePassword( String value ) {
- checkClusterSSLKeyStorePassword( value );
+ value = (String)checkAttribute(CLUSTER_SSL_KEYSTORE_PASSWORD_NAME, value);
this.getClusterSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_PASSWORD_NAME, value);
- this.clusterSSLKeyStorePassword = value;
+ this.clusterSSLKeyStorePassword =value;
}
public void setClusterSSLTrustStore( String value ) {
- checkClusterSSLTrustStore( value );
+ value = (String)checkAttribute(CLUSTER_SSL_TRUSTSTORE_NAME, value);
this.getClusterSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_NAME, value);
this.clusterSSLTrustStore = value;
}
public void setClusterSSLTrustStorePassword( String value ) {
- checkClusterSSLTrustStorePassword( value );
+ value = (String)checkAttribute(CLUSTER_SSL_TRUSTSTORE_PASSWORD_NAME, value);
this.getClusterSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_PASSWORD_NAME, value);
this.clusterSSLTrustStorePassword = value;
}
@@ -1835,8 +1792,7 @@ public class DistributionConfigImpl
}
public void setMcastSendBufferSize(int value) {
- checkMcastSendBufferSize(value);
- mcastSendBufferSize = value;
+ mcastSendBufferSize = (Integer)checkAttribute(MCAST_SEND_BUFFER_SIZE_NAME, value);
}
public int getMcastRecvBufferSize() {
@@ -1844,20 +1800,16 @@ public class DistributionConfigImpl
}
public void setMcastRecvBufferSize(int value) {
- checkMcastRecvBufferSize(value);
- mcastRecvBufferSize = value;
+ mcastRecvBufferSize = (Integer)checkAttribute(MCAST_RECV_BUFFER_SIZE_NAME, value);
}
public void setAsyncDistributionTimeout(int value) {
- checkAsyncDistributionTimeout(value);
- this.asyncDistributionTimeout = value;
+ this.asyncDistributionTimeout = (Integer)checkAttribute(ASYNC_DISTRIBUTION_TIMEOUT_NAME, value);
}
public void setAsyncQueueTimeout(int value) {
- checkAsyncQueueTimeout(value);
- this.asyncQueueTimeout = value;
+ this.asyncQueueTimeout = (Integer)checkAttribute(ASYNC_QUEUE_TIMEOUT_NAME, value);
}
public void setAsyncMaxQueueSize(int value) {
- checkAsyncMaxQueueSize(value);
- this.asyncMaxQueueSize = value;
+ this.asyncMaxQueueSize = (Integer)checkAttribute(ASYNC_MAX_QUEUE_SIZE_NAME, value);
}
public FlowControlParams getMcastFlowControl() {
@@ -1865,8 +1817,7 @@ public class DistributionConfigImpl
}
public void setMcastFlowControl(FlowControlParams values) {
- checkMcastFlowControl(values);
- mcastFlowControl = values;
+ mcastFlowControl = (FlowControlParams)checkAttribute(MCAST_FLOW_CONTROL_NAME, values);
}
public int getUdpFragmentSize() {
@@ -1874,8 +1825,7 @@ public class DistributionConfigImpl
}
public void setUdpFragmentSize(int value) {
- checkUdpFragmentSize(value);
- udpFragmentSize = value;
+ udpFragmentSize = (Integer)checkAttribute(UDP_FRAGMENT_SIZE_NAME, value);
}
public int getUdpSendBufferSize() {
@@ -1883,8 +1833,7 @@ public class DistributionConfigImpl
}
public void setUdpSendBufferSize(int value) {
- checkUdpSendBufferSize(value);
- udpSendBufferSize = value;
+ udpSendBufferSize = (Integer)checkAttribute(UDP_SEND_BUFFER_SIZE_NAME, value);
}
public int getUdpRecvBufferSize() {
@@ -1892,8 +1841,7 @@ public class DistributionConfigImpl
}
public void setUdpRecvBufferSize(int value) {
- checkUdpRecvBufferSize(value);
- udpRecvBufferSize = value;
+ udpRecvBufferSize = (Integer)checkAttribute(UDP_RECV_BUFFER_SIZE_NAME, value);
}
public boolean getDisableTcp() {
@@ -1917,8 +1865,7 @@ public class DistributionConfigImpl
}
public void setMemberTimeout(int value) {
- checkMemberTimeout(value);
- memberTimeout = value;
+ memberTimeout = (Integer)checkAttribute(MEMBER_TIMEOUT_NAME, value);
}
/** @since 5.7 */
@@ -1928,8 +1875,7 @@ public class DistributionConfigImpl
/** @since 5.7 */
public void setClientConflation(String value) {
- checkClientConflation(value);
- this.clientConflation = value;
+ this.clientConflation = (String)checkAttribute(CLIENT_CONFLATION_PROP_NAME, value);
}
public String getDurableClientId() {
@@ -1937,8 +1883,7 @@ public class DistributionConfigImpl
}
public void setDurableClientId(String value) {
- checkDurableClientId(value);
- durableClientId = value;
+ durableClientId = (String)checkAttribute(DURABLE_CLIENT_ID_NAME, value);
}
public int getDurableClientTimeout() {
@@ -1946,8 +1891,7 @@ public class DistributionConfigImpl
}
public void setDurableClientTimeout(int value) {
- checkDurableClientTimeout(value);
- durableClientTimeout = value;
+ durableClientTimeout = (Integer)checkAttribute(DURABLE_CLIENT_TIMEOUT_NAME, value);
}
public String getSecurityClientAuthInit() {
@@ -1955,8 +1899,7 @@ public class DistributionConfigImpl
}
public void setSecurityClientAuthInit(String value) {
- checkSecurityClientAuthInit(value);
- securityClientAuthInit = value;
+ securityClientAuthInit = (String)checkAttribute(SECURITY_CLIENT_AUTH_INIT_NAME, value);
}
public String getSecurityClientAuthenticator() {
@@ -1978,8 +1921,7 @@ public class DistributionConfigImpl
}
public void setSecurityClientAuthenticator(String value) {
- checkSecurityClientAuthenticator(value);
- securityClientAuthenticator = value;
+ securityClientAuthenticator = (String)checkAttribute(SECURITY_CLIENT_AUTHENTICATOR_NAME, value);
}
public String getSecurityClientDHAlgo() {
@@ -1987,8 +1929,7 @@ public class DistributionConfigImpl
}
public void setSecurityClientDHAlgo(String value) {
- checkSecurityClientDHAlgo(value);
- securityClientDHAlgo = value;
+ securityClientDHAlgo = (String)checkAttribute(SECURITY_CLIENT_DHALGO_NAME, value);
}
public String getSecurityPeerAuthInit() {
@@ -1996,8 +1937,7 @@ public class DistributionConfigImpl
}
public void setSecurityPeerAuthInit(String value) {
- checkSecurityPeerAuthInit(value);
- securityPeerAuthInit = value;
+ securityPeerAuthInit = (String)checkAttribute(SECURITY_PEER_AUTH_INIT_NAME, value);
}
public String getSecurityPeerAuthenticator() {
@@ -2005,8 +1945,7 @@ public class DistributionConfigImpl
}
public void setSecurityPeerAuthenticator(String value) {
- checkSecurityPeerAuthenticator(value);
- securityPeerAuthenticator = value;
+ securityPeerAuthenticator = (String)checkAttribute(SECURITY_PEER_AUTHENTICATOR_NAME, value);
}
public String getSecurityClientAccessor() {
@@ -2014,8 +1953,7 @@ public class DistributionConfigImpl
}
public void setSecurityClientAccessor(String value) {
- checkSecurityClientAccessor(value);
- securityClientAccessor = value;
+ securityClientAccessor = (String)checkAttribute(SECURITY_CLIENT_ACCESSOR_NAME, value);
}
public String getSecurityClientAccessorPP() {
@@ -2023,8 +1961,7 @@ public class DistributionConfigImpl
}
public void setSecurityClientAccessorPP(String value) {
- checkSecurityClientAccessorPP(value);
- securityClientAccessorPP = value;
+ securityClientAccessorPP = (String)checkAttribute(SECURITY_CLIENT_ACCESSOR_PP_NAME, value);
}
public int getSecurityLogLevel() {
@@ -2032,8 +1969,7 @@ public class DistributionConfigImpl
}
public void setSecurityLogLevel(int value) {
- checkSecurityLogLevel(value);
- securityLogLevel = value;
+ securityLogLevel = (Integer)checkAttribute(SECURITY_LOG_LEVEL_NAME, value);
}
public File getSecurityLogFile() {
@@ -2041,8 +1977,7 @@ public class DistributionConfigImpl
}
public void setSecurityLogFile(File value) {
- checkSecurityLogFile(value);
- securityLogFile = value;
+ securityLogFile = (File)checkAttribute(SECURITY_LOG_FILE_NAME, value);
}
public int getSecurityPeerMembershipTimeout() {
@@ -2050,8 +1985,7 @@ public class DistributionConfigImpl
}
public void setSecurityPeerMembershipTimeout(int value) {
- checkSecurityPeerMembershipTimeout(value);
- securityPeerMembershipTimeout = value;
+ securityPeerMembershipTimeout = (Integer)checkAttribute(SECURITY_PEER_VERIFYMEMBER_TIMEOUT_NAME, value);
}
public Properties getSecurityProps() {
@@ -2065,7 +1999,7 @@ public class DistributionConfigImpl
}
public void setSecurity(String attName, String attValue) {
- checkSecurity(attName, attValue);
+ checkAttribute(attName, attValue);
security.setProperty(attName, attValue);
}
@@ -2082,8 +2016,7 @@ public class DistributionConfigImpl
}
public void setDistributedSystemId(int distributedSystemId) {
- checkDistributedSystemId(distributedSystemId);
- this.distributedSystemId = distributedSystemId;
+ this.distributedSystemId = (Integer)checkAttribute(DISTRIBUTED_SYSTEM_ID_NAME, distributedSystemId);
}
@@ -2097,19 +2030,17 @@ public class DistributionConfigImpl
}
public void setEnforceUniqueHost(boolean enforceUniqueHost) {
- checkEnforceUniqueHostModifiable();
- this.enforceUniqueHost = enforceUniqueHost;
+ this.enforceUniqueHost = (Boolean)checkAttribute(ENFORCE_UNIQUE_HOST_NAME, enforceUniqueHost);
}
public void setRedundancyZone(String redundancyZone) {
- checkRedundancyZoneModifiable();
- this.redundancyZone = redundancyZone;
+ this.redundancyZone = (String)checkAttribute(REDUNDANCY_ZONE_NAME, redundancyZone);
}
public void setSSLProperty(String attName, String attValue) {
- checkSSLPropertyModifiable();
+ checkAttribute(attName, attValue);
if (attName.startsWith(SYS_PROP_NAME)) {
attName = attName.substring(SYS_PROP_NAME.length());
}
@@ -2150,11 +2081,10 @@ public class DistributionConfigImpl
return this.groups;
}
public void setGroups(String value) {
- checkGroups(value);
if (value == null) {
value = DEFAULT_GROUPS;
}
- this.groups = value;
+ this.groups = (String)checkAttribute(GROUPS_NAME, value);
}
@Override
@@ -2182,10 +2112,6 @@ public class DistributionConfigImpl
this.jmxManagerSSL= value;
}
@Override
- public boolean isJmxManagerSSLModifiable() {
- return false;
- }
- @Override
public boolean getJmxManagerSSLEnabled() {
return this.jmxManagerSSLEnabled;
}
@@ -2219,29 +2145,29 @@ public class DistributionConfigImpl
}
public void setJmxManagerSSLKeyStore( String value ) {
- checkJmxManagerSSLKeyStore( value );
+ value = (String)checkAttribute(JMX_MANAGER_SSL_KEYSTORE_NAME, value);
this.getJmxSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_NAME, value);
this.jmxManagerSSLKeyStore = value;
}
public void setJmxManagerSSLKeyStoreType( String value ) {
- checkJmxManagerSSLKeyStoreType( value );
+ value =(String)checkAttribute(JMX_MANAGER_SSL_KEYSTORE_TYPE_NAME, value);
this.getJmxSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_TYPE_NAME, value);
this.jmxManagerSSLKeyStoreType = value;
}
public void setJmxManagerSSLKeyStorePassword( String value ) {
- checkJmxManagerSSLKeyStorePassword( value );
+ value = (String)checkAttribute(JMX_MANAGER_SSL_KEYSTORE_PASSWORD_NAME, value);
this.getJmxSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_PASSWORD_NAME, value);
this.jmxManagerSSLKeyStorePassword = value;
}
public void setJmxManagerSSLTrustStore( String value ) {
- checkJmxManagerSSLTrustStore( value );
+ value = (String)checkAttribute(JMX_MANAGER_SSL_TRUSTSTORE_NAME, value);
this.getJmxSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_NAME, value);
this.jmxManagerSSLTrustStore = value;
}
public void setJmxManagerSSLTrustStorePassword( String value ) {
- checkJmxManagerSSLTrustStorePassword( value );
+ value = (String)checkAttribute(JMX_MANAGER_SSL_TRUSTSTORE_PASSWORD_NAME, value);
this.getJmxSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_PASSWORD_NAME, value);
- this.jmxManagerSSLTrustStorePassword = value;
+ this.jmxManagerSSLTrustStorePassword =value;
}
public String getJmxManagerSSLKeyStore( ){
@@ -2269,8 +2195,7 @@ public class DistributionConfigImpl
}
@Override
public void setJmxManagerPort(int value) {
- checkJmxManagerPort(value);
- this.jmxManagerPort = value;
+ this.jmxManagerPort = (Integer)checkAttribute(JMX_MANAGER_PORT_NAME, value);
}
@Override
public String getJmxManagerBindAddress() {
@@ -2281,8 +2206,7 @@ public class DistributionConfigImpl
if (value == null) {
value = "";
}
- checkJmxManagerBindAddress(value);
- this.jmxManagerBindAddress = value;
+ this.jmxManagerBindAddress = (String)checkAttribute(JMX_MANAGER_BIND_ADDRESS_NAME, value);
}
@Override
public String getJmxManagerHostnameForClients() {
@@ -2293,8 +2217,7 @@ public class DistributionConfigImpl
if (value == null) {
value = "";
}
- checkJmxManagerHostnameForClients(value);
- this.jmxManagerHostnameForClients = value;
+ this.jmxManagerHostnameForClients = (String)checkAttribute(JMX_MANAGER_HOSTNAME_FOR_CLIENTS_NAME, value);
}
@Override
public String getJmxManagerPasswordFile() {
@@ -2305,8 +2228,7 @@ public class DistributionConfigImpl
if (value == null) {
value = "";
}
- checkJmxManagerPasswordFile(value);
- this.jmxManagerPasswordFile = value;
+ this.jmxManagerPasswordFile = (String)checkAttribute(JMX_MANAGER_PASSWORD_FILE_NAME, value);
}
@Override
public String getJmxManagerAccessFile() {
@@ -2317,8 +2239,7 @@ public class DistributionConfigImpl
if (value == null) {
value = "";
}
- checkJmxManagerAccessFile(value);
- this.jmxManagerAccessFile = value;
+ this.jmxManagerAccessFile = (String)checkAttribute(JMX_MANAGER_ACCESS_FILE_NAME, value);
}
@Override
@@ -2338,8 +2259,7 @@ public class DistributionConfigImpl
@Override
public void setJmxManagerUpdateRate(int value) {
- checkJmxManagerUpdateRate(value);
- this.jmxManagerUpdateRate = value;
+ this.jmxManagerUpdateRate = (Integer)checkAttribute(JMX_MANAGER_UPDATE_RATE_NAME, value);
}
@Override
@@ -3177,15 +3097,14 @@ public class DistributionConfigImpl
* @see com.gemstone.gemfire.distributed.internal.DistributionConfig#setMembershipPortRange(int[])
*/
public void setMembershipPortRange(int[] range) {
- checkMembershipPortRange(range);
- membershipPortRange = range;
+ membershipPortRange = (int[])checkAttribute(MEMBERSHIP_PORT_RANGE_NAME, range);
}
/**
* Set the host-port information of remote site locator
*/
public void setRemoteLocators(String value) {
- this.remoteLocators = checkRemoteLocators(value);
+ this.remoteLocators = (String)checkAttribute(REMOTE_LOCATORS_NAME, value);
}
/**
@@ -3206,8 +3125,7 @@ public class DistributionConfigImpl
@Override
public void setMemcachedPort(int value) {
- checkMemcachedPort(value);
- this.memcachedPort = value;
+ this.memcachedPort = (Integer)checkAttribute(MEMCACHED_PORT_NAME, value);
}
@Override
@@ -3217,8 +3135,7 @@ public class DistributionConfigImpl
@Override
public void setMemcachedProtocol(String protocol) {
- checkMemcachedProtocol(protocol);
- this.memcachedProtocol = protocol;
+ this.memcachedProtocol = (String)checkAttribute(MEMCACHED_PROTOCOL_NAME, protocol);
}
@Override
@@ -3228,8 +3145,7 @@ public class DistributionConfigImpl
@Override
public void setRedisPort(int value) {
- checkRedisPort(value);
- this.redisPort = value;
+ this.redisPort = (Integer)checkAttribute(REDIS_PORT_NAME, value);
}
@Override
@@ -3239,8 +3155,7 @@ public class DistributionConfigImpl
@Override
public void setRedisBindAddress(String bindAddress) {
- checkRedisBindAddress(bindAddress);
- this.redisBindAddress = bindAddress;
+ this.redisBindAddress = (String)checkAttribute(REDIS_BIND_ADDRESS_NAME, bindAddress);
}
@Override
@@ -3260,12 +3175,7 @@ public class DistributionConfigImpl
@Override
public void setOffHeapMemorySize(String value) {
- checkOffHeapMemorySize(value);
- this.offHeapMemorySize = value;
- }
-
- protected void checkOffHeapMemorySize(String value) {
- super.checkOffHeapMemorySize(value);
+ this.offHeapMemorySize = (String)checkAttribute(OFF_HEAP_MEMORY_SIZE_NAME, value);
}
@Override
@@ -3275,14 +3185,12 @@ public class DistributionConfigImpl
@Override
public void setMemcachedBindAddress(String bindAddress) {
- checkMemcachedBindAddress(bindAddress);
- this.memcachedBindAddress = bindAddress;
+ this.memcachedBindAddress = (String)checkAttribute(MEMCACHED_BIND_ADDRESS_NAME, bindAddress);
}
@Override
public void setEnableClusterConfiguration(boolean value) {
- checkEnableSharedConfiguration();
- this.enableSharedConfiguration = value;
+ this.enableSharedConfiguration = (Boolean)checkAttribute(ENABLE_CLUSTER_CONFIGURATION_NAME, value);
}
@Override
@@ -3293,8 +3201,7 @@ public class DistributionConfigImpl
@Override
public void setUseSharedConfiguration(boolean newValue) {
- checkUseSharedConfiguration();
- this.useSharedConfiguration = newValue;
+ this.useSharedConfiguration = (Boolean)checkAttribute(USE_CLUSTER_CONFIGURATION_NAME, newValue);
}
@Override
@@ -3303,8 +3210,7 @@ public class DistributionConfigImpl
}
@Override
public void setLoadClusterConfigFromDir(boolean newValue) {
- checkLoadSharedConfigFromDir();
- this.loadSharedConfigurationFromDir = newValue;
+ this.loadSharedConfigurationFromDir = (Boolean)checkAttribute(LOAD_CLUSTER_CONFIG_FROM_DIR_NAME, newValue);
}
@Override
@@ -3314,8 +3220,7 @@ public class DistributionConfigImpl
@Override
public void setClusterConfigDir(String clusterConfigDir) {
- checkClusterConfigDir();
- this.clusterConfigDir = clusterConfigDir;
+ this.clusterConfigDir = (String)checkAttribute(CLUSTER_CONFIGURATION_DIR, clusterConfigDir);
}
@Override
@@ -3329,8 +3234,7 @@ public class DistributionConfigImpl
@Override
public void setServerSSLEnabled(boolean value) {
- checkServerSSLEnabled();
- this.serverSSLEnabled = value;
+ this.serverSSLEnabled = (Boolean)checkAttribute(SERVER_SSL_ENABLED_NAME, value);
}
@@ -3341,8 +3245,7 @@ public class DistributionConfigImpl
@Override
public void setServerSSLRequireAuthentication(boolean value) {
- checkServerSSLRequireAuthentication();
- this.serverSslRequireAuthentication = value;
+ this.serverSslRequireAuthentication = (Boolean)checkAttribute(SERVER_SSL_REQUIRE_AUTHENTICATION_NAME, value);
}
@Override
@@ -3352,8 +3255,7 @@ public class DistributionConfigImpl
@Override
public void setServerSSLProtocols(String protocols) {
- checkServerSSLProtocols();
- this.serverSslProtocols = protocols;
+ this.serverSslProtocols = (String)checkAttribute(SERVER_SSL_PROTOCOLS_NAME, protocols);
}
@Override
@@ -3363,32 +3265,31 @@ public class DistributionConfigImpl
@Override
public void setServerSSLCiphers(String ciphers) {
- checkServerSSLCiphers();
- this.serverSslCiphers = ciphers;
+ this.serverSslCiphers = (String)checkAttribute(SERVER_SSL_CIPHERS_NAME, ciphers);
}
public void setServerSSLKeyStore( String value ) {
- checkServerSSLKeyStore( value );
+ value = (String)checkAttribute(SERVER_SSL_KEYSTORE_NAME, value);
this.getServerSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_NAME, value);
this.serverSSLKeyStore = value;
}
public void setServerSSLKeyStoreType( String value ) {
- checkServerSSLKeyStoreType( value );
+ value = (String)checkAttribute(SERVER_SSL_KEYSTORE_TYPE_NAME, value);
this.getServerSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_TYPE_NAME, value);
this.serverSSLKeyStoreType = value;
}
public void setServerSSLKeyStorePassword( String value ) {
- checkServerSSLKeyStorePassword( value );
+ value = (String) checkAttribute(SERVER_SSL_KEYSTORE_PASSWORD_NAME, value );
this.getServerSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_PASSWORD_NAME, value);
this.serverSSLKeyStorePassword = value;
}
public void setServerSSLTrustStore( String value ) {
- checkServerSSLTrustStore( value );
+ value = (String)checkAttribute(SERVER_SSL_TRUSTSTORE_NAME, value);
this.getServerSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_NAME, value);
this.serverSSLTrustStore = value;
}
public void setServerSSLTrustStorePassword( String value ) {
- checkServerSSLTrustStorePassword( value );
+ value = (String)checkAttribute(SERVER_SSL_TRUSTSTORE_PASSWORD_NAME, value);
this.getServerSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_PASSWORD_NAME, value);
this.serverSSLTrustStorePassword = value;
}
@@ -3424,8 +3325,7 @@ public class DistributionConfigImpl
@Override
public void setGatewaySSLEnabled(boolean value) {
- checkServerSSLEnabled();
- this.gatewaySSLEnabled = value;
+ this.gatewaySSLEnabled = (Boolean)checkAttribute(SERVER_SSL_ENABLED_NAME, value);
}
@@ -3436,8 +3336,7 @@ public class DistributionConfigImpl
@Override
public void setGatewaySSLRequireAuthentication(boolean value) {
- checkGatewaySSLRequireAuthentication();
- this.gatewaySslRequireAuthentication = value;
+ this.gatewaySslRequireAuthentication = (Boolean)checkAttribute(GATEWAY_SSL_REQUIRE_AUTHENTICATION_NAME, value);
}
@Override
@@ -3447,8 +3346,7 @@ public class DistributionConfigImpl
@Override
public void setGatewaySSLProtocols(String protocols) {
- checkServerSSLProtocols();
- this.gatewaySslProtocols = protocols;
+ this.gatewaySslProtocols = (String)checkAttribute(SERVER_SSL_PROTOCOLS_NAME, protocols);
}
@Override
@@ -3458,32 +3356,31 @@ public class DistributionConfigImpl
@Override
public void setGatewaySSLCiphers(String ciphers) {
- checkGatewaySSLCiphers();
- this.gatewaySslCiphers = ciphers;
+ this.gatewaySslCiphers = (String)checkAttribute(GATEWAY_SSL_CIPHERS_NAME, ciphers);
}
public void setGatewaySSLKeyStore( String value ) {
- checkGatewaySSLKeyStore( value );
+ checkAttribute(GATEWAY_SSL_KEYSTORE_NAME, value);
this.getGatewaySSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_NAME, value);
this.gatewaySSLKeyStore = value;
}
public void setGatewaySSLKeyStoreType( String value ) {
- checkGatewaySSLKeyStoreType( value );
+ checkAttribute(GATEWAY_SSL_KEYSTORE_TYPE_NAME, value);
this.getGatewaySSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_TYPE_NAME, value);
this.gatewaySSLKeyStoreType = value;
}
public void setGatewaySSLKeyStorePassword( String value ) {
- checkGatewaySSLKeyStorePassword( value );
+ checkAttribute(GATEWAY_SSL_KEYSTORE_PASSWORD_NAME, value);
this.getGatewaySSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_PASSWORD_NAME, value);
this.gatewaySSLKeyStorePassword = value;
}
public void setGatewaySSLTrustStore( String value ) {
- checkGatewaySSLTrustStore( value );
+ checkAttribute(GATEWAY_SSL_TRUSTSTORE_NAME, value);
this.getGatewaySSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_NAME, value);
this.gatewaySSLTrustStore = value;
}
public void setGatewaySSLTrustStorePassword( String value ) {
- checkGatewaySSLTrustStorePassword( value );
+ checkAttribute(GATEWAY_SSL_TRUSTSTORE_PASSWORD_NAME, value);
this.getGatewaySSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_PASSWORD_NAME, value);
this.gatewaySSLTrustStorePassword = value;
}
@@ -3560,7 +3457,7 @@ public class DistributionConfigImpl
@Override
public void setHttpServiceSSLKeyStore(String httpServiceSSLKeyStore) {
- checkHttpServiceSSLKeyStore(httpServiceSSLKeyStore);
+ checkAttribute(HTTP_SERVICE_SSL_KEYSTORE_NAME, httpServiceSSLKeyStore);
this.getHttpServiceSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_NAME, httpServiceSSLKeyStore);
this.httpServiceSSLKeyStore = httpServiceSSLKeyStore;
}
@@ -3572,7 +3469,7 @@ public class DistributionConfigImpl
@Override
public void setHttpServiceSSLKeyStoreType(String httpServiceSSLKeyStoreType) {
- checkHttpServiceSSLKeyStoreType(httpServiceSSLKeyStoreType);
+ checkAttribute(HTTP_SERVICE_SSL_KEYSTORE_TYPE_NAME, httpServiceSSLKeyStoreType);
this.getHttpServiceSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_TYPE_NAME, httpServiceSSLKeyStoreType);
this.httpServiceSSLKeyStoreType = httpServiceSSLKeyStoreType;
}
@@ -3584,7 +3481,7 @@ public class DistributionConfigImpl
@Override
public void setHttpServiceSSLKeyStorePassword(String httpServiceSSLKeyStorePassword) {
- checkHttpServiceSSLKeyStorePassword(httpServiceSSLKeyStorePassword);
+ checkAttribute(HTTP_SERVICE_SSL_KEYSTORE_PASSWORD_NAME, httpServiceSSLKeyStorePassword);
this.getHttpServiceSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + KEY_STORE_PASSWORD_NAME,
httpServiceSSLKeyStorePassword);
this.httpServiceSSLKeyStorePassword = httpServiceSSLKeyStorePassword;
@@ -3597,7 +3494,7 @@ public class DistributionConfigImpl
@Override
public void setHttpServiceSSLTrustStore(String httpServiceSSLTrustStore) {
- checkHttpServiceSSLTrustStore(httpServiceSSLTrustStore);
+ checkAttribute(HTTP_SERVICE_SSL_TRUSTSTORE_NAME, httpServiceSSLTrustStore);
this.getHttpServiceSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_NAME, httpServiceSSLTrustStore);
this.httpServiceSSLTrustStore = httpServiceSSLTrustStore;
}
@@ -3609,7 +3506,7 @@ public class DistributionConfigImpl
@Override
public void setHttpServiceSSLTrustStorePassword(String httpServiceSSLTrustStorePassword) {
- checkHttpServiceSSLTrustStorePassword(httpServiceSSLTrustStorePassword);
+ checkAttribute(HTTP_SERVICE_SSL_TRUSTSTORE_PASSWORD_NAME, httpServiceSSLTrustStorePassword);
this.getHttpServiceSSLProperties().setProperty(SSL_SYSTEM_PROPS_NAME + TRUST_STORE_PASSWORD_NAME,
httpServiceSSLTrustStorePassword);
this.httpServiceSSLTrustStorePassword = httpServiceSSLTrustStorePassword;
@@ -3631,4 +3528,6 @@ public class DistributionConfigImpl
this.distributedTransactions = value;
}
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
index 299744a..f2e3a62 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/distributed/internal/RuntimeDistributionConfigImpl.java
@@ -17,12 +17,14 @@
package com.gemstone.gemfire.distributed.internal;
-import java.io.File;
-
import com.gemstone.gemfire.GemFireIOException;
import com.gemstone.gemfire.internal.ConfigSource;
import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppenders;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
/**
* Provides an implementation of <code>DistributionConfig</code> that
* is used at runtime by a {@link InternalDistributedSystem}. It allows
@@ -56,33 +58,23 @@ public final class RuntimeDistributionConfigImpl
}
//////////////////// Configuration Methods ////////////////////
-
@Override
public void setLogLevel(int value) {
- checkLogLevel(value);
- this.logLevel = value;
+ this.logLevel = (Integer)checkAttribute(LOG_LEVEL_NAME, value);
getAttSourceMap().put(LOG_LEVEL_NAME, ConfigSource.runtime());
this.ds.getInternalLogWriter().setLogWriterLevel(value);
LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
}
- @Override
- public boolean isLogLevelModifiable() {
- return true;
- }
@Override
public void setStatisticSamplingEnabled(boolean value) {
- checkStatisticSamplingEnabled(value);
- this.statisticSamplingEnabled = value;
+ this.statisticSamplingEnabled = (Boolean)checkAttribute(STATISTIC_SAMPLING_ENABLED_NAME, value);
getAttSourceMap().put(STATISTIC_SAMPLING_ENABLED_NAME, ConfigSource.runtime());
}
- @Override
- public boolean isStatisticSamplingEnabledModifiable() {
- return true;
- }
+
@Override
public void setStatisticSampleRate(int value) {
- checkStatisticSampleRate(value);
+ value = (Integer)checkAttribute(STATISTIC_SAMPLE_RATE_NAME, value);
if (value < DEFAULT_STATISTIC_SAMPLE_RATE) {
// fix 48228
this.ds.getLogWriter().info("Setting statistic-sample-rate to " + DEFAULT_STATISTIC_SAMPLE_RATE + " instead of the requested " + value + " because VSD does not work with sub-second sampling.");
@@ -90,13 +82,10 @@ public final class RuntimeDistributionConfigImpl
}
this.statisticSampleRate = value;
}
- @Override
- public boolean isStatisticSampleRateModifiable() {
- return true;
- }
+
@Override
public void setStatisticArchiveFile(File value) {
- checkStatisticArchiveFile(value);
+ value = (File)checkAttribute(STATISTIC_ARCHIVE_FILE_NAME, value);
if (value == null) {
value = new File("");
}
@@ -108,55 +97,42 @@ public final class RuntimeDistributionConfigImpl
this.statisticArchiveFile = value;
getAttSourceMap().put(STATISTIC_ARCHIVE_FILE_NAME, ConfigSource.runtime());
}
- @Override
- public boolean isStatisticArchiveFileModifiable() {
- return true;
- }
+
@Override
public void setArchiveDiskSpaceLimit(int value) {
- checkArchiveDiskSpaceLimit(value);
- this.archiveDiskSpaceLimit = value;
+ this.archiveDiskSpaceLimit = (Integer)checkAttribute(ARCHIVE_DISK_SPACE_LIMIT_NAME, value);
getAttSourceMap().put(ARCHIVE_DISK_SPACE_LIMIT_NAME, ConfigSource.runtime());
}
- @Override
- public boolean isArchiveDiskSpaceLimitModifiable() {
- return true;
- }
+
@Override
public void setArchiveFileSizeLimit(int value) {
- checkArchiveFileSizeLimit(value);
- this.archiveFileSizeLimit = value;
+ this.archiveFileSizeLimit = (Integer)checkAttribute(ARCHIVE_FILE_SIZE_LIMIT_NAME, value);
getAttSourceMap().put(ARCHIVE_FILE_SIZE_LIMIT_NAME, ConfigSource.runtime());
}
- @Override
- public boolean isArchiveFileSizeLimitModifiable() {
- return true;
- }
+
@Override
public void setLogDiskSpaceLimit(int value) {
- checkLogDiskSpaceLimit(value);
- this.logDiskSpaceLimit = value;
+ this.logDiskSpaceLimit = (Integer)checkAttribute(LOG_DISK_SPACE_LIMIT_NAME, value);
getAttSourceMap().put(LOG_DISK_SPACE_LIMIT_NAME, ConfigSource.runtime());
LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
}
- @Override
- public boolean isLogDiskSpaceLimitModifiable() {
- return true;
- }
+
@Override
public void setLogFileSizeLimit(int value) {
- checkLogFileSizeLimit(value);
- this.logFileSizeLimit = value;
+ this.logFileSizeLimit = (Integer)checkAttribute(LOG_FILE_SIZE_LIMIT_NAME, value);
getAttSourceMap().put(this.LOG_FILE_SIZE_LIMIT_NAME, ConfigSource.runtime());
LogWriterAppenders.configChanged(LogWriterAppenders.Identifier.MAIN);
}
- @Override
- public boolean isLogFileSizeLimitModifiable() {
- return true;
- }
public DistributionConfig takeSnapshot() {
return new DistributionConfigSnapshot(this);
}
+
+ public List<String> getModifiableAttributes(){
+ String[] modifiables = {HTTP_SERVICE_PORT_NAME,JMX_MANAGER_HTTP_PORT_NAME, ARCHIVE_DISK_SPACE_LIMIT_NAME,
+ ARCHIVE_FILE_SIZE_LIMIT_NAME, LOG_DISK_SPACE_LIMIT_NAME, LOG_FILE_SIZE_LIMIT_NAME,
+ LOG_LEVEL_NAME, STATISTIC_ARCHIVE_FILE_NAME, STATISTIC_SAMPLE_RATE_NAME, STATISTIC_SAMPLING_ENABLED_NAME};
+ return Arrays.asList(modifiables);
+ };
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
index ddf2970..ee4aceb 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/AbstractConfig.java
@@ -17,31 +17,18 @@
package com.gemstone.gemfire.internal;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Array;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeSet;
-
import com.gemstone.gemfire.InternalGemFireException;
import com.gemstone.gemfire.UnmodifiableException;
-import com.gemstone.gemfire.distributed.internal.AbstractDistributionConfig;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
import com.gemstone.gemfire.distributed.internal.FlowControlParams;
import com.gemstone.gemfire.internal.i18n.LocalizedStrings;
+import java.io.*;
+import java.lang.reflect.Array;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+
/**
* Provides an implementation of the {@link Config} interface
* that implements functionality that all {@link Config} implementations
@@ -71,16 +58,6 @@ public abstract class AbstractConfig implements Config {
protected boolean _modifiableDefault() {
return false;
}
-
- /**
- * Checks to see if the named attribute can be modified.
- * @throws UnmodifiableException if it is unmodifiable.
- */
- protected void _checkIfModifiable(String attName) {
- if (!isAttributeModifiable(attName)) {
- throw new UnmodifiableException(_getUnmodifiableMsg(attName));
- }
- }
/**
* Use {@link #toLoggerString()} instead. If you need to override this in a
@@ -117,7 +94,6 @@ public abstract class AbstractConfig implements Config {
public Map<String, String> getConfigPropsFromSource(ConfigSource source) {
Map<String, String> configProps = new HashMap<String, String>();
String[] validAttributeNames = getAttributeNames();
- boolean sourceFound = false;
Map<String, ConfigSource> sm = getAttSourceMap();
for (int i=0; i < validAttributeNames.length; i++) {
@@ -128,14 +104,6 @@ public abstract class AbstractConfig implements Config {
}
} else if (!source.equals(sm.get(attName))) {
continue;
- }
- if (!sourceFound) {
- sourceFound = true;
- if (source == null) {
- //configProps.put(sourceHeader, "### GemFire Properties using default values ###");
- } else {
- //configProps.put(sourceHeader, "### GemFire Properties defined with " + source.getDescription() + " ###");
- }
}
configProps.put(attName, this.getAttribute(attName));
}
@@ -328,12 +296,18 @@ public abstract class AbstractConfig implements Config {
Object result = getAttributeObject(attName);
if (result instanceof String) {
return (String)result;
- } if (attName.equalsIgnoreCase(DistributionConfig.MEMBERSHIP_PORT_RANGE_NAME)) {
+ }
+
+ if (attName.equalsIgnoreCase(DistributionConfig.MEMBERSHIP_PORT_RANGE_NAME)) {
int[] value = (int[])result;
return ""+value[0]+"-"+value[1];
- } else if (result.getClass().isArray()) {
+ }
+
+ if (result.getClass().isArray()) {
return SystemAdmin.join((Object[])result);
- } else if (result instanceof InetAddress) {
+ }
+
+ if (result instanceof InetAddress) {
InetAddress addr = (InetAddress)result;
String addrName = null;
if (addr.isMulticastAddress() || !SocketCreator.resolve_dns) {
@@ -342,9 +316,9 @@ public abstract class AbstractConfig implements Config {
addrName = SocketCreator.getHostName(addr);
}
return addrName;
- } else {
- return result.toString();
}
+
+ return result.toString();
}
public ConfigSource getAttributeSource(String attName) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ConfigSource.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ConfigSource.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ConfigSource.java
index 08f51e4..6991b3b 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ConfigSource.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/ConfigSource.java
@@ -29,10 +29,31 @@ public class ConfigSource implements Serializable {
public enum Type {API, SYSTEM_PROPERTY, FILE, SECURE_FILE, XML, RUNTIME, LAUNCHER};
private final Type type;
private final String description;
-
- private ConfigSource(Type t, String d) {
+
+ private ConfigSource(Type t) {
this.type = t;
- this.description = d;
+ switch (t) {
+ case API: this.description = "api"; break;
+ case SYSTEM_PROPERTY: this.description = "system property"; break;
+ case FILE: this.description = "file"; break;
+ case SECURE_FILE: this.description = "secure file"; break;
+ case XML: this.description = "cache.xml"; break;
+ case RUNTIME: this.description = "runtime modification"; break;
+ case LAUNCHER: this.description = "launcher"; break;
+ default:
+ this.description = "";
+ }
+ }
+
+ private ConfigSource(String fileName, boolean secure) {
+ if(secure) {
+ this.type = Type.SECURE_FILE;
+ this.description = (fileName==null)?"secure file":fileName;
+ }
+ else {
+ this.type = Type.FILE;
+ this.description = (fileName==null)?"file":fileName;
+ }
}
/**
* @return returns the type of this source
@@ -41,32 +62,20 @@ public class ConfigSource implements Serializable {
return this.type;
}
public String getDescription() {
- String result = this.description;
- if (result == null) {
- switch (getType()) {
- case API: result = "api"; break;
- case SYSTEM_PROPERTY: result = "system property"; break;
- case FILE: result = "file"; break;
- case SECURE_FILE: result = "secure file"; break;
- case XML: result = "cache.xml"; break;
- case RUNTIME: result = "runtime modification"; break;
- case LAUNCHER: result = "launcher"; break;
- }
- }
- return result;
+ return this.description;
}
- private static final ConfigSource API_SINGLETON = new ConfigSource(Type.API, null);
- private static final ConfigSource SYSPROP_SINGLETON = new ConfigSource(Type.SYSTEM_PROPERTY, null);
- private static final ConfigSource XML_SINGLETON = new ConfigSource(Type.XML, null);
- private static final ConfigSource RUNTIME_SINGLETON = new ConfigSource(Type.RUNTIME, null);
- private static final ConfigSource LAUNCHER_SINGLETON = new ConfigSource(Type.LAUNCHER, null);
+ private static final ConfigSource API_SINGLETON = new ConfigSource(Type.API);
+ private static final ConfigSource SYSPROP_SINGLETON = new ConfigSource(Type.SYSTEM_PROPERTY);
+ private static final ConfigSource XML_SINGLETON = new ConfigSource(Type.XML);
+ private static final ConfigSource RUNTIME_SINGLETON = new ConfigSource(Type.RUNTIME);
+ private static final ConfigSource LAUNCHER_SINGLETON = new ConfigSource(Type.LAUNCHER);
public static ConfigSource api() {return API_SINGLETON;}
public static ConfigSource sysprop() {return SYSPROP_SINGLETON;}
public static ConfigSource xml() {return XML_SINGLETON;}
public static ConfigSource runtime() {return RUNTIME_SINGLETON;}
- public static ConfigSource file(String fileName, boolean secure) {return new ConfigSource(secure ? Type.SECURE_FILE : Type.FILE, fileName);}
+ public static ConfigSource file(String fileName, boolean secure) {return new ConfigSource(fileName, secure);}
public static ConfigSource launcher() {return LAUNCHER_SINGLETON;}
@Override
@@ -87,14 +96,9 @@ public class ConfigSource implements Serializable {
if (getClass() != obj.getClass())
return false;
ConfigSource other = (ConfigSource) obj;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (type != other.type)
- return false;
- return true;
+
+ return (type == other.type
+ && description.equals(other.description));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
index 8c8dd5c..3e4fbc6 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogConfig.java
@@ -46,7 +46,17 @@ public interface LogConfig {
* property
*/
public int getLogDiskSpaceLimit();
-
+
+ /**
+ * Returns the value of the <a
+ * href="../DistributedSystem.html#name">"name"</a> property
+ * Gets the member's name.
+ * A name is optional and by default empty.
+ * If set it must be unique in the ds.
+ * When set its used by tools to help identify the member.
+ * <p> The default value is: {@link #DEFAULT_NAME}.
+ * @return the system's name.
+ */
public String getName();
public String toLoggerString();
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
new file mode 100644
index 0000000..d2b5643
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.distributed.internal;
+
+import com.gemstone.gemfire.InternalGemFireException;
+import com.gemstone.gemfire.UnmodifiableException;
+import com.gemstone.gemfire.internal.ConfigSource;
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.*;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * Created by jiliao on 2/2/16.
+ */
+@Category(UnitTest.class)
+
+public class DistributionConfigJUnitTest {
+ static Map<String, ConfigAttribute> attributes;
+ static Map<String, Method> setters;
+ static Map<String, Method> getters;
+ static Map<String, Method> isModifiables;
+ static Map<String, Method> checkers;
+ static String[] attNames;
+ DistributionConfigImpl config;
+
+ @BeforeClass
+ public static void beforeClass() {
+ attributes = DistributionConfig.attributes;
+ setters = DistributionConfig.setters;
+ getters = DistributionConfig.getters;
+ attNames = DistributionConfig.dcValidAttributeNames;
+ checkers = AbstractDistributionConfig.checkers;
+ }
+
+ @Before
+ public void before() {
+ config = new DistributionConfigImpl(new Properties());
+ }
+
+ @Test
+ public void testGetAttributeNames() {
+ String[] attNames = AbstractDistributionConfig._getAttNames();
+ assertEquals(attNames.length, 140);
+
+ List boolList = new ArrayList();
+ List intList = new ArrayList();
+ List fileList = new ArrayList();
+ List stringList = new ArrayList();
+ List otherList = new ArrayList();
+ for (String attName : attNames) {
+ Class clazz = AbstractDistributionConfig._getAttributeType(attName);
+ if (clazz.equals(Boolean.class)) {
+ boolList.add(attName);
+ } else if (clazz.equals(Integer.class)) {
+ intList.add(attName);
+ } else if (clazz.equals(String.class)) {
+ stringList.add(attName);
+ } else if (clazz.equals(File.class)) {
+ fileList.add(attName);
+ } else {
+ otherList.add(attName);
+ }
+ }
+
+ System.out.println("boolList: " + boolList);
+ System.out.println();
+ System.out.println("intList: " + intList);
+ System.out.println();
+ System.out.println("stringlList: " + stringList);
+ System.out.println();
+ System.out.println("filelList: " + fileList);
+ System.out.println();
+ System.out.println("otherList: " + otherList);
+ assertEquals(boolList.size(), 30);
+ assertEquals(intList.size(), 33);
+ assertEquals(stringList.size(), 69);
+ assertEquals(fileList.size(), 5);
+ assertEquals(otherList.size(), 3);
+ }
+
+ @Test
+ public void sameCount() {
+ assertEquals(attributes.size(), setters.size());
+ assertEquals(setters.size(), getters.size());
+ }
+
+ @Test
+ public void everyAttrHasValidSetter() {
+ for (String attr : attributes.keySet()) {
+ Method setter = setters.get(attr);
+ assertNotNull(attr + " should have a setter", setter);
+ assertTrue(setter.getName().startsWith("set"));
+ assertEquals(setter.getParameterCount(), 1);
+
+ if (!(attr.equalsIgnoreCase(DistributionConfig.LOG_LEVEL_NAME) || attr.equalsIgnoreCase(DistributionConfig.SECURITY_LOG_LEVEL_NAME))) {
+ Class clazz = attributes.get(attr).type();
+ try {
+ setter.invoke(mock(DistributionConfig.class), any(clazz));
+ } catch (Exception e) {
+ throw new RuntimeException("Error calling setter " + setter.getName(), e);
+ }
+ }
+
+ }
+ }
+
+ @Test
+ public void everyAttrHasValidGetter() {
+ for (String attr : attributes.keySet()) {
+ Method getter = getters.get(attr);
+ assertNotNull(attr + " should have a getter", getter);
+ assertTrue(getter.getName().startsWith("get"));
+ assertEquals(getter.getParameterCount(), 0);
+
+ if (!(attr.equalsIgnoreCase(DistributionConfig.LOG_LEVEL_NAME) || attr.equalsIgnoreCase(DistributionConfig.SECURITY_LOG_LEVEL_NAME))) {
+ Class clazz = attributes.get(attr).type();
+ Class returnClass = getter.getReturnType();
+ if (returnClass.isPrimitive()) {
+ returnClass = classMap.get(returnClass);
+ }
+ assertEquals(returnClass, clazz);
+ }
+ }
+ }
+
+ @Test
+ public void everyGetterSetterSameNameSameType() {
+ for (String attr : getters.keySet()) {
+ Method getter = getters.get(attr);
+ Method setter = setters.get(attr);
+ assertNotNull("every getter should have a corresponding setter " + attr, setter);
+ String setterName = setter.getName();
+ String getterName = getter.getName();
+ assertEquals(setterName.substring(setterName.indexOf("set") + 3), getterName.substring(getterName.indexOf("get") + 3));
+ assertEquals(setter.getParameterTypes()[0], getter.getReturnType());
+ }
+
+ for (String attr : setters.keySet()) {
+ Method getter = getters.get(attr);
+ assertNotNull("every setter should have a corresponding getter: " + attr, getter);
+ }
+ }
+
+ @Test
+ public void everySetterHasAttributeDefined() {
+ for (String attr : setters.keySet()) {
+ ConfigAttribute configAttribute = attributes.get(attr);
+ assertNotNull(attr + " should be defined a ConfigAttribute", configAttribute);
+ }
+ }
+
+ @Test
+ public void everyGetterHasAttributeDefined() {
+ for (String attr : getters.keySet()) {
+ ConfigAttribute configAttribute = attributes.get(attr);
+ assertNotNull(attr + " should be defined a ConfigAttribute", configAttribute);
+ }
+ }
+
+ @Test
+ public void testGetAttributeObject() {
+ assertEquals(config.getAttributeObject(DistributionConfig.LOG_LEVEL_NAME), "config");
+ assertEquals(config.getAttributeObject(DistributionConfig.SECURITY_LOG_LEVEL_NAME), "config");
+ assertEquals(config.getAttributeObject(DistributionConfig.REDUNDANCY_ZONE_NAME), "");
+ assertEquals(config.getAttributeObject(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME).getClass(), Boolean.class);
+ }
+
+ @Test
+ public void testCheckerChecksValidAttribute() {
+ for (String att : checkers.keySet()) {
+ assertTrue(attributes.containsKey(att));
+ Method checker = checkers.get(att);
+ assertEquals(checker.getParameterCount(), 1);
+ assertEquals("invalid checker: " + checker.getName(), checker.getReturnType(), checker.getParameterTypes()[0]);
+
+ //TODO assert checker and setter accepts this same type of parameter
+ }
+ }
+
+ @Test
+ public void testDistributionConfigImplModifiable() {
+ // default DistributionConfigImpl contains only 2 modifiable attributes
+ List modifiables = new ArrayList<>();
+ for (String attName : attNames) {
+ if (config.isAttributeModifiable(attName)) {
+ modifiables.add(attName);
+ }
+ }
+ assertEquals(modifiables.size(), 2);
+ assertEquals(modifiables.get(0), "http-service-port");
+ assertEquals(modifiables.get(1), "jmx-manager-http-port");
+ }
+
+ @Test
+ public void testRuntimeConfigModifiable() {
+ InternalDistributedSystem ds = mock(InternalDistributedSystem.class);
+ when(ds.getOriginalConfig()).thenReturn(config);
+ RuntimeDistributionConfigImpl runtime = new RuntimeDistributionConfigImpl(ds);
+ List modifiables = new ArrayList<>();
+ for (String attName : attNames) {
+ if (runtime.isAttributeModifiable(attName)) {
+ modifiables.add(attName);
+ }
+ }
+ assertEquals(modifiables.size(), 10);
+ assertEquals(modifiables.get(0), "archive-disk-space-limit");
+ assertEquals(modifiables.get(1), "archive-file-size-limit");
+ assertEquals(modifiables.get(2), "http-service-port");
+ assertEquals(modifiables.get(3), "jmx-manager-http-port");
+ assertEquals(modifiables.get(4), "log-disk-space-limit");
+ assertEquals(modifiables.get(5), "log-file-size-limit");
+ assertEquals(modifiables.get(6), "log-level");
+ assertEquals(modifiables.get(7), "statistic-archive-file");
+ assertEquals(modifiables.get(8), "statistic-sample-rate");
+ assertEquals(modifiables.get(9), "statistic-sampling-enabled");
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testSetInvalidAttributeObject() {
+ config.setAttributeObject("fake attribute", "test", ConfigSource.api());
+ }
+
+ @Test(expected = UnmodifiableException.class)
+ public void testSetUnmodifiableAttributeObject() {
+ config.setAttributeObject("archive-disk-space-limit", 0, ConfigSource.api());
+ }
+
+ @Test
+ public void testValidAttributeObject() {
+ config.setAttributeObject("http-service-port", 8080, ConfigSource.api());
+ assertEquals(config.getHttpServicePort(), 8080);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testOutOfRangeAttributeObject() {
+ config.setAttributeObject("http-service-port", -1, ConfigSource.api());
+ }
+
+ @Test
+ public void testLogLevel() {
+ config.modifiable = true;
+ config.setAttribute(DistributionConfig.LOG_LEVEL_NAME, "config", ConfigSource.api());
+ assertEquals(config.getLogLevel(), 700);
+
+ config.setAttributeObject(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "debug", ConfigSource.api());
+ assertEquals(config.getSecurityLogLevel(), 500);
+ }
+
+ @Test
+ public void testValidLocatorAddress() {
+ String address = "81.240.0.1[7056]";
+ config.modifiable = true;
+ config.setStartLocator(address);
+ assertEquals(config.getStartLocator(), address);
+ }
+
+ @Test(expected = InternalGemFireException.class)
+ public void testInvalidLocatorAddress() {
+ String address = "bad.bad[7056]";
+ config.modifiable = true;
+ config.setStartLocator(address);
+ }
+
+ @Test
+ public void testAttributesAlwaysModifiable() {
+ config.modifiable = false;
+ assertTrue(config.isAttributeModifiable(DistributionConfig.HTTP_SERVICE_PORT_NAME));
+ assertTrue(config.isAttributeModifiable("jmx-manager-http-port"));
+
+ config.modifiable = true;
+ assertTrue(config.isAttributeModifiable(DistributionConfig.HTTP_SERVICE_PORT_NAME));
+ assertTrue(config.isAttributeModifiable("jmx-manager-http-port"));
+ }
+
+ public final static Map<Class<?>, Class<?>> classMap = new HashMap<Class<?>, Class<?>>();
+
+ static {
+ classMap.put(boolean.class, Boolean.class);
+ classMap.put(byte.class, Byte.class);
+ classMap.put(short.class, Short.class);
+ classMap.put(char.class, Character.class);
+ classMap.put(int.class, Integer.class);
+ classMap.put(long.class, Long.class);
+ classMap.put(float.class, Float.class);
+ classMap.put(double.class, Double.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/70059905/gemfire-core/src/test/java/com/gemstone/gemfire/internal/ConfigSourceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/ConfigSourceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/ConfigSourceJUnitTest.java
new file mode 100644
index 0000000..73cd9a0
--- /dev/null
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/ConfigSourceJUnitTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.gemstone.gemfire.internal;
+
+import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by jiliao on 2/2/16.
+ */
+@Category(UnitTest.class)
+public class ConfigSourceJUnitTest {
+ @Test
+ public void testDescriptions() {
+ ConfigSource cs = ConfigSource.api();
+ assertEquals(cs.getDescription(), "api");
+
+ cs = ConfigSource.file("test", true);
+ assertEquals(cs.getDescription(), "test");
+
+ cs = ConfigSource.file("test2", false);
+ assertEquals(cs.getDescription(), "test2");
+
+ cs = ConfigSource.file(null, true);
+ assertEquals(cs.getDescription(), "secure file");
+
+ cs = ConfigSource.file(null, false);
+ assertEquals(cs.getDescription(), "file");
+
+ cs = ConfigSource.file("", true);
+ assertEquals(cs.getDescription(), "");
+
+ cs = ConfigSource.launcher();
+ assertEquals(cs.getDescription(), "launcher");
+
+ cs = ConfigSource.sysprop();
+ assertEquals(cs.getDescription(), "system property");
+
+ cs = ConfigSource.runtime();
+ assertEquals(cs.getDescription(), "runtime modification");
+
+ cs = ConfigSource.xml();
+ assertEquals(cs.getDescription(), "cache.xml");
+ }
+
+ @Test
+ public void testEquals() {
+ ConfigSource cs1 = ConfigSource.file("name", true);
+ ConfigSource cs2 = ConfigSource.file("name", false);
+ assertFalse(cs1.equals(cs2));
+
+ cs1 = ConfigSource.file("name", true);
+ cs2 = ConfigSource.file("name", true);
+ assertTrue(cs1.equals(cs2));
+
+ cs1 = ConfigSource.file(null, true);
+ cs2 = ConfigSource.file(null, false);
+ assertFalse(cs1.equals(cs2));
+
+ cs1 = ConfigSource.file(null, true);
+ cs2 = ConfigSource.file(null, true);
+ assertTrue(cs1.equals(cs2));
+
+ cs1 = ConfigSource.file(null, true);
+ cs2 = ConfigSource.file("", true);
+ assertFalse(cs1.equals(cs2));
+
+ cs1 = ConfigSource.xml();
+ cs2 = ConfigSource.xml();
+ assertTrue(cs1.equals(cs2));
+ }
+}