@ThreadSafe
public final class JobContext
extends java.lang.Object
implements java.io.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.
|
java.net.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 java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic java.net.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 © 2022. All Rights Reserved.