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's dependencies. Then, when you run the application, specify those dependencies in the application's classpath.
Compile and Determine Dependencies
See HPE Ezmeral Data Fabric Streams Streams Sample Programs on GitHub for an example pom.xml file.
- Add MapR's 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>
- Add a dependency to the MapR Streams Java client (kakfa-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 MapR version that you are running. The versions are listed in the following location: https://repository.mapr.com/nexus/content/groups/mapr-public/org/apache/kafka/kafka-clients/ - Add a dependency to the MapR Streams
project:
<dependency> <groupId>com.mapr.streams</groupId> <artifactId>mapr-streams</artifactId> <version><version selected from the repository></version> </dependency>
NOTE: The MapR Streams project version mentioned above is an example. The actual version that your application requires is based on the current EEP and MapR version that you are running. The versions are listed in the following location:https://repository.mapr.com/nexus/content/groups/mapr-public/com/mapr/streams/mapr-streams/ - Use Maven to compile the application and resolve dependencies. For example, you can run
mvn clean package
.
Run the Application
- Compile the Java application without including dependencies
- Specify the required classpath when you submit the application to the cluster
When the cluster is secure, the node must also have a mapr ticket configured for the user that runs the application.
java -cp <classpath>:. -Djava.library.path=/opt/mapr/lib <main class JAR> <command line arguments>