public abstract class AbstractLocalDeployerSupport extends Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractLocalDeployerSupport.Instance |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SERVER_PORT |
protected org.slf4j.Logger |
logger |
static String |
SPRING_APPLICATION_JSON |
protected static Set<Integer> |
usedPorts |
Constructor and Description |
---|
AbstractLocalDeployerSupport(LocalDeployerProperties properties)
Instantiates a new abstract deployer support.
|
Modifier and Type | Method and Description |
---|---|
protected ProcessBuilder |
buildProcessBuilder(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request,
Map<String,String> appInstanceEnv,
Optional<Integer> appInstanceNumber,
String deploymentId)
Builds the process builder.
|
protected String |
buildRemoteDebugInstruction(LocalDeployerProperties deployerProperties,
String deploymentId,
int instanceIndex,
int port) |
protected org.springframework.web.client.RestTemplate |
buildRestTemplate(LocalDeployerProperties properties)
Builds a
RestTemplate used for calling app's shutdown endpoint. |
protected int |
calcServerPort(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request,
boolean useDynamicPort,
Map<String,String> appInstanceEnvVars) |
protected int |
calculateDebugPort(LocalDeployerProperties deployerProperties,
int instanceIndex)
Gets the base debug port value and adds the instance count.
|
protected boolean |
containsValidDebugPort(LocalDeployerProperties deployerProperties,
String deploymentId)
Determines if there is a valid debug port specified in the deployment
properites.
|
protected org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo |
createRuntimeEnvironmentInfo(Class<?> spiClass,
Class<?> implementationClass)
Create the RuntimeEnvironmentInfo.
|
protected Map<String,String> |
formatApplicationProperties(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request,
Map<String,String> appInstanceEnvToUse) |
protected LocalDeployerProperties |
getLocalDeployerProperties()
Gets the local deployer properties.
|
int |
getRandomPort() |
protected boolean |
isAlive(Process process) |
protected Integer |
isServerPortKeyPresentOnArgs(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request) |
protected boolean |
shouldInheritLogging(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)
Will check if
LocalDeployerProperties.INHERIT_LOGGING is set by checking
deployment properties. |
protected void |
shutdownAndWait(AbstractLocalDeployerSupport.Instance instance)
Shut down the
Process backing the application AbstractLocalDeployerSupport.Instance . |
protected boolean |
useSpringApplicationJson(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request) |
protected final org.slf4j.Logger logger
public static final String SPRING_APPLICATION_JSON
public static final int DEFAULT_SERVER_PORT
public AbstractLocalDeployerSupport(LocalDeployerProperties properties)
properties
- the local deployer propertiesprotected org.springframework.web.client.RestTemplate buildRestTemplate(LocalDeployerProperties properties)
RestTemplate
used for calling app's shutdown endpoint. If
needed can be overridden from an implementing class. This default
implementation sets connection and read timeouts for
SimpleClientHttpRequestFactory
and configures RestTemplate
to
use that factory. If shutdown timeout in properties negative, returns default
RestTemplate
which doesn't use timeouts.properties
- the local deployer propertiesprotected String buildRemoteDebugInstruction(LocalDeployerProperties deployerProperties, String deploymentId, int instanceIndex, int port)
protected org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo createRuntimeEnvironmentInfo(Class<?> spiClass, Class<?> implementationClass)
protected final LocalDeployerProperties getLocalDeployerProperties()
protected ProcessBuilder buildProcessBuilder(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, Map<String,String> appInstanceEnv, Optional<Integer> appInstanceNumber, String deploymentId)
ProcessBuilder
.request
- the requestappInstanceEnv
- the instance environment variablesprotected Map<String,String> formatApplicationProperties(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, Map<String,String> appInstanceEnvToUse)
protected void shutdownAndWait(AbstractLocalDeployerSupport.Instance instance)
Process
backing the application AbstractLocalDeployerSupport.Instance
.
If the application exposes a /shutdown
endpoint, that will be
invoked followed by a wait that will not exceed the number of seconds
indicated by LocalDeployerProperties.shutdownTimeout
. If the
timeout period is exceeded (or if the /shutdown
endpoint is not exposed),
the process will be shut down via Process.destroy()
.instance
- the application instance to shut downprotected boolean isAlive(Process process)
protected boolean containsValidDebugPort(LocalDeployerProperties deployerProperties, String deploymentId)
deployerProperties
- the deployment properties to validatedeploymentId
- the deployment Id for logging purposesprotected int calculateDebugPort(LocalDeployerProperties deployerProperties, int instanceIndex)
containsValidDebugPort(LocalDeployerProperties, String)
has been
called before to validate the deployment properties.deployerProperties
- deployment properties with a valid value of debug
portinstanceIndex
- the index of the application to deployprotected boolean useSpringApplicationJson(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)
protected int calcServerPort(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request, boolean useDynamicPort, Map<String,String> appInstanceEnvVars)
protected boolean shouldInheritLogging(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)
LocalDeployerProperties.INHERIT_LOGGING
is set by checking
deployment properties.public int getRandomPort()
protected Integer isServerPortKeyPresentOnArgs(org.springframework.cloud.deployer.spi.core.AppDeploymentRequest request)
Copyright © 2019 Pivotal Software, Inc.. All rights reserved.