Package alluxio

Class ClientContext

  • Direct Known Subclasses:
    MasterClientContext

    @PublicApi
    public class ClientContext
    extends java.lang.Object
    A ClientContext contains information required and pertaining to making network connections and performing operations with remote Alluxio processes. The ClientContext should only contain the information which is necessary to make those connections. A ClientContext are not expensive objects to create, however it is important to be aware that if the configuration with which the instance is created does not have the cluster default configuration loaded that any new clients which use the context will need to load the cluster defaults upon connecting to the Alluxio master. Path level configuration may not be needed for any ClientContext, it is currently only used in BaseFileSystem, so it is initially lazily loaded by FileSystemContext when it's needed. Ideally only a single ClientContext should be needed when initializing an application. This will use as few network resources as possible.
    • Constructor Detail

      • ClientContext

        protected ClientContext​(ClientContext ctx)
        This constructor does not create a copy of the configuration.
    • Method Detail

      • create

        public static ClientContext create​(javax.security.auth.Subject subject,
                                           AlluxioConfiguration alluxioConf)
        A client context with information about the subject and configuration of the client.
        Parameters:
        subject - the security subject to use
        alluxioConf - the AlluxioConfiguration to use
        Returns:
        a new client context with the specified properties and subject
      • create

        public static ClientContext create()
        Returns:
        a new ClientContext with values loaded from the alluxio-site properties and an empty subject.
      • loadConf

        public void loadConf​(java.net.InetSocketAddress address,
                             boolean loadClusterConf,
                             boolean loadPathConf)
                      throws AlluxioStatusException
        This method will load the cluster and path level configuration defaults and update the configuration in one RPC. This method should be synchronized so that concurrent calls to it don't continually overwrite the previous configuration. The cluster defaults are updated per connection establishment, or when cluster defaults updates are detected on client side.
        Parameters:
        address - the address to load cluster defaults from
        loadClusterConf - whether to load cluster level configuration
        loadPathConf - whether to load path level configuration
        Throws:
        AlluxioStatusException
      • loadConfIfNotLoaded

        public void loadConfIfNotLoaded​(java.net.InetSocketAddress address)
                                 throws AlluxioStatusException
        Loads configuration if not loaded from meta master yet.
        Parameters:
        address - meta master address
        Throws:
        AlluxioStatusException
      • setUriValidationEnabled

        public ClientContext setUriValidationEnabled​(boolean uriValidationEnabled)
        Parameters:
        uriValidationEnabled - whether URI validation is enabled
        Returns:
        updated instance of ClientContext
      • getUriValidationEnabled

        public boolean getUriValidationEnabled()
        Returns:
        true if URI validation is enabled
      • getClusterConf

        public AlluxioConfiguration getClusterConf()
        Returns:
        the cluster level configuration backing this context
      • getPathConf

        public PathConfiguration getPathConf()
        Returns:
        the path level configuration backing this context
      • getClusterConfHash

        public java.lang.String getClusterConfHash()
        Returns:
        hash of cluster level configuration
      • getPathConfHash

        public java.lang.String getPathConfHash()
        Returns:
        hash of path level configuration
      • getSubject

        public javax.security.auth.Subject getSubject()
        Returns:
        the Subject backing this context
      • getUserState

        public UserState getUserState()
        Returns:
        the UserState for this context