Class JobContext

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    @ThreadSafe
    public final class JobContext
    extends java.lang.Object
    implements java.io.Closeable
    A shared context that isolates all operations within the same JVM. Usually, one user only needs one instance of 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.

    • Method Detail

      • create

        public static JobContext create​(alluxio.conf.AlluxioConfiguration alluxioConf,
                                        alluxio.security.user.UserState userState)
        Creates a job context.
        Parameters:
        alluxioConf - Alluxio configuration
        userState - user state
        Returns:
        the context
      • close

        public void close()
                   throws java.io.IOException
        Closes 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:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.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 is Closeable.
        Returns:
        the acquired job master client resource