Skip to content

Commit

Permalink
Merge pull request #114 from jialinsun/0.3.3.0
Browse files Browse the repository at this point in the history
Fix issue #30
  • Loading branch information
ywang19 committed Sep 3, 2013
2 parents f6a9001 + 3ae2573 commit d2d5f87
Show file tree
Hide file tree
Showing 34 changed files with 1,052 additions and 27 deletions.
8 changes: 4 additions & 4 deletions dev/cosbench-controller-web/WEB-INF/freemarker/metrics.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</tr>
<#list allMetrics as mInfo>
<tr>
<td>${mInfo.opName}<#if mInfo.opType != mInfo.sampleType>-${mInfo.sampleType}</#if></td>
<td>${mInfo.opName}<#if mInfo.opName != mInfo.sampleType>-${mInfo.sampleType}</#if></td>
<td>
<#assign op = mInfo.sampleCount >
<#if (op >= 1000) >
Expand Down Expand Up @@ -88,10 +88,10 @@
</#if>
</td>
<td>
<#if mInfo.totalSampleCount == 0 >
<#if mInfo.ratio == 0.0 >
N/A
<#else>
<#assign sRatio = mInfo.sampleCount / mInfo.totalSampleCount >
<#assign sRatio = mInfo.ratio >
${sRatio?string("0.##%")}
</#if>
</td>
Expand All @@ -112,7 +112,7 @@
</tr>
<#list allMetrics as mInfo>
<tr>
<td>${mInfo.opType}<#if mInfo.opType != mInfo.sampleType>-${mInfo.sampleType}</#if></td>
<td>${mInfo.opName}<#if mInfo.opName != mInfo.sampleType>-${mInfo.sampleType}</#if></td>
<td>
<#if !mInfo.latency._60?? >
N/A
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@
</#list>
<#list allMetrics as mInfo >
<td>
<#if mInfo.totalSampleCount == 0 >
<#if mInfo.ratio == 0.0 >
N/A
<#else>
<#assign sRatio = mInfo.sampleCount / mInfo.totalSampleCount >
<#assign sRatio = mInfo.ratio >
${sRatio?string("0.##%")}
</#if>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import static com.intel.cosbench.model.StageState.*;

import java.io.IOException;

import javax.servlet.http.*;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -55,6 +57,13 @@ protected ModelAndView process(String wid, String sid) {
StageInfo sInfo = wInfo.getStageInfo(sid);
if (sInfo == null)
throw new NotFoundException();
if (sInfo.getSnapshotRegistry().getSize() == 0)
try {
controller.getWorkloadLoader().loadStagePageInfo(wInfo,
sInfo.getId());
} catch (IOException e) {
e.printStackTrace();
}
return process(wInfo, sInfo);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import static com.intel.cosbench.model.WorkloadState.*;

import java.io.IOException;

import javax.servlet.http.*;

import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -49,6 +51,13 @@ protected ModelAndView process(String id) {
WorkloadInfo info = controller.getWorkloadInfo(id);
if (info == null)
throw new NotFoundException();
if (info.getArchived() && info.getReport().getAllMetrics().length==0) {
try {
controller.getWorkloadLoader().loadWorkloadPageInfo(info);
} catch (IOException e) {
e.printStackTrace();
}
}
return process(info);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
Copyright 2013 Intel Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.intel.cosbench.controller.loader;

import java.io.*;
import java.util.List;

import com.intel.cosbench.model.WorkloadInfo;

/**
* This class is the base class for exporting run information.
*
* @author ywang19, qzheng7
*
*/
abstract class AbstractRunLoader implements RunLoader{

protected BufferedReader reader;

public AbstractRunLoader() {
/* empty */
}

@Override
public void init(BufferedReader reader) throws IOException{
this.reader = reader;
readHeader();
}

@Override
public List<WorkloadInfo> load() throws IOException{
return readWorkload();
}

protected abstract void readHeader() throws IOException;

protected abstract List<WorkloadInfo> readWorkload() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
Copyright 2013 Intel Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.intel.cosbench.controller.loader;

import java.io.*;

import com.intel.cosbench.model.StageInfo;
import com.intel.cosbench.model.WorkloadInfo;

/**
* This class is the base class for exporting run information.
*
* @author ywang19, qzheng7
*
*/
abstract class AbstractSnapshotLoader implements SnapshotLoader{

protected BufferedReader reader;
protected WorkloadInfo workloadContext;
protected StageInfo stageContext;

public AbstractSnapshotLoader() {
/* empty */
}

@Override
public void init(BufferedReader reader, WorkloadInfo workloadContext,
String stageId) throws IOException {
this.reader = reader;
this.workloadContext = workloadContext;
this.stageContext = workloadContext.getStageInfo(stageId);
}

@Override
public void load() throws IOException{
readHeader();
readSnapshot();
}

protected abstract void readHeader() throws IOException;

protected abstract void readSnapshot() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
Copyright 2013 Intel Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.intel.cosbench.controller.loader;

import java.io.*;

import com.intel.cosbench.model.WorkloadInfo;

/**
* This class is the base class for exporting run information.
*
* @author ywang19, qzheng7
*
*/
abstract class AbstractWorkloadFileLoader implements WorkloadFileLoader{

protected BufferedReader reader;
protected WorkloadInfo workloadContext;

public AbstractWorkloadFileLoader() {
/* empty */
}

@Override
public void init(BufferedReader reader, WorkloadInfo workloadContext) throws IOException{
this.reader = reader;
this.workloadContext = workloadContext;
readHeader();
}

@Override
public void load() throws IOException{
readWorkload();
}

protected abstract void readHeader() throws IOException;

protected abstract void readWorkload() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
Copyright 2013 Intel Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.intel.cosbench.controller.loader;

import static com.intel.cosbench.controller.loader.Formats.DATETIME;

import java.io.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.intel.cosbench.bench.Report;
import com.intel.cosbench.config.Workload;
import com.intel.cosbench.controller.model.WorkloadContext;
import com.intel.cosbench.model.WorkloadInfo;
import com.intel.cosbench.model.WorkloadState;


class CSVRunLoader extends AbstractRunLoader {

private List<WorkloadInfo> workloads = new ArrayList<WorkloadInfo>();

public CSVRunLoader(BufferedReader reader) throws IOException {
super.init(reader);
}

@Override
protected void readHeader() throws IOException {
this.reader.readLine();
}

@Override
protected List<WorkloadInfo> readWorkload() throws IOException {
String workloadRecordLine = null;
while ((workloadRecordLine = this.reader.readLine()) != null) {
String[] columns = workloadRecordLine.split(",");
WorkloadContext workloadContext = new WorkloadContext();
workloadContext.setArchived(true);
workloadContext.setId(columns[0]);
Report report = new Report();
workloadContext.setReport(report);
Workload workload = new Workload();
workload.setName(columns[1]);
workloadContext.setWorkload(workload);
try {
workloadContext.setSubmitDate(DATETIME.parse(columns[2]));
workloadContext.setStartDate(DATETIME.parse(columns[3]));
workloadContext.setStopDate(DATETIME.parse(columns[4]));
} catch (ParseException e) {
e.printStackTrace();
}

workloadContext.setOpInfo(columns[5].split(" "));
for (WorkloadState state : WorkloadState.values()){
if(columns[6].equalsIgnoreCase(state.toString().toLowerCase())){
workloadContext.setState(state);
break;
}
}
int index = 6;
while(++index <= columns.length-1) {
String str[] = columns[index].split("@");
String stateName = str[0].trim();
Date stateDate = null;
try {
stateDate = DATETIME.parse(str[1].trim());
} catch (ParseException e) {
e.printStackTrace();
}
workloadContext.setState(stateName, stateDate);
}
workloads.add(workloadContext);
}
return workloads;
}

}
Loading

0 comments on commit d2d5f87

Please sign in to comment.