Class Modules
java.lang.Object
com.google.appengine.tools.development.Modules
- All Implemented Interfaces:
ModulesController,ModulesFilterHelper
- Direct Known Subclasses:
Modules,ModulesEE8
Manager for
DevAppServer servers.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.appengine.tools.development.ModulesController
ModulesController.ModuleState -
Field Summary
Fields inherited from interface com.google.appengine.tools.development.ModulesController
MODULES_CONTROLLER_ATTRIBUTE_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacquireServingPermit(String moduleName, int instanceNumber, boolean allowQueueOnBackends) This method guards access to module instances to limit the number of concurrent requests.booleancheckInstanceExists(String moduleName, int instance) Verifies if a specific module instance is configured.booleancheckInstanceStopped(String moduleName, int instance) Verifies if a specific existing module or backend instance is stopped.booleancheckModuleExists(String moduleName) Verifies if a specific module or backend is configured.booleancheckModuleStopped(String serverName) Verifies if a specific existing module or backend is stopped.voidvoidstatic ModulescreateModules(ApplicationConfigurationManager applicationConfigurationManager, String serverInfo, File externalResourceDir, String address, DevAppServer devAppServer) booleanexpectsGeneratedStartRequests(String moduleName, int instance) Returns true if internally generated "/_ah/start" requests are provided for the specified module or backend instance.intgetAndReserveFreeInstance(String moduleName) Acquires a serving permit for an instance with available capacity and returns the instance id.getDefaultVersion(String moduleName) Returns the default version for a named module.getHostname(String moduleName, String version, int instance) Returns the host name of the requested module version instance.static ModulesReturns all the known module names.getModuleState(String moduleName) Returns the current state of this module.intgetNumInstances(String moduleName, String version) Returns the number of instances for the requested module version.intReturns the port for the specified module of backend instance.getScalingType(String moduleName) Returns the type of scaling in use for this module.getVersions(String moduleName) Returns all known versions of the requested module.booleanisLoadBalancingInstance(String moduleName, int instance) Returns true if the specified module or backend instance is a load balancing instance which will forward requests to an available instance.voidreturnServingPermit(String moduleName, int instance) Returns a serving permit after a request has completed.voidsetApiProxyDelegate(com.google.apphosting.api.ApiProxy.Delegate<?> apiProxyDelegate) voidsetNumInstances(String moduleName, String version, int numInstances) Sets the number of instances for the requested module version.voidshutdown()voidstartModule(String moduleName, String version) Starts the requested module version.voidstartup()voidstopModule(String moduleName, String version) Stops the requested module version.
-
Constructor Details
-
Modules
-
-
Method Details
-
createModules
public static Modules createModules(ApplicationConfigurationManager applicationConfigurationManager, String serverInfo, File externalResourceDir, String address, DevAppServer devAppServer) -
getInstance
-
shutdown
- Throws:
Exception
-
configure
- Throws:
Exception
-
setApiProxyDelegate
public void setApiProxyDelegate(com.google.apphosting.api.ApiProxy.Delegate<?> apiProxyDelegate) -
createConnections
- Throws:
Exception
-
startup
- Throws:
Exception
-
getMainModule
-
getLocalServerEnvironment
-
getModule
-
getModuleNames
Description copied from interface:ModulesControllerReturns all the known module names.- Specified by:
getModuleNamesin interfaceModulesController
-
getVersions
public Iterable<String> getVersions(String moduleName) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns all known versions of the requested module.- Specified by:
getVersionsin interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configuredinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE
-
getDefaultVersion
public String getDefaultVersion(String moduleName) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns the default version for a named module.- Specified by:
getDefaultVersionin interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configuredinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE
-
getNumInstances
public int getNumInstances(String moduleName, String version) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns the number of instances for the requested module version.- Specified by:
getNumInstancesin interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configured andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUEif the requested version is not configured.invalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_VERSION_VALUE
-
setNumInstances
public void setNumInstances(String moduleName, String version, int numInstances) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerSets the number of instances for the requested module version.- Specified by:
setNumInstancesin interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configured andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUEif the requested version is not configured for setting instancesinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_VERSION_VALUE.ErrorCode#INVALID_INSTANCESif numInstances is not a legal value.
-
getHostname
public String getHostname(String moduleName, String version, int instance) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns the host name of the requested module version instance.- Specified by:
getHostnamein interfaceModulesController- Parameters:
moduleName- the moduleName whose host we return.version- the version whose host we return.instance- the instance whose host we return orinvalid reference
.tools.development.LocalEnvironment#MAIN_INSTANCE- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configured andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUEif the requested version is not configured andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_VERSION_VALUEif the requested instance is not configured.invalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_INSTANCES_VALUE
-
getModuleState
public ModulesController.ModuleState getModuleState(String moduleName) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns the current state of this module.- Specified by:
getModuleStatein interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configuredinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE
-
getScalingType
public String getScalingType(String moduleName) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerReturns the type of scaling in use for this module.- Specified by:
getScalingTypein interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException- with error codeif the requested module is not configuredinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE
-
startModule
public void startModule(String moduleName, String version) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerStarts the requested module version.- Specified by:
startModulein interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException-if the requested module is not a configured manual scaling module andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE.ErrorCode#INVALID_VERSION_VALUEif the requested version is not configured or is not a manual scaling module and.ModulesServiceError.ErrorCode#UNEXPECTED_STATEif the module instance is not stopped and ready to be started.
-
stopModule
public void stopModule(String moduleName, String version) throws com.google.apphosting.api.ApiProxy.ApplicationException Description copied from interface:ModulesControllerStops the requested module version.- Specified by:
stopModulein interfaceModulesController- Throws:
com.google.apphosting.api.ApiProxy.ApplicationException-if the requested module is not a configured manual scaling module andinvalid reference
.modules.ModulesServicePb.ModulesServiceError.ErrorCode#INVALID_MODULE_VALUE.ModulesServiceError.ErrorCode#INVALID_VERSION_VALUEif the requested version is not configured or is not a manual scaling module and.ErrorCode#UNEXPECTED_STATEif the module instance is not running and ready to be stopped.
-
acquireServingPermit
public boolean acquireServingPermit(String moduleName, int instanceNumber, boolean allowQueueOnBackends) Description copied from interface:ModulesFilterHelperThis method guards access to module instances to limit the number of concurrent requests. Each request running on a module instance must acquire a serving permit. If no permits are available a 500 response should be sent.- Specified by:
acquireServingPermitin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend for which to acquire a permit.instanceNumber- The server instance for which to acquire a permit.allowQueueOnBackends- If set to false the method will return instantly, if set to true (and the specified server allows pending queues) this method can block for up to 10 s waiting for a serving permit to become available.- Returns:
- true if a permit was acquired, false otherwise
-
getAndReserveFreeInstance
Description copied from interface:ModulesFilterHelperAcquires a serving permit for an instance with available capacity and returns the instance id. If no instance has capacity this returns -1.For backends which support queued requests this may block for a limited time waiting for an instance to become available (see
for details). Supported for modules that support load balancing (currentlyinvalid reference
AbstractBackendServers#getAndReserveFreeInstanceManualModule). The client can check withModulesFilterHelper.isLoadBalancingInstance(String, int).- Specified by:
getAndReserveFreeInstancein interfaceModulesFilterHelper- Parameters:
moduleName- Name of the requested module or backend.- Returns:
- the instance id of an available server instance, or -1 if no instance is available.
-
returnServingPermit
Description copied from interface:ModulesFilterHelperReturns a serving permit after a request has completed.- Specified by:
returnServingPermitin interfaceModulesFilterHelper- Parameters:
moduleName- The server nameinstance- The server instance
-
checkInstanceExists
Description copied from interface:ModulesFilterHelperVerifies if a specific module instance is configured.- Specified by:
checkInstanceExistsin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend nameinstance- The module instance- Returns:
- true if the module instance is configured and false otherwise.
-
checkModuleExists
Description copied from interface:ModulesFilterHelperVerifies if a specific module or backend is configured.- Specified by:
checkModuleExistsin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend name- Returns:
- true if the module is configured and false otherwise.
-
checkModuleStopped
Description copied from interface:ModulesFilterHelperVerifies if a specific existing module or backend is stopped.- Specified by:
checkModuleStoppedin interfaceModulesFilterHelper- Parameters:
serverName- The module or backend name- Returns:
- true if the module is stopped, false otherwise.
-
checkInstanceStopped
Description copied from interface:ModulesFilterHelperVerifies if a specific existing module or backend instance is stopped.- Specified by:
checkInstanceStoppedin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backedn nameinstance- The module instance- Returns:
- true if the module instance is stopped and false otherwise.
-
isLoadBalancingInstance
Description copied from interface:ModulesFilterHelperReturns true if the specified module or backend instance is a load balancing instance which will forward requests to an available instance.- Specified by:
isLoadBalancingInstancein interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend nameinstance- The requested instance which can be -1.
-
expectsGeneratedStartRequests
Description copied from interface:ModulesFilterHelperReturns true if internally generated "/_ah/start" requests are provided for the specified module or backend instance.Http "/_ah/start" requests for instances where this returns true are presumed to be internally generated and receive special treatment by
DevAppServerModulesFilter. Requests to "/_ah/start" for other instances are treated as normal requests.- Specified by:
expectsGeneratedStartRequestsin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend nameinstance- The module instance which can be -1.
-
getPort
Description copied from interface:ModulesFilterHelperReturns the port for the specified module of backend instance.- Specified by:
getPortin interfaceModulesFilterHelper- Parameters:
moduleName- The module or backend nameinstance- The requested instance which can be -1.
-