Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #11 #94

Merged
merged 9 commits into from
Aug 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 107 additions & 12 deletions dev/cosbench-controller-web/WEB-INF/freemarker/index.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,71 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="60">
<link rel="stylesheet" type="text/css" href="resources/cosbench.css" />
<title>COSBench Controller</title>
<script type="text/javascript">
function checkAll(event, str) {
var e = window.event ? window.event.srcElement : event.currentTarget;
var a = document.getElementsByName(str);
for ( var i = 0; i < a.length; i++)
a[i].checked = e.checked;
}
function checkItem(event, allId) {
var e = window.event ? window.event.srcElement : event.currentTarget;
var all = document.getElementById(allId);
check(e, all);
}
function checkMe(id, allId) {
document.getElementById('checkbox-' + id).checked = !document
.getElementById('checkbox-' + id).checked;
var all = document.getElementById(allId);
check(document.getElementById('checkbox-' + id), all);
}
function check(item, all) {
if (item.checked) {
var a = document.getElementsByName(item.name);
all.checked = true;
for ( var i = 0; i < a.length; i++) {
if (!a[i].checked) {
all.checked = false;
break;
}
}
} else
all.checked = false;
}
function findChecked(name) {
var a = document.getElementsByName(name);
var value = "";
for ( var i = 0; i < a.length; i++) {
if (a[i].checked) {
value += a[i].value;
value += "_";
}
}
return value.substring(0, value.length - 1);
}
function changeOrder(id, value) {
var neighid = findChecked('ActiveWorkload');
if (neighid.indexOf("_") != -1) {
neighid = 0;
}
document.getElementById('neighid-' + id).value = neighid;
document.getElementById('up-' + id).value = value;
}
function cancelWorkloads() {
var answer = confirm("Are you sure to cancel checked workload?");
if (answer == true) {
var ids = findChecked('ActiveWorkload');
document.getElementById('cancelIds').value = ids;
document.getElementById('cancelForm').submit();
}
}
function resubmitWorkloads() {
var ids = findChecked('HistoryWorkload');
document.getElementById('resubmitIds').value = ids;
document.getElementById('resubmitForm').submit();
}
</script>
<title>COSBench Controller</title>
</head>
<body>
<#include "header.ftl">
Expand Down Expand Up @@ -43,31 +107,56 @@
<div>
<table class="info-table">
<tr>
<th style="width:5%;"><input type="checkbox" id="AllActive" onclick="checkAll(event,'ActiveWorkload')"></th>
<th class="id" style="width:5%;">ID</th>
<th>Name</th>
<th>Submitted-At</th>
<th>State</th>
<th style="width:5%;">Order</th>
<th style="width:15%;">Link</th>
</tr>
<#list aInfos as aInfo >
<tr>
<td>${aInfo.id}</td>
<td>${aInfo.workload.name}</td>
<td>${aInfo.submitDate?datetime}</td>
<td><span class="workload-state-${aInfo.state?lower_case} state">${aInfo.state?lower_case}</span></td>
<#list aInfos?sort_by("order") as aInfo >
<#if highlightId?? && aInfo.id == highlightId >
<tr class="high-light">
<#else>
<tr>
</#if>
<td><input type="checkbox" id="checkbox-${aInfo.id}" name="ActiveWorkload" onclick="checkItem(event,'AllActive')" value="${aInfo.id}"></td>
<td onclick="checkMe('${aInfo.id}','AllActive');">${aInfo.id}</td>
<td onclick="checkMe('${aInfo.id}','AllActive');">${aInfo.workload.name}</td>
<td onclick="checkMe('${aInfo.id}','AllActive');">${aInfo.submitDate?datetime}</td>
<td onclick="checkMe('${aInfo.id}','AllActive');"><span class="workload-state-${aInfo.state?lower_case} state">${aInfo.state?lower_case}</span></td>
<td>
<#if aInfo.state?lower_case == "queuing" >
<form id="form-${aInfo.id}" method="POST" align="center" action="index.html">
<input id="id-${aInfo.id}" type="hidden" name="id" value="${aInfo.id}">
<input id="neighid-${aInfo.id}" type="hidden" name="neighid" value="">
<input id="up-${aInfo.id}" type="hidden" name="up" value="yes">
<input type="image" style="width:20px;height:20px;" src="resources/up_arrow.png" onclick="changeOrder('${aInfo.id}','yes');" value="up">
<input type="image" style="width:20px;height:20px;" src="resources/down_arrow.png" onclick="changeOrder('${aInfo.id}','no');" value="up">
</form>
</#if>
</td>
<td><a href="workload.html?id=${aInfo.id}">view details</a></td>
</tr>
</#list>
</table>
</div>
<p class="warn">There are currently ${aInfos?size} active workloads.</p>

<form id="cancelForm" method="POST" action="index.html">
<input id="cancelIds" type="hidden" name="cancelIds" value="">
<input type="hidden" name="cancel" value="yes">
<input type="button" onclick="cancelWorkloads();" value="Cancel">
</form>
<p><a href="submit.html">submit new workloads</a></p>
<p><a href="config.html">config workloads</a></p>
<h3>Historical Workloads</h3>
<div>
<p><a href="matrix.html?ops=read&ops=write&ops=delete&metrics=rt&rthisto=_95rt&metrics=t&metrics=succ">view performance matrix</a></p>
<table class="info-table">
<tr>
<th style="width:5%;"><input type="checkbox" id="AllHistory" onclick="checkAll(event,'HistoryWorkload')"></th>
<th class="id" style="width:5%;">ID</th>
<th>Name</th>
<th>Duration</th>
Expand All @@ -77,22 +166,28 @@
</tr>
<#list hInfos as hInfo >
<tr>
<td>${hInfo.id}</td>
<td>${hInfo.workload.name}</td>
<td><#if hInfo.startDate?? >${hInfo.startDate?datetime}<#else>N/A</#if> - ${hInfo.stopDate?time}</td>
<td>
<td><input type="checkbox" id="checkbox-${hInfo.id}" name="HistoryWorkload" onclick="checkItem(event,'AllHistory')" value="${hInfo.id}"></td>
<td onclick="checkMe('${hInfo.id}','AllHistory');");">${hInfo.id}</td>
<td onclick="checkMe('${hInfo.id}','AllHistory');");">${hInfo.workload.name}</td>
<td onclick="checkMe('${hInfo.id}','AllHistory');");"><#if hInfo.startDate?? >${hInfo.startDate?datetime}<#else>N/A</#if> - ${hInfo.stopDate?time}</td>
<td onclick="checkMe('${hInfo.id}','AllHistory');");">
<#list hInfo.allOperations as op >
${op}<#if op_has_next>,</#if>
</#list>
</td>
<td><span class="workload-state-${hInfo.state?lower_case} state">${hInfo.state?lower_case}</span></td>
<td onclick="checkMe('${hInfo.id}','AllHistory');"><span class="workload-state-${hInfo.state?lower_case} state">${hInfo.state?lower_case}</span></td>
<td><a href="workload.html?id=${hInfo.id}">view details</a></td>
</tr>
</#list>
</table>
<#if (hInfos?size < 10) >
<p class="warn">There are ${hInfos?size} Historical workloads.</p>
</#if>
<form id="resubmitForm" method="POST" action="index.html">
<input id="resubmitIds" type="hidden" name="resubmitIds" value="">
<input type="hidden" name="resubmit" value="yes">
<input type="button" onclick="resubmitWorkloads();" value="resubmit">
</form>
</div>
</div> <#-- end of content -->
<div class="bottom"><br /></div>
Expand Down
2 changes: 1 addition & 1 deletion dev/cosbench-controller-web/WEB-INF/freemarker/submit.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<th>State</th>
<th style="width:15%;">Link</th>
</tr>
<#list aInfos as aInfo >
<#list aInfos?sort_by("order") as aInfo >
<#if submitted?? && aInfo.id == id >
<tr class="high-light">
<#else>
Expand Down
Binary file added dev/cosbench-controller-web/resources/down_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@

package com.intel.cosbench.controller.web;

import java.io.IOException;

import javax.servlet.http.*;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.ModelAndView;

import com.intel.cosbench.service.ControllerService;
Expand All @@ -38,14 +41,40 @@ public void setController(ControllerService controller) {
this.controller = controller;
}

@Override
protected ModelAndView process(HttpServletRequest req,
HttpServletResponse res) {
ModelAndView result = new ModelAndView("index");
@Override
protected ModelAndView process(HttpServletRequest req,
HttpServletResponse res) throws IOException {
ModelAndView result = new ModelAndView("index");
String id = req.getParameter("id");
String up = req.getParameter("up");
String neighId = req.getParameter("neighid");
String cancelIds = req.getParameter("cancelIds");
String cancel = req.getParameter("cancel");
String resubmitIds = req.getParameter("resubmitIds");
String resubmit = req.getParameter("resubmit");
if (!StringUtils.isEmpty(id) && !StringUtils.isEmpty(up)) {
boolean isUp = up.equalsIgnoreCase("yes") ? true : false;
boolean changeOrderOk = controller.changeOrder(id, neighId,
isUp);
if (changeOrderOk) {
result.addObject("highlightId", id);
}
} else if (!StringUtils.isEmpty(cancelIds)
&& !StringUtils.isEmpty(cancel)) {
String[] ids = cancelIds.split("_");
for (String cancelId : ids) {
controller.cancel(cancelId);
}
} else if (!StringUtils.isEmpty(resubmit)&&!StringUtils.isEmpty(resubmitIds)){
String[] ids = resubmitIds.split("_");
for (String resubmitId : ids){
String newId = controller.resubmit(resubmitId);
controller.fire(newId);
}
}
result.addObject("cInfo", controller.getControllerInfo());
result.addObject("aInfos", controller.getActiveWorkloads());
result.addObject("hInfos", controller.getHistoryWorkloads());
return result;
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class WorkloadContext implements WorkloadInfo {
private Workload workload;
private transient volatile StageInfo currentStage;
private StageRegistry stageRegistry;
private int order; /* workload order */

/* Report will be available after the workload is finished */
private volatile Report report = null; // will be merged from stage reports
Expand All @@ -56,6 +57,14 @@ public String getId() {
public void setId(String id) {
this.id = id;
}

public int getOrder(){
return this.order;
}

public void setOrder(int order){
this.order = order;
}

@Override
public Date getSubmitDate() {
Expand Down Expand Up @@ -232,7 +241,7 @@ public void addListener(WorkloadListener listener) {
public void disposeRuntime() {
for (StageContext stage : stageRegistry)
stage.disposeRuntime();
config = null;
// config = null;
future = null;
currentStage = null;
listeners = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ public RAMWorkloadRepository() {
WorkloadList workloads = new SimpleWorkloadList(getMaxCapacity());
this.workloads = workloads;
}

private int getMaxCapacity() {

@Override
public int getMaxCapacity() {
int maxCapacity = MAX_WORKLOAD_DEFAULT;
String config = System.getProperty(MAX_WORKLOAD_KEY);
if (!StringUtils.isEmpty(config))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ public interface WorkloadRepository {
public WorkloadContext[] getActiveWorkloads();

public WorkloadContext[] getInactiveWorkloads();

public int getMaxCapacity();

}
Loading