Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper endpoint to retrive the online storage connector #192

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
)