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
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

Spark ThriftServer APIs

Updated on 2024-12-10 GMT+08:00

Introduction

ThriftServer is another HiveServer2 implementation in Hive. It uses the Spark structured query language (SQL) to process the SQL statements, providing higher performance than Hive.

ThriftServer is a JDBC API. Users can use JDBC to connect to Thrift Server to access SparkSQL data. When ThriftServer is started, a SparkSQL application is started, and the clients connected through the JDBC share the resources of the SparkSQL application, that is, different users can share data. When ThriftServer is started, a monitor is enabled to wait for the connections and queries submitted by the JDBC client. Therefore, when configuring ThriftServer, you must configure at least the host name and port number of ThriftServer. If you want to use Hive data, you also need to provide the URIs of Hive Metastore.

ThriftServer starts a JDBC service on port 10000 of the installation node by default. Users can connect to ThriftServer using Beeline or running the JDBC client code to run SQL statements.

For other information about ThriftServer, visit Spark's official website.

Beeline

For details about the Beeline connection modes provided by the open source community, visit https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients.

JDBC Client Code

You can run the JDBC client code to connect to the ThriftServer to access SparkSQL data.

Enhanced Features

Compared with the open source community, MRS provides two enhanced features: ThriftServer HA solution and timeout interval setting for ThriftServer connections.

  • In the ThriftServer HA solution, when the active ThriftServer node is faulty, the standby node can automatically switch to the active one to provide services for the cluster. The operations of using Beeline or JDBC client code for connection are the same.

    The difference between the character strings used for connecting to ThriftServer in HA or non-HA modes is that you need to replace ip:port with ha-cluster for connecting to ThriftServer in HA mode. Table 1 provides other parameters that will be used.

    Table 1 List of client parameters

    Parameter

    Description

    Default Value

    spark.thriftserver.ha.enabled

    Indicates whether to enable the HA mode. The value true indicates that the HA mode is enabled. If the HA mode is enabled, change host:port to ha-cluster in the connection string. Otherwise, the system automatically exits the HA mode.

    false

    spark.thriftserver.zookeeper.dir

    ThriftServer path for storing metadata on the ZooKeeper. The parameter value must be the same as those on the server. The subdirectory named active_thriftserver in this directory is used for storing the IP address and port number of the Hive ThriftServer.

    /thriftserver

    spark.deploy.zookeeper.url

    ZooKeeper URL. The parameter value must be the same as those on the server.

    -

    spark.thriftserver.retry.times

    Maximum number of attempts to connect to the server. If the value is set to a negative number or zero, the client does not attempt to connect to the server again.

    5

    spark.thriftserver.retry.wait.time

    Interval for attempting to reconnect to the server. The unit is second.

    10

    The parameters in Table 1 must be configured in the hive-site.xml file in classpath on the client. For example:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <configuration>
        <property>
            <name>spark.thriftserver.ha.enabled</name>
            <value>true</value>
        </property>
    </configuration>

    The spark.deploy.zookeeper.url parameter can also be replaced with zk.quorum in the connection string. For example:

    !connect jdbc:hive2://ha-cluster/default;zk.quorum=spark25:2181,spark
    26:2181,spark27:2181
  • Set a timeout interval for a connection between the client and the ThriftServer.
    • Beeline

      In the case of network congestion, this feature prevents the beeline from being suspended due to the infinite waiting for the response of the server. The configuration method is as follows:

      When the beeline is started, append --socketTimeOut=n, where n indicates the timeout interval (unit: second) for waiting for the service response. The default value is 0, indicating that the beeline never times out. You are advised to set this parameter to the maximum value allowed based on the service scenario.

    • JDBC client code

      In the case of network congestion, this feature prevents the client from being suspended due to the infinite waiting for the response of the server. The configuration method is as follows:

      Before using the DriverManager.getConnection method to obtain the JDBC connection, add the DriverManager.setLoginTimeout(n) method to configure a timeout interval. n indicates the timeout interval for waiting for the return result from the server. The unit is second, the type is Int, and the default value is 0 (indicating never timing out). You are advised to set this parameter to the maximum value allowed based on the service scenario.

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