Search in sources :

Example 1 with FeaturestoreJdbcConnector

use of io.hops.hopsworks.persistence.entity.featurestore.storageconnector.jdbc.FeaturestoreJdbcConnector in project hopsworks by logicalclocks.

the class OnlineFeaturestoreController method createJdbcConnectorForOnlineFeaturestore.

/**
 * Utility function for create a JDBC connection to the online featurestore for a particular user.
 *
 * @param onlineDbUsername the db-username of the connection
 * @param featurestore the featurestore metadata
 * @param dbName name of the MySQL database
 * @return DTO of the newly created connector
 * @throws FeaturestoreException
 */
public void createJdbcConnectorForOnlineFeaturestore(String onlineDbUsername, Featurestore featurestore, String dbName) throws FeaturestoreException {
    String connectorName = onlineDbUsername + FeaturestoreConstants.ONLINE_FEATURE_STORE_CONNECTOR_SUFFIX;
    if (featurestoreConnectorFacade.findByFeaturestoreName(featurestore, connectorName).isPresent()) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_STORAGE_CONNECTOR_NAME, Level.FINE, "a storage connector with that name already exists");
    }
    FeaturestoreConnector featurestoreConnector = new FeaturestoreConnector();
    featurestoreConnector.setName(connectorName);
    featurestoreConnector.setDescription("JDBC connection to Hopsworks Project Online " + "Feature Store NDB Database for user: " + onlineDbUsername);
    featurestoreConnector.setFeaturestore(featurestore);
    featurestoreConnector.setConnectorType(FeaturestoreConnectorType.JDBC);
    FeaturestoreJdbcConnector featurestoreJdbcConnector = new FeaturestoreJdbcConnector();
    featurestoreJdbcConnector.setConnectionString(settings.getFeaturestoreJdbcUrl() + dbName + "?useSSL=false&allowPublicKeyRetrieval=true");
    List<OptionDTO> arguments = new ArrayList<>();
    arguments.add(new OptionDTO(FeaturestoreConstants.ONLINE_FEATURE_STORE_JDBC_PASSWORD_ARG, FeaturestoreConstants.ONLINE_FEATURE_STORE_CONNECTOR_PASSWORD_TEMPLATE));
    arguments.add(new OptionDTO(FeaturestoreConstants.ONLINE_FEATURE_STORE_JDBC_USER_ARG, onlineDbUsername));
    arguments.add(new OptionDTO(FeaturestoreConstants.ONLINE_FEATURE_STORE_JDBC_DRIVER_ARG, MYSQL_DRIVER));
    arguments.add(new OptionDTO("isolationLevel", "NONE"));
    arguments.add(new OptionDTO("batchsize", "500"));
    featurestoreJdbcConnector.setArguments(storageConnectorUtil.fromOptions(arguments));
    featurestoreConnector.setJdbcConnector(featurestoreJdbcConnector);
    featurestoreConnectorFacade.update(featurestoreConnector);
}
Also used : FeaturestoreConnector(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnector) FeaturestoreJdbcConnector(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.jdbc.FeaturestoreJdbcConnector) ArrayList(java.util.ArrayList) OptionDTO(io.hops.hopsworks.common.featurestore.OptionDTO) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException)

Example 2 with FeaturestoreJdbcConnector

use of io.hops.hopsworks.persistence.entity.featurestore.storageconnector.jdbc.FeaturestoreJdbcConnector in project hopsworks by logicalclocks.

the class FeaturestoreJdbcConnectorController method createFeaturestoreJdbcConnector.

public FeaturestoreJdbcConnector createFeaturestoreJdbcConnector(FeaturestoreJdbcConnectorDTO featurestoreJdbcConnectorDTO) throws FeaturestoreException {
    verifyJdbcConnectorConnectionString(featurestoreJdbcConnectorDTO.getConnectionString());
    String argumentsString = storageConnectorUtil.fromOptions(featurestoreJdbcConnectorDTO.getArguments());
    verifyJdbcConnectorArguments(argumentsString);
    FeaturestoreJdbcConnector featurestoreJdbcConnector = new FeaturestoreJdbcConnector();
    featurestoreJdbcConnector.setArguments(argumentsString);
    featurestoreJdbcConnector.setConnectionString(featurestoreJdbcConnectorDTO.getConnectionString());
    return featurestoreJdbcConnector;
}
Also used : FeaturestoreJdbcConnector(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.jdbc.FeaturestoreJdbcConnector)

Aggregations

FeaturestoreJdbcConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.jdbc.FeaturestoreJdbcConnector)2 OptionDTO (io.hops.hopsworks.common.featurestore.OptionDTO)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 FeaturestoreConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnector)1 ArrayList (java.util.ArrayList)1