public abstract class Locator extends Object
This class allows a GemFire application VM to host a distribution locator. Such a configuration minimizes the number of processes that are required to run GemFire. However, hosting distribution locators is not generally recommended because if the application VM exits it would not be possible for new applications to connect to the distributed system until it is restarted.
Locators persist membership information in a locatorXXXview.dat file. This file is used to recover information about the cluster when a locator starts if there are no other currently running locators. It allows the restarted locator to rejoin the cluster.
NOTE: In this release of the product locators log membership views and cache server status in a locatorXXXviews.log file, where XXX is the locator's port. This is a rolling log capped in size at 5mb. In order to log cache server status the locator will enable server-location, so the locator must be started with a DistributedSystem or be started so that it creates a DistributedSystem. This means that it is not possible in this release to use APIs to start a locator and then start a DistributedSystem.
Modifier and Type | Field and Description |
---|---|
protected InetAddress |
bindAddress
no longer used but kept for binary compatibility
|
protected org.apache.geode.distributed.internal.tcpserver.HostAddress |
hostAddress
The bind address for this locator
|
protected String |
hostnameForClients
the hostname to give to clients so they can connect to this locator.
|
protected File |
logFile
The file to which this locator logs
|
Constructor and Description |
---|
Locator() |
Modifier and Type | Method and Description |
---|---|
String |
asString()
Get the string representation of this
Locator in host[port] format. |
InetAddress |
getBindAddress()
Returns the IP address to which this locator's listening socket is bound.
|
abstract DistributedSystem |
getDistributedSystem()
Returns the distributed system started by this locator, if any
|
String |
getHostnameForClients()
Returns the hostname that will be given to clients so that they can connect to this locator.
|
static Locator |
getLocator()
Returns the locator if it exists in this JVM.
|
static List<Locator> |
getLocators()
Deprecated.
as of 7.0 use
getLocator() instead |
File |
getLogFile()
Returns the log file to which this locator's output is written
|
abstract Integer |
getPort()
Returns the port on which this locator runs
|
static boolean |
hasLocator()
Returns true if a locator exists in this JVM.
|
static boolean |
hasLocators()
Deprecated.
as of 7.0 use
hasLocator() instead. |
abstract boolean |
isPeerLocator()
Indicates whether the locator provides peer location services to members
|
abstract boolean |
isServerLocator()
Indicates whether the locator provides server location services to clients
|
static void |
main(String[] args)
Deprecated.
as of Geode 1.4 use
"LocatorLauncher" to start a locator |
static Locator |
startLocator(int port,
File logFile)
Deprecated.
as of 7.0 use startLocatorAndDS instead.
|
static Locator |
startLocator(int port,
File logFile,
InetAddress bindAddress)
Deprecated.
as of 7.0 use startLocatorAndDS instead.
|
static Locator |
startLocatorAndDS(int port,
File logFile,
InetAddress bindAddress,
Properties dsProperties)
Starts a new distribution locator host by this VM that binds to the given network address.
|
static Locator |
startLocatorAndDS(int port,
File logFile,
InetAddress bindAddress,
Properties dsProperties,
boolean peerLocator,
boolean serverLocator,
String hostnameForClients)
Deprecated.
use a different startup method peerLocator and serverLocator parameters are ignored
|
static Locator |
startLocatorAndDS(int port,
File logFile,
Properties distributedSystemProperties)
Starts a new distribution locator host by this VM, and an admin distributed system controlled
by the locator.
|
abstract void |
stop()
Stops this distribution locator.
|
String |
toString()
Returns a brief description of this
Locator |
protected File logFile
protected InetAddress bindAddress
protected org.apache.geode.distributed.internal.tcpserver.HostAddress hostAddress
protected String hostnameForClients
@Deprecated public static Locator startLocator(int port, File logFile) throws IOException
The locator will not start a distributed system. The locator will provide peer location services only.
port
- The port on which the locator will listen for membership information requests from
new memberslogFile
- The file to which the locator logs information. The directory that contains the
log file is used as the output directory of the locator (see -dir
option to
the gemfire
command).IllegalArgumentException
- If port
is not in the range 0 to 65536SystemIsRunningException
- If another locator is already running in
outputDir
GemFireIOException
- If the directory containing the
logFile
does not exist or cannot be written toIOException
- If the locator cannot be startedpublic static Locator startLocatorAndDS(int port, File logFile, Properties distributedSystemProperties) throws IOException
The locator starts a AdminDistributedSystem configured with the given properties to provide the system with a long-running process that can be relied on for stable membership information. The locator will provide provide peer and cache server location services.
port
- The port on which the locator will listen for membership information requests from
new memberslogFile
- The file to which the locator logs information. The directory that contains the
log file is used as the output directory of the locator (see -dir
option to
the gemfire
command).distributedSystemProperties
- The properties used to configure the locator's distributed
system. If there are multiple locators in the system, this should note them in the
"locators" setting. If The distributed system is using multicast, the "mcast-port"
should also be set.IllegalArgumentException
- If port
is not in the range 0 to 65536SystemIsRunningException
- If another locator is already running in
outputDir
GemFireIOException
- If the directory containing the
logFile
does not exist or cannot be written toIOException
- If the locator cannot be started@Deprecated public static Locator startLocator(int port, File logFile, InetAddress bindAddress) throws IOException
The locator will not start a distributed system. The locator will provide peer location services only.
port
- The port on which the locator will listen for membership information requests from
new memberslogFile
- The file to which the locator logs information. The directory that contains the
log file is used as the output directory of the locator (see -dir
option to
the gemfire
command).bindAddress
- The IP address to which the locator's socket bindsIllegalArgumentException
- If port
is not in the range 0 to 65536SystemIsRunningException
- If another locator is already running in
outputDir
GemFireIOException
- If the directory containing the
logFile
does not exist or cannot be written toIOException
- If the locator cannot be startedpublic static Locator startLocatorAndDS(int port, File logFile, InetAddress bindAddress, Properties dsProperties) throws IOException
The locator starts a AdminDistributedSystem configured with the given properties to provide the system with a long-running process that can be relied on for stable membership information. The locator will provide peer and cache server location services.
port
- The port on which the locator will listen for membership information requests from
new memberslogFile
- The file to which the locator logs information. The directory that contains the
log file is used as the output directory of the locator (see -dir
option to
the gemfire
command).bindAddress
- The IP address to which the locator's socket bindsdsProperties
- The properties used to configure the locator's DistributedSystem. If there
are multiple locators, the "locators" property should be set. If multicast is being
used, the "mcast-port" property should be set.IllegalArgumentException
- If port
is not in the range 0 to 65536SystemIsRunningException
- If another locator is already running in
outputDir
GemFireIOException
- If the directory containing the
logFile
does not exist or cannot be written toIOException
- If the locator cannot be started@Deprecated public static Locator startLocatorAndDS(int port, File logFile, InetAddress bindAddress, Properties dsProperties, boolean peerLocator, boolean serverLocator, String hostnameForClients) throws IOException
The locator starts a AdminDistributedSystem configured with the given properties to provide the system with a long-running process that can be relied on for stable membership information. The locator will provide provide peer and cache server location services.
port
- The port on which the locator will listen for membership information requests from
new memberslogFile
- The file to which the locator logs information. The directory that contains the
log file is used as the output directory of the locator (see -dir
option to
the gemfire
command).bindAddress
- The IP address to which the locator's socket bindsdsProperties
- The properties used to configure the locator's DistributedSystem. If there
are multiple locators, the "locators" property should be set. If multicast is being
used, the "mcast-port" property should be set.peerLocator
- True if the locator should provide membership information to peers in the
distributed system.serverLocator
- True if the locator should provide information about cache servers to
clients connecting to the distributed system.hostnameForClients
- the name to give to clients for connecting to this locatorIllegalArgumentException
- If port
is not in the range 0 to 65536 or
peerLocator
and serverLocator
are both false.SystemIsRunningException
- If another locator is already running in
outputDir
GemFireIOException
- If the directory containing the
logFile
does not exist or cannot be written toIOException
- If the locator cannot be started@Deprecated public static List<Locator> getLocators()
getLocator()
insteadList
of all of the Locator
s that are hosted
by this VM.List
of all of the Locator
s that are hosted
by this VMpublic static Locator getLocator()
@Deprecated public static boolean hasLocators()
hasLocator()
instead.public static boolean hasLocator()
public abstract Integer getPort()
public abstract DistributedSystem getDistributedSystem()
public File getLogFile()
public InetAddress getBindAddress()
public String getHostnameForClients()
null
if clients should use the bind address.public abstract boolean isPeerLocator()
public abstract boolean isServerLocator()
public abstract void stop()
public String toString()
Locator
public String asString()
Locator
in host[port] format.Locator
in host[port] format@Deprecated public static void main(String[] args)
"LocatorLauncher" to start a locator
This method of starting the locator is provided as an alternative to the gemfire start-locator command to give you complete control over the java virtual machine's configuration.
The gemfire stop-locator command can be used to stop a locator that is started with this class.
java org.apache.geode.distributed.Locator port [bind-address] [gemfire-properties-file] [peer] [server]
port - the tcp/ip port that the locator should listen on. This is the port number that applications will refer to in their locators property in gemfire.properties
bind-address - the tcp/ip address that the locator should bind to. This can be missing or be an empty string, which causes the locator to listen on all host addresses.
gemfire-properties-file - the location of a gemfire.properties file to be used in configuring the locator's distributed system. This can be missing or be an empty string, which will cause the locator to use the default search for gemfire.properties.
peer - true to start the peer locator service, false to disable it. If unspecified, default to true.
server - true to start the cache server locator service, false to disable it. If unspecified, defaults to true.
hostname-for-clients - the ip address or host name that clients will be told to use to connect to this locator. If unspecified, defaults to the bind-address.
args
- the arguments to start the locator with