public class ProcessClientSpawner extends ClientSpawner
This class is tricky to understand because the main part of it runs on the server while the
TemporaryClientTask inner class is serialized and sent down to execute on the
client side. That client side code then calls methods which are implemented as a remote
object with the Spawner interface, which the server portions of this class implement.
The spawner process will connect to the server using a secure socket and temporary credentials to establish a secure session. If that works, it will lookup the credentials to use for spawning the client based on a unique UUID for this spawning session. Using those credentials it will start the client and notify the server about success or failure.
This notification must not be treated as the client process authenticated successfully; it needs to be interpreted as a signal that the temporary connection has finished successfully.
| Modifier and Type | Class and Description |
|---|---|
private static class |
ProcessClientSpawner.TemporaryClientTask
On P2J client side, it will do custom work after authenticating using the temporary
credentials.
|
| Modifier and Type | Field and Description |
|---|---|
private ProcessClientBuilder |
cb
The
ClientBuilder used to spawn the P2J client process. |
private java.lang.String |
process
The P2J process ID being spawned by this instance.
|
CLIENT_STARTUP_TIMEOUT_SEC| Constructor and Description |
|---|
ProcessClientSpawner(java.lang.String process,
java.lang.String osUser,
java.lang.String osPass,
java.util.Map<java.lang.String,java.lang.String> env)
Create a new spawner for P2J processes.
|
| Modifier and Type | Method and Description |
|---|---|
protected ProcessClientBuilder |
getBuilder()
Get a
ProcessClientBuilder used to spawn P2J clients for the target process. |
ProcessBuilderParameters |
getBuildParams()
Get
ProcessBuilderParameters used to spawn P2J clients. |
private java.util.Map<java.lang.String,java.lang.Object> |
getServerData()
Get a map containing the P2J process secure credentials: the serialized process keystore and
trust store and other details, like target aliases in the keystore and truststore.
|
TemporaryClient |
getTemporaryClient(java.lang.String uuid,
java.lang.String projectToken)
Get a
TemporaryClient worker which will do the work after authenticating on the P2J
server using the temporary credentials. |
static void |
launch(java.lang.String batchProcess)
Launch the specified batch process.
|
static void |
launch(java.lang.String batchProcess,
java.util.Map<java.lang.String,java.lang.String> env)
Launch the specified batch process.
|
void |
releaseClient()
Releases the system resources for this spawned client.
|
clientIsReady, spawn, spawnprivate final ProcessClientBuilder cb
ClientBuilder used to spawn the P2J client process.private java.lang.String process
public ProcessClientSpawner(java.lang.String process,
java.lang.String osUser,
java.lang.String osPass,
java.util.Map<java.lang.String,java.lang.String> env)
process - The P2J process ID.env - Map of additional environment properties, in the key=value form.public ProcessBuilderParameters getBuildParams()
ProcessBuilderParameters used to spawn P2J clients.getBuildParams in class ClientSpawnerpublic static void launch(java.lang.String batchProcess)
If the P2J process is linked with an appserver, it will delegate the launching to
AppServerLauncher.launch(String). Else, it will use the spawner infrastructure to start a P2J client.
batchProcess - The name of the batch process to be launched.public static void launch(java.lang.String batchProcess,
java.util.Map<java.lang.String,java.lang.String> env)
If the P2J process is linked with an appserver, it will delegate the launching to
AppServerLauncher.launch(String). Else, it will use the spawner infrastructure to start a P2J client.
batchProcess - The name of the batch process to be launched.env - Map of additional environment properties, in the key=value form.private java.util.Map<java.lang.String,java.lang.Object> getServerData()
protected ProcessClientBuilder getBuilder()
ProcessClientBuilder used to spawn P2J clients for the target process.getBuilder in class ClientSpawnerpublic TemporaryClient getTemporaryClient(java.lang.String uuid, java.lang.String projectToken)
TemporaryClient worker which will do the work after authenticating on the P2J
server using the temporary credentials.uuid - The client identifier uuid.projectToken - The project token to be set for the temporary session.public void releaseClient()
SpawnerListener