Skip to content

Commit 6a4e618

Browse files
authored
[FSTORE-1008] enable interacting with java client to hopsworks (#200)
1 parent 69c043e commit 6a4e618

File tree

7 files changed

+779
-1
lines changed

7 files changed

+779
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ dmypy.json
124124
.vscode
125125
*.iml
126126
target/
127-
127+
**target/
128128
# Mac
129129
.DS_Store
130130

@@ -196,3 +196,4 @@ advanced_tutorials/recommender-system/catboost_info/test/events.out.tfevents
196196
advanced_tutorials/recommender-system/querymodel_transformer.py
197197
advanced_tutorials/recommender-system/ranking_transformer.py
198198
advanced_tutorials/recommender-system/ranking_predictor.py
199+
integrations/java/flink/dependency-reduced-pom.xml

java/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Online Feature Vector Retrieval Using Java Application
2+
3+
## Introduction
4+
In this tutorial you will learn how to fetch feature vectors from online feature store for near real-time model serving
5+
using external java application.
6+
7+
## Clone tutorials repository
8+
This section requires maven; java 1.8 and git.
9+
10+
```bash
11+
git clone https://github.com/logicalclocks/hopsworks-tutorials
12+
cd ./hopsworks-tutorials/java
13+
mvn clean package
14+
```
15+
16+
## Execute java application:
17+
Now you will create [connection](https://docs.hopsworks.ai/hopsworks-api/3.3/generated/api/connection/) with
18+
your Hopsworks cluster. For this you need to have Hopsworks cluster host address and [api key](https://docs.hopsworks.ai/3.3/user_guides/projects/api_key/create_api_key/)
19+
20+
Then define environment variables
21+
22+
```bash
23+
HOPSWORKS_HOST=REPLACE_WITH_YOUR_HOPSWORKS_CLUSTER_HOST
24+
HOPSWORKS_API_KEY=REPLACE_WITH_YOUR_HOPSWORKS_API_KEY
25+
HOPSWORKS_PROJECT_NAME=REPLACE_WITH_YOUR_HOPSWORKS_PROJECT_NAME
26+
27+
FEATURE_GROUP_NAME=java_data
28+
FEATURE_GROUP_VERSION=1
29+
FEATURE_VIEW_NAME=products_fv
30+
FEATURE_VIEW_VERSION=1
31+
```
32+
33+
```bash
34+
python3 ./setup_fv_fg.py --host $HOPSWORKS_HOST --api_key $HOPSWORKS_API_KEY --project $HOPSWORKS_PROJECT_NAME --feature_group_name $FEATURE_GROUP_NAME --feature_group_version $FEATURE_GROUP_VERSION --feature_view_name $FEATURE_VIEW_NAME --feature_view_version $FEATURE_VIEW_VERSION
35+
java -jar ./target/hopsworks-java-tutorial-3.9.0-RC9-jar-with-dependencies.jar $HOPSWORKS_HOST $HOPSWORKS_API_KEY $HOPSWORKS_PROJECT_NAME $FEATURE_GROUP_NAME $FEATURE_GROUP_VERSION $FEATURE_VIEW_NAME $FEATURE_VIEW_VERSION
36+
```

java/pom.xml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.hopsworks.tutorials</groupId>
8+
<artifactId>hopsworks-java-tutorial</artifactId>
9+
<version>3.9.0-RC9</version>
10+
11+
<properties>
12+
<maven.compiler.source>1.8</maven.compiler.source>
13+
<maven.compiler.target>1.8</maven.compiler.target>
14+
<guava.version>32.1.2-jre</guava.version>
15+
<httpclient.version>4.5.6</httpclient.version>
16+
<httpcore.version>4.4.13</httpcore.version>
17+
<surefire-plugin.version>2.22.0</surefire-plugin.version>
18+
<avro.version>1.8.2</avro.version>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.logicalclocks</groupId>
24+
<artifactId>hsfs</artifactId>
25+
<version>${project.version}</version>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.apache.httpcomponents</groupId>
30+
<artifactId>httpclient</artifactId>
31+
<version>${httpclient.version}</version>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>org.apache.httpcomponents</groupId>
36+
<artifactId>httpcore</artifactId>
37+
<version>${httpcore.version}</version>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>mysql</groupId>
42+
<artifactId>mysql-connector-java</artifactId>
43+
<version>8.0.33</version>
44+
<scope>runtime</scope>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>com.google.guava</groupId>
49+
<artifactId>guava</artifactId>
50+
<version>${guava.version}</version>
51+
</dependency>
52+
</dependencies>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-assembly-plugin</artifactId>
59+
<version>2.4.1</version>
60+
<configuration>
61+
<archive>
62+
<manifest>
63+
<mainClass>com.hopsworks.tutorials.Main</mainClass>
64+
</manifest>
65+
</archive>
66+
<!-- get all project dependencies -->
67+
<descriptorRefs>
68+
<descriptorRef>jar-with-dependencies</descriptorRef>
69+
</descriptorRefs>
70+
</configuration>
71+
<executions>
72+
<execution>
73+
<id>make-assembly</id>
74+
<!-- bind to the packaging phase -->
75+
<phase>package</phase>
76+
<goals>
77+
<goal>single</goal>
78+
</goals>
79+
</execution>
80+
</executions>
81+
</plugin>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-surefire-plugin</artifactId>
85+
<version>${surefire-plugin.version}</version>
86+
<configuration>
87+
<systemProperties>
88+
<property>
89+
<name>hadoop.home.dir</name>
90+
<value>${project.basedir}/src/test/resources/hadoop/</value>
91+
</property>
92+
</systemProperties>
93+
<systemPropertiesFile>src/test/resources/system.properties</systemPropertiesFile>
94+
</configuration>
95+
</plugin>
96+
97+
<plugin>
98+
<groupId>org.apache.avro</groupId>
99+
<artifactId>avro-maven-plugin</artifactId>
100+
<version>${avro.version}</version>
101+
<executions>
102+
<execution>
103+
<phase>generate-sources</phase>
104+
<goals>
105+
<goal>schema</goal>
106+
<goal>protocol</goal>
107+
<goal>idl-protocol</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
</plugins>
113+
<testResources>
114+
<testResource>
115+
<directory>src/test/resources</directory>
116+
</testResource>
117+
</testResources>
118+
</build>
119+
120+
<repositories>
121+
<repository>
122+
<id>Hops</id>
123+
<name>Hops Repo</name>
124+
<url>https://archiva.hops.works/repository/Hops/</url>
125+
<releases>
126+
<enabled>true</enabled>
127+
</releases>
128+
<snapshots>
129+
<enabled>true</enabled>
130+
</snapshots>
131+
</repository>
132+
</repositories>
133+
134+
<distributionManagement>
135+
<repository>
136+
<id>Hops</id>
137+
<name>Hops Repo</name>
138+
<url>https://archiva.hops.works/repository/Hops/</url>
139+
</repository>
140+
</distributionManagement>
141+
</project>

0 commit comments

Comments
 (0)