Gemfire JavaDocs_test
Package org.apache.geode.distributed
Class AbstractLauncher<T extends java.lang.Comparable<T>>
- java.lang.Object
-
- org.apache.geode.distributed.AbstractLauncher<T>
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
LocatorLauncher
,ServerLauncher
public abstract class AbstractLauncher<T extends java.lang.Comparable<T>> extends java.lang.Object implements java.lang.Runnable
The AbstractLauncher class is a base class for implementing various launchers to construct and run different GemFire processes, like Cache Servers, Locators, Managers, HTTP servers and so on.- Since:
- GemFire 7.0
- See Also:
Comparable
,Runnable
,Identifiable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractLauncher.ServiceState<T extends java.lang.Comparable<T>>
The ServiceState is an immutable type representing the state of the specified Locator at any given moment in time.static class
AbstractLauncher.Status
The Status enumerated type represents the various lifecycle states of a GemFire service (such as a Cache Server, a Locator or a Manager).
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.Boolean
DEFAULT_FORCE
static java.lang.String
DEFAULT_WORKING_DIRECTORY
protected java.util.logging.Logger
logger
Deprecated.Please use Log4J 2 instead.static java.lang.String
MEMBER_NAME_ERROR_MESSAGE
protected static java.lang.String
OPTION_PREFIX
protected static long
READ_PID_FILE_TIMEOUT_MILLIS
Deprecated.This timeout is no longer needed.protected java.util.concurrent.atomic.AtomicBoolean
running
static java.lang.String
SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY
static java.lang.String
WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
static java.lang.String
WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
-
Constructor Summary
Constructors Constructor Description AbstractLauncher()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static void
assertPortAvailable(int port)
Asserts that the specified port is available on all network interfaces on this local system.protected static void
assertPortAvailable(java.net.InetAddress bindAddress, int port)
Asserts that the specified port is available on the specified network interface, indicated by it's assigned IP address, on this local system.protected void
debug(java.lang.String message, java.lang.Object... args)
Prints the specified debug message to standard err, replacing any placeholder values with the specified arguments on output, if debugging has been enabled.protected void
debug(java.lang.Throwable t)
Prints the stack trace of the given Throwable to standard err if debugging has been enabled.protected java.util.Properties
getDistributedSystemProperties()
Creates a Properties object with configuration settings that the launcher has that should take precedence over anything the user has defined in their gemfire properties file.protected java.util.Properties
getDistributedSystemProperties(java.util.Properties defaults)
Creates a Properties object with configuration settings that the launcher has that should take precedence over anything the user has defined in their gemfire properties file.protected java.io.File
getLogFile()
Gets a File reference with the path to the log file for the process.protected java.lang.String
getLogFileCanonicalPath()
Gets the fully qualified canonical path of the log file for the process.abstract java.lang.String
getLogFileName()
Gets the name of the log file used to log information about this GemFire service.java.lang.String
getMember()
Gets the name or ID of the member in the GemFire distributed system.java.lang.String
getMemberId()
Gets the ID of the member in the GemFire distributed system as determined and assigned by GemFire when the member process joins the distributed system.java.lang.String
getMemberName()
Gets the name of the member in the GemFire distributed system as determined by the 'name' GemFire property.abstract java.lang.Integer
getPid()
Gets the user-specified process ID (PID) of the running GemFire service that AbstractLauncher implementations can use to determine status, or stop the service.abstract java.lang.String
getServiceName()
Gets the name of the GemFire service.java.lang.String
getWorkingDirectory()
Gets the working directory pathname in which the process will be run.protected void
info(java.lang.Object message, java.lang.Object... args)
Prints the specified informational message to standard err, replacing any placeholder values with the specified arguments on output.boolean
isDebugging()
Determines whether the Locator launcher is in debug mode.boolean
isRunning()
Determines whether the Locator referenced by this launcher is running.protected static boolean
isSet(java.util.Properties properties, java.lang.String propertyName)
Determines whether the specified property with name is set to a value in the referenced Properties.protected static java.util.Properties
loadGemFireProperties(java.net.URL url)
Loads the GemFire properties at the specified URL.protected void
redirectOutput(DistributedSystem distributedSystem)
Redirects the standard out and standard err to the configured log file as specified in the GemFire distributed system properties.void
setDebug(boolean debug)
Sets the debug mode of the GemFire launcher class.java.lang.String
version()
Gets the version of GemFire currently running.
-
-
-
Field Detail
-
MEMBER_NAME_ERROR_MESSAGE
public static final java.lang.String MEMBER_NAME_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
public static final java.lang.String WORKING_DIRECTORY_OPTION_NOT_VALID_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
public static final java.lang.String WORKING_DIRECTORY_NOT_FOUND_ERROR_MESSAGE
- See Also:
- Constant Field Values
-
DEFAULT_FORCE
@Immutable protected static final java.lang.Boolean DEFAULT_FORCE
-
READ_PID_FILE_TIMEOUT_MILLIS
@Deprecated protected static final long READ_PID_FILE_TIMEOUT_MILLIS
Deprecated.This timeout is no longer needed.- See Also:
- Constant Field Values
-
DEFAULT_WORKING_DIRECTORY
public static final java.lang.String DEFAULT_WORKING_DIRECTORY
-
SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY
public static final java.lang.String SIGNAL_HANDLER_REGISTRATION_SYSTEM_PROPERTY
- See Also:
- Constant Field Values
-
OPTION_PREFIX
protected static final java.lang.String OPTION_PREFIX
- See Also:
- Constant Field Values
-
running
protected final transient java.util.concurrent.atomic.AtomicBoolean running
-
logger
@Deprecated protected java.util.logging.Logger logger
Deprecated.Please use Log4J 2 instead.
-
-
Method Detail
-
assertPortAvailable
protected static void assertPortAvailable(int port) throws java.net.BindException
Asserts that the specified port is available on all network interfaces on this local system.- Parameters:
port
- an integer indicating the network port to listen for client network requests.- Throws:
java.net.BindException
- if the network port is not available.
-
assertPortAvailable
protected static void assertPortAvailable(java.net.InetAddress bindAddress, int port) throws java.net.BindException
Asserts that the specified port is available on the specified network interface, indicated by it's assigned IP address, on this local system.- Parameters:
bindAddress
- an InetAddress indicating the bounded network interface to determine whether the service port is available or not.port
- an integer indicating the network port to listen for client network requests.- Throws:
java.net.BindException
- if the network address and port are not available. Address defaults to localhost (or all network interfaces on the local system) if null.- See Also:
AvailablePort
-
isSet
protected static boolean isSet(java.util.Properties properties, java.lang.String propertyName)
Determines whether the specified property with name is set to a value in the referenced Properties. The property is considered "set" if the String value of the property is not non-null, non-empty and non-blank. Therefore, the Properties may "have" a property with name, but having no value as determined by this method.- Parameters:
properties
- the Properties used in determining whether the given property is set.propertyName
- a String indicating the name of the property to check if set.- Returns:
- a boolean indicating whether the specified property with name has been given a value in the referenced Properties.
- See Also:
Properties
-
loadGemFireProperties
protected static java.util.Properties loadGemFireProperties(java.net.URL url)
Loads the GemFire properties at the specified URL.- Parameters:
url
- the URL to the gemfire.properties to load.- Returns:
- a Properties instance populated with the gemfire.properties.
- See Also:
URL
-
isDebugging
public boolean isDebugging()
Determines whether the Locator launcher is in debug mode.- Returns:
- a boolean to indicate whether the Locator launcher is in debug mode.
- See Also:
setDebug(boolean)
-
setDebug
public void setDebug(boolean debug)
Sets the debug mode of the GemFire launcher class. This mutable property of the launcher enables the user to turn the debug mode on and off programmatically.- Parameters:
debug
- a boolean used to enable or disable debug mode.- See Also:
isDebugging()
-
isRunning
public boolean isRunning()
Determines whether the Locator referenced by this launcher is running.- Returns:
- a boolean valued indicating if the referenced Locator is running.
-
getDistributedSystemProperties
protected java.util.Properties getDistributedSystemProperties()
Creates a Properties object with configuration settings that the launcher has that should take precedence over anything the user has defined in their gemfire properties file.- Returns:
- a Properties object with GemFire properties that the launcher has defined.
- See Also:
getDistributedSystemProperties(java.util.Properties)
,Properties
-
getDistributedSystemProperties
protected java.util.Properties getDistributedSystemProperties(java.util.Properties defaults)
Creates a Properties object with configuration settings that the launcher has that should take precedence over anything the user has defined in their gemfire properties file.- Parameters:
defaults
- default GemFire Distributed System properties as configured in the Builder.- Returns:
- a Properties object with GemFire properties that the launcher has defined.
- See Also:
Properties
-
getLogFile
protected java.io.File getLogFile()
Gets a File reference with the path to the log file for the process.- Returns:
- a File reference to the path of the log file for the process.
-
getLogFileCanonicalPath
protected java.lang.String getLogFileCanonicalPath()
Gets the fully qualified canonical path of the log file for the process.- Returns:
- a String value indicating the canonical path of the log file for the process.
-
getLogFileName
public abstract java.lang.String getLogFileName()
Gets the name of the log file used to log information about this GemFire service.- Returns:
- a String value indicating the name of this GemFire service's log file.
-
getMember
public java.lang.String getMember()
Gets the name or ID of the member in the GemFire distributed system. This method prefers name if specified, otherwise the ID is returned. If name was not specified to the Builder that created this Launcher and this call is not in-process, then null is returned.- Returns:
- a String value indicating the member's name if specified, otherwise the member's ID is returned if this call is made in-process, or finally, null is returned if neither name name was specified or the call is out-of-process.
- See Also:
getMemberName()
,getMemberId()
-
getMemberId
public java.lang.String getMemberId()
Gets the ID of the member in the GemFire distributed system as determined and assigned by GemFire when the member process joins the distributed system. Note, this call only works if the API is used in-process.- Returns:
- a String value indicating the ID of the member in the GemFire distributed system.
-
getMemberName
public java.lang.String getMemberName()
Gets the name of the member in the GemFire distributed system as determined by the 'name' GemFire property. Note, this call only works if the API is used in-process.- Returns:
- a String value indicating the name of the member in the GemFire distributed system.
-
getPid
public abstract java.lang.Integer getPid()
Gets the user-specified process ID (PID) of the running GemFire service that AbstractLauncher implementations can use to determine status, or stop the service.- Returns:
- an Integer value indicating the process ID (PID) of the running GemFire service.
-
getServiceName
public abstract java.lang.String getServiceName()
Gets the name of the GemFire service.- Returns:
- a String indicating the name of the GemFire service.
-
getWorkingDirectory
public java.lang.String getWorkingDirectory()
Gets the working directory pathname in which the process will be run.- Returns:
- a String value indicating the pathname of the Server's working directory.
-
debug
protected void debug(java.lang.String message, java.lang.Object... args)
Prints the specified debug message to standard err, replacing any placeholder values with the specified arguments on output, if debugging has been enabled.- Parameters:
message
- the String value written to standard err.args
- an Object array containing arguments to replace the placeholder values in the message.- See Also:
System.err
,isDebugging()
,debug(Throwable)
,info(Object, Object...)
-
debug
protected void debug(java.lang.Throwable t)
Prints the stack trace of the given Throwable to standard err if debugging has been enabled.- Parameters:
t
- the Throwable who's stack trace is printed to standard err.- See Also:
System.err
,isDebugging()
,debug(String, Object...)
-
info
protected void info(java.lang.Object message, java.lang.Object... args)
Prints the specified informational message to standard err, replacing any placeholder values with the specified arguments on output.- Parameters:
message
- the String value written to standard err.args
- an Object array containing arguments to replace the placeholder values in the message.- See Also:
System.err
,debug(String, Object...)
-
redirectOutput
protected void redirectOutput(DistributedSystem distributedSystem) throws java.io.IOException
Redirects the standard out and standard err to the configured log file as specified in the GemFire distributed system properties.- Parameters:
distributedSystem
- the GemFire model for a distributed system.- Throws:
java.io.IOException
- if the standard out and err redirection was unsuccessful.
-
version
public java.lang.String version()
Gets the version of GemFire currently running.- Returns:
- a String representation of GemFire's version.
-
-