Class GramJob

  • All Implemented Interfaces:
    GRAMConstants
    Direct Known Subclasses:
    GramJobRun

    public class GramJob
    extends java.lang.Object
    implements GRAMConstants
    This class represents a simple gram job. It allows for submitting a job to a gatekeeper, canceling it, sending a signal command and registering and unregistering from callback.
    • Field Detail

      • credential

        private org.ietf.jgss.GSSCredential credential
      • rsl

        private java.lang.String rsl
      • status

        protected int status
      • error

        protected int error
      • exitCode

        protected int exitCode
      • listeners

        private java.util.Vector listeners
    • Constructor Detail

      • GramJob

        public GramJob​(java.lang.String rsl)
        Creates a gram job with specified rsl with default user credentials.
        Parameters:
        rsl - resource specification string
      • GramJob

        public GramJob​(org.ietf.jgss.GSSCredential cred,
                       java.lang.String rsl)
        Creates a gram job with specified rsl and user credentials.
        Parameters:
        cred - user credentials
        rsl - resource specification string
    • Method Detail

      • addListener

        public void addListener​(GramJobListener listener)
        Add a listener to the GramJob. The listener will be notified whenever the status of the GramJob changes.
        Parameters:
        listener - The object that wishes to receive status updates.
        See Also:
        GramJobListener
      • removeListener

        public void removeListener​(GramJobListener listener)
        Remove a listener from the GramJob. The listener will no longer be notified of status changes for the GramJob.
        Parameters:
        listener - The object that wishes to stop receiving status updates.
        See Also:
        GramJobListener
      • getRSL

        public java.lang.String getRSL()
        Gets the rsl of this job.
        Returns:
        resource specification string
      • getCredentials

        public org.ietf.jgss.GSSCredential getCredentials()
        Gets the credentials of this job.
        Returns:
        job credentials. If null none were set.
      • setCredentials

        public void setCredentials​(org.ietf.jgss.GSSCredential credential)
        Sets credentials of the job
        Parameters:
        credential - user credentials
      • setID

        public void setID​(java.lang.String jobUrl)
                   throws java.net.MalformedURLException
        Sets the job handle. It is automatically set after the job successfuly has been successfuly started on a gatekeeper.
        Parameters:
        jobUrl - job handle in form of url
        Throws:
        java.net.MalformedURLException - if the job handle is invalid
      • getID

        public GlobusURL getID()
        Gets the job handle of this job.
        Returns:
        job handle
      • getIDAsString

        public java.lang.String getIDAsString()
        Gets the job handle of this job and returns it as a string representaion.
        Returns:
        job handle as string
      • getStatus

        public int getStatus()
        Gets the current status of this job.
        Returns:
        current job status
      • setStatus

        protected void setStatus​(int status)
        Sets the status of the job. User should not call this function.
        Parameters:
        status - status of the job
      • setExitCode

        protected void setExitCode​(int exitCode)
        Sets the job exit code. This method is called internally and should not be used by client code.
        Parameters:
        exitCode - the job exit code
      • getExitCode

        public int getExitCode()

        Allows querying the job exit code. It only makes sense to retrieve the exit code after the job has completed. If the job has not completed, or if the service did not provide an exit code for this job, this method will return 0 and isExitCodeValid() will return false.

        Returns:
        the job exit code or 0 if the service did not provide one or the job has not completed.
      • isExitCodeValid

        public boolean isExitCodeValid()

        Can be used to determine whether the job exit code returned by getExitCode() is valid.

        This method will return false if either of the following is true:

        • The job has not completed yet
        • The service did not provide an exit code for the job
        Returns:
        a boolean value indicating whether the value returned by getExitCode() represents the actual process exit code of this job.
      • request

        public void request​(java.lang.String contact)
                     throws GramException,
                            org.ietf.jgss.GSSException
        Submits a job to the specified gatekeeper as an interactive job. Performs limited delegation.
        Parameters:
        contact - the resource manager contact. The contact can be specified in number of ways for 1.1.3 gatekeepers:
        host
        host:port
        host:port/service
        host/service
        host:/service
        host::subject
        host:port:subject
        host/service:subject
        host:/service:subject
        host:port/service:subject
        For 1.1.2 gatekeepers full contact string must be specifed.
        Throws:
        GramException - if error occurs during job submission.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • request

        public void request​(java.lang.String contact,
                            boolean batch)
                     throws GramException,
                            org.ietf.jgss.GSSException
        Submits a job to the specified gatekeeper either as an interactive or batch job. Performs limited delegation.
        Parameters:
        contact - the resource manager contact.
        batch - specifies if the job should be submitted as a batch job.
        Throws:
        GramException - if error occurs during job submission.
        org.ietf.jgss.GSSException - if user credentials are invalid.
        See Also:
        for detailed resource manager contact specification.
      • request

        public void request​(java.lang.String contact,
                            boolean batch,
                            boolean limitedDelegation)
                     throws GramException,
                            org.ietf.jgss.GSSException
        Submits a job to the specified gatekeeper either as an interactive or batch job. It can perform limited or full delegation.
        Parameters:
        contact - the resource manager contact.
        batch - specifies if the job should be submitted as a batch job.
        limitedDelegation - true for limited delegation, false for full delegation.
        Throws:
        GramException - if error occurs during job submission.
        org.ietf.jgss.GSSException - if user credentials are invalid.
        See Also:
        for detailed resource manager contact specification.
      • renew

        public void renew​(org.ietf.jgss.GSSCredential newCred)
                   throws GramException,
                          org.ietf.jgss.GSSException
        Requests that the job's delegated credentials be renewed/refreshed. Uses limited delegation.
        Parameters:
        newCred - The credentials to use in the delegation process
        Throws:
        GramException - if a connection/comunication error occurs or if delegation failed
        org.ietf.jgss.GSSException - if a GSSAPI error occurs
      • renew

        public void renew​(org.ietf.jgss.GSSCredential newCred,
                          boolean limitedDelegation)
                   throws GramException,
                          org.ietf.jgss.GSSException
        Requests that the job's delegated credentials be renewed/refreshed.
        Parameters:
        newCred - The credentials to use in the delegation process
        limitedDelegation - Whether to use limited or full delegated proxy
        Throws:
        GramException - if a connection/comunication error occurs or if delegation failed
        org.ietf.jgss.GSSException - if a GSSAPI error occurs
      • cancel

        public void cancel()
                    throws GramException,
                           org.ietf.jgss.GSSException
        Cancels a job.
        Throws:
        GramException - if error occurs during job cancelation.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • bind

        public void bind()
                  throws GramException,
                         org.ietf.jgss.GSSException
        Registers a callback listener for this job. (Reconnects to the job)
        Throws:
        GramException - if error occurs during job registration.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • unbind

        public void unbind()
                    throws GramException,
                           org.ietf.jgss.GSSException
        Unregisters a callback listener for this job. (Disconnects from the job)
        Throws:
        GramException - if error occurs during job unregistration.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • signal

        public int signal​(int signal,
                          java.lang.String arg)
                   throws GramException,
                          org.ietf.jgss.GSSException
        Sends a signal command to the job.
        Parameters:
        signal - signal type
        arg - argument of signal
        Throws:
        GramException - if error occurs during signalization.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • signal

        public int signal​(int signal)
                   throws GramException,
                          org.ietf.jgss.GSSException
        Sends a signal command to the job.
        Parameters:
        signal - signal type
        Throws:
        GramException - if error occurs during signalization.
        org.ietf.jgss.GSSException - if user credentials are invalid.
      • setError

        protected void setError​(int code)
        Sets the error code of the job. Note: User should not use this method.
        Parameters:
        code - error code
      • getError

        public int getError()
        Gets the error of the job.
        Returns:
        error number of the job.
      • toString

        public java.lang.String toString()
        Returns string representation of this job.
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation of this job. Useful for debugging.
      • getStatusAsString

        public java.lang.String getStatusAsString()
        Get the status of the GramJob.
        Returns:
        string representing the status of the GramJob. This String is useful for user-readable output.
      • getStatusAsString

        public static java.lang.String getStatusAsString​(int status)
        Convert the status of a GramJob from an integer to a string. This method is not typically called by users.
        Returns:
        string representing the status of the GramJob passed as an argument.