Skip to content

Commit

Permalink
Merge pull request #83 from jialinsun/0.3.3.0
Browse files Browse the repository at this point in the history
issue #34
  • Loading branch information
ywang19 committed Jul 25, 2013
2 parents c675af1 + ec31a2d commit 7b490b7
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dev/cosbench-controller-web/resources/cosbench.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ a:visited {
background-color: #18A9FF;
}

.workload-state-cancelled,.workload-state-terminated,.stage-state-cancelled,.stage-state-aborted,.stage-state-terminated,.task-state-aborted,.task-state-terminated,.mission-state-aborted,.mission-state-terminated
.workload-state-cancelled,.workload-state-terminated,.workload-state-failed,.stage-state-cancelled,.stage-state-aborted,.stage-state-terminated,.stage-state-failed,.task-state-aborted,.task-state-terminated,.task-state-failed,.mission-state-aborted,.mission-state-terminated,.mission-state-failed
{
background-color: #FF3366;
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ private void runStage() {
if (Thread.interrupted())
throw new CancelledException();
closeTasks();

TaskRegistry tasks = stageContext.getTaskRegistry();
for (TaskContext task : tasks) {
if (task.getState().equals(TaskState.FAILED)) {
stageContext.setState(FAILED);
return;
}
}
stageContext.setState(COMPLETED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ private void processWorkload() {
}
workloadContext.setStopDate(new Date());
workloadContext.setCurrentStage(null);
for (StageContext stageContext : workloadContext.getStageRegistry()
.getAllItems()) {
if (stageContext.getState().equals(StageState.FAILED)) {
workloadContext.setState(FAILED);
return;
}
}
workloadContext.setState(FINISHED);
}

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

package com.intel.cosbench.controller.tasklet;

import static com.intel.cosbench.model.TaskState.ACCOMPLISHED;

import com.intel.cosbench.bench.*;
import com.intel.cosbench.controller.model.TaskContext;
import com.intel.cosbench.protocol.CloseResponse;
Expand Down Expand Up @@ -46,7 +44,6 @@ protected void execute() {
} catch (Exception e) {
LOGGER.error("unexpected exception", e);
}
context.setState(ACCOMPLISHED);
}

@Override
Expand All @@ -56,6 +53,7 @@ protected void handleResponse(CloseResponse response) {
report.addMetrics(metrics);
context.setReport(report);
context.setLog(response.getDriverLog());
context.setState(response.getState());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public enum MissionState {
LAUNCHED,

FINISHED,

FAILED,

ACCOMPLISHED,

Expand All @@ -41,6 +43,7 @@ public enum MissionState {

static {
FINAL_STATES = new HashSet<MissionState>();
FINAL_STATES.add(FAILED);
FINAL_STATES.add(ACCOMPLISHED);
FINAL_STATES.add(TERMINATED);
FINAL_STATES.add(ABORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public enum StageState {
CLOSING,

COMPLETED,

FAILED,

TERMINATED,

Expand All @@ -47,6 +49,7 @@ public enum StageState {

static {
FINAL_STATES = new HashSet<StageState>();
FINAL_STATES.add(FAILED);
FINAL_STATES.add(COMPLETED);
FINAL_STATES.add(TERMINATED);
FINAL_STATES.add(CANCELLED);
Expand Down
3 changes: 3 additions & 0 deletions dev/cosbench-core/src/com/intel/cosbench/model/TaskState.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public enum TaskState {
LAUNCHED,

FINISHED,

FAILED,

ACCOMPLISHED,

Expand All @@ -47,6 +49,7 @@ public enum TaskState {

static {
FINAL_STATES = new HashSet<TaskState>();
FINAL_STATES.add(FAILED);
FINAL_STATES.add(ACCOMPLISHED);
FINAL_STATES.add(TERMINATED);
FINAL_STATES.add(ABORTED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum WorkloadState {
PROCESSING,

FINISHED,

FAILED,

TERMINATED,

Expand All @@ -35,6 +37,7 @@ public enum WorkloadState {

static {
FINAL_STATES = new HashSet<WorkloadState>();
FINAL_STATES.add(FAILED);
FINAL_STATES.add(FINISHED);
FINAL_STATES.add(TERMINATED);
FINAL_STATES.add(CANCELLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.model.TaskState;

/**
* The response to get log from driver when closed.
Expand All @@ -31,10 +32,19 @@ public class CloseResponse extends Response {

private List<Metrics> report; /* metrics report */
private String driverLog; /* driver log */
private TaskState state;

public CloseResponse() {
/* empty */
}

public TaskState getState(){
return state;
}

public void setState(TaskState state){
this.state = state;
}

public List<Metrics> getReport() {
return report;
Expand Down
2 changes: 1 addition & 1 deletion dev/cosbench-driver-web/resources/cosbench.css
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ a:visited {
background-color: #18A9FF;
}

.workload-state-cancelled,.workload-state-terminated,.stage-state-cancelled,.stage-state-aborted,.stage-state-terminated,.task-state-aborted,.task-state-terminated,.mission-state-aborted,.mission-state-terminated
.workload-state-cancelled,.workload-state-terminated,.workload-state-failed,.stage-state-cancelled,.stage-state-aborted,.stage-state-terminated,.stage-state-failed,.task-state-aborted,.task-state-terminated,.task-state-failed,.mission-state-aborted,.mission-state-terminated,.mission-state-failed
{
background-color: #FF3366;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
package com.intel.cosbench.driver.handler;

import static com.intel.cosbench.model.MissionState.TERMINATED;
import static com.intel.cosbench.model.MissionState.FAILED;

import java.io.IOException;
import java.util.Arrays;

import com.intel.cosbench.bench.Report;
import com.intel.cosbench.model.MissionInfo;
import com.intel.cosbench.model.TaskState;
import com.intel.cosbench.protocol.*;

public class CloseHandler extends MissionHandler {
Expand All @@ -41,6 +43,10 @@ private Response getResponse(MissionInfo info) {
CloseResponse response = new CloseResponse();
Report report = info.getReport();
response.setReport(Arrays.asList(report.getAllMetrics()));
if (info.getState().equals(FAILED))
response.setState(TaskState.FAILED);
else
response.setState(TaskState.ACCOMPLISHED);
String log = null;
try {
log = info.getLogManager().getLogAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public MissionState getState() {
public void setState(MissionState state) {
this.state = state;
stateHistory.addState(state.name());
if (MissionState.isStopped(state))
if (MissionState.isStopped(state) && !state.equals(MissionState.FAILED))
fireMissionStopped();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,19 @@ public void close() {
"mission should be in the state of finished");
String id = missionContext.getId();
missionContext.setState(ACCOMPLISHED);
for (int i = 0; i < missionContext.getReport().getAllMetrics().length; i++) {
LOGGER.debug("!!!! mission op: "
+ missionContext.getReport().getAllMetrics()[i].getOpType()
+ "-"
+ missionContext.getReport().getAllMetrics()[i].getOpType());
if (missionContext.getReport().getAllMetrics()[i].getSampleCount() == 0
&& missionContext.getReport().getAllMetrics()[i]
.getTotalSampleCount() > 0) {
missionContext.setState(FAILED);
LOGGER.debug("!!!! mission opt -> FAILED");
break;
}
}
LOGGER.info("mission {} has been closed successfully", id);
}

Expand Down

0 comments on commit 7b490b7

Please sign in to comment.