@ThreadSafe public final class JobContext extends Object implements Closeable
JobContext
for interacting with job service.
NOTE: The context maintains a pool of job master clients that is already thread-safe.
Synchronizing JobContext
methods could lead to deadlock: thread A attempts to acquire a
client when there are no clients left in the pool and blocks holding a lock on the
JobContext
, when thread B attempts to release a client it owns it is unable to do so,
because thread A holds the lock on JobContext
.
Modifier and Type | Method and Description |
---|---|
JobMasterClient |
acquireMasterClient()
Acquires a job master client from the job master client pool.
|
CloseableResource<JobMasterClient> |
acquireMasterClientResource()
Acquires a job master client from the job master client pool.
|
void |
close()
Closes all the resources associated with the context.
|
static JobContext |
create(AlluxioConfiguration alluxioConf,
UserState userState)
Creates a job context.
|
InetSocketAddress |
getJobMasterAddress() |
void |
releaseMasterClient(JobMasterClient masterClient)
Releases a job master client into the job master client pool.
|
public static JobContext create(AlluxioConfiguration alluxioConf, UserState userState)
alluxioConf
- Alluxio configurationuserState
- user statepublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public InetSocketAddress getJobMasterAddress() throws UnavailableException
UnavailableException
- if the master address cannot be determinedpublic JobMasterClient acquireMasterClient()
public void releaseMasterClient(JobMasterClient masterClient)
masterClient
- a job master client to releasepublic CloseableResource<JobMasterClient> acquireMasterClientResource()
Closeable
.Copyright © 2023. All Rights Reserved.