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

Development Plan

Overview

You can customize JDBCServer clients and use JDBC connections to create, load data to, query, and delete data tables.

Preparing Data

  1. Ensure that the JDBCServer service has been started in multi-active instance HA mode and at least one instance provides connections for client. Create the /home/data file on each JDBCServer node. The file content is as follows:

    Miranda,32
    Karlie,23
    Candice,27

  2. Ensure that the user who starts the JDBCServer has the read and write permissions.
  3. Ensure that the hive-site.xml file exists in classpath and set parameters required for the client connection. For details about parameters required for JDBCServer, see Spark JDBCServer APIs.

Development Guidelines

  1. Create the child table in the default database.
  2. Load data in /home/data to the child table.
  3. Query data in the child table.
  4. Delete the child table.

Packaging the Project

Running the Task

Go to the Spark client directory and run the java -cp command to run the code (The class name and file name must be the same as those in the actual code. The following is only an example).

  • Run the Java sample code:

    java -cp $SPARK_HOME/jars/*:$SPARK_HOME/jars/hive/*:$SPARK_HOME/conf:/opt/female/SparkThriftServerJavaExample-1.0.jar com.huawei.bigdata.spark.examples.ThriftServerQueriesTest $SPARK_HOME/conf/hive-site.xml $SPARK_HOME/conf/spark-defaults.conf

  • Run the Scala sample code:

    java -cp $SPARK_HOME/jars/*:$SPARK_HOME/jars/hive/*:$SPARK_HOME/conf:/opt/female/SparkThriftServerExample-1.0.jar com.huawei.bigdata.spark.examples.ThriftServerQueriesTest $SPARK_HOME/conf/hive-site.xml $SPARK_HOME/conf/spark-defaults.conf

    After the SSL feature of ZooKeeper is enabled for the cluster (check the ssl.enabled parameter of the ZooKeeper service), add the -Dzookeeper.client.secure=true -Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty parameter to the command:

    java -Dzookeeper.client.secure=true -Dzookeeper.clientCnxnSocket=org.apache.zookeeper.ClientCnxnSocketNetty -cp $SPARK_HOME/jars/*:$SPARK_HOME/jars/hive/*:$SPARK_HOME/conf:/opt/female/SparkThriftServerJavaExample-1.0.jar com.huawei.bigdata.spark.examples.ThriftServerQueriesTest $SPARK_HOME/conf/hive-site.xml $SPARK_HOME/conf/spark-defaults.conf