VMware GemFire Java API Reference
Class DistributedSystem
- java.lang.Object
-
- org.apache.geode.distributed.DistributedSystem
-
- All Implemented Interfaces:
StatisticsFactory,StatisticsTypeFactory
public abstract class DistributedSystem extends java.lang.Object implements StatisticsFactory
A "connection" to a GemFire distributed system. ADistributedSystemis created by invoking theconnect(java.util.Properties)method with a configuration as described below. ADistributedSystemis used when callingCacheFactory.create().When a program connects to the distributed system, a "distribution manager" is started in this VM and the other members of the distributed system are located. This discovery is performed by contacting "locators" running on a given host and port. All DistributedSystems that are configured to use the same locators are part of the same distributed system.
The current version of GemFire only supports creating one
DistributedSystemper virtual machine. Attempts to connect to multiple distributed systems (that is callingconnect(java.util.Properties)multiple times with different configurationProperties) will result in anIllegalStateExceptionbeing thrown (ifconnectis invoked multiple times with equivalentProperties, then the same instance ofDistributedSystemwill be returned). A common practice is to connect to the distributed system and store a reference to theDistributedSystemobject in a well-known location such as astaticvariable. This practice provides access to theDistributedSystemslightly faster than invokingconnectmultiple times. Note that it is always advisable todisconnect()from the distributed system when a program will no longer access it. Disconnecting frees up certain resources and allows your application to connect to a different distributed system, if desirable.Users should never subclass this class.
- Since:
- GemFire 3.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.List<org.apache.geode.distributed.internal.InternalDistributedSystem>existingSystemsThe instances ofDistributedSystemcreated in this VM.protected static java.lang.ObjectexistingSystemsLockThis lock must be changed to add or remove a system.static java.lang.StringPROPERTIES_FILE_DEFAULTThe default value ofPROPERTIES_FILE_PROPERTYis"gemfire.properties".static java.lang.StringPROPERTIES_FILE_PROPERTYThePROPERTIES_FILE_PROPERTYis the system property that can be used to specify the name of the properties file that the connect method will check for when it looks for a properties file.static java.lang.StringPROPERTY_FILEDeprecated.As of 9.0, please usegetPropertiesFile()instead.static java.lang.StringSECURITY_PROPERTIES_FILE_DEFAULTThe default value ofSECURITY_PROPERTIES_FILE_PROPERTYis"gfsecurity.properties".static java.lang.StringSECURITY_PROPERTIES_FILE_PROPERTYTheSECURITY_PROPERTIES_FILE_PROPERTYis the system property that can be used to specify the name of the property file that the connect method will check for when it looks for a property file.static java.lang.StringSECURITY_PROPERTY_FILEDeprecated.As of 9.0, please usegetSecurityPropertiesFile()instead.static java.lang.StringSHUTDOWN_COMMANDString constant representing 'gfsh shutdown' as the reason for disconnecting this distributed system.-
Fields inherited from interface org.apache.geode.StatisticsTypeFactory
MAX_DESCRIPTORS_PER_TYPE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDistributedSystem()Creates a new instance ofDistributedSystem.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected static voidaddSystem(org.apache.geode.distributed.internal.InternalDistributedSystem newSystem)static DistributedSystemconnect(java.util.Properties config)Deprecated.as of 6.5 useCacheFactory.create()orClientCacheFactory.create()instead.protected static DistributedSystemconnectForAdmin(java.util.Properties props)Returns a connection to the distributed system that is appropriate for administration.abstract voiddisconnect()Deprecated.as of 6.5 useCache.close(boolean)orClientCache.close(boolean)instead.abstract DistributedMemberfindDistributedMember(java.lang.String name)Find the distributed member with the given nameabstract java.util.Set<DistributedMember>findDistributedMembers(java.net.InetAddress address)Find the set of distributed members running on a given addressabstract java.util.Set<DistributedMember>getAllOtherMembers()Returns a set of all the other members in this distributed system.abstract CancelCriteriongetCancelCriterion()protected static DistributedSystemgetConnection(java.util.Properties config)Returns an existing connection to the distributed system described by the given properties.abstract DistributedMembergetDistributedMember()Returns theDistributedMemberthat identifies this connection to the distributed system.abstract java.util.Set<DistributedMember>getGroupMembers(java.lang.String group)Returns a set of all the members in the given group.abstract longgetId()Deprecated.getDistributedMember()provides an identity for this connection that is unique across the entire distributed system.abstract LogWritergetLogWriter()Deprecated.abstract java.lang.StringgetMemberId()Deprecated.as of GemFire 5.0, usegetDistributedMember()insteadabstract java.lang.StringgetName()Returns the name of this connection to the distributed system.abstract java.util.PropertiesgetProperties()Returns the configuration properties.static java.lang.StringgetPropertiesFile()Returns the current value ofPROPERTIES_FILE_PROPERTYsystem property if set or the default valuePROPERTIES_FILE_DEFAULT.static java.net.URLgetPropertiesFileURL()Gets anURLfor the properties file, if one can be found, that the connect method will use as its properties file.static java.net.URLgetPropertyFileURL()Deprecated.As of 9.0, please usegetPropertiesFileURL()abstract DistributedSystemgetReconnectedSystem()Returns the new DistributedSystem if there was an auto-reconnectabstract LogWritergetSecurityLogWriter()Deprecated.abstract java.util.PropertiesgetSecurityProperties()Returns the security specific configuration properties.static java.lang.StringgetSecurityPropertiesFile()Returns the current value ofSECURITY_PROPERTIES_FILE_PROPERTYsystem property if set or the default valueSECURITY_PROPERTIES_FILE_DEFAULT.static java.net.URLgetSecurityPropertiesFileURL()Gets anURLfor the security properties file, if one can be found, that the connect method will use as its properties file.abstract booleanisConnected()Returns whether or not thisDistributedSystemis connected to the distributed system.abstract booleanisReconnecting()Test to see whether the DistributedSystem is in the process of reconnecting and recreating the cache after it has been removed from the system by other members or has shut down due to missing Roles and is reconnecting.static voidreleaseThreadsSockets()Frees up any socket resources owned by the calling thread.protected static voidremoveSystem(org.apache.geode.distributed.internal.InternalDistributedSystem oldSystem)static voidsetThreadsSocketPolicy(boolean conserveSockets)Sets the calling thread's socket policy.abstract voidstopReconnecting()Force the DistributedSystem to stop reconnecting.abstract booleanwaitUntilReconnected(long time, java.util.concurrent.TimeUnit units)Wait for the DistributedSystem to finish reconnecting to the system and recreate the cache.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.geode.StatisticsFactory
createAtomicStatistics, createAtomicStatistics, createAtomicStatistics, createStatistics, createStatistics, createStatistics, findStatisticsByNumericId, findStatisticsByTextId, findStatisticsByType
-
Methods inherited from interface org.apache.geode.StatisticsTypeFactory
createDoubleCounter, createDoubleCounter, createDoubleGauge, createDoubleGauge, createIntCounter, createIntCounter, createIntGauge, createIntGauge, createLongCounter, createLongCounter, createLongGauge, createLongGauge, createType, createTypesFromXml, findType
-
-
-
-
Field Detail
-
existingSystems
protected static volatile java.util.List<org.apache.geode.distributed.internal.InternalDistributedSystem> existingSystems
The instances ofDistributedSystemcreated in this VM. Presently only one connect to a distributed system is allowed in a VM. This set is never modified in place (it is always read only) but the reference can be updated by holders ofexistingSystemsLock.
-
existingSystemsLock
protected static final java.lang.Object existingSystemsLock
This lock must be changed to add or remove a system. It is notified when a system is removed.- See Also:
existingSystems
-
SHUTDOWN_COMMAND
public static final java.lang.String SHUTDOWN_COMMAND
String constant representing 'gfsh shutdown' as the reason for disconnecting this distributed system.- See Also:
- Constant Field Values
-
PROPERTIES_FILE_PROPERTY
public static final java.lang.String PROPERTIES_FILE_PROPERTY
ThePROPERTIES_FILE_PROPERTYis the system property that can be used to specify the name of the properties file that the connect method will check for when it looks for a properties file. Unless the value specifies the fully qualified path to the file, the file will be searched for, in order, in the following directories:- the current directory
- the home directory
- the class path
The default value is
PROPERTIES_FILE_DEFAULT. However if thePROPERTIES_FILE_PROPERTYis set then its value will be used instead of the default. If this value is a relative file system path then the above search is done. If it is an absolute file system path then that file must exist; no search for it is done.- Since:
- Geode 1.0
- See Also:
PROPERTIES_FILE_DEFAULT,getPropertiesFile(), Constant Field Values
-
PROPERTIES_FILE_DEFAULT
public static final java.lang.String PROPERTIES_FILE_DEFAULT
The default value ofPROPERTIES_FILE_PROPERTYis"gemfire.properties". The location of the file will be resolved during connect as described forPROPERTIES_FILE_PROPERTY.- Since:
- Geode 1.0
- See Also:
PROPERTIES_FILE_PROPERTY,getPropertiesFile(), Constant Field Values
-
PROPERTY_FILE
@Deprecated public static final java.lang.String PROPERTY_FILE
Deprecated.As of 9.0, please usegetPropertiesFile()instead.ThePROPERTY_FILEis the name of the properties file that the connect method will check for when it looks for a properties file. The file will be searched for, in order, in the following directories:- the current directory
- the home directory
- the class path
The default value of PROPERTY_FILE is
"gemfire.properties". However if the "gemfirePropertyFile" system property is set then its value is the value of PROPERTY_FILE. If this value is a relative file system path then the above search is done. If it is an absolute file system path then that file must exist; no search for it is done.- Since:
- GemFire 5.0
- See Also:
getPropertiesFile()
-
SECURITY_PROPERTIES_FILE_PROPERTY
public static final java.lang.String SECURITY_PROPERTIES_FILE_PROPERTY
TheSECURITY_PROPERTIES_FILE_PROPERTYis the system property that can be used to specify the name of the property file that the connect method will check for when it looks for a property file. Unless the value specifies the fully qualified path to the file, the file will be searched for, in order, in the following directories:- the current directory
- the home directory
- the class path
The default value is
SECURITY_PROPERTIES_FILE_DEFAULT. However if theSECURITY_PROPERTIES_FILE_PROPERTYis set then its value will be used instead of the default. If this value is a relative file system path then the above search is done. If it is an absolute file system path then that file must exist; no search for it is done.- Since:
- Geode 1.0
- See Also:
SECURITY_PROPERTIES_FILE_DEFAULT,getSecurityPropertiesFile(), Constant Field Values
-
SECURITY_PROPERTIES_FILE_DEFAULT
public static final java.lang.String SECURITY_PROPERTIES_FILE_DEFAULT
The default value ofSECURITY_PROPERTIES_FILE_PROPERTYis"gfsecurity.properties". The location of the file will be resolved during connect as described forSECURITY_PROPERTIES_FILE_PROPERTY.- Since:
- Geode 1.0
- See Also:
SECURITY_PROPERTIES_FILE_PROPERTY,getSecurityPropertiesFile(), Constant Field Values
-
SECURITY_PROPERTY_FILE
@Deprecated public static final java.lang.String SECURITY_PROPERTY_FILE
Deprecated.As of 9.0, please usegetSecurityPropertiesFile()instead.TheSECURITY_PROPERTY_FILEis the name of the property file that the connect method will check for when it looks for a security property file. The file will be searched for, in order, in the following directories:- the current directory
- the home directory
- the class path
The default value of SECURITY_PROPERTY_FILE is
"gfsecurity.properties". However if the "gemfireSecurityPropertyFile" system property is set then its value is the value of SECURITY_PROPERTY_FILE. If this value is a relative file system path then the above search is done. If it is an absolute file system path then that file must exist; no search for it is done.- Since:
- GemFire 6.6.2
- See Also:
getSecurityPropertiesFile()
-
-
Method Detail
-
connect
@Deprecated public static DistributedSystem connect(java.util.Properties config)
Deprecated.as of 6.5 useCacheFactory.create()orClientCacheFactory.create()instead.Connects to a GemFire distributed system with a configuration supplemented by the given properties. See ConfigurationProperties for available GemFire properties and their meanings.The actual configuration attribute values used to connect comes from the following sources:
- System properties. If a system property named "
gemfire.propertyName" is defined and its value is not an empty string then its value will be used for the named configuration attribute. - Code properties. Otherwise if a property is defined in the
configparameter object and its value is not an empty string then its value will be used for that configuration attribute. - File properties. Otherwise if a property is defined in a configuration property file found by this application and its value is not an empty string then its value will be used for that configuration attribute. A configuration property file may not exist. See the following section for how configuration property files are found.
- Defaults. Otherwise a default value is used.
The name of the property file can be specified using the "gemfirePropertyFile" system property. If the system property is set to a relative file name then it is searched for in following locations. If the system property is set to an absolute file name then that file is used as the property file. If the system property is not set, then the name of the property file defaults to "gemfire.properties". The configuration file is searched for in the following locations:
- Current directory (directory in which the VM was launched)
- User's home directory
- Class path (loaded as a system resource)
- Parameters:
config- The configuration properties used when connecting to the distributed system- Returns:
- a connection to the distributed system that is appropriate for administration
- Throws:
java.lang.IllegalArgumentException- Ifconfigcontains an unknown configuration property or a configuration property does not have an allowed value. Note that the values of boolean properties are parsed usingBoolean.valueOf(java.lang.String). Therefore all values other than "true" values will be consideredfalse-- an exception will not be thrown.java.lang.IllegalStateException- If aDistributedSystemwith a different configuration has already been created in this VM.GemFireIOException- Problems while reading configuration properties file or while opening the log file.GemFireConfigException- The distribution transport is not configured correctly
- System properties. If a system property named "
-
addSystem
protected static void addSystem(org.apache.geode.distributed.internal.InternalDistributedSystem newSystem)
-
removeSystem
protected static void removeSystem(org.apache.geode.distributed.internal.InternalDistributedSystem oldSystem)
-
setThreadsSocketPolicy
public static void setThreadsSocketPolicy(boolean conserveSockets)
Sets the calling thread's socket policy. This value will override that default set by theconserve-socketsconfiguration property.- Parameters:
conserveSockets- Iftruethen calling thread will share socket connections with other threads. Iffalsethen calling thread will have its own sockets.- Since:
- GemFire 4.1
-
releaseThreadsSockets
public static void releaseThreadsSockets()
Frees up any socket resources owned by the calling thread.- Since:
- GemFire 4.1
-
getConnection
protected static DistributedSystem getConnection(java.util.Properties config)
Returns an existing connection to the distributed system described by the given properties.- Parameters:
config- the properties used when creating a connection to the distributed system- Returns:
- a connection to the distributed system that is appropriate for administration
- Since:
- GemFire 4.0
-
connectForAdmin
protected static DistributedSystem connectForAdmin(java.util.Properties props)
Returns a connection to the distributed system that is appropriate for administration. This method is for internal use only by the admin API.- Parameters:
props- the properties used when creating a connection to the distributed system- Returns:
- a connection to the distributed system that is appropriate for administration
- Since:
- GemFire 4.0
-
getLogWriter
@Deprecated public abstract LogWriter getLogWriter()
Deprecated.Returns theLogWriterused for logging information. See logFile.- Returns:
- the
LogWriterused for logging information - Throws:
java.lang.IllegalStateException- This VM has disconnected from the distributed system.
-
getSecurityLogWriter
@Deprecated public abstract LogWriter getSecurityLogWriter()
Deprecated.Returns theLogWriterused for logging security related information. See logFile.- Returns:
- the
LogWriterused for logging security related information - Throws:
java.lang.IllegalStateException- This VM has disconnected from the distributed system.- Since:
- GemFire 5.5
-
getProperties
public abstract java.util.Properties getProperties()
Returns the configuration properties.- Returns:
- the configuration Properties
-
getSecurityProperties
public abstract java.util.Properties getSecurityProperties()
Returns the security specific configuration properties.- Returns:
- the configuration Properties
- Since:
- GemFire 5.5
-
getCancelCriterion
public abstract CancelCriterion getCancelCriterion()
- Returns:
- the cancel criterion for this system
-
disconnect
@Deprecated public abstract void disconnect()
Deprecated.as of 6.5 useCache.close(boolean)orClientCache.close(boolean)instead.Disconnects from this distributed system. This operation will close the distribution manager and render theCacheand all distributed collections obtained from this distributed system inoperable. After a disconnect has completed, a VM may connect to another distributed system.Attempts to access a distributed system after a VM has disconnected from it will result in an
IllegalStateExceptionbeing thrown.
-
isConnected
public abstract boolean isConnected()
Returns whether or not thisDistributedSystemis connected to the distributed system.- Returns:
- whether this
DistributedSystemis connected to the distributed system - See Also:
disconnect()
-
getId
@Deprecated public abstract long getId()
Deprecated.getDistributedMember()provides an identity for this connection that is unique across the entire distributed system.Returns the id of this connection to the distributed system.- Returns:
- the id of this connection to the distributed system
-
getMemberId
@Deprecated public abstract java.lang.String getMemberId()
Deprecated.as of GemFire 5.0, usegetDistributedMember()insteadReturns a string that uniquely identifies this connection to the distributed system.- Returns:
- a string that uniquely identifies this connection to the distributed system
- Since:
- GemFire 4.0
-
getDistributedMember
public abstract DistributedMember getDistributedMember()
Returns theDistributedMemberthat identifies this connection to the distributed system.- Returns:
- the member that represents this distributed system connection.
- Since:
- GemFire 5.0
-
getAllOtherMembers
public abstract java.util.Set<DistributedMember> getAllOtherMembers()
Returns a set of all the other members in this distributed system.- Returns:
- returns a set of all the other members in this distributed system.
- Since:
- GemFire 7.0
-
getGroupMembers
public abstract java.util.Set<DistributedMember> getGroupMembers(java.lang.String group)
Returns a set of all the members in the given group. Members join a group by setting the "groups" gemfire property.- Parameters:
group- the group to which the distributed members to find belong- Returns:
- returns a set of all the member in a group.
- Since:
- GemFire 7.0
-
findDistributedMembers
public abstract java.util.Set<DistributedMember> findDistributedMembers(java.net.InetAddress address)
Find the set of distributed members running on a given address- Parameters:
address- the address of the distributed members to find- Returns:
- a set of all DistributedMembers that have any interfaces that match the given IP address. May be empty if there are no members.
- Since:
- GemFire 7.1
-
findDistributedMember
public abstract DistributedMember findDistributedMember(java.lang.String name)
Find the distributed member with the given name- Parameters:
name- the name of the distributed member to find- Returns:
- the distributed member that has the given name, or null if no member is currently running with the given name.
- Since:
- GemFire 7.1
-
getName
public abstract java.lang.String getName()
Returns the name of this connection to the distributed system.- Returns:
- the name of this connection to the distributed system
-
getPropertiesFile
public static java.lang.String getPropertiesFile()
Returns the current value ofPROPERTIES_FILE_PROPERTYsystem property if set or the default valuePROPERTIES_FILE_DEFAULT.- Returns:
- the current value of
PROPERTIES_FILE_PROPERTYsystem property if set or the default valuePROPERTIES_FILE_DEFAULT - Since:
- Geode 1.0
- See Also:
PROPERTIES_FILE_PROPERTY,PROPERTIES_FILE_DEFAULT
-
getSecurityPropertiesFile
public static java.lang.String getSecurityPropertiesFile()
Returns the current value ofSECURITY_PROPERTIES_FILE_PROPERTYsystem property if set or the default valueSECURITY_PROPERTIES_FILE_DEFAULT.- Returns:
- the current value of
SECURITY_PROPERTIES_FILE_PROPERTYsystem property if set or the default valueSECURITY_PROPERTIES_FILE_DEFAULT - Since:
- Geode 1.0
- See Also:
SECURITY_PROPERTIES_FILE_PROPERTY,SECURITY_PROPERTIES_FILE_DEFAULT
-
getPropertiesFileURL
public static java.net.URL getPropertiesFileURL()
Gets anURLfor the properties file, if one can be found, that the connect method will use as its properties file.See
PROPERTIES_FILE_PROPERTYfor information on the name of the properties file and what locations it will be looked for in.- Returns:
- a
URLthat names the GemFire property file. Null is returned if no property file was found. - Since:
- Geode 1.0
- See Also:
PROPERTIES_FILE_PROPERTY,PROPERTIES_FILE_DEFAULT,getPropertiesFile()
-
getPropertyFileURL
@Deprecated public static java.net.URL getPropertyFileURL()
Deprecated.As of 9.0, please usegetPropertiesFileURL()Gets anURLfor the property file, if one can be found, that the connect method will use as its property file.See
PROPERTIES_FILE_PROPERTYfor information on the name of the property file and what locations it will be looked for in.- Returns:
- a
URLthat names the GemFire property file. Null is returned if no property file was found. - Since:
- GemFire 5.0
- See Also:
getPropertiesFileURL()
-
getSecurityPropertiesFileURL
public static java.net.URL getSecurityPropertiesFileURL()
Gets anURLfor the security properties file, if one can be found, that the connect method will use as its properties file.See
SECURITY_PROPERTIES_FILE_PROPERTYfor information on the name of the properties file and what locations it will be looked for in.- Returns:
- a
URLthat names the GemFire security properties file. Null is returned if no properties file was found. - Since:
- GemFire 6.6.2
- See Also:
SECURITY_PROPERTIES_FILE_PROPERTY,SECURITY_PROPERTIES_FILE_DEFAULT,getSecurityPropertiesFile()
-
isReconnecting
public abstract boolean isReconnecting()
Test to see whether the DistributedSystem is in the process of reconnecting and recreating the cache after it has been removed from the system by other members or has shut down due to missing Roles and is reconnecting.This will also return true if the DistributedSystem has finished reconnecting. When reconnect has completed you can use
getReconnectedSystem()to retrieve the new distributed system.- Returns:
- true if the DistributedSystem is attempting to reconnect or has finished reconnecting
-
waitUntilReconnected
public abstract boolean waitUntilReconnected(long time, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedExceptionWait for the DistributedSystem to finish reconnecting to the system and recreate the cache. This may throw a DistributedSystemDisconnectedException if reconnect fails. The exception will detail what went wrong.- Parameters:
time- amount of time to wait, or -1 to wait foreverunits- the units associated with the time- Returns:
- true if the system was reconnected
- Throws:
java.lang.InterruptedException- if the thread is interrupted while waiting
-
stopReconnecting
public abstract void stopReconnecting()
Force the DistributedSystem to stop reconnecting. If the DistributedSystem is currently connected this will disconnect it and close the cache.
-
getReconnectedSystem
public abstract DistributedSystem getReconnectedSystem()
Returns the new DistributedSystem if there was an auto-reconnect- Returns:
- the new DistributedSystem if there was an auto-reconnect
-
-