Search in sources :

Example 1 with ProjectServices

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

the class ProjectServiceFacade method persistServicesForProject.

// TODO: write tests for this
public void persistServicesForProject(Project project, ProjectServiceEnum[] services) {
    // TODO: use copy instead
    List<ProjectServices> newSrvs = new ArrayList<>(services.length);
    List<ProjectServices> toPersist = new ArrayList<>(services.length);
    for (ProjectServiceEnum sse : services) {
        ProjectServices c = new ProjectServices(project, sse);
        newSrvs.add(c);
        toPersist.add(c);
    }
    List<ProjectServices> current = getAllProjectServicesForProject(project);
    toPersist.removeAll(current);
    current.removeAll(newSrvs);
    for (ProjectServices se : toPersist) {
        em.persist(se);
    }
    for (ProjectServices se : current) {
        em.remove(se);
    }
}
Also used : ProjectServices(io.hops.hopsworks.persistence.entity.project.service.ProjectServices) ArrayList(java.util.ArrayList) ProjectServiceEnum(io.hops.hopsworks.persistence.entity.project.service.ProjectServiceEnum)

Example 2 with ProjectServices

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

the class ProjectServiceFacade method addServiceForProject.

public void addServiceForProject(Project project, ProjectServiceEnum service) {
    if (!findEnabledServicesForProject(project).contains(service)) {
        ProjectServices ss = new ProjectServices(project, service);
        em.persist(ss);
    }
}
Also used : ProjectServices(io.hops.hopsworks.persistence.entity.project.service.ProjectServices)

Example 3 with ProjectServices

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

the class YarnExecutionFinalizer method cleanCerts.

private void cleanCerts(Execution exec) {
    // Remove local files required for the job (Kafka certs etc.)
    // Search for other jobs using Kafka in the same project. If any active
    // ones are found
    Collection<ProjectServices> projectServices = exec.getJob().getProject().getProjectServicesCollection();
    Iterator<ProjectServices> iter = projectServices.iterator();
    boolean removeKafkaCerts = true;
    while (iter.hasNext()) {
        ProjectServices projectService = iter.next();
        // If the project is of type KAFKA
        if (projectService.getProjectServicesPK().getService() == ProjectServiceEnum.KAFKA) {
            List<Execution> execs = executionFacade.findByProjectAndType(exec.getJob().getProject(), JobType.FLINK);
            if (execs != null) {
                execs.addAll(executionFacade.findByProjectAndType(exec.getJob().getProject(), JobType.SPARK));
            }
            // Find if this project has running jobs
            if (execs != null && !execs.isEmpty()) {
                for (Execution exe : execs) {
                    if (!exe.getState().isFinalState()) {
                        removeKafkaCerts = false;
                        break;
                    }
                }
            }
        }
    }
    if (removeKafkaCerts) {
        String k_certName = exec.getHdfsUser() + "__kstore.jks";
        String t_certName = exec.getHdfsUser() + "__tstore.jks";
        File k_cert = new File(settings.getHopsworksDomainDir() + "/domain1/config/" + k_certName);
        File t_cert = new File(settings.getHopsworksDomainDir() + "/domain1/config/" + t_certName);
        if (k_cert.exists()) {
            k_cert.delete();
        }
        if (t_cert.exists()) {
            t_cert.delete();
        }
    }
}
Also used : ProjectServices(io.hops.hopsworks.persistence.entity.project.service.ProjectServices) Execution(io.hops.hopsworks.persistence.entity.jobs.history.Execution) File(java.io.File)

Aggregations

ProjectServices (io.hops.hopsworks.persistence.entity.project.service.ProjectServices)3 Execution (io.hops.hopsworks.persistence.entity.jobs.history.Execution)1 ProjectServiceEnum (io.hops.hopsworks.persistence.entity.project.service.ProjectServiceEnum)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1