public abstract class ClientSpawner extends java.lang.Object implements SpawnerListener
Actual implementations of this class will need to provide the following info:
ClientBuilder instance, to spawn the P2J client process.ClientBuilderParameters instance, to configure the P2J client.SpawnerListener.getTemporaryClient(String, String), with the work
needed to be done after authenticating with the temporary credentials.| Modifier and Type | Field and Description |
|---|---|
static int |
CLIENT_STARTUP_TIMEOUT_SEC
Timeout
|
private java.util.concurrent.CountDownLatch |
clientStartupCountDown
Synchronize
|
private static java.util.concurrent.ExecutorService |
GENERIC_EXECUTOR
Executor service for simple tasks that don't throw exceptions.
|
private static CentralLogger |
LOG
Logger.
|
private boolean |
ready
Flag indicating the P2J client has been started.
|
| Constructor and Description |
|---|
ClientSpawner() |
| Modifier and Type | Method and Description |
|---|---|
void |
clientIsReady(java.lang.String data)
Notify when the client has started.
|
protected abstract ClientBuilder |
getBuilder()
Get a
ClientBuilder used to spawn P2J clients. |
abstract ClientBuilderParameters |
getBuildParams()
Get
ClientBuilderParameters used to spawn P2J clients. |
void |
spawn()
Launch a P2J client local or remote.
|
int |
spawn(WebClientAllocator allocator,
java.lang.String[] requestParameters)
Launch a P2J client local or remote.
|
private int |
spawnLocal(java.util.Map<java.lang.String,java.lang.String> environmentMap,
WebClientAllocator allocator,
java.lang.String[] requestParameters,
java.util.concurrent.atomic.AtomicBoolean isSpawnerRunning)
Launch a new local P2J client.
|
private int |
spawnRemote(Brokers brokers,
java.util.Map<java.lang.String,java.lang.String> environmentMap,
WebClientAllocator allocator,
java.lang.String[] requestParameters)
Launch a new remote P2J client.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTemporaryClient, releaseClientpublic static final int CLIENT_STARTUP_TIMEOUT_SEC
private static final CentralLogger LOG
private static final java.util.concurrent.ExecutorService GENERIC_EXECUTOR
private java.util.concurrent.CountDownLatch clientStartupCountDown
private volatile boolean ready
public abstract ClientBuilderParameters getBuildParams()
ClientBuilderParameters used to spawn P2J clients.protected abstract ClientBuilder getBuilder()
ClientBuilder used to spawn P2J clients.public void spawn()
public int spawn(WebClientAllocator allocator, java.lang.String[] requestParameters)
allocator - The web client allocatorrequestParameters - The given requests parametersprivate int spawnLocal(java.util.Map<java.lang.String,java.lang.String> environmentMap,
WebClientAllocator allocator,
java.lang.String[] requestParameters,
java.util.concurrent.atomic.AtomicBoolean isSpawnerRunning)
throws java.io.IOException
environmentMap - Environment variables.allocator - The web client allocatorrequestParameters - The given requests parametersisSpawnerRunning - The thread-safe boolean flag to notify the logger to stop listening for spawner msgs.java.io.IOExceptionprivate int spawnRemote(Brokers brokers, java.util.Map<java.lang.String,java.lang.String> environmentMap, WebClientAllocator allocator, java.lang.String[] requestParameters)
brokers - Wrapper for list of available brokers.environmentMap - Environment variables.allocator - The web client allocatorrequestParameters - The given requests parameterspublic void clientIsReady(java.lang.String data)
clientIsReady in interface SpawnerListenerdata - Custom data sent by the P2J client back to the server.