Package org.lab41.dendrite.metagraph

Examples of org.lab41.dendrite.metagraph.DendriteGraph


                if (jobMap.containsKey(hadoopJobId)) {
                    setJobState(jobMap.get(hadoopJobId), JobMetadata.DONE);
                } else {
                    MetaGraphTx tx = metaGraph.newTransaction();
                    JobMetadata jobMetadata = tx.getJob(jobId);
                    JobMetadata childJobMetadata = tx.createJob(jobMetadata);
                    childJobMetadata.setName("faunusHadoopJob");
                    childJobMetadata.setState(JobMetadata.DONE);
                    childJobMetadata.setProgress(1.0f);
                    childJobMetadata.setMapreduceJobId(hadoopJobId.toString());
                    tx.commit();

                    jobMap.put(hadoopJobId, childJobMetadata.getId());
                }
            }
        }

        for (Job hadoopJob: failedJobs) {
            JobID hadoopJobId = hadoopJob.getJobID();
            logger.debug("found failed hadoop job:", hadoopJobId.toString());

            if (jobMap.containsKey(hadoopJobId)) {
                setJobState(jobMap.get(hadoopJobId), JobMetadata.ERROR);
            } else {
                MetaGraphTx tx = metaGraph.newTransaction();
                JobMetadata jobMetadata = tx.getJob(jobId);
                JobMetadata childJobMetadata = tx.createJob(jobMetadata);
                childJobMetadata.setName("faunusHadoopJob");
                childJobMetadata.setMapreduceJobId(hadoopJobId.toString());
                childJobMetadata.setState(JobMetadata.ERROR);
                tx.commit();

                jobMap.put(hadoopJobId, childJobMetadata.getId());
            }
        }

        float totalProgress;

        // Don't divide by zero if we don't have any jobs in progress.
        if (jobsInProgress.isEmpty()) {
            totalProgress = 1;
        } else {
            totalProgress = ((float) successfulJobs.size()) / ((float) jobsInProgress.size());
        }

        Job hadoopRunningJob = jobControl.getRunningJob();
        if (hadoopRunningJob != null) {
            JobID hadoopJobId = hadoopRunningJob.getJobID();
            logger.debug("found active hadoop job:", hadoopJobId.toString());

            JobStatus status = hadoopRunningJob.getStatus();
            float progress = 0.25f * (
                    status.getSetupProgress() +
                            status.getMapProgress() +
                            status.getReduceProgress() +
                            status.getCleanupProgress());

            logger.debug("found progress: "
                    + status.getSetupProgress() + " "
                    + status.getMapProgress() + " "
                    + status.getReduceProgress() + " "
                    + status.getCleanupProgress() + " "
                    + progress);

            if (jobMap.containsKey(hadoopJobId)) {
                setJobProgress(jobMap.get(hadoopJobId), progress);
            } else {
                MetaGraphTx tx = metaGraph.newTransaction();
                JobMetadata jobMetadata = tx.getJob(jobId);
                JobMetadata childJobMetadata = tx.createJob(jobMetadata);
                childJobMetadata.setName("faunusHadoopJob");
                childJobMetadata.setProgress(progress);
                childJobMetadata.setState(JobMetadata.RUNNING);
                childJobMetadata.setMapreduceJobId(hadoopJobId.toString());
                tx.commit();

                jobMap.put(hadoopJobId, childJobMetadata.getId());
            }

            JobMetadata.Id jobMetadataId = jobMap.get(hadoopJobId);
            setJobProgress(jobMetadataId, progress);
            totalProgress += (progress / ((float) jobsInProgress.size()));
View Full Code Here


    MetaGraphService metaGraphService;

    protected void setJobName(JobMetadata.Id jobId, String name) {
        MetaGraphTx tx = metaGraphService.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setName(name);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
View Full Code Here

    }

    protected void setJobState(JobMetadata.Id jobId, String state, String msg) {
        MetaGraphTx tx = metaGraphService.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setState(state);
            jobMetadata.setMessage(msg);

            if (state.equals(JobMetadata.DONE)) {
                jobMetadata.setProgress(1.0f);
            }

            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
View Full Code Here

    }

    protected void setJobProgress(JobMetadata.Id jobId, float progress) {
        MetaGraphTx tx = metaGraphService.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setProgress(progress);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
View Full Code Here

    }

    protected void setJobName(JobMetadata.Id jobId, String name) {
        MetaGraphTx tx = metaGraph.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setName(name);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
View Full Code Here

    }

    protected void setJobState(JobMetadata.Id jobId, String state, String msg) {
        MetaGraphTx tx = metaGraph.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setState(state);
            jobMetadata.setMessage(msg);

            if (state.equals(JobMetadata.DONE)) {
                jobMetadata.setProgress(1.0f);
            }

            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
View Full Code Here

    public GetJobsResponse getJobs(@PathVariable String projectId) throws NotFound {

        MetaGraphTx tx = metaGraphService.buildTransaction().readOnly().start();

        try {
            ProjectMetadata project = tx.getProject(projectId);
            if (project == null) {
                throw new NotFound(ProjectMetadata.class, projectId);
            }

            List<GetJobResponse> jobs = new ArrayList<>();
            for (JobMetadata jobMetadata : project.getJobs()) {
                jobs.add(new GetJobResponse(jobMetadata));
            }

            return new GetJobsResponse(jobs);
        } finally {
View Full Code Here

            response.put("msg", "missing graph metadata '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }

        ProjectMetadata projectMetadata = graphMetadata.getProject();
        if (projectMetadata == null) {
            response.put("status", "error");
            response.put("msg", "missing project metadata for graph '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
View Full Code Here

            response.put("msg", "missing graph metadata '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }

        ProjectMetadata projectMetadata = graphMetadata.getProject();
        if (projectMetadata == null) {
            response.put("status", "error");
            response.put("msg", "missing project metadata for graph '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
View Full Code Here

            response.put("msg", "missing graph metadata '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }

        ProjectMetadata projectMetadata = graphMetadata.getProject();
        if (projectMetadata == null) {
            response.put("status", "error");
            response.put("msg", "missing project metadata for graph '" + graphId + "'");
            tx.rollback();
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
View Full Code Here

TOP

Related Classes of org.lab41.dendrite.metagraph.DendriteGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.