Search in sources :

Example 1 with FeaturestoreJdbcConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreController method createOfflineJdbcConnector.

public FeaturestoreStorageConnectorDTO createOfflineJdbcConnector(String databaseName) throws FeaturestoreException {
    String hiveEndpoint = "";
    try {
        hiveEndpoint = serviceDiscoveryController.constructServiceFQDNWithPort(ServiceDiscoveryController.HopsworksService.HIVE_SERVER_TLS);
    } catch (ServiceDiscoveryException e) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.CONNECTOR_NOT_FOUND, Level.SEVERE, "Could not create Hive connection string", e.getMessage(), e);
    }
    String connectionString = HiveController.HIVE_JDBC_PREFIX + hiveEndpoint + "/" + databaseName + ";auth=noSasl;ssl=true;twoWay=true;";
    List<OptionDTO> arguments = FeaturestoreConstants.OFFLINE_JDBC_CONNECTOR_ARGS.stream().map(arg -> new OptionDTO(arg, null)).collect(Collectors.toList());
    FeaturestoreJdbcConnectorDTO featurestoreJdbcConnectorDTO = new FeaturestoreJdbcConnectorDTO();
    featurestoreJdbcConnectorDTO.setStorageConnectorType(FeaturestoreConnectorType.JDBC);
    featurestoreJdbcConnectorDTO.setName(databaseName);
    featurestoreJdbcConnectorDTO.setDescription("JDBC connector for the Offline Feature Store");
    featurestoreJdbcConnectorDTO.setConnectionString(connectionString);
    featurestoreJdbcConnectorDTO.setArguments(arguments);
    return featurestoreJdbcConnectorDTO;
}
Also used : ActivityFlag(io.hops.hopsworks.persistence.entity.user.activity.ActivityFlag) InodeController(io.hops.hopsworks.common.hdfs.inode.InodeController) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) DatasetController(io.hops.hopsworks.common.dataset.DatasetController) FeaturestoreJdbcConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO) Date(java.util.Date) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) FeaturegroupFacade(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupFacade) FeaturestoreConnectorType(io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnectorType) OnlineFeaturestoreController(io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController) Project(io.hops.hopsworks.persistence.entity.project.Project) Level(java.util.logging.Level) Settings(io.hops.hopsworks.common.util.Settings) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) TransactionAttributeType(javax.ejb.TransactionAttributeType) DatasetSharedWith(io.hops.hopsworks.persistence.entity.dataset.DatasetSharedWith) ServiceDiscoveryController(io.hops.hopsworks.common.hosts.ServiceDiscoveryController) TransactionAttribute(javax.ejb.TransactionAttribute) HdfsUsersController(io.hops.hopsworks.common.hdfs.HdfsUsersController) Path(org.apache.hadoop.fs.Path) ProjectException(io.hops.hopsworks.exceptions.ProjectException) FeaturestoreStorageConnectorController(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorController) EJB(javax.ejb.EJB) HiveController(io.hops.hopsworks.common.hive.HiveController) Stateless(javax.ejb.Stateless) TrainingDatasetFacade(io.hops.hopsworks.common.featurestore.trainingdatasets.TrainingDatasetFacade) ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) Collection(java.util.Collection) DatasetException(io.hops.hopsworks.exceptions.DatasetException) RESTCodes(io.hops.hopsworks.restutils.RESTCodes) ActivityFacade(io.hops.hopsworks.common.dao.user.activity.ActivityFacade) FeaturestoreConnectorFacade(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreConnectorFacade) DatasetType(io.hops.hopsworks.persistence.entity.dataset.DatasetType) Featurestore(io.hops.hopsworks.persistence.entity.featurestore.Featurestore) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) Collectors(java.util.stream.Collectors) FeaturestoreStorageConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO) FeaturestoreHopsfsConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO) UserException(io.hops.hopsworks.exceptions.UserException) ProjectTeamFacade(io.hops.hopsworks.common.dao.project.team.ProjectTeamFacade) List(java.util.List) Dataset(io.hops.hopsworks.persistence.entity.dataset.Dataset) Users(io.hops.hopsworks.persistence.entity.user.Users) DistributedFsService(io.hops.hopsworks.common.hdfs.DistributedFsService) FeaturestoreJdbcConnectorDTO(io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException)

Example 2 with FeaturestoreJdbcConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO 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)

Example 3 with FeaturestoreJdbcConnectorDTO

use of io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO in project hopsworks by logicalclocks.

the class FeaturestoreStorageConnectorController method updateStorageConnector.

@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Transactional(rollbackOn = FeaturestoreException.class)
public void updateStorageConnector(Users user, Project project, Featurestore featurestore, FeaturestoreStorageConnectorDTO featurestoreStorageConnectorDTO, String connectorName) throws FeaturestoreException, UserException, ProjectException {
    validateUser(user, featurestore);
    if (!connectorName.equalsIgnoreCase(featurestoreStorageConnectorDTO.getName())) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.ILLEGAL_STORAGE_CONNECTOR_ARG, Level.FINE, "Can not update connector name.");
    }
    FeaturestoreConnector featurestoreConnector = featurestoreConnectorFacade.findByFeaturestoreName(featurestore, connectorName).orElseThrow(() -> new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.CONNECTOR_NOT_FOUND, Level.FINE, "Cannot find storage connector with name: " + connectorName));
    verifyDescription(featurestoreStorageConnectorDTO);
    featurestoreConnector.setDescription(featurestoreStorageConnectorDTO.getDescription());
    switch(featurestoreConnector.getConnectorType()) {
        case HOPSFS:
            featurestoreConnector.setHopsfsConnector(hopsfsConnectorController.updateFeaturestoreHopsfsConnector(featurestore, (FeaturestoreHopsfsConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getHopsfsConnector()));
            break;
        case S3:
            featurestoreConnector.setS3Connector(s3ConnectorController.updateFeaturestoreS3Connector(user, featurestore, (FeaturestoreS3ConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getS3Connector()));
            break;
        case JDBC:
            featurestoreConnector.setJdbcConnector(jdbcConnectorController.updateFeaturestoreJdbcConnector((FeaturestoreJdbcConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getJdbcConnector()));
            break;
        case REDSHIFT:
            featurestoreConnector.setRedshiftConnector(redshiftConnectorController.updateFeaturestoreRedshiftConnector(user, featurestore, (FeaturestoreRedshiftConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getRedshiftConnector()));
            break;
        case ADLS:
            featurestoreConnector.setAdlsConnector(adlsConnectorController.updateAdlConnector(user, featurestore, (FeaturestoreADLSConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getAdlsConnector()));
            break;
        case SNOWFLAKE:
            featurestoreConnector.setSnowflakeConnector(snowflakeConnectorController.updateConnector(user, (FeaturestoreSnowflakeConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getSnowflakeConnector()));
            break;
        case KAFKA:
            featurestoreConnector.setKafkaConnector((kafkaConnectorController.updateConnector(user, featurestore, (FeatureStoreKafkaConnectorDTO) featurestoreStorageConnectorDTO, featurestoreConnector.getKafkaConnector())));
            break;
        default:
            // We should not reach this point
            throw new IllegalArgumentException("Feature Store connector type not recognized");
    }
    featurestoreConnector = featurestoreConnectorFacade.update(featurestoreConnector);
    activityFacade.persistActivity(ActivityFacade.UPDATED_FEATURESTORE_STORAGE_CONNECTOR + featurestoreConnector.getName(), project, user, ActivityFlag.SERVICE);
}
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) 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) TransactionAttribute(javax.ejb.TransactionAttribute) Transactional(javax.transaction.Transactional)

Aggregations

FeaturestoreHopsfsConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.hopsfs.FeaturestoreHopsfsConnectorDTO)3 FeaturestoreJdbcConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.jdbc.FeaturestoreJdbcConnectorDTO)3 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)3 FeaturestoreADLSConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.adls.FeaturestoreADLSConnectorDTO)2 FeaturestoreRedshiftConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.redshift.FeaturestoreRedshiftConnectorDTO)2 FeaturestoreS3ConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.s3.FeaturestoreS3ConnectorDTO)2 FeaturestoreSnowflakeConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.snowflake.FeaturestoreSnowflakeConnectorDTO)2 FeaturestoreConnector (io.hops.hopsworks.persistence.entity.featurestore.storageconnector.FeaturestoreConnector)2 TransactionAttribute (javax.ejb.TransactionAttribute)2 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)1 ProjectTeamFacade (io.hops.hopsworks.common.dao.project.team.ProjectTeamFacade)1 ActivityFacade (io.hops.hopsworks.common.dao.user.activity.ActivityFacade)1 DatasetController (io.hops.hopsworks.common.dataset.DatasetController)1 FeaturegroupFacade (io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupFacade)1 OnlineFeaturestoreController (io.hops.hopsworks.common.featurestore.online.OnlineFeaturestoreController)1 FeaturestoreConnectorFacade (io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreConnectorFacade)1 FeaturestoreStorageConnectorController (io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorController)1 FeaturestoreStorageConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.FeaturestoreStorageConnectorDTO)1 FeatureStoreKafkaConnectorDTO (io.hops.hopsworks.common.featurestore.storageconnectors.kafka.FeatureStoreKafkaConnectorDTO)1 TrainingDatasetFacade (io.hops.hopsworks.common.featurestore.trainingdatasets.TrainingDatasetFacade)1