Package alluxio.client.job
Class JobContext
- java.lang.Object
-
- alluxio.client.job.JobContext
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
@ThreadSafe public final class JobContext extends java.lang.Object implements java.io.CloseableA shared context that isolates all operations within the same JVM. Usually, one user only needs one instance ofJobContextfor interacting with job service.NOTE: The context maintains a pool of job master clients that is already thread-safe. Synchronizing
JobContextmethods 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 theJobContext, when thread B attempts to release a client it owns it is unable to do so, because thread A holds the lock onJobContext.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JobMasterClientacquireMasterClient()Acquires a job master client from the job master client pool.alluxio.resource.CloseableResource<JobMasterClient>acquireMasterClientResource()Acquires a job master client from the job master client pool.voidclose()Closes all the resources associated with the context.static JobContextcreate(alluxio.conf.AlluxioConfiguration alluxioConf, alluxio.security.user.UserState userState)Creates a job context.java.net.InetSocketAddressgetJobMasterAddress()voidreleaseMasterClient(JobMasterClient masterClient)Releases a job master client into the job master client pool.
-
-
-
Method Detail
-
create
public static JobContext create(alluxio.conf.AlluxioConfiguration alluxioConf, alluxio.security.user.UserState userState)
Creates a job context.- Parameters:
alluxioConf- Alluxio configurationuserState- user state- Returns:
- the context
-
close
public void close() throws java.io.IOExceptionCloses all the resources associated with the context. Make sure all the resources are released back to this context before calling this close. After closing the context, all the resources that acquired from this context might fail.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getJobMasterAddress
public java.net.InetSocketAddress getJobMasterAddress() throws alluxio.exception.status.UnavailableException- Returns:
- the job master address
- Throws:
alluxio.exception.status.UnavailableException- if the master address cannot be determined
-
acquireMasterClient
public JobMasterClient acquireMasterClient()
Acquires a job master client from the job master client pool.- Returns:
- the acquired job master client
-
releaseMasterClient
public void releaseMasterClient(JobMasterClient masterClient)
Releases a job master client into the job master client pool.- Parameters:
masterClient- a job master client to release
-
acquireMasterClientResource
public alluxio.resource.CloseableResource<JobMasterClient> acquireMasterClientResource()
Acquires a job master client from the job master client pool. The resource isCloseable.- Returns:
- the acquired job master client resource
-
-