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