Package com.elastisys.autoscaler.server
Class AutoScalerFactoryServer
- java.lang.Object
-
- com.elastisys.autoscaler.server.AutoScalerFactoryServer
-
public class AutoScalerFactoryServer extends java.lang.ObjectMain class with factory method for creating a REST API server that exposes anAutoScalerFactory.- See Also:
AutoScalerFactory,AutoScalerFactoryRestApi
-
-
Constructor Summary
Constructors Constructor Description AutoScalerFactoryServer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.eclipse.jetty.server.ServercreateServer(com.elastisys.autoscaler.core.autoscaler.factory.AutoScalerFactory factory, AutoScalerFactoryServerOptions options)Creates a HTTPS server that serves REST API requests for a givenAutoScalerFactory.static voidlaunchServer(AutoScalerFactoryServerOptions options, java.util.Map<java.lang.String,java.lang.String> addonSubsystems)Launches anAutoScalerFactoryServerwith the options and add-on subsystems.static java.util.Map<java.lang.String,java.lang.String>loadAddons(java.lang.String addonConfigPath)Loads any add-on subsystems from the given file path.static voidmain(java.lang.String[] args)Parses command-line arguments and start an HTTPS server that serves REST API requests for anAutoScalerFactory.static AutoScalerFactoryServerOptionsparseCommandLine(java.lang.String[] args)Parses the command-line arguments and returns theAutoScalerFactoryServerOptionsthat were specified.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionParses command-line arguments and start an HTTPS server that serves REST API requests for anAutoScalerFactory. A failure to parse the command-line arguments will cause the program to print a usage message and exit with an error code. The function blocks until the started server is stopped.- Parameters:
args- The command-line arguments.- Throws:
java.lang.Exception
-
launchServer
public static void launchServer(AutoScalerFactoryServerOptions options, java.util.Map<java.lang.String,java.lang.String> addonSubsystems) throws java.lang.IllegalArgumentException, java.lang.InterruptedException
Launches anAutoScalerFactoryServerwith the options and add-on subsystems. The function blocks until the started server is stopped.- Parameters:
options- A set of options that control the behavior of the server.addonSubsystems- The collection of add-on subsystems that will be added to allAutoScalerinstances theAutoScalerFactorycreates. These add-on subsystems are not strictly necessary for theAutoScalerto operate, but may extend it with additional functionality. Accounting and high-availability are two examples of what such add-on subsystems could achieve. Keys are names, such asaccountingSubsystem, and values are class names, such ascom.elastisys.AccountingSubsystemImpl.- Throws:
java.lang.IllegalArgumentExceptionjava.lang.InterruptedException
-
parseCommandLine
public static AutoScalerFactoryServerOptions parseCommandLine(java.lang.String[] args)
Parses the command-line arguments and returns theAutoScalerFactoryServerOptionsthat were specified. Will exit the process in case parsing failed or if--helpor--versionwas specified.- Parameters:
args- Command-line arguments.- Returns:
-
createServer
public static org.eclipse.jetty.server.Server createServer(com.elastisys.autoscaler.core.autoscaler.factory.AutoScalerFactory factory, AutoScalerFactoryServerOptions options)Creates a HTTPS server that serves REST API requests for a givenAutoScalerFactory. The created server is returned with theAutoScalerFactoryREST API deployed, but in an unstarted state, so the client is responsible for starting the server. The behavior of the HTTPS server is controlled via a set ofAutoScalerFactoryServerOptions.- Parameters:
factory- TheAutoScalerFactoryto be published by theServer. Note: assumed to be passed in a configured state.options- A set of options that control the behavior of the HTTPS server.- Returns:
- The created
Server. - Throws:
java.lang.Exception- Thrown on a failure to initialize theAutoScalerFactoryor create the server.
-
loadAddons
public static java.util.Map<java.lang.String,java.lang.String> loadAddons(java.lang.String addonConfigPath)
Loads any add-on subsystems from the given file path. On failure to parse the JSON file, an exception is raised.- Parameters:
addonConfigFile- A file system path.- Returns:
- The collection of add-on subsystems to configure the autoscaler server with.
-
-