This section describes considerations for building a connector, including selecting an IDE and/or build tool, setting up the PXF development environment, and identifying compile-time dependencies.

Note: The PXF developer documentation includes a set of exercises that expand on the topics covered. These exercises operate on a built-in PXF connecter named Demo, an example connector to the local file system. You will extend a local copy of the Demo connector throughout exercises in this guide.

Identifying Connector Compile-Time Dependencies

You must identify and satisfy the compile-time dependencies that your connector or plug-in has on external components. For example, the PXF HDFS connector utilizes the Hadoop Java API. This connector has compile-time dependencies on several classes in the com.apache.hadoop package. These dependencies are fulfilled via a number of JAR files provided in a Hadoop client installation.

You can set up the build environment for your connector to retrieve compile-time dependencies from maven or other remote repositories. Your connector may also have compile-time dependencies that you fulfill via a JAR file local to your build system.

All PXF connectors have a compile-time dependency on the pxf-api-<version>.jar file. Your connector may also have compile-time dependencies on other PXF jar files if you extend any of the PXF classes implemented in those JAR files.

PXF JAR files are not currently available from a remote repository. You must copy the JAR file(s) from your Greenplum Database installation to your development system before you build your connector.

PXF JAR files are available from the following directory in your Greenplum Database installation:

$GPHOME/pxf/lib

Setting up the PXF Development Environment

You can develop with the PXF SDK on your operating system of choice and with the IDE or build environment of your choice.

You must install the Java Development Kit on your development system to develop with the PXF SDK. You must also obtain the PXF API JAR file, and the JAR file(s) for any PXF built-in connectors whose plug-in classes you will extend.

Prerequisites

Before setting up your PXF development environment, ensure that you have:

Exercises in this guide reference your work directory. You may consider adding $PXFDEV_BASE to your .bash_profile or equivalent shell initialization script.

If not already present on your development system, install Java Development Kit version 1.7 or 1.8. You must have superuser permissions to install operating system packages. For example, to install the JDK on a CentOS development system:

root@devsystem$ sudo yum install java-1.8.0-openjdk-1.8.0*

Obtain the PXF API JAR file pxf-api-<version>.jar and copy it to your work directory. You can copy this file from your Greenplum Database installation. For example:

The source code for the PXF Demo connector is located in the incubator-hawq/pxf/pxf-api/src/main/java/org/apache/hawq/pxf/api/examples directory of the repository you cloned in Step 1. Copy this code to your work area. For example:

The original PXF Demo connector resides in the org.apache.hawq.pxf.api.examples package. Your Demo connector resides in a package named org.greenplum.pxf.example.demo. Update the package name in your local copy of the Demo connector source code. You can edit the files, run a script, etc. For example:

This command generates build configuration files and scripts. Before building your Demo connector project, you must customize the build.gradle and settings.gradle files.

Gradle uses the settings.gradle file rootProject.name setting for the base name of the built Java library JAR file. The default rootProject.name setting value is the base name of current working directory. Edit the settings.gradle file and supply a custom root project name for your Demo connector. For example:

user@devsystem$ vi settings.gradle

rootProject.name = 'my-demo-connector'

Gradle uses the build.gradle file to identify the compile time dependencies for a project and other configuration. Your Demo connector depends on the PXF API JAR file (available locally) and the commons-logging.jar file (available from a maven repository). Edit your build.gradle file to supply these dependencies. For example:

user@devsystem$ vi build.gradle

Search for the repositories block, and add the bolded text to identify the location of the PXF API JAR file. Recall that you copied this file to the libs/ directory in Step 3. For example: