From cf91299ceae13caeaa5e660960e669ba0aeabf97 Mon Sep 17 00:00:00 2001 From: Fabio Buso Date: Wed, 9 Dec 2020 22:06:42 +0100 Subject: [PATCH] Use proper endpoint to retrive the online storage connector --- .../hsfs/metadata/StorageConnectorApi.java | 9 ++------- python/hsfs/core/storage_connector_api.py | 14 ++++---------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/java/src/main/java/com/logicalclocks/hsfs/metadata/StorageConnectorApi.java b/java/src/main/java/com/logicalclocks/hsfs/metadata/StorageConnectorApi.java index 11b6efd3ed..cc588ba910 100644 --- a/java/src/main/java/com/logicalclocks/hsfs/metadata/StorageConnectorApi.java +++ b/java/src/main/java/com/logicalclocks/hsfs/metadata/StorageConnectorApi.java @@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.Arrays; public class StorageConnectorApi { @@ -34,7 +33,6 @@ public class StorageConnectorApi { 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); @@ -62,7 +60,7 @@ 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()) @@ -70,9 +68,6 @@ public StorageConnector getOnlineStorageConnector(FeatureStore featureStore) .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); } } diff --git a/python/hsfs/core/storage_connector_api.py b/python/hsfs/core/storage_connector_api.py index 115b7800b8..94f438bc3f 100644 --- a/python/hsfs/core/storage_connector_api.py +++ b/python/hsfs/core/storage_connector_api.py @@ -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) + )