Search in sources :

Example 1 with FeatureStoreKafkaConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.kafka.FeatureStoreKafkaConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorController method createStorageConnector.

/**
 * Creates a new Storage Connector of a specific type in a feature store
 *
 * @param user the user making the request
 * @param featurestore the featurestore to create the new connector
 * @param featurestoreStorageConnectorDTO the data to use when creating the storage connector
 * @return A JSON/XML DTOs representation of the created storage connector
 * @throws FeaturestoreException
 */
public FeaturestoreStorageConnectorDTO createStorageConnector(Users user, Project project, Featurestore featurestore, FeaturestoreStorageConnectorDTO featurestoreStorageConnectorDTO) throws FeaturestoreException, UserException, ProjectException {
    validateUser(user, featurestore);
    if (featurestoreConnectorFacade.findByFeaturestoreName(featurestore, featurestoreStorageConnectorDTO.getName()).isPresent()) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_STORAGE_CONNECTOR_NAME, Level.FINE, "Storage connector with the same name already exists. Name=" + featurestoreStorageConnectorDTO.getName());
    }
    FeaturestoreConnector featurestoreConnector = new FeaturestoreConnector();
    verifyName(featurestoreStorageConnectorDTO);
    featurestoreConnector.setName(featurestoreStorageConnectorDTO.getName());
    verifyDescription(featurestoreStorageConnectorDTO);
    featurestoreConnector.setDescription(featurestoreStorageConnectorDTO.getDescription());
    featurestoreConnector.setFeaturestore(featurestore);
    switch(featurestoreStorageConnectorDTO.getStorageConnectorType()) {
        case HOPSFS:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.HOPSFS);
            featurestoreConnector.setHopsfsConnector(hopsfsConnectorController.createFeaturestoreHopsfsConnector(featurestore, (FeaturestoreHopsfsConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case S3:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.S3);
            featurestoreConnector.setS3Connector(s3ConnectorController.createFeaturestoreS3Connector(user, featurestore, (FeaturestoreS3ConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case JDBC:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.JDBC);
            featurestoreConnector.setJdbcConnector(jdbcConnectorController.createFeaturestoreJdbcConnector((FeaturestoreJdbcConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case REDSHIFT:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.REDSHIFT);
            featurestoreConnector.setRedshiftConnector(redshiftConnectorController.createFeaturestoreRedshiftConnector(user, featurestore, (FeaturestoreRedshiftConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case ADLS:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.ADLS);
            featurestoreConnector.setAdlsConnector(adlsConnectorController.createADLConnector(user, project, featurestore, (FeaturestoreADLSConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case SNOWFLAKE:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.SNOWFLAKE);
            featurestoreConnector.setSnowflakeConnector(snowflakeConnectorController.createConnector(user, featurestore, (FeaturestoreSnowflakeConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        case KAFKA:
            featurestoreConnector.setConnectorType(FeaturestoreConnectorType.KAFKA);
            featurestoreConnector.setKafkaConnector(kafkaConnectorController.createConnector(user, featurestore, (FeatureStoreKafkaConnectorDTO) featurestoreStorageConnectorDTO));
            break;
        default:
            // We should not reach this point
            throw new IllegalArgumentException("Feature Store connector type not recognized");
    }
    // Update object to populate id (auto-increment) information
    featurestoreConnector = featurestoreConnectorFacade.update(featurestoreConnector);
    activityFacade.persistActivity(ActivityFacade.ADDED_FEATURESTORE_STORAGE_CONNECTOR + featurestoreConnector.getName(), project, user, ActivityFlag.SERVICE);
    return convertToConnectorDTO(user, project, featurestoreConnector);
}
Also used : FeaturestoreConnector(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnector) FeaturestoreJdbcConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO) FeaturestoreSnowflakeConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.snowflake.FeaturestoreSnowflakeConnectorDTO) FeaturestoreHopsfsConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO) FeatureStoreKafkaConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.kafka.FeatureStoreKafkaConnectorDTO) FeaturestoreS3ConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.s3.FeaturestoreS3ConnectorDTO) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) FeaturestoreADLSConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.adls.FeaturestoreADLSConnectorDTO) FeaturestoreRedshiftConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.redshift.FeaturestoreRedshiftConnectorDTO)

Aggregations

FeaturestoreADLSConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.adls.FeaturestoreADLSConnectorDTO)1 FeaturestoreHopsfsConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO)1 FeaturestoreJdbcConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO)1 FeatureStoreKafkaConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.kafka.FeatureStoreKafkaConnectorDTO)1 FeaturestoreRedshiftConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.redshift.FeaturestoreRedshiftConnectorDTO)1 FeaturestoreS3ConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.s3.FeaturestoreS3ConnectorDTO)1 FeaturestoreSnowflakeConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.snowflake.FeaturestoreSnowflakeConnectorDTO)1 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)1 FeaturestoreConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnector)1