Gemfire JavaDocs
Package org.apache.geode.distributed
Class ServerLauncher
- java.lang.Object
-
- org.apache.geode.distributed.AbstractLauncher<java.lang.String>
-
- org.apache.geode.distributed.ServerLauncher
-
- All Implemented Interfaces:
java.lang.Runnable
public class ServerLauncher extends AbstractLauncher<java.lang.String>
The ServerLauncher class is a launcher class with main method to start a GemFire server (implying a Geode Cache Server process).- Since:
- GemFire 7.0
- See Also:
AbstractLauncher
,LocatorLauncher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServerLauncher.Builder
The Builder class, modeled after the Builder creational design pattern, is used to construct a properly configured and initialized instance of the ServerLauncher to control and run Geode servers (in particular, cache servers).static class
ServerLauncher.Command
An enumerated type representing valid commands to the Server launcher.static class
ServerLauncher.ServerState
The ServerState is an immutable type representing the state of the specified Server at any given moment in time.-
Nested classes/interfaces inherited from class org.apache.geode.distributed.AbstractLauncher
AbstractLauncher.ServiceState<T extends java.lang.Comparable<T>>, AbstractLauncher.Status
-
-
Field Summary
-
Fields inherited from class org.apache.geode.distributed.AbstractLauncher
DEFAULT_FORCE, DEFAULT_WORKING_DIRECTORY, MEMBER_NAME_ERROR_MESSAGE, OPTION_PREFIX, READ_PID_FILE_TIMEOUT_MILLIS, running, SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY, WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE, WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Cache
getCache()
Gets a reference to theCache
that was created by thisServerLauncher
.org.apache.geode.internal.cache.CacheConfig
getCacheConfig()
Gets the CacheConfig object used to configure additional Geode Cache components and features (e.g.ServerLauncher.Command
getCommand()
Get the Server launcher command used to invoke the Server.java.lang.Float
getCriticalHeapPercentage()
java.lang.Float
getCriticalOffHeapPercentage()
java.lang.Float
getEvictionHeapPercentage()
java.lang.Float
getEvictionOffHeapPercentage()
java.lang.String
getHostNameForClients()
java.lang.String
getId()
Gets an identifier that uniquely identifies and represents the Server associated with this launcher.static ServerLauncher
getInstance()
Gets the instance of the ServerLauncher used to launch the Geode Cache Server, or null if this VM does not have an instance of ServerLauncher indicating no Geode Cache Server is running.java.lang.String
getLogFileName()
Gets the name of the log file used to log information about this Server.java.lang.Integer
getMaxConnections()
java.lang.Float
getMaxConnectionsNotificationThreshold()
java.lang.Integer
getMaxMessageCount()
java.lang.Integer
getMaxThreads()
java.lang.String
getMemberName()
Gets the name of this member (this Server) in the Geode distributed system as determined by the 'name' Geode property.java.lang.Integer
getMessageTimeToLive()
java.lang.Integer
getPid()
Gets the user-specified process ID (PID) of the running Server that ServerLauncher uses to issue status and stop commands to the Server.java.util.Properties
getProperties()
Gets the Geode Distributed System (cluster) Properties.java.net.InetAddress
getServerBindAddress()
Gets the IP address to which the Server is bound listening for and accepting cache client connections.java.lang.String
getServerBindAddressAsString()
Gets the host, as either hostname or IP address, on which the Server was bound and running.protected java.io.File
getServerPidFile()
Gets a File reference with the path to the PID file for the Server.java.lang.Integer
getServerPort()
Gets the port on which the Server is listening for cache client connections.java.lang.String
getServerPortAsString()
Gets the server port on which the Server is listening for client requests represented as a String value.static ServerLauncher.ServerState
getServerState()
Gets the ServerState for this process or null if this process was not launched using this VM's ServerLauncher reference .java.lang.String
getServiceName()
Gets the name for a GemFire server.java.lang.Integer
getSocketBufferSize()
java.lang.String
getSpringXmlLocation()
Gets the location of the Spring XML configuration meta-data file used to bootstrap, configure and initialize the GemFire server on start.java.lang.String
getWorkingDirectory()
Gets the working directory pathname in which the Server will be run.void
help(ServerLauncher.Command command)
Displays help for the specified Server launcher command to standard err.boolean
isAssignBuckets()
Determines whether buckets should be assigned to partitioned regions in the cache upon Server start.protected boolean
isDefaultServerEnabled(Cache cache)
Determines whether a default server (a cache server) should be created on startup as determined by the absence of specifying the --disable-default-server command-line option (switch).boolean
isDisableDefaultServer()
Determines whether a default cache server will be added when the GemFire server comes online.boolean
isForcing()
Determines whether the PID file is allowed to be overwritten when the Server is started and a PID file already exists in the Server's specified working directory.boolean
isHelping()
Determines whether this launcher will be used to display help information.boolean
isRebalancing()
Determines whether a rebalance operation on the cache will occur upon starting the Geode server using this launcher.boolean
isRedirectingOutput()
Determines whether this launcher will redirect output to system logs when starting a new Server process.protected boolean
isServing(Cache cache)
Determines whether the specified Cache has any CacheServers.boolean
isSpringXmlLocationSpecified()
Determines whether this GemFire server was configured and initialized with Spring configuration meta-data.protected boolean
isStartingOrRunning()
Determines whether the Server is the process of starting or is already running.static void
main(java.lang.String... args)
Deprecated.as of 10.0 Please use com.vmware.gemfire.bootstrap.ServerLauncher}void
run()
A Runnable method used to invoke the GemFire server (cache server) with the specified command.ServerLauncher.ServerState
start()
Invokes the 'start' command and operation to startup a GemFire server (a cache server).ServerLauncher.ServerState
status()
Invokes the 'status' command and operation to check the status of a GemFire server (a cache server).ServerLauncher.ServerState
stop()
Invokes the 'stop' command and operation to stop a GemFire server (a cache server).void
usage()
Displays usage information on the proper invocation of the ServerLauncher from the command-line to standard err.void
waitOnServer()
Causes the calling Thread to block until the Geode Cache Server/Data Member stops.-
Methods inherited from class org.apache.geode.distributed.AbstractLauncher
assertPortAvailable, assertPortAvailable, debug, debug, getDistributedSystemProperties, getDistributedSystemProperties, getLogFile, getLogFileCanonicalPath, getMember, getMemberId, info, isDebugging, isRunning, isSet, loadGemFireProperties, redirectOutput, setDebug, version
-
-
-
-
Method Detail
-
main
@Deprecated public static void main(java.lang.String... args)
Deprecated.as of 10.0 Please use com.vmware.gemfire.bootstrap.ServerLauncher}Launches a GemFire server from the command-line configured with the given arguments.- Parameters:
args
- the command-line arguments used to configure the GemFire server at runtime.
-
getInstance
public static ServerLauncher getInstance()
Gets the instance of the ServerLauncher used to launch the Geode Cache Server, or null if this VM does not have an instance of ServerLauncher indicating no Geode Cache Server is running.- Returns:
- the instance of ServerLauncher used to launcher a Geode Cache Server in this VM.
-
getServerState
public static ServerLauncher.ServerState getServerState()
Gets the ServerState for this process or null if this process was not launched using this VM's ServerLauncher reference .- Returns:
- the ServerState for this process or null.
-
getCache
public Cache getCache()
Gets a reference to theCache
that was created by thisServerLauncher
.- Returns:
- a reference to the Cache
- See Also:
Cache
-
getCacheConfig
public org.apache.geode.internal.cache.CacheConfig getCacheConfig()
Gets the CacheConfig object used to configure additional Geode Cache components and features (e.g. PDX).- Returns:
- a CacheConfig object with additional Geode Cache configuration meta-data used on startup to configure the Cache.
-
getId
public java.lang.String getId()
Gets an identifier that uniquely identifies and represents the Server associated with this launcher.- Returns:
- a String value identifier to uniquely identify the Server and it's launcher.
- See Also:
getServerBindAddressAsString()
,getServerPortAsString()
-
getCommand
public ServerLauncher.Command getCommand()
Get the Server launcher command used to invoke the Server.- Returns:
- the Server launcher command used to invoke the Server.
- See Also:
ServerLauncher.Command
-
isAssignBuckets
public boolean isAssignBuckets()
Determines whether buckets should be assigned to partitioned regions in the cache upon Server start.- Returns:
- a boolean indicating if buckets should be assigned upon Server start.
-
isDisableDefaultServer
public boolean isDisableDefaultServer()
Determines whether a default cache server will be added when the GemFire server comes online.- Returns:
- a boolean value indicating whether to add a default cache server.
-
isForcing
public boolean isForcing()
Determines whether the PID file is allowed to be overwritten when the Server is started and a PID file already exists in the Server's specified working directory.- Returns:
- boolean indicating if force has been enabled.
-
isHelping
public boolean isHelping()
Determines whether this launcher will be used to display help information. If so, then none of the standard Server launcher commands will be used to affect the state of the Server. A launcher is said to be 'helping' if the user entered the "--help" option (switch) on the command-line.- Returns:
- a boolean value indicating if this launcher is used for displaying help information.
- See Also:
ServerLauncher.Command
-
isRebalancing
public boolean isRebalancing()
Determines whether a rebalance operation on the cache will occur upon starting the Geode server using this launcher.- Returns:
- a boolean indicating if the cache will be rebalance when the GemFire server starts.
-
isRedirectingOutput
public boolean isRedirectingOutput()
Determines whether this launcher will redirect output to system logs when starting a new Server process.- Returns:
- a boolean value indicating if this launcher will redirect output to system logs when starting a new Server process
-
getLogFileName
public java.lang.String getLogFileName()
Gets the name of the log file used to log information about this Server.- Specified by:
getLogFileName
in classAbstractLauncher<java.lang.String>
- Returns:
- a String value indicating the name of this Server's log file.
-
getMemberName
public java.lang.String getMemberName()
Gets the name of this member (this Server) in the Geode distributed system as determined by the 'name' Geode property.- Overrides:
getMemberName
in classAbstractLauncher<java.lang.String>
- Returns:
- a String indicating the name of the member (this Server) in the Geode distributed system.
-
getPid
public java.lang.Integer getPid()
Gets the user-specified process ID (PID) of the running Server that ServerLauncher uses to issue status and stop commands to the Server.- Specified by:
getPid
in classAbstractLauncher<java.lang.String>
- Returns:
- an Integer value indicating the process ID (PID) of the running Server.
-
getProperties
public java.util.Properties getProperties()
Gets the Geode Distributed System (cluster) Properties.- Returns:
- a Properties object containing the configuration settings for the Geode Distributed System (cluster).
- See Also:
Properties
-
getServerBindAddress
public java.net.InetAddress getServerBindAddress()
Gets the IP address to which the Server is bound listening for and accepting cache client connections. This property should not be confused with 'bindAddress' ServerLauncher property, which is the port for binding the Server's ServerSocket used in distribution and messaging between the peers of the Geode distributed system.- Returns:
- an InetAddress indicating the IP address that the Server is bound to listening for and accepting cache client connections in a client/server topology.
-
getServerBindAddressAsString
public java.lang.String getServerBindAddressAsString()
Gets the host, as either hostname or IP address, on which the Server was bound and running. An attempt is made to get the canonical hostname for IP address to which the Server was bound for accepting client requests. If the server bind address is null or localhost is unknown, then a default String value of "localhost/127.0.0.1" is returned.Note, this information is purely information and should not be used to re-construct state or for other purposes.
- Returns:
- the hostname or IP address of the host running the Server, based on the bind-address, or 'localhost/127.0.0.1' if the bind address is null and localhost is unknown.
- See Also:
InetAddress
,getServerBindAddress()
-
getServerPort
public java.lang.Integer getServerPort()
Gets the port on which the Server is listening for cache client connections. This property should not be confused with the 'port' ServerLauncher property, which is used by the Server to set the 'tcp-port' distribution config property and is used by the ServerSocket for peer distribution and messaging.- Returns:
- an Integer value indicating the port the Server is listening on for cache client connections in the client/server topology.
-
getServerPortAsString
public java.lang.String getServerPortAsString()
Gets the server port on which the Server is listening for client requests represented as a String value.- Returns:
- a String representing the server port on which the Server is listening for client requests.
- See Also:
getServerPort()
-
getServiceName
public java.lang.String getServiceName()
Gets the name for a GemFire server.- Specified by:
getServiceName
in classAbstractLauncher<java.lang.String>
- Returns:
- a String indicating the name for a GemFire server.
-
getSpringXmlLocation
public java.lang.String getSpringXmlLocation()
Gets the location of the Spring XML configuration meta-data file used to bootstrap, configure and initialize the GemFire server on start.- Returns:
- a String indicating the location of the Spring XML configuration file.
- See Also:
ServerLauncher.Builder.getSpringXmlLocation()
-
isSpringXmlLocationSpecified
public boolean isSpringXmlLocationSpecified()
Determines whether this GemFire server was configured and initialized with Spring configuration meta-data.- Returns:
- a boolean value indicating whether this GemFire server was configured with Spring configuration meta-data.
-
getWorkingDirectory
public java.lang.String getWorkingDirectory()
Gets the working directory pathname in which the Server will be run.- Overrides:
getWorkingDirectory
in classAbstractLauncher<java.lang.String>
- Returns:
- a String value indicating the pathname of the Server's working directory.
-
getCriticalHeapPercentage
public java.lang.Float getCriticalHeapPercentage()
-
getEvictionHeapPercentage
public java.lang.Float getEvictionHeapPercentage()
-
getCriticalOffHeapPercentage
public java.lang.Float getCriticalOffHeapPercentage()
-
getEvictionOffHeapPercentage
public java.lang.Float getEvictionOffHeapPercentage()
-
getHostNameForClients
public java.lang.String getHostNameForClients()
-
getMaxConnections
public java.lang.Integer getMaxConnections()
-
getMaxConnectionsNotificationThreshold
public java.lang.Float getMaxConnectionsNotificationThreshold()
-
getMaxMessageCount
public java.lang.Integer getMaxMessageCount()
-
getMessageTimeToLive
public java.lang.Integer getMessageTimeToLive()
-
getMaxThreads
public java.lang.Integer getMaxThreads()
-
getSocketBufferSize
public java.lang.Integer getSocketBufferSize()
-
help
public void help(ServerLauncher.Command command)
Displays help for the specified Server launcher command to standard err. If the Server launcher command is unspecified, then usage information is displayed instead.- Parameters:
command
- the Server launcher command in which to display help information.- See Also:
usage()
-
usage
public void usage()
Displays usage information on the proper invocation of the ServerLauncher from the command-line to standard err.- See Also:
help(ServerLauncher.Command)
-
run
public void run()
A Runnable method used to invoke the GemFire server (cache server) with the specified command. From run, a user can invoke 'start', 'status', 'stop' and 'version'. Note, that 'version' is also a command-line option, but can be treated as a "command" as well.- See Also:
Runnable
-
getServerPidFile
protected java.io.File getServerPidFile()
Gets a File reference with the path to the PID file for the Server.- Returns:
- a File reference to the path of the Server's PID file.
-
start
public ServerLauncher.ServerState start()
Invokes the 'start' command and operation to startup a GemFire server (a cache server). Note, this method will cause the JVM to block upon server start, providing the calling Thread is a non-daemon Thread.- Returns:
- a
ServerLauncher.ServerState
representing the state of the server following the attempt to start - See Also:
run()
-
isServing
protected boolean isServing(Cache cache)
Determines whether the specified Cache has any CacheServers.- Parameters:
cache
- the Cache to check for existing CacheServers.- Returns:
- a boolean value indicating if any CacheServers were added to the Cache.
-
waitOnServer
public void waitOnServer()
Causes the calling Thread to block until the Geode Cache Server/Data Member stops.
-
isDefaultServerEnabled
protected boolean isDefaultServerEnabled(Cache cache)
Determines whether a default server (a cache server) should be created on startup as determined by the absence of specifying the --disable-default-server command-line option (switch). In addition, a default cache server is started only if no cache servers have been added to the Cache by way of cache.xml.- Parameters:
cache
- the reference to the Cache to check for any existing cache servers.- Returns:
- a boolean indicating whether a default server should be added to the Cache.
- See Also:
isDisableDefaultServer()
-
isStartingOrRunning
protected boolean isStartingOrRunning()
Determines whether the Server is the process of starting or is already running.- Returns:
- a boolean indicating if the Server is starting or is already running.
-
status
public ServerLauncher.ServerState status()
Invokes the 'status' command and operation to check the status of a GemFire server (a cache server).- Returns:
- a
ServerLauncher.ServerState
representing the status of the server
-
stop
public ServerLauncher.ServerState stop()
Invokes the 'stop' command and operation to stop a GemFire server (a cache server).- Returns:
- a
ServerLauncher.ServerState
representing the state of the server following the attempt to stop
-
-