Search in sources :

Example 11 with HpcAccount

use of edu.pitt.dbmi.tetrad.db.entity.HpcAccount in project tetrad by cmu-phil.

the class HpcJobActivityEditor method getFinishedRowData.

private Vector<Vector<String>> getFinishedRowData(final TetradDesktop desktop, final List<HpcAccount> exclusiveHpcAccounts) throws Exception {
    final Vector<Vector<String>> finishedRowData = new Vector<>();
    HpcJobManager hpcJobManager = desktop.getHpcJobManager();
    Map<Long, HpcJobInfo> finishedHpcJobIdMap = null;
    // Finished jobs
    Map<HpcAccount, Set<HpcJobInfo>> finishedHpcJobInfoMap = hpcJobManager.getFinishedHpcJobInfoMap();
    for (HpcAccount hpcAccount : finishedHpcJobInfoMap.keySet()) {
        if (exclusiveHpcAccounts != null && !exclusiveHpcAccounts.contains(hpcAccount)) {
            continue;
        }
        Set<HpcJobInfo> finishedHpcJobSet = finishedHpcJobInfoMap.get(hpcAccount);
        for (HpcJobInfo hpcJobInfo : finishedHpcJobSet) {
            if (finishedHpcJobIdMap == null) {
                finishedHpcJobIdMap = new HashMap<>();
            }
            finishedHpcJobIdMap.put(hpcJobInfo.getId(), hpcJobInfo);
        }
    }
    if (finishedHpcJobIdMap != null) {
        List<Long> finishedJobIds = new ArrayList<>(finishedHpcJobIdMap.keySet());
        Collections.sort(finishedJobIds);
        Collections.reverse(finishedJobIds);
        for (Long jobId : finishedJobIds) {
            final HpcJobInfo hpcJobInfo = finishedHpcJobIdMap.get(jobId);
            Vector<String> rowData = new Vector<>();
            HpcJobLog hpcJobLog = hpcJobManager.getHpcJobLog(hpcJobInfo);
            // Local job id
            rowData.add(hpcJobInfo.getId().toString());
            int status = hpcJobInfo.getStatus();
            switch(status) {
                case 3:
                    rowData.add("Finished");
                    break;
                case 4:
                    rowData.add("Canceled");
                    break;
                case 5:
                    rowData.add("Finished");
                    break;
                case 6:
                    rowData.add("Error");
                    break;
            }
            // Locally added time
            rowData.add(FilePrint.fileTimestamp(hpcJobLog.getAddedTime().getTime()));
            // HPC node name
            HpcAccount hpcAccount = hpcJobInfo.getHpcAccount();
            rowData.add(hpcAccount.getConnectionName());
            // Algorithm
            rowData.add(hpcJobInfo.getAlgoId());
            // Submitted time
            rowData.add(hpcJobInfo.getSubmittedTime() != null ? FilePrint.fileTimestamp(hpcJobInfo.getSubmittedTime().getTime()) : "");
            // HPC job id
            rowData.add("" + hpcJobInfo.getPid());
            // Result Name
            switch(status) {
                case 3:
                    rowData.add(hpcJobInfo.getResultFileName());
                    break;
                case 4:
                    rowData.add("");
                    break;
                case 5:
                    rowData.add(hpcJobInfo.getResultFileName());
                    break;
                case 6:
                    rowData.add(hpcJobInfo.getErrorResultFileName());
                    break;
            }
            // Finished time
            if (status != 4) {
                rowData.add(FilePrint.fileTimestamp(hpcJobLog.getEndedTime().getTime()));
            } else {
                rowData.add("");
            }
            // Canceled time
            if (status == 4) {
                rowData.add(hpcJobLog.getCanceledTime() != null ? FilePrint.fileTimestamp(hpcJobLog.getCanceledTime().getTime()) : "");
            } else {
                rowData.add("");
            }
            // Last update time
            rowData.add(FilePrint.fileTimestamp(hpcJobLog.getLastUpdatedTime().getTime()));
            // Delete job from db
            rowData.add("Delete");
            finishedRowData.add(rowData);
        }
    }
    return finishedRowData;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ArrayList(java.util.ArrayList) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) FilePrint(edu.pitt.dbmi.ccd.commons.file.FilePrint) HpcJobManager(edu.cmu.tetradapp.app.hpc.manager.HpcJobManager) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo) Vector(java.util.Vector) HpcJobLog(edu.pitt.dbmi.tetrad.db.entity.HpcJobLog)

Example 12 with HpcAccount

use of edu.pitt.dbmi.tetrad.db.entity.HpcAccount in project tetrad by cmu-phil.

the class HpcJobManager method updateSubmittedHpcJobInfo.

public synchronized void updateSubmittedHpcJobInfo(final HpcJobInfo hpcJobInfo) {
    final HpcAccount hpcAccount = hpcJobInfo.getHpcAccount();
    Set<HpcJobInfo> hpcJobInfos = submittedHpcJobInfoMap.get(hpcAccount);
    if (hpcJobInfos != null) {
        for (HpcJobInfo jobInfo : hpcJobInfos) {
            if (jobInfo.getId() == hpcJobInfo.getId()) {
                // LOGGER.debug("updateSubmittedHpcJobInfo: Found
                // hpcJobInfo in the submittedHpcJobInfoMap & removed it!");
                hpcJobInfos.remove(jobInfo);
            }
        }
        hpcJobInfos.add(hpcJobInfo);
        submittedHpcJobInfoMap.put(hpcAccount, hpcJobInfos);
    }
}
Also used : HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)

Example 13 with HpcAccount

use of edu.pitt.dbmi.tetrad.db.entity.HpcAccount in project tetrad by cmu-phil.

the class HpcJobManager method removeFinishedHpcJob.

public synchronized void removeFinishedHpcJob(final HpcJobInfo hpcJobInfo) {
    HpcAccount hpcAccount = hpcJobInfo.getHpcAccount();
    LOGGER.debug("removedFinishedHpcJob: connection: " + hpcAccount.getConnectionName());
    LOGGER.debug("removedFinishedHpcJob: algorithm: " + hpcJobInfo.getAlgoId());
    LOGGER.debug("removedFinishedHpcJob: status: " + hpcJobInfo.getStatus());
    LOGGER.debug("removedFinishedHpcJob: pid: " + hpcJobInfo.getPid());
    Set<HpcJobInfo> hpcJobInfos = submittedHpcJobInfoMap.get(hpcAccount);
    if (hpcJobInfos != null) {
        for (HpcJobInfo jobInfo : hpcJobInfos) {
            if (jobInfo.getId() == hpcJobInfo.getId()) {
                // LOGGER.debug("removeFinishedHpcJob: Found
                // hpcJobInfo in the submittedHpcJobInfoMap & removed it!");
                hpcJobInfos.remove(jobInfo);
            }
        }
        if (hpcJobInfos.isEmpty()) {
            submittedHpcJobInfoMap.remove(hpcAccount);
        } else {
            submittedHpcJobInfoMap.put(hpcAccount, hpcJobInfos);
        }
    }
    hpcGraphResultMap.remove(hpcJobInfo);
}
Also used : HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)

Example 14 with HpcAccount

use of edu.pitt.dbmi.tetrad.db.entity.HpcAccount in project tetrad by cmu-phil.

the class HpcJobManager method resumePreProcessJobs.

private synchronized void resumePreProcessJobs() {
    // Lookup on DB for HpcJobInfo with status -1 (Pending)
    List<HpcJobInfo> pendingHpcJobInfo = hpcJobInfoService.findByStatus(-1);
    if (pendingHpcJobInfo != null) {
        for (HpcJobInfo hpcJobInfo : pendingHpcJobInfo) {
            LOGGER.debug("resumePreProcessJobs: " + hpcJobInfo.getAlgoId() + " : " + hpcJobInfo.getHpcAccount().getConnectionName() + " : " + hpcJobInfo.getAlgorithmParamRequest().getDatasetPath());
            final HpcAccount hpcAccount = hpcJobInfo.getHpcAccount();
            Set<HpcJobInfo> hpcJobInfos = pendingHpcJobInfoMap.get(hpcAccount);
            if (hpcJobInfos == null) {
                hpcJobInfos = new LinkedHashSet<>();
            }
            hpcJobInfos.add(hpcJobInfo);
            pendingHpcJobInfoMap.put(hpcAccount, hpcJobInfos);
            HpcJobPreProcessTask preProcessTask = new HpcJobPreProcessTask(hpcJobInfo);
            executorService.submit(preProcessTask);
        }
    } else {
        LOGGER.debug("resumePreProcessJobs: no pending jobs to be resumed");
    }
}
Also used : HpcJobPreProcessTask(edu.cmu.tetradapp.app.hpc.task.HpcJobPreProcessTask) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)

Example 15 with HpcAccount

use of edu.pitt.dbmi.tetrad.db.entity.HpcAccount in project tetrad by cmu-phil.

the class HpcJobManager method getFinishedHpcJobInfoMap.

public synchronized Map<HpcAccount, Set<HpcJobInfo>> getFinishedHpcJobInfoMap() {
    final Map<HpcAccount, Set<HpcJobInfo>> finishedHpcJobInfoMap = new HashMap<>();
    // 5 (Result Downloaded); 6 (Error Result Downloaded);
    for (int status = 3; status <= 6; status++) {
        // LOGGER.debug("getFinishedHpcJobInfoMap: "
        // + "looping status: " + status);
        List<HpcJobInfo> finishedHpcJobInfo = hpcJobInfoService.findByStatus(status);
        if (finishedHpcJobInfo != null) {
            for (HpcJobInfo hpcJobInfo : finishedHpcJobInfo) {
                final HpcAccount hpcAccount = hpcJobInfo.getHpcAccount();
                Set<HpcJobInfo> hpcJobInfos = finishedHpcJobInfoMap.get(hpcAccount);
                if (hpcJobInfos == null) {
                    hpcJobInfos = new LinkedHashSet<>();
                }
                hpcJobInfos.add(hpcJobInfo);
                finishedHpcJobInfoMap.put(hpcAccount, hpcJobInfos);
            }
        }
    }
    return finishedHpcJobInfoMap;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) HpcAccount(edu.pitt.dbmi.tetrad.db.entity.HpcAccount) HpcJobInfo(edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)

Aggregations

HpcAccount (edu.pitt.dbmi.tetrad.db.entity.HpcAccount)20 HpcJobInfo (edu.pitt.dbmi.tetrad.db.entity.HpcJobInfo)14 HpcJobLog (edu.pitt.dbmi.tetrad.db.entity.HpcJobLog)7 Set (java.util.Set)7 HashSet (java.util.HashSet)6 HpcAccountManager (edu.cmu.tetradapp.app.hpc.manager.HpcAccountManager)5 HpcJobManager (edu.cmu.tetradapp.app.hpc.manager.HpcJobManager)5 FilePrint (edu.pitt.dbmi.ccd.commons.file.FilePrint)5 HashMap (java.util.HashMap)4 TetradDesktop (edu.cmu.tetradapp.app.TetradDesktop)3 JobInfo (edu.pitt.dbmi.ccd.rest.client.dto.algo.JobInfo)3 AlgorithmParamRequest (edu.pitt.dbmi.tetrad.db.entity.AlgorithmParamRequest)3 BorderLayout (java.awt.BorderLayout)3 Dimension (java.awt.Dimension)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Vector (java.util.Vector)3 JPanel (javax.swing.JPanel)3 HpcAccountService (edu.cmu.tetradapp.app.hpc.manager.HpcAccountService)2 HpcJobPreProcessTask (edu.cmu.tetradapp.app.hpc.task.HpcJobPreProcessTask)2