Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Performing Secondary Development After Interconnection

Updated on 2024-02-21 GMT+08:00

You can perform secondary development as required. Currently, the following examples are provided.

  • Custom authentication information obtaining class: used to obtain IAM authentication information for accessing LakeFormation.
  • Custom user information obtaining class: used to obtain the information of the user who accesses LakeFormation.

Custom Authentication Information Obtaining Class

The IdentityGenerator class is used to obtain IAM authentication information (token, permanent AK/SK, and temporary AK/SK and securityToken) for accessing LakeFormation.

LakeFormation provides a default class for obtaining authentication information. The AK/SK is obtained from the configuration file to generate authentication information.

In addition to the default authentication information obtaining class provided by LakeFormation, you can implement the default authentication information obtaining class.

  1. Develop code.

    The implementation project is as follows. Add the lakeformation-lakecat-client dependency to the POM file of the Maven project.

    <dependency>
    <groupId>com.huawei.lakeformation</groupId>
    <artifactId>lakeformation-lakecat-client</artifactId>
    <version>${lakeformation.version}</version>
    </dependency>
    Add a class for obtaining authentication information to implement the IdentityGenerator API.
    
    /*
    * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
    */
    
    package com.huawei.cloud.dalf.lakecat.examples;
    
    import com.huawei.cloud.dalf.lakecat.client.ConfigCenter;
    import com.huawei.cloud.dalf.lakecat.client.identity.Identity;
    import com.huawei.cloud.dalf.lakecat.client.identity.IdentityGenerator;
    
    import java.util.Collections;
    
    /**
    * Identity information generator example
    *
    */
    public class LakeFormationExampleIdentityGenerator implements IdentityGenerator {
    public String token;
    
    @Override
    public void initialize(ConfigCenter configCenter) {
    //Perform initialization.
    }
    
    @Override
    public Identity generateIdentity() {
    //Return the IAM authentication information.
    }
    }
  2. Configure integration.

    Use Maven to pack the code and place the JAR package in the spark/jars directory.

    Add the corresponding configurations for different interconnection methods:

    • If SparkCatalogPlugin is used for interconnection, add the following configurations to the spark-default.conf configuration file:
      # Authentication information obtaining class. Set this parameter based on the implementation class path. The value is for reference only.
      spark.sql.catalog.catalog_name.lakecat.auth.identity.util.class=com.huawei.cloud.dalf.lakecat.client.spark.v31.impl.SparkDefaultIdentityGenerator
    • You can use either of the following method to complete interconnection using MetastoreClient:

      Add the following configuration to spark-default.conf:

      # Authentication information obtaining class. Set this parameter based on the implementation class path. The value is for reference only.
      spark.hadoop.lakecat.auth.identity.util.class=com.huawei.cloud.dalf.lakecat.client.spark.v31.impl.SparkDefaultIdentityGenerator

      Alternatively, add the following configuration to hive-site.xml:

      <!--Authentication information obtaining class. The value is for reference only.-->
      <property>
      <name>lakecat.auth.identity.util.class</name>
      <value>com.huawei.cloud.dalf.lakecat.examples.LakeFormationExampleIdentityGenerator</value>
      </property>

Custom User Information Obtaining Class

The AuthenticationManager class is used to obtain the information of the user who accesses LakeFormation, which may be an IAM user or a local LDAP user. The default user information obtaining class obtains the user information using UserGroupInformation.getCurrentUser().

In addition to the default user information obtaining class introduced here, you can implement other user information obtaining method.

NOTE:

If user authentication information is used to access LakeFormation, the user information must be consistent with the user identity information (that is, the username and source must be consistent).

  1. Develop code.

    The implementation project is as follows. Add the lakeformation-lakecat-client dependency to the POM file of the Maven project.

    <dependency>
    <groupId>com.huawei.lakeformation</groupId>
    <artifactId>lakeformation-lakecat-client</artifactId>
    <version>${lakeformation.version}</version>
    </dependency>
    User information obtaining class, which implements the AuthenticationManager API.
    
    /*
    * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
    */
    
    package com.huawei.cloud.dalf.lakecat.examples;
    
    import com.huawei.cloud.dalf.lakecat.client.ConfigCenter;
    import com.huawei.cloud.dalf.lakecat.client.identity.AuthenticationManager;
    import com.huawei.cloud.dalf.lakecat.client.model.Principal;
    
    public class ExampleAuthenticationManager implements AuthenticationManager {
    @Override
    public void initialize(ConfigCenter configCenter) {
    //Perform initialization.
    }
    
    @Override
    public Principal getCurrentUser() {
    //Return the information about the current user.
    }
    }
  2. Configure integration.

    Use Maven to pack the code and place the JAR package in the spark/jars directory.

    Add the corresponding configurations for different interconnection methods:

    • If SparkCatalogPlugin is used for interconnection, add the following configurations to the spark-default.conf configuration file:
      # Optional parameter. Authentication manager implementation class, which is used to obtain the information of the current user. The value configured here is for reference only.
      spark.sql.catalog.catalog_name.lakeformation.authentication.manager.class=com.huawei.cloud.dalf.lakecat.examples.ExampleAuthenticationManager
      # Optional parameter, which specifies whether to specify the current user as the resource owner during resource creation. The default value is false.
      spark.sql.catalog.catalog_name.lakeformation.owner.designate=true
    • You can use either of the following method to complete interconnection using MetastoreClient:

      Add the following configuration to spark-default.conf:

      # Optional parameter. Authentication manager implementation class, which is used to obtain the information of the current user. The value configured here is for reference only.
      spark.hadoop.lakeformation.authentication.manager.class=com.huawei.cloud.dalf.lakecat.examples.ExampleAuthenticationManager
      # Optional parameter, which specifies whether to specify the current user as the resource owner during resource creation. The default value is false.
      spark.hadoop.lakeformation.owner.designate=true

      Alternatively, add the following configuration to hive-site.xml:

      <!--Optional parameter. Authentication manager implementation class, which is used to obtain the information of the current user. The value configured here is for reference only.-->
      <property>
      <name>lakeformation.authentication.manager.class</name>
      <value>com.huawei.cloud.dalf.lakecat.examples.ExampleAuthenticationManager</value>
      </property>
      <!--Optional parameter, which specifies whether to specify the current user as the resource owner during resource creation. The default value is false.-->
      <property>
      <name>lakeformation.owner.designate</name>
      <value>true</value>
      </property>
      </configuration>

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback