Skip to content

Commit

Permalink
Use proper endpoint to retrive the online storage connector
Browse files Browse the repository at this point in the history
  • Loading branch information
SirOibaf committed Dec 9, 2020
1 parent 5ed9d60 commit cf91299
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Arrays;

public class StorageConnectorApi {

private static final String CONNECTOR_PATH = "/storageconnectors";
private static final String CONNECTOR_TYPE_PATH =
CONNECTOR_PATH + "{/connType}{/name}{?temporaryCredentials}";
private static final String ONLINE_CONNECTOR_PATH = CONNECTOR_PATH + "/onlinefeaturestore";
private static final String ONLINE_FEATURE_STORE_CONNECTOR_SUFFIX = "_onlinefeaturestore";

private static final Logger LOGGER = LoggerFactory.getLogger(StorageConnectorApi.class);

Expand Down Expand Up @@ -62,17 +60,14 @@ public StorageConnector getOnlineStorageConnector(FeatureStore featureStore)
HopsworksClient hopsworksClient = HopsworksClient.getInstance();
String pathTemplate = HopsworksClient.PROJECT_PATH
+ FeatureStoreApi.FEATURE_STORE_PATH
+ CONNECTOR_PATH;
+ ONLINE_CONNECTOR_PATH;

String uri = UriTemplate.fromTemplate(pathTemplate)
.set("projectId", featureStore.getProjectId())
.set("fsId", featureStore.getId())
.expand();

LOGGER.info("Sending metadata request: " + uri);
StorageConnector[] storageConnectors = hopsworksClient.handleRequest(new HttpGet(uri), StorageConnector[].class);
return Arrays.stream(storageConnectors).filter(s -> s.getName().contains(ONLINE_FEATURE_STORE_CONNECTOR_SUFFIX))
.findFirst()
.orElseThrow(() -> new FeatureStoreException("Could not find online storage connector"));
return hopsworksClient.handleRequest(new HttpGet(uri), StorageConnector.class);
}
}
14 changes: 4 additions & 10 deletions python/hsfs/core/storage_connector_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,9 @@ def get_online_connector(self):
"featurestores",
self._feature_store_id,
"storageconnectors",
"onlinefeaturestore",
]

result = [
conn
for conn in _client._send_request("GET", path_params)
if self.CONST_ONLINE_FEATURE_STORE_CONNECTOR_SUFFIX in conn["name"]
]

if len(result) > 0:
return storage_connector.StorageConnector.from_response_json(result[0])
else:
raise Exception("Could not find online storage connector")
return storage_connector.StorageConnector.from_response_json(
_client._send_request("GET", path_params)
)

0 comments on commit cf91299

Please sign in to comment.