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()));
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations