Skip to content

Commit dad8fc4

Browse files
author
mehmettokgoz
committed
Fix template bugs and address review comments.
Signed-off-by: mehmettokgoz <mehmet.tokgoz@hazelcast.com>
1 parent 8ad15ac commit dad8fc4

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

sdk/python/feast/infra/online_stores/contrib/hazelcast_online_store/README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ In order to use [Hazelcast](https://hazelcast.com) as online store, you need to
3636
You can create a cluster using Hazelcast Viridian Serverless easily or deploy one on your local/remote machine.
3737
See this [getting started](https://hazelcast.com/get-started/) page for more details.
3838

39-
Hazelcast online store provides capability to connect TLS/SSL enabled cluster or Hazelcast Viridian Serverless cluster.
40-
Following is an example to connect local cluster named "dev" running on port 5701 with SSL enabled.
39+
Hazelcast online store provides capability to connect local/remote or Hazelcast Viridian Serverless cluster.
40+
Following is an example to connect local cluster named "dev" running on port 5701 with TLS/SSL enabled.
4141

4242
```yaml
4343
[...]
@@ -48,7 +48,8 @@ online_store:
4848
ssl_cafile_path: /path/to/ca/file
4949
ssl_certfile_path: /path/to/cert/file
5050
ssl_keyfile_path: /path/to/key/file
51-
ssl_password: <YOUR_SSL_PASSWORD>
51+
ssl_password: ${SSL_PASSWORD} # The password will be read form the `SSL_PASSWORD` environment variable.
52+
key_ttl_seconds: 86400 # The default is 0 and means infinite.
5253
```
5354
5455
If you want to connect your Hazelcast Viridian cluster instead of local/remote one, specify your configuration as follows:
@@ -57,12 +58,13 @@ If you want to connect your Hazelcast Viridian cluster instead of local/remote o
5758
[...]
5859
online_store:
5960
type: hazelcast
60-
cluster_name: <YOUR_CLUSTER_ID>
61-
discovery_token: <YOUR_DISCOVERY_TOKEN>
61+
cluster_name: YOUR_CLUSTER_ID
62+
discovery_token: YOUR_DISCOVERY_TOKEN
6263
ssl_cafile_path: /path/to/ca/file
6364
ssl_certfile_path: /path/to/cert/file
6465
ssl_keyfile_path: /path/to/key/file
65-
ssl_password: <YOUR_SSL_PASSWORD>
66+
ssl_password: ${SSL_PASSWORD} # The password will be read form the `SSL_PASSWORD` environment variable.
67+
key_ttl_seconds: 86400 # The default is 0 and means infinite.
6668
```
6769
6870
#### TTL configuration
@@ -78,7 +80,7 @@ Its default value is 0, which means infinite.
7880
[...]
7981
online_store:
8082
[...]
81-
key_ttl_seconds: 36000
83+
key_ttl_seconds: 86400
8284
```
8385
8486
### More info

sdk/python/feast/infra/online_stores/contrib/hazelcast_online_store/hazelcast_online_store.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import pytz
2626
from hazelcast.client import HazelcastClient
2727
from hazelcast.core import HazelcastJsonValue
28+
from hazelcast.discovery import HazelcastCloudDiscovery
2829
from pydantic import StrictStr
2930

3031
from feast import Entity, FeatureView, RepoConfig
@@ -110,11 +111,14 @@ def _get_client(self, config: HazelcastOnlineStoreConfig):
110111
with self._lock:
111112
if self._client is None:
112113
if config.discovery_token != "":
114+
HazelcastCloudDiscovery._CLOUD_URL_BASE = (
115+
"api.viridian.hazelcast.com"
116+
)
113117
self._client = HazelcastClient(
114118
cluster_name=config.cluster_name,
119+
cloud_discovery_token=config.discovery_token,
115120
statistics_enabled=True,
116121
ssl_enabled=True,
117-
cloud_discovery_token=config.discovery_token,
118122
ssl_cafile=config.ssl_cafile_path,
119123
ssl_certfile=config.ssl_certfile_path,
120124
ssl_keyfile=config.ssl_keyfile_path,
@@ -161,7 +165,7 @@ def online_write_batch(
161165
entity_key_str = base64.b64encode(
162166
serialize_entity_key(
163167
entity_key,
164-
entity_key_serialization_version=config.entity_key_serialization_version,
168+
entity_key_serialization_version=2,
165169
)
166170
).decode("utf-8")
167171
event_ts_utc = pytz.utc.localize(event_ts, is_dst=None).timestamp()
@@ -213,7 +217,7 @@ def online_read(
213217
entity_key_str = base64.b64encode(
214218
serialize_entity_key(
215219
entity_key,
216-
entity_key_serialization_version=config.entity_key_serialization_version,
220+
entity_key_serialization_version=2,
217221
)
218222
).decode("utf-8")
219223
if requested_features:

sdk/python/feast/templates/hazelcast/bootstrap.py

+24-25
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@
1919

2020
import click
2121

22-
from feast.file_utils import replace_str_in_file, write_setting_or_remove
22+
from feast.file_utils import (
23+
remove_lines_from_file,
24+
replace_str_in_file,
25+
write_setting_or_remove,
26+
)
2327

2428

2529
def collect_hazelcast_online_store_settings():
26-
c_cluster_name = ""
30+
c_cluster_name = None
2731
c_members = None
2832
c_ca_path = None
2933
c_cert_path = None
3034
c_key_path = None
31-
c_ssl_password = None
3235
c_discovery_token = None
33-
c_ttl_seconds = 0
36+
c_ttl_seconds = None
3437

3538
cluster_type = click.prompt(
3639
"Would you like to connect a [L]ocal cluster or [V]iridian cluster?",
@@ -46,23 +49,20 @@ def collect_hazelcast_online_store_settings():
4649
c_ca_path = click.prompt("CA file path: ")
4750
c_cert_path = click.prompt("CERT file path: ")
4851
c_key_path = click.prompt("Key file path: ")
49-
c_ssl_password = click.prompt("SSL password: ")
5052
else:
5153
c_cluster_name = click.prompt(
52-
"Cluster_name: ",
54+
"Cluster name: ",
5355
default="dev",
5456
)
5557
c_members = click.prompt(
5658
"Cluster members:",
5759
default="localhost:5701",
5860
)
59-
6061
needs_ssl = click.confirm("Use TLS/SSL?", default=False)
6162
if needs_ssl:
6263
c_ca_path = click.prompt("CA file path: ")
6364
c_cert_path = click.prompt("CERT file path: ")
6465
c_key_path = click.prompt("Key file path: ")
65-
c_ssl_password = click.prompt("SSL password: ")
6666

6767
c_ttl_seconds = click.prompt(
6868
"Key TTL seconds: ",
@@ -74,14 +74,12 @@ def collect_hazelcast_online_store_settings():
7474
"c_ca_path": c_ca_path,
7575
"c_cert_path": c_cert_path,
7676
"c_key_path": c_key_path,
77-
"c_ssl_password": c_ssl_password,
7877
"c_discovery_token": c_discovery_token,
7978
"c_ttl_seconds": c_ttl_seconds,
8079
}
8180

8281

83-
def apply_cassandra_store_settings(config_file, settings):
84-
82+
def apply_hazelcast_store_settings(config_file, settings):
8583
write_setting_or_remove(
8684
config_file,
8785
settings["c_cluster_name"],
@@ -91,16 +89,18 @@ def apply_cassandra_store_settings(config_file, settings):
9189
#
9290
write_setting_or_remove(
9391
config_file,
94-
"[" + settings["c_members"] + "]",
95-
"cluster_members",
96-
"c_members",
92+
settings["c_discovery_token"],
93+
"discovery_token",
94+
"c_discovery_token",
9795
)
9896
#
97+
if settings["c_members"] is not None:
98+
settings["c_members"] = "[" + settings["c_members"] + "]"
9999
write_setting_or_remove(
100100
config_file,
101-
settings["c_discovery_token"],
102-
"discovery_token",
103-
"c_discovery_token",
101+
settings["c_members"],
102+
"cluster_members",
103+
"c_members",
104104
)
105105
#
106106
write_setting_or_remove(
@@ -123,13 +123,12 @@ def apply_cassandra_store_settings(config_file, settings):
123123
"ssl_keyfile_path",
124124
"c_key_path",
125125
)
126-
#
127-
write_setting_or_remove(
128-
config_file,
129-
settings["c_ssl_password"],
130-
"ssl_password",
131-
"c_ssl_password",
132-
)
126+
if settings["c_ca_path"] is None:
127+
remove_lines_from_file(
128+
config_file,
129+
"ssl_password: ${SSL_PASSWORD}",
130+
True,
131+
)
133132
#
134133
replace_str_in_file(
135134
config_file,
@@ -170,7 +169,7 @@ def bootstrap():
170169

171170
# store config yaml, interact with user and then customize file:
172171
settings = collect_hazelcast_online_store_settings()
173-
apply_cassandra_store_settings(config_file, settings)
172+
apply_hazelcast_store_settings(config_file, settings)
174173

175174

176175
if __name__ == "__main__":

sdk/python/feast/templates/hazelcast/feature_repo/feature_store.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ online_store:
99
ssl_cafile_path: c_ca_path
1010
ssl_certfile_path: c_cert_path
1111
ssl_keyfile_path: c_key_path
12-
ssl_password: c_ssl_password
12+
ssl_password: ${SSL_PASSWORD} # This value will be read form the `SSL_PASSWORD` environment variable.
1313
key_ttl_seconds: c_ttl_seconds
1414
entity_key_serialization_version: 2

0 commit comments

Comments
 (0)