Class ConfiguratorBase

    • Field Detail

      • log

        protected static final org.apache.log4j.Logger log
    • Constructor Detail

      • ConfiguratorBase

        public ConfiguratorBase()
    • Method Detail

      • enumToConfKey

        protected static String enumToConfKey​(Class<?> implementingClass,
                                              Enum<?> e)
        Provides a configuration key for a given feature enum, prefixed by the implementingClass
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        e - the enum used to provide the unique part of the configuration key
        Returns:
        the configuration key
        Since:
        1.6.0
      • enumToConfKey

        protected static String enumToConfKey​(Enum<?> e)
        Provides a configuration key for a given feature enum.
        Parameters:
        e - the enum used to provide the unique part of the configuration key
        Returns:
        the configuration key
      • setConnectorInfo

        public static void setConnectorInfo​(Class<?> implementingClass,
                                            org.apache.hadoop.conf.Configuration conf,
                                            String principal,
                                            AuthenticationToken token)
        Sets the connector information needed to communicate with Accumulo in this job.

        WARNING: The serialized token is stored in the configuration and shared with all MapReduce tasks. It is BASE64 encoded to provide a charset safe conversion to a string, and is not intended to be secure.

        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        principal - a valid Accumulo user name
        token - the user's password
        Since:
        1.6.0
      • setConnectorInfo

        public static void setConnectorInfo​(Class<?> implementingClass,
                                            org.apache.hadoop.conf.Configuration conf,
                                            String principal,
                                            String tokenFile)
        Sets the connector information needed to communicate with Accumulo in this job.

        Pulls a token file into the Distributed Cache that contains the authentication token in an attempt to be more secure than storing the password in the Configuration. Token file created with "bin/accumulo create-token".

        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        principal - a valid Accumulo user name
        tokenFile - the path to the token file in DFS
        Since:
        1.6.0
      • isConnectorInfoSet

        public static Boolean isConnectorInfoSet​(Class<?> implementingClass,
                                                 org.apache.hadoop.conf.Configuration conf)
        Determines if the connector info has already been set for this instance.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        Returns:
        true if the connector info has already been set, false otherwise
        Since:
        1.6.0
        See Also:
        setConnectorInfo(Class, Configuration, String, AuthenticationToken)
      • getPrincipal

        public static String getPrincipal​(Class<?> implementingClass,
                                          org.apache.hadoop.conf.Configuration conf)
        Gets the user name from the configuration.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        Returns:
        the principal
        Since:
        1.6.0
        See Also:
        setConnectorInfo(Class, Configuration, String, AuthenticationToken)
      • getTokenFromFile

        public static AuthenticationToken getTokenFromFile​(Class<?> implementingClass,
                                                           org.apache.hadoop.conf.Configuration conf,
                                                           String principal,
                                                           String tokenFile)
        Reads from the token file in distributed cache. Currently, the token file stores data separated by colons e.g. principal:token_class:token
        Parameters:
        conf - the Hadoop context for the configured job
        Returns:
        path to the token file as a String
        Since:
        1.6.0
        See Also:
        setConnectorInfo(Class, Configuration, String, AuthenticationToken)
      • setZooKeeperInstance

        public static void setZooKeeperInstance​(Class<?> implementingClass,
                                                org.apache.hadoop.conf.Configuration conf,
                                                ClientConfiguration clientConfig)
        Configures a ZooKeeperInstance for this job.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        clientConfig - client configuration for specifying connection timeouts, SSL connection options, etc.
        Since:
        1.6.0
      • getInstance

        public static Instance getInstance​(Class<?> implementingClass,
                                           org.apache.hadoop.conf.Configuration conf)
        Initializes an Accumulo Instance based on the configuration.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        Returns:
        an Accumulo instance
        Since:
        1.6.0
      • getClientConfiguration

        public static ClientConfiguration getClientConfiguration​(Class<?> implementingClass,
                                                                 org.apache.hadoop.conf.Configuration conf)
        Obtain a ClientConfiguration based on the configuration.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        Returns:
        A ClientConfiguration
        Since:
        1.7.0
      • setLogLevel

        public static void setLogLevel​(Class<?> implementingClass,
                                       org.apache.hadoop.conf.Configuration conf,
                                       org.apache.log4j.Level level)
        Sets the log level for this job.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        level - the logging level
        Since:
        1.6.0
      • getLogLevel

        public static org.apache.log4j.Level getLogLevel​(Class<?> implementingClass,
                                                         org.apache.hadoop.conf.Configuration conf)
        Gets the log level from this configuration.
        Parameters:
        implementingClass - the class whose name will be used as a prefix for the property configuration key
        conf - the Hadoop configuration object to configure
        Returns:
        the log level
        Since:
        1.6.0
        See Also:
        setLogLevel(Class, Configuration, Level)
      • setVisibilityCacheSize

        public static void setVisibilityCacheSize​(org.apache.hadoop.conf.Configuration conf,
                                                  int visibilityCacheSize)
        Sets the valid visibility count for this job.
        Parameters:
        conf - the Hadoop configuration object to configure
        visibilityCacheSize - the LRU cache size
      • getVisibilityCacheSize

        public static int getVisibilityCacheSize​(org.apache.hadoop.conf.Configuration conf)
        Gets the valid visibility count for this job.
        Parameters:
        conf - the Hadoop configuration object to configure
        Returns:
        the valid visibility count
      • unwrapAuthenticationToken

        public static AuthenticationToken unwrapAuthenticationToken​(org.apache.hadoop.mapred.JobConf job,
                                                                    AuthenticationToken token)
        Unwraps the provided AuthenticationToken if it is an instance of DelegationTokenStub, reconstituting it from the provided JobConf.
        Parameters:
        job - The job
        token - The authentication token
      • unwrapAuthenticationToken

        public static AuthenticationToken unwrapAuthenticationToken​(org.apache.hadoop.mapreduce.JobContext job,
                                                                    AuthenticationToken token)
        Unwraps the provided AuthenticationToken if it is an instance of DelegationTokenStub, reconstituting it from the provided JobConf.
        Parameters:
        job - The job
        token - The authentication token