Search in sources :

Example 11 with ProjectTeam

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

the class ProjectController method getProjectByID.

/**
 * Project info as data transfer object that can be sent to the user.
 *
 * @param projectID of the project
 * @return project DTO that contains team members and services
 */
public ProjectDTO getProjectByID(Integer projectID) throws ProjectException {
    Project project = projectFacade.find(projectID);
    if (project == null) {
        throw new ProjectException(RESTCodes.ProjectErrorCode.PROJECT_NOT_FOUND, Level.FINE, "projectId: " + projectID);
    }
    // find the project as an inode from hops database
    Inode inode = inodeController.getInodeAtPath(Utils.getProjectPath(project.getName()));
    List<ProjectTeam> projectTeam = projectTeamFacade.findMembersByProject(project);
    List<ProjectServiceEnum> projectServices = projectServicesFacade.findEnabledServicesForProject(project);
    List<String> services = new ArrayList<>();
    for (ProjectServiceEnum s : projectServices) {
        services.add(s.toString());
    }
    QuotasDTO quotas = getQuotasInternal(project);
    return new ProjectDTO(project, inode.getId(), services, projectTeam, quotas, settings.getHopsExamplesSparkFilename(), projectUtils.dockerImageIsPreinstalled(project.getDockerImage()), projectUtils.isOldDockerImage(project.getDockerImage()));
}
Also used : ProjectException(io.hops.hopsworks.exceptions.ProjectException) JupyterProject(io.hops.hopsworks.persistence.entity.jupyter.JupyterProject) Project(io.hops.hopsworks.persistence.entity.project.Project) ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) Inode(io.hops.hopsworks.persistence.entity.hdfs.inode.Inode) ArrayList(java.util.ArrayList) ProjectServiceEnum(io.hops.hopsworks.persistence.entity.project.service.ProjectServiceEnum)

Example 12 with ProjectTeam

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

the class ProjectController method addProjectOwner.

// Set the project owner as project master in ProjectTeam table
private void addProjectOwner(Project project, Users user) {
    ProjectTeamPK stp = new ProjectTeamPK(project.getId(), user.getEmail());
    ProjectTeam st = new ProjectTeam(stp);
    st.setTeamRole(ProjectRoleTypes.DATA_OWNER.getRole());
    // We don't trigger ProjectTeamRole handlers here. Owner's project team role must be handled within the project
    // creation handler.
    st.setTimestamp(new Date());
    st.setProject(project);
    st.setUser(user);
    project.getProjectTeamCollection().add(st);
    projectFacade.update(project);
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) ProjectTeamPK(io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK) Date(java.util.Date)

Example 13 with ProjectTeam

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

the class ProjectController method addServiceUser.

private Future<CertificatesController.CertsResult> addServiceUser(Project project, String username) throws IOException, HopsSecurityException, ProjectException {
    // Add the Serving Manager user to the project team
    Users serviceUser = userFacade.findByUsername(username);
    ProjectTeamPK stp = new ProjectTeamPK(project.getId(), serviceUser.getEmail());
    ProjectTeam st = new ProjectTeam(stp);
    st.setTeamRole(ProjectRoleTypes.DATA_SCIENTIST.getRole());
    st.setTimestamp(new Date());
    st.setUser(serviceUser);
    // Not fetched by jpa from project id in PK
    st.setProject(project);
    projectTeamFacade.persistProjectTeam(st);
    // Create the Hdfs user
    hdfsUsersController.addNewMember(st);
    // Create the certificate for this project user
    Future<CertificatesController.CertsResult> certsResultFuture = null;
    try {
        certsResultFuture = certificatesController.generateCertificates(project, serviceUser);
    } catch (Exception e) {
        throw new HopsSecurityException(RESTCodes.SecurityErrorCode.CERT_CREATION_ERROR, Level.SEVERE, "failed adding service user to project: " + project.getName() + "owner: " + username, e.getMessage(), e);
    }
    // trigger project team role add handlers
    ProjectTeamRoleHandler.runProjectTeamRoleAddMembersHandlers(projectTeamRoleHandlers, project, Collections.singletonList(serviceUser), ProjectRoleTypes.fromString(st.getTeamRole()), true);
    return certsResultFuture;
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) ProjectTeamPK(io.hops.hopsworks.persistence.entity.project.team.ProjectTeamPK) HdfsUsers(io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers) Users(io.hops.hopsworks.persistence.entity.user.Users) Date(java.util.Date) TensorBoardException(io.hops.hopsworks.exceptions.TensorBoardException) DatasetException(io.hops.hopsworks.exceptions.DatasetException) EJBException(javax.ejb.EJBException) AlertException(io.hops.hopsworks.exceptions.AlertException) PythonException(io.hops.hopsworks.exceptions.PythonException) FeaturestoreException(io.hops.hopsworks.exceptions.FeaturestoreException) RESTException(io.hops.hopsworks.restutils.RESTException) SQLException(java.sql.SQLException) ElasticException(io.hops.hopsworks.exceptions.ElasticException) AlertManagerConfigUpdateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigUpdateException) IOException(java.io.IOException) ServiceException(io.hops.hopsworks.exceptions.ServiceException) UserException(io.hops.hopsworks.exceptions.UserException) ExecutionException(java.util.concurrent.ExecutionException) ServingException(io.hops.hopsworks.exceptions.ServingException) AlertManagerResponseException(io.hops.hopsworks.alerting.exceptions.AlertManagerResponseException) CryptoPasswordNotFoundException(io.hops.hopsworks.exceptions.CryptoPasswordNotFoundException) ProjectException(io.hops.hopsworks.exceptions.ProjectException) AlertManagerUnreachableException(io.hops.hopsworks.alert.exception.AlertManagerUnreachableException) AlertManagerConfigReadException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigReadException) ServiceDiscoveryException(com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException) JobException(io.hops.hopsworks.exceptions.JobException) GenericException(io.hops.hopsworks.exceptions.GenericException) AlertManagerConfigCtrlCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerConfigCtrlCreateException) KafkaException(io.hops.hopsworks.exceptions.KafkaException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) ProvenanceException(io.hops.hopsworks.exceptions.ProvenanceException) AlertManagerClientCreateException(io.hops.hopsworks.alerting.exceptions.AlertManagerClientCreateException) SchemaException(io.hops.hopsworks.exceptions.SchemaException) HopsSecurityException(io.hops.hopsworks.exceptions.HopsSecurityException)

Example 14 with ProjectTeam

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

the class LivyController method getLivySessions.

/**
 * Get Livy sessions for project, depending on service type.
 *
 * @param project
 * @return
 */
public List<LivyMsg.Session> getLivySessions(Project project) {
    List<LivyMsg.Session> sessions = new ArrayList<>();
    LivyMsg sessionList = getLivySessions();
    if (sessionList == null || sessionList.getSessions() == null || sessionList.getSessions().length == 0) {
        return sessions;
    }
    List<ProjectTeam> projectTeam = teambean.findMembersByProject(project);
    for (ProjectTeam member : projectTeam) {
        String hdfsUsername = hdfsUserBean.getHdfsUserName(project, member.getUser());
        for (LivyMsg.Session s : sessionList.getSessions()) {
            if (hdfsUsername.equals(s.getProxyUser())) {
                YarnApplicationstate appStates = appStateBean.findByAppId(s.getAppId());
                if (appStates == null) {
                    continue;
                }
                s.setOwner(member.getUser().getEmail());
                sessions.add(s);
            }
        }
    }
    return sessions;
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam) YarnApplicationstate(io.hops.hopsworks.persistence.entity.jobs.history.YarnApplicationstate) ArrayList(java.util.ArrayList)

Example 15 with ProjectTeam

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

the class LivyController method deleteAllLivySessionsForProject.

/**
 * Deletes all livy sessions in the project
 *
 * @param project
 */
public void deleteAllLivySessionsForProject(Project project) {
    List<ProjectTeam> projectTeam;
    projectTeam = teambean.findMembersByProject(project);
    String hdfsUsername;
    for (ProjectTeam member : projectTeam) {
        hdfsUsername = hdfsUserBean.getHdfsUserName(project, member.getUser());
        deleteAllLivySessions(hdfsUsername);
    }
}
Also used : ProjectTeam(io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)

Aggregations

ProjectTeam (io.hops.hopsworks.persistence.entity.project.team.ProjectTeam)30 Users (io.hops.hopsworks.persistence.entity.user.Users)13 Project (io.hops.hopsworks.persistence.entity.project.Project)11 ArrayList (java.util.ArrayList)10 ProjectException (io.hops.hopsworks.exceptions.ProjectException)9 HdfsUsers (io.hops.hopsworks.persistence.entity.hdfs.user.HdfsUsers)8 IOException (java.io.IOException)7 GenericException (io.hops.hopsworks.exceptions.GenericException)6 Date (java.util.Date)6 UserException (io.hops.hopsworks.exceptions.UserException)5 Produces (javax.ws.rs.Produces)5 DatasetException (io.hops.hopsworks.exceptions.DatasetException)4 FeaturestoreException (io.hops.hopsworks.exceptions.FeaturestoreException)4 HopsSecurityException (io.hops.hopsworks.exceptions.HopsSecurityException)4 KafkaException (io.hops.hopsworks.exceptions.KafkaException)4 ServiceException (io.hops.hopsworks.exceptions.ServiceException)4 Inode (io.hops.hopsworks.persistence.entity.hdfs.inode.Inode)4 Path (javax.ws.rs.Path)4 ServiceDiscoveryException (com.logicalclocks.servicediscoverclient.exceptions.ServiceDiscoveryException)3 AlertManagerUnreachableException (io.hops.hopsworks.alert.exception.AlertManagerUnreachableException)3