public class DistributedSystemHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DistributedSystemHelper.Endpoint
Represents the endpoint for a locator.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DISCOVERY_FILE_NAME
Name of the file containing locator or multicast endpoints
|
| Constructor and Description |
|---|
DistributedSystemHelper() |
| Modifier and Type | Method and Description |
|---|---|
static String |
adminToString(com.gemstone.gemfire.admin.AdminDistributedSystem ads)
Returns the given admin distributed system as a string.
|
static void |
cleanupAfterAutoDisconnect()
Cleans up disconnect-related variables in this helper class so that the JVM
can use it to reconnect.
|
static com.gemstone.gemfire.admin.DistributedSystemConfig |
configureAdmin(String adminConfig)
Returns the configuration for an admin distributed system, using the
AdminDescription corresponding to the given admin configuration
from AdminPrms.names. |
static com.gemstone.gemfire.distributed.DistributedSystem |
connect()
Connects to a distributed system using properties from the
GemFireDescription corresponding to the logical gemfire configuration
name from the system property GemFirePrms.GEMFIRE_NAME_PROPERTY. |
static void |
connectAdmin(com.gemstone.gemfire.admin.AdminDistributedSystem ads)
Connects the admin distributed system.
|
static com.gemstone.gemfire.admin.AdminDistributedSystem |
connectAdmin(String adminConfig)
Configures, creates and connects an admin distributed system, using the
AdminDescription corresponding to the given admin configuration
from AdminPrms.names. |
static com.gemstone.gemfire.distributed.DistributedSystem |
connectWithXml(String cacheXmlFile)
Connects to a distributed system using properties from the
GemFireDescription corresponding to the logical gemfire configuration
name from the system property GemFirePrms.GEMFIRE_NAME_PROPERTY. |
static com.gemstone.gemfire.admin.AdminDistributedSystem |
createAdmin(com.gemstone.gemfire.admin.DistributedSystemConfig dsConfig)
Creates an unconnected admin distributed system from the given
configuration.
|
static com.gemstone.gemfire.admin.AdminDistributedSystem |
createAdmin(String adminConfig)
Configures and creates an unconnected admin distributed system, using the
AdminDescription corresponding to the given admin configuration
from AdminPrms.names. |
static void |
createLocator()
Creates a locator endpoint that this VM and other locator VMs in its
distributed system can use when configuring their locator lists.
|
static void |
disconnect()
Disconnects the distributed system if it is connected.
|
static void |
disconnectAdmin()
Disconnects the admin distributed system if it is connected.
|
static String |
endpointsToString(List endpoints)
Converts a list of locator endpoints to a locator string, or the empty
string if the list is null.
|
static String |
endpointToString(DistributedSystemHelper.Endpoint endpoint)
Converts a locator endpoint to a locator string, or the empty string if
the endpoint is null.
|
static AdminDescription |
getAdminDescription(String adminConfig)
Returns the
AdminDescription with the given configuration name
from AdminPrms.names. |
static com.gemstone.gemfire.admin.AdminDistributedSystem |
getAdminDistributedSystem()
Returns the admin distributed system if it is connected, otherwise null.
|
static Set |
getAdminMembers()
Returns a collection of the current admin distribution members.
|
static List |
getContacts()
Returns all contacts (server locator endpoints) from the
DistributedSystemBlackboard map, a possibly empty list. |
static List<String> |
getContacts(List<String> distributedSystemNames)
Returns all contacts (server locator endpoints) for the specified
distributed systems from the
DistributedSystemBlackboard map, a
possibly empty list. |
static List |
getContacts(String distributedSystemName)
Returns all contacts (server locator endpoints) for the specified
distributed system from the
DistributedSystemBlackboard map, a
possibly empty list. |
static com.gemstone.gemfire.distributed.DistributedSystem |
getDistributedSystem()
Returns the distributed system if it is connected, otherwise null.
|
static Integer |
getDistributedSystemId()
Returns the distributed system id.
|
static int |
getDistributedSystemId(String distributedSystemName)
Returns the distributed system id for the given distributed system name.
|
static String |
getDistributedSystemName()
Returns the distributed system name.
|
static String |
getDistributedSystemName(int distributedSystemId)
Returns the distributed system name for the given distributed system id.
|
static Properties |
getDistributedSystemProperties(String cacheXmlFile)
Returns distributed system properties using the optional cache XML file.
|
static List |
getEndpoints()
Returns all peer locator endpoints from the
DistributedSystemBlackboard map, a possibly empty list. |
static List |
getEndpoints(String distributedSystemName)
Returns all peer locator endpoints for the specified distributed system
from the
DistributedSystemBlackboard map, a possibly empty list. |
static GemFireDescription |
getGemFireDescription()
Returns the
GemFireDescription for this VM, as specified by the
system property GemFirePrms.GEMFIRE_NAME_PROPERTY. |
static com.gemstone.gemfire.distributed.Locator |
getLocator()
Returns the currently running locator, or null if no locator exists.
|
static Set |
getMembers()
Returns a collection of the current distribution members.
|
static List |
getSystemContacts()
Returns all contacts (server locator endpoints) for this VM's distributed
system from the
DistributedSystemBlackboard map, a possibly empty
list. |
static List |
getSystemEndpoints()
Returns all peer locator endpoints for this VM's distributed system from
the
DistributedSystemBlackboard map, a possibly empty list. |
static String |
locatorToString(com.gemstone.gemfire.distributed.Locator locator)
Returns the given locator as a string.
|
static com.gemstone.gemfire.distributed.Locator |
startLocatorAndAdminDS()
Starts the locator whose endpoint was created by
createLocator()
and connects it to an admin distributed system (it cannot create
a cache). |
static com.gemstone.gemfire.distributed.Locator |
startLocatorAndDS()
Starts the locator whose endpoint was created by
createLocator()
and connects it to a non-admin distributed system (it can create
a cache). |
static void |
stopLocator()
Stops the currently running locator, if it exists.
|
public static final String DISCOVERY_FILE_NAME
public static com.gemstone.gemfire.distributed.DistributedSystem connect()
GemFireDescription corresponding to the logical gemfire configuration
name from the system property GemFirePrms.GEMFIRE_NAME_PROPERTY.
Returns the existing distributed system if it is currently connected.HydraRuntimeException - if an attempt is made to reconfigure an
existing distributed system.public static com.gemstone.gemfire.distributed.DistributedSystem connectWithXml(String cacheXmlFile)
GemFireDescription corresponding to the logical gemfire configuration
name from the system property GemFirePrms.GEMFIRE_NAME_PROPERTY.
Returns the existing distributed system if it is currently connected.
Subsequent cache creation will use the configuration in the XML file.
HydraRuntimeException - if an attempt is made to reconfigure an
existing distributed system.public static com.gemstone.gemfire.distributed.DistributedSystem getDistributedSystem()
public static String getDistributedSystemName()
public static Integer getDistributedSystemId()
public static void disconnect()
public static void cleanupAfterAutoDisconnect()
NOTE: For use only after the product has automatically disconnected the JVM from the distributed system. The test is responsible for verifying this.
public static com.gemstone.gemfire.admin.AdminDistributedSystem connectAdmin(String adminConfig)
AdminDescription corresponding to the given admin configuration
from AdminPrms.names.HydraRuntimeException - if an attempt is made to reconfigure an
existing distributed system.public static com.gemstone.gemfire.admin.AdminDistributedSystem createAdmin(String adminConfig)
AdminDescription corresponding to the given admin configuration
from AdminPrms.names.
To connect the system, use connectAdmin(AdminDistributedSystem).
HydraRuntimeException - if an attempt is made to reconfigure an
existing distributed system.public static com.gemstone.gemfire.admin.DistributedSystemConfig configureAdmin(String adminConfig)
AdminDescription corresponding to the given admin configuration
from AdminPrms.names. This can be mutated as needed before
creating and connecting the system.
To create the system, use createAdmin(DistributedSystemConfig).
To connect the system, use connectAdmin(AdminDistributedSystem).
HydraRuntimeException - if an attempt is made to reconfigure an
existing admin distributed system.public static com.gemstone.gemfire.admin.AdminDistributedSystem createAdmin(com.gemstone.gemfire.admin.DistributedSystemConfig dsConfig)
To connect the system, use connectAdmin(AdminDistributedSystem).
HydraRuntimeException - if an attempt is made to reconfigure an
existing admin distributed system.public static void connectAdmin(com.gemstone.gemfire.admin.AdminDistributedSystem ads)
public static com.gemstone.gemfire.admin.AdminDistributedSystem getAdminDistributedSystem()
public static void disconnectAdmin()
public static String adminToString(com.gemstone.gemfire.admin.AdminDistributedSystem ads)
public static int getDistributedSystemId(String distributedSystemName)
public static String getDistributedSystemName(int distributedSystemId)
public static Set getMembers()
HydraRuntimeException - if not currently connected.DistributedMemberpublic static Set getAdminMembers()
HydraRuntimeException - if not currently connected.DistributedMemberpublic static Properties getDistributedSystemProperties(String cacheXmlFile)
public static AdminDescription getAdminDescription(String adminConfig)
AdminDescription with the given configuration name
from AdminPrms.names.public static GemFireDescription getGemFireDescription()
GemFireDescription for this VM, as specified by the
system property GemFirePrms.GEMFIRE_NAME_PROPERTY. Also verifies
that the configured host is local.public static void createLocator()
Upon initial creation, selects a random port and registers the locator
DistributedSystemHelper.Endpoint in the DistributedSystemBlackboard map. The
locator will always use this port during startup.
All locators associated with a given distributed system must be created before locators are started, so that the locator list is complete. At least one locator must be started before non-locators can connect.
To start the locator, use startLocatorAndDS() or startLocatorAndAdminDS().
HydraRuntimeException - if the VM already has a locator that did
not create its endpoint using this method or if master is managing
locators.public static com.gemstone.gemfire.distributed.Locator startLocatorAndDS()
createLocator()
and connects it to a non-admin distributed system (it can create
a cache). The locator is configured using the GemFireDescription
corresponding to the logical gemfire configuration name from the system
property GemFirePrms.GEMFIRE_NAME_PROPERTY. Returns the existing
locator if it is already started.
At least one locator must be started before non-locators can connect.
When starting multiple locators, use synchronization to ensure that one locator starts up before the others, as a workaround for Bug 30341.
HydraRuntimeException - if the VM is already connected or an attempt
is made to reconfigure an existing locator.public static com.gemstone.gemfire.distributed.Locator startLocatorAndAdminDS()
createLocator()
and connects it to an admin distributed system (it cannot create
a cache). The locator is configured using the GemFireDescription
corresponding to the logical gemfire configuration name from the system
property GemFirePrms.GEMFIRE_NAME_PROPERTY. Returns the existing
locator if it is already started.
At least one locator must be started before non-locators can connect.
When starting multiple locators, use synchronization to ensure that one locator starts up before the others, as a workaround for Bug 30341.
HydraRuntimeException - if the VM is already connected or an attempt
is made to reconfigure an existing locator.public static com.gemstone.gemfire.distributed.Locator getLocator()
HydraRuntimeException - if there are multiple locators.public static void stopLocator()
public static String locatorToString(com.gemstone.gemfire.distributed.Locator locator)
public static List getEndpoints()
DistributedSystemBlackboard map, a possibly empty list. This includes
all peer locators that have ever started, regardless of their distributed
system or current active status.public static List getSystemEndpoints()
DistributedSystemBlackboard map, a possibly empty list. This
includes all peer locators that have ever started for this system,
regardless of their current active status.public static List getEndpoints(String distributedSystemName)
DistributedSystemBlackboard map, a possibly empty list.
This includes all peer locators that have ever started for the system,
regardless of their current active status.public static List getContacts()
DistributedSystemBlackboard map, a possibly empty list. This includes
all server locators that have ever started, regardless of their distributed
system or current active status.public static List getSystemContacts()
DistributedSystemBlackboard map, a possibly empty
list. This includes all server locators that have ever started for this
system, regardless of their current active status.public static List getContacts(String distributedSystemName)
DistributedSystemBlackboard map, a
possibly empty list. This includes all server locators that have ever
started for the system, regardless of their current active status.public static List<String> getContacts(List<String> distributedSystemNames)
DistributedSystemBlackboard map, a
possibly empty list. This includes all server locators that have ever
started for the system, regardless of their current active status.public static String endpointsToString(List endpoints)
public static String endpointToString(DistributedSystemHelper.Endpoint endpoint)
Copyright © 2010-2015 Pivotal Software, Inc. All rights reserved.