Search in sources :

Example 81 with Project

use of io.hops.hopsworks.persistence.entity.project.Project in project hopsworks by logicalclocks.

the class ProjectsAdmin method setProjectAdminInfo.

@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Path("/projects")
public Response setProjectAdminInfo(ProjectAdminInfoDTO projectAdminInfoDTO, @Context SecurityContext sc) throws ProjectException {
    // for changes in space quotas we need to check that both space and ns options are not null
    QuotasDTO quotasDTO = projectAdminInfoDTO.getProjectQuotas();
    if (quotasDTO != null && (((quotasDTO.getHdfsQuotaInBytes() == null) != (quotasDTO.getHdfsNsQuota() == null)) || ((quotasDTO.getHiveHdfsQuotaInBytes() == null) != (quotasDTO.getHiveHdfsNsQuota() == null)) || ((quotasDTO.getFeaturestoreHdfsQuotaInBytes() == null) != (quotasDTO.getFeaturestoreHdfsNsQuota() == null)))) {
        throw new IllegalArgumentException("projectAdminInfoDTO did not provide quotasDTO or the latter was incomplete.");
    }
    // Build the new project state as Project object
    Project project = new Project();
    project.setKafkaMaxNumTopics(settings.getKafkaMaxNumTopics());
    project.setName(projectAdminInfoDTO.getProjectName());
    project.setArchived(projectAdminInfoDTO.getArchived());
    project.setPaymentType(projectAdminInfoDTO.getPaymentType());
    projectController.adminProjectUpdate(project, quotasDTO);
    return noCacheResponse.getNoCacheResponseBuilder(Response.Status.OK).build();
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) QuotasDTO(io.hops.hopsworks.common.project.QuotasDTO) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT)

Example 82 with Project

use of io.hops.hopsworks.persistence.entity.project.Project in project hopsworks by logicalclocks.

the class ProjectsAdmin method builder.

private ProjectRestDTO builder(Users users, UriInfo uriInfo) {
    List<Project> projects = projectFacade.findByUser(users);
    ProjectRestDTO dto = new ProjectRestDTO(uriInfo.getAbsolutePathBuilder().build());
    projects.forEach(project -> dto.addItem(new ProjectRestDTO(uriInfo.getBaseUriBuilder().path("admin").path("projects").path(project.getId().toString()).build(), project.getId(), project.getName(), project.getCreated())));
    return dto;
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) ProjectRestDTO(io.hops.hopsworks.api.project.ProjectRestDTO)

Example 83 with Project

use of io.hops.hopsworks.persistence.entity.project.Project in project hopsworks by logicalclocks.

the class ConfigUtil method getMatch.

public static Map<String, String> getMatch(ProjectServiceAlert alert) {
    Project project = alert.getProject();
    Map<String, String> match = new HashMap<>();
    match.put(Constants.ALERT_TYPE_LABEL, alert.getAlertType().getValue());
    match.put(Constants.LABEL_PROJECT, project.getName());
    match.put(Constants.LABEL_STATUS, alert.getStatus().getName());
    return match;
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) HashMap(java.util.HashMap)

Example 84 with Project

use of io.hops.hopsworks.persistence.entity.project.Project in project hopsworks by logicalclocks.

the class ConfigUtil method getMatch.

public static Map<String, String> getMatch(JobAlert alert) {
    Project project = alert.getJobId().getProject();
    Map<String, String> match = new HashMap<>();
    match.put(Constants.ALERT_TYPE_LABEL, alert.getAlertType().getValue());
    match.put(Constants.LABEL_PROJECT, project.getName());
    match.put(Constants.LABEL_JOB, alert.getJobId().getName());
    match.put(Constants.LABEL_STATUS, alert.getStatus().getName());
    return match;
}
Also used : Project(io.hops.hopsworks.persistence.entity.project.Project) HashMap(java.util.HashMap)

Example 85 with Project

use of io.hops.hopsworks.persistence.entity.project.Project in project hopsworks by logicalclocks.

the class FeatureGroupValidationsController method putFeatureGroupValidationResults.

public FeatureGroupValidation putFeatureGroupValidationResults(Users user, Project project, Featuregroup featuregroup, List<ExpectationResult> results, Long validationTime, Boolean logActivity) throws FeaturestoreException {
    FeatureGroupValidation.Status status = getValidationResultStatus(results);
    alertController.sendAlert(featuregroup, results, status);
    String hdfsUsername = hdfsUsersController.getHdfsUserName(project, user);
    DistributedFileSystemOps udfso = null;
    try {
        String path2result = String.format(PATH_TO_DATA_VALIDATION_RESULT, project.getName(), featuregroup.getName(), featuregroup.getVersion()) + Path.SEPARATOR + validationTime;
        udfso = distributedFsService.getDfsOps(hdfsUsername);
        Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
        try (FSDataOutputStream outStream = udfso.create(path2result)) {
            outStream.writeBytes(gson.toJson(results));
            outStream.hflush();
        }
        Date validationTimeDate = new Timestamp(validationTime);
        FeatureGroupValidation featureGroupValidation = new FeatureGroupValidation(validationTimeDate, inodeController.getInodeAtPath(path2result), featuregroup, getValidationResultStatus(results));
        featureGroupValidationFacade.persist(featureGroupValidation);
        // Activity logged only if validations ran as part of a fg.save/insert operation
        if (logActivity) {
            activityFacade.logValidationActivity(featuregroup, user, featureGroupValidation);
        }
        // Persist validation results but throw an error if the data is invalid so that the client (hsfs) does not insert
        if (featuregroup.getValidationType().getSeverity() < status.getSeverity()) {
            throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.FEATURE_GROUP_CHECKS_FAILED, FINE, "Results: " + results.stream().filter(result -> result.getStatus().getSeverity() >= FeatureGroupValidation.Status.WARNING.getSeverity()).collect(Collectors.toList()));
        }
        return featureGroupValidation;
    } catch (IOException ex) {
        throw new FeaturestoreException(RESTCodes.FeaturestoreErrorCode.COULD_NOT_READ_DATA_VALIDATION_RESULT, java.util.logging.Level.WARNING, "Failed to persist validation results", "Failed to persist validation result to HDFS for Feature group " + featuregroup.getName(), ex);
    } finally {
        distributedFsService.closeDfsClient(udfso);
    }
}
Also used : Arrays(java.util.Arrays) Expectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Expectation) Date(java.util.Date) FileStatus(org.apache.hadoop.fs.FileStatus) GsonBuilder(com.google.gson.GsonBuilder) ExpectationResult(io.hops.hopsworks.common.featurestore.featuregroup.ExpectationResult) Settings(io.hops.hopsworks.common.util.Settings) Rule(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Rule) TransactionAttributeType(javax.ejb.TransactionAttributeType) Gson(com.google.gson.Gson) Map(java.util.Map) Path(org.apache.hadoop.fs.Path) FeatureType(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureType) FeatureGroupFeatureDTO(io.hops.hopsworks.common.featurestore.feature.FeatureGroupFeatureDTO) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) Stateless(javax.ejb.Stateless) FeatureGroupCommit(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.cached.FeatureGroupCommit) Timestamp(java.sql.Timestamp) Featuregroup(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup) Set(java.util.Set) RESTCodes(io.hops.hopsworks.restutils.RESTCodes) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) ValidationRule(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.ValidationRule) Pair(org.javatuples.Pair) Predicate(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Predicate) JsonArray(com.google.gson.JsonArray) List(java.util.List) ValidationResult(io.hops.hopsworks.common.featurestore.featuregroup.ValidationResult) FeatureStoreExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureStoreExpectation) Optional(java.util.Optional) FeatureGroupCommitFacade(io.hops.hopsworks.common.featurestore.featuregroup.cached.FeatureGroupCommitFacade) Level(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Level) DistributedFsService(io.hops.hopsworks.common.hdfs.DistributedFsService) InodeController(io.hops.hopsworks.common.hdfs.inode.InodeController) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) HashMap(java.util.HashMap) AlertController(io.hops.hopsworks.common.alert.AlertController) Project(io.hops.hopsworks.persistence.entity.project.Project) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) HashSet(java.util.HashSet) Strings(com.google.common.base.Strings) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) FieldNamingPolicy(com.google.gson.FieldNamingPolicy) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) FeaturestoreActivityFacade(io.hops.hopsworks.common.featurestore.activity.FeaturestoreActivityFacade) TransactionAttribute(javax.ejb.TransactionAttribute) HdfsUsersController(io.hops.hopsworks.common.hdfs.HdfsUsersController) FeatureGroupValidation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupValidation) EJB(javax.ejb.EJB) FINE(java.util.logging.Level.FINE) IOException(java.io.IOException) Featurestore(io.hops.hopsworks.persistence.entity.featurestore.Featurestore) Name(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.Name) FeaturegroupController(io.hops.hopsworks.common.featurestore.featuregroup.FeaturegroupController) IOUtils(org.apache.hadoop.io.IOUtils) Users(io.hops.hopsworks.persistence.entity.user.Users) FeatureGroupExpectation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupExpectation) Collections(java.util.Collections) GsonBuilder(com.google.gson.GsonBuilder) FeatureGroupValidation(io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidation.FeatureGroupValidation) DistributedFileSystemOps(io.hops.hopsworks.common.hdfs.DistributedFileSystemOps) Gson(com.google.gson.Gson) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) IOException(java.io.IOException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Aggregations

Project (io.hops.hopsworks.persistence.entity.project.Project)179 Users (io.hops.hopsworks.persistence.entity.user.Users)73 Produces (javax.ws.rs.Produces)54 ProjectException (io.hops.hopsworks.exceptions.ProjectException)51 Path (javax.ws.rs.Path)46 AllowedProjectRoles (io.hops.hopsworks.api.filter.AllowedProjectRoles)40 JWTRequired (io.hops.hopsworks.jwt.annotation.JWTRequired)39 ArrayList (java.util.ArrayList)32 ApiOperation (io.swagger.annotations.ApiOperation)31 DatasetException (io.hops.hopsworks.exceptions.DatasetException)29 IOException (java.io.IOException)29 ResourceRequest (io.hops.hopsworks.common.api.ResourceRequest)26 TransactionAttribute (javax.ejb.TransactionAttribute)26 GET (javax.ws.rs.GET)26 Dataset (io.hops.hopsworks.persistence.entity.dataset.Dataset)25 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)23 EJB (javax.ejb.EJB)23 TransactionAttributeType (javax.ejb.TransactionAttributeType)23 Featurestore (io.hops.hopsworks.persistence.entity.featurestore.Featurestore)21 Featuregroup (io.hops.hopsworks.persistence.entity.featurestore.featuregroup.Featuregroup)21