Compiling and Running HPE Ezmeral Data Fabric Streams Java Apps

For producer and consumer applications that use the HPE Ezmeral Data Fabric Streams Java API, use Maven to compile and determine the application dependencies. Then, when you run the application, specify those dependencies in the application classpath.

Compile and Determine Dependencies

For an example pom.xml file, see HPE Ezmeral Data Fabric Streams Streams Sample Programs on GitHub.

  1. Add the HPE Maven repository to your pom.xml file, if it is not already added:
    <repositories>
        <repository>
          <id>mapr-releases</id>
          <url>https://repository.mapr.com/nexus/content/repositories/releases</url>
          <snapshots><enabled>true</enabled></snapshots>
          <releases><enabled>true</enabled></releases>
        </repository>
    </repositories>
  2. Add a dependency to the Data Fabric Streams Java client (kafka-clients) project:
    <dependency>
          <groupId>org.apache.kafka</groupId>
          <artifactId>kafka-clients</artifactId>
          <version><version selected from the repository></version>
    </dependency>
    NOTE
    The kafka-clients version mentioned above is an example. The actual version that your application requires is based on the current EEP and Data Fabric core version that you are running. The versions are listed in the following locations: https://repository.mapr.com/nexus/content/groups/mapr-public/org/apache/kafka/kafka-clients/
  3. Add a dependency to the Data Fabric Streams project:
    If you are using EEP version 9.1.2 and later:
    <dependency>
          <groupId>org.apache.kafka</groupId>
          <artifactId>kafka-eventstreams</artifactId>
          <version><version selected from the repository></version>
    </dependency>
    If you are using EEP version 8.1.0 through 9.1.1:
    <dependency>
          <groupId>com.mapr.kafka</groupId>
          <artifactId>mapr-streams</artifactId>
          <version><version selected from the repository></version>
    </dependency>
    NOTE
    The Data Fabric Streams project version mentioned above is an example. The actual version that your application requires is based on the current EEP and Data Fabric version that you are running. The versions are listed in the following locations:
  4. Use Maven to compile the application and resolve dependencies. For example, you can run mvn clean package.

Run the Application

When you develop a Java application, you can use a dependency management tool such as Maven to compile your application. However, it is recommended that you do the following instead:
  1. Compile the Java application without including dependencies
  2. Specify the required classpath when you submit the application to the cluster
If you choose to bundle the JAR file, and there is a mismatch between the bundled JAR file and the version that your Data Fabric cluster expects, this can result in failures. The failures differ depending on the version of Data Fabric you are using. For more information, see Using the File System JAR to Connect to the Cluster.

When the cluster is secure, the node must also have a Data Fabric ticket configured for the user that runs the application.

Use the following command to launch HPE Ezmeral Data Fabric Streams applications:
java -cp <classpath>:. -Djava.library.path=/opt/mapr/lib <main class JAR> <command line arguments>

References