private void buildJobProcessListEntry()

in uima-ducc-web/src/main/java/org/apache/uima/ducc/ws/server/DuccHandler.java [698:1082]


	private void buildJobProcessListEntry(EffectiveUser eu, StringBuffer pb, DuccWorkJob job, IDuccProcess process, DetailsType dType, AllocationType sType, int counter, Map<String, FileInfo> fileInfoMap) {
		StringBuffer rb = new StringBuffer();
		int COLS = 26;
		switch(sType) {
		case SPC:
		case SPU:
			COLS++;	// Services
			COLS++;	// Memory
			break;
		default:
			break;
		}
		StringBuffer[] cbList = new StringBuffer[COLS];
		for(int i=0; i < COLS; i++) {
			cbList[i] = new StringBuffer();
		}
		String logsjobdir = job.getUserLogDir();
		String logfile = buildLogFileName(job, process, sType);

		String file_name = logsjobdir+logfile;

		String url = Helper.getFilePagerUrl(eu, file_name);
		String href = "<a href=\""+url+"\" onclick=\"var newWin = window.open(this.href,'"+_window_file_pager+"','height=800,width=1200,scrollbars');  newWin.focus(); return false;\">"+logfile+"</a>";
		String tr = trGet(counter);
		rb.append(tr);
		int index = -1;
		// Id
		index++; // jp.00
		cbList[index].append("<td align=\"right\">");
		String id = "";
		switch(sType) {
		case SPC:
			id = getId(job,process);
			break;
		case SPU:
			id = getId(job,process);
			break;
		case MR:
			id = getId(job,process);
			break;
		default:
			id = ""+process.getDuccId().getFriendly();
			break;
		}
		cbList[index].append(id);
		logAppend(index,"id",id);
		cbList[index].append("</td>");
		// State
		switch(sType) {
		case SPC:
		case SPU:
			index++; // jp.00.1
			cbList[index].append("<td>");
			String state = job.getJobState().toString();
			cbList[index].append(state);
			logAppend(index,"state",state);
			cbList[index].append("</td>");
			break;
		default:
			break;
		}
		// Services
		switch(sType) {
		case SPC:
		case SPU:
			ServicesRegistry servicesRegistry = ServicesRegistry.getInstance();
			index++; // jp.00.2
			cbList[index].append("<td valign=\"bottom\" align=\"right\">");
			String services = evaluateServices(job,servicesRegistry);
			cbList[index].append(services);
			logAppend(index,"services",services);
			cbList[index].append("</td>");
			break;
		default:
			break;
		}
		// Log
		index++; // jp.01
		cbList[index].append("<td>");
		String log = getLog(job, process, href);
		cbList[index].append(log);
		logAppend(index,"log",log);
		cbList[index].append("</td>");
		// Log Size (in MB)
		index++; // jp.02
		cbList[index].append("<td align=\"right\">");
		String fileSize = Helper.getLogFileSize(job, process, logfile, fileInfoMap);
		cbList[index].append(fileSize);
		logAppend(index,"fileSize",fileSize);
		cbList[index].append("</td>");
		// Hostname
		index++; // jp.03
		cbList[index].append("<td>");
		String hostname = Helper.getHostname(job, process);
		cbList[index].append(hostname);
		logAppend(index,"hostname",hostname);
		cbList[index].append("</td>");
		// PID
		index++; // jp.04
		cbList[index].append("<td align=\"right\">");
		String pid = getPid(job,process);
		cbList[index].append(pid);
		logAppend(index,"pid",pid);
		cbList[index].append("</td>");
		// Memory
		switch(sType) {
		case SPC:
		case SPU:
			index++; // jp.05
			cbList[index].append("<td align=\"right\">");
			DuccId duccId = job.getDuccId();
			IDuccSchedulingInfo si;
			SizeBytes sizeBytes;
			String requested;
			String actual;
			si = job.getSchedulingInfo();
			sizeBytes = new SizeBytes(SizeBytes.Type.Bytes, si.getMemorySizeAllocatedInBytes());
			actual = getProcessMemorySize(duccId,sizeBytes);
			sizeBytes = new SizeBytes(si.getMemoryUnits().name(), Long.parseLong(si.getMemorySizeRequested()));
			requested = getProcessMemorySize(duccId,sizeBytes);
			cbList[index].append("<span title=\""+"requested: "+requested+"\">");
			cbList[index].append(actual);
			cbList[index].append("</span>");
			logAppend(index,"actual",actual);
			logAppend(index,"requested",requested);
			break;
		default:
			break;
		}
		// State:scheduler
		index++; // jp.06
		cbList[index].append("<td>");
		String stateScheduler = getStateScheduler(job,process);
		cbList[index].append(stateScheduler);
		logAppend(index,"stateScheduler",stateScheduler);
		cbList[index].append("</td>");
		// Reason:scheduler
		index++; // jp.07
		cbList[index].append("<td>");
		String reasonScheduler = getReasonScheduler(job,process);
		cbList[index].append(reasonScheduler);
		logAppend(index,"reasonScheduler",reasonScheduler);
		cbList[index].append("</td>");
		// State:agent
		index++; // jp.08
		cbList[index].append("<td>");
		String stateAgent = getStateAgent(job,process);
		if(isIdleJobProcess(job,process,sType)) {
			stateAgent = process.getProcessState()+":Idle";
		}
		cbList[index].append(stateAgent);
		logAppend(index,"stateAgent",stateAgent);
		cbList[index].append("</td>");
		// Reason:agent
		index++; // jp.09
		cbList[index].append("<td>");
		String reasonAgent = getReasonAgent(job,process);
		cbList[index].append(reasonAgent);
		logAppend(index,"reasonAgent",reasonAgent);
		cbList[index].append("</td>");
		// Exit
		index++; // jp.10
		cbList[index].append("<td>");
		String exit = getExit(job,process);
		cbList[index].append(exit);
		logAppend(index,"exit",exit);
		cbList[index].append("</td>");
		// Time:init
		switch(sType) {
		case MR:
			break;
		default:
			index++; // jp.11
			cbList[index].append("<td align=\"right\">");
			String timeInitPrefix = "<span class=\"health_black\">";
			if(isTimeInitEstimated(job, process, sType)) {
				timeInitPrefix = "<span class=\"health_green\">";
			}
			String timeInitBody = getTimeInit(job,process,sType);
			String timeInitSuffix = "</span>";
			String timeInit = timeInitPrefix+timeInitBody+timeInitSuffix;
			cbList[index].append(timeInit);
			logAppend(index,"timeInit",timeInit);
			cbList[index].append("</td>");
			break;
		}
		// Time:run
		index++; // jp.12
		cbList[index].append("<td align=\"right\">");
		String timeRunPrefix = "<span class=\"health_black\">";
		if(isTimeRunEstimated(job, process, sType)) {
			timeRunPrefix = "<span class=\"health_green\">";
		}
		String timeRunBody = getTimeRun(job,process,sType);
		String timeRunSuffix = "</span>";
		String timeRun = timeRunPrefix+timeRunBody+timeRunSuffix;
		cbList[index].append(timeRun);
		logAppend(index,"timeRun",timeRun);
		cbList[index].append("</td>");
		// Time:GC
		switch(sType) {
		case MR:
			break;
		default:
			index++; // jp.13
			cbList[index].append("<td align=\"right\">");
			String timeGC = getTimeGC(job,process,sType);
			cbList[index].append(timeGC);
			logAppend(index,"timeGC",timeGC);
			cbList[index].append("</td>");
			break;
		}
		// PgIn
		switch(sType) {
		case MR:
		default:
			index++; // jp.14
			cbList[index].append("<td align=\"right\">");
			String pgin = getPgIn(job,process,sType);
			cbList[index].append(pgin);
			logAppend(index,"pgin",pgin);
			cbList[index].append("</td>");
			break;
		}
		// Swap
		switch(sType) {
		case MR:
		default:
			index++; // jp.15
			cbList[index].append("<td align=\"right\">");
			String swap = getSwap(job,process,sType);
			cbList[index].append(swap);
			logAppend(index,"swap",swap);
			cbList[index].append("</td>");
			break;
		}
		// %cpu
		index++; // jp.16
		cbList[index].append("<td align=\"right\">");
		String pctCPU = getPctCpu(job,process,sType);
		cbList[index].append(pctCPU);
		logAppend(index,"%cpu",pctCPU);
		cbList[index].append("</td>");
		// rss
		index++; // jp.17
		cbList[index].append("<td align=\"right\">");
		String rss = getRSS(job,process,sType);
		cbList[index].append(rss);
		logAppend(index,"rss",rss);
		cbList[index].append("</td>");
		// other
		switch(sType) {
		case SPC:
			break;
		case SPU:
			break;
		case MR:
			break;
		default:
			// Time:avg
			index++; // jp.18
			String timeAvg = "";
			cbList[index].append("<td align=\"right\">");
			timeAvg = Helper.getWiTimeAvg(job, process, sType);
			cbList[index].append(timeAvg);
			logAppend(index,"timeAvg",timeAvg);
			cbList[index].append("</td>");
			// Time:max
			index++; // jp.19
			cbList[index].append("<td align=\"right\">");
			String timeMax = Helper.getWiTimeMax(job, process, sType);
			cbList[index].append(timeMax);
			logAppend(index,"timeMax",timeMax);
			cbList[index].append("</td>");
			// Time:min
			index++; // jp.20
			cbList[index].append("<td align=\"right\">");
			String timeMin = Helper.getWiTimeMin(job, process, sType);
			cbList[index].append(timeMin);
			logAppend(index,"timeMin",timeMin);
			cbList[index].append("</td>");
			// Done
			index++; // jp.21
			cbList[index].append("<td align=\"right\">");
			String done = Helper.getWiDone(job, process, sType);
			cbList[index].append(done);
			logAppend(index,"done",done);
			cbList[index].append("</td>");
			// Error
			index++; // jp.22
			cbList[index].append("<td align=\"right\">");
			String error = Helper.getWiError(job, process, sType);
			cbList[index].append(error);
			logAppend(index,"error",error);
			cbList[index].append("</td>");
			// Dispatch
			switch(dType) {
			case Job:
				index++; // jp.23
				cbList[index].append("<td align=\"right\">");
				String dispatch = Helper.getWiDispatch(job, process, sType);
				cbList[index].append(dispatch);
				logAppend(index,"dispatch",dispatch);
				cbList[index].append("</td>");
				break;
			default:
				break;
			}
			// Retry
			index++; // jp.24
			cbList[index].append("<td align=\"right\">");
			String retry = Helper.getWiRetry(job, process, sType);
			cbList[index].append(retry);
			logAppend(index,"retry",retry);
			cbList[index].append("</td>");
			// Preempt
			index++; // jp.25
			cbList[index].append("<td align=\"right\">");
			String preempt = Helper.getWiPreempt(job, process, sType);
			cbList[index].append(preempt);
			logAppend(index,"exit",exit);
			cbList[index].append("</td>");
			break;
		}
		// Jconsole:Url
		switch(sType) {
		case MR:
			break;
		default:
			index++; // jp.26
			cbList[index].append("<td>");
			String jConsole = getJConsole(job,process,sType);
			cbList[index].append(jConsole);
			logAppend(index,"jConsole",jConsole);
			cbList[index].append("</td>");
			break;
		}
		// ResponseBuffer
		for(int i=0; i < COLS; i++) {
			rb.append(cbList[i]);
		}
		rb.append("</tr>");
		pb.append(rb.toString());
		// additional job driver related log files
		switch(sType) {
		case JD:
			String errfile = "jd.err.log";
			// jd.err.log
			if(fileExists(logsjobdir+errfile)) {
				rb = new StringBuffer();
				cbList = new StringBuffer[COLS];
				for(int i=0; i < COLS; i++) {
					cbList[i] = new StringBuffer();
					cbList[i].append("<td>");
					cbList[i].append("</td>");
				}
				// Id
				index = 0;
				// Log
				index = 1;
				String jd_url = Helper.getFilePagerUrl(eu, logsjobdir+errfile);
				String href2 = "<a href=\""+jd_url+"\" onclick=\"var newWin = window.open(this.href,'"+_window_file_pager+"','height=800,width=1200,scrollbars');  newWin.focus(); return false;\">"+errfile+"</a>";
				cbList[index] = new StringBuffer();
				cbList[index].append("<td>");
				cbList[index].append(href2);
				cbList[index].append("</td>");
				// Size
				index = 2;
				cbList[index] = new StringBuffer();
				cbList[index].append("<td align=\"right\">");
				cbList[index].append(normalizeFileSize(getLogFileSize(errfile, fileInfoMap)));
				cbList[index].append("</td>");
				// row
				rb.append(tr);
				for(int i=0; i < COLS; i++) {
					rb.append(cbList[i]);
				}
				rb.append("</tr>");
				pb.append(rb.toString());
			}
			break;
		default:
			break;
		}
	}