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

get report for cancelled/terminated stage #183

Merged
merged 1 commit into from
Jun 12, 2014
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
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,18 @@ public void cancel() {
private void cancelWorkload() {
String id = workloadContext.getId();
LOGGER.info("begin to cancel workload {}", id);
executor.shutdownNow();
executor.shutdown();
if (Thread.interrupted())
LOGGER.warn("get cancelled when canceling workload");
LOGGER.warn("get cancelled when canceling workload {}", id);
try {
executor.awaitTermination(5, TimeUnit.SECONDS);
if (!executor.awaitTermination(5, TimeUnit.SECONDS)
&& !executor.awaitTermination(5, TimeUnit.SECONDS))
executor.shutdownNow();
if (!awaitTermination(5) && !awaitTermination(10) && !awaitTermination(30))
LOGGER.warn("get cancelled when canceling workload {}", id);
} catch (InterruptedException e) {
LOGGER.warn("get cancelled when canceling workload");
executor.shutdownNow();
Thread.currentThread().interrupt();
}
if (!executor.isTerminated())
LOGGER.warn("fail to cancel current stage for workload {}", id);
Expand All @@ -309,5 +314,17 @@ private void cancelWorkload() {
workloadContext.setState(CANCELLED);
LOGGER.info("successfully cancelled workload {}", id);
}

private boolean awaitTermination(int seconds) {
try {
if (!executor.isTerminated()) {
LOGGER.info("wait {} seconds for workload to cancel ...", seconds);
executor.awaitTermination(seconds, TimeUnit.SECONDS);
}
} catch (InterruptedException e) {
LOGGER.debug("get cancelled when canceling workload");
}
return executor.isTerminated();
}

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

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

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.controller.model.TaskContext;
import com.intel.cosbench.protocol.AbortResponse;

Expand Down Expand Up @@ -61,6 +63,10 @@ private void executeAbort() {

@Override
protected void handleResponse(AbortResponse response) {
Report report = new Report();
for (Metrics metrics : response.getReport())
report.addMetrics(metrics);
context.setReport(report);
context.setLog(response.getDriverLog());
}

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

package com.intel.cosbench.protocol;

import java.util.List;

import com.intel.cosbench.bench.Metrics;


/**
* The response to get log from driver when aborted.
Expand All @@ -27,6 +31,7 @@
public class AbortResponse extends Response {

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

public AbortResponse() {
/* empty */
Expand All @@ -39,5 +44,13 @@ public String getDriverLog() {
public void setDriverLog(String driverLog) {
this.driverLog = driverLog;
}

public List<Metrics> getReport() {
return report;
}

public void setReport(List<Metrics> report) {
this.report = report;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
package com.intel.cosbench.driver.handler;

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

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

Expand All @@ -33,6 +35,8 @@ protected Response process(MissionInfo info) {

private Response getResponse(MissionInfo info) {
AbortResponse response = new AbortResponse();
Report report = info.getReport();
response.setReport(Arrays.asList(report.getAllMetrics()));
String log = null;
try {
log = info.getLogManager().getLogAsString();
Expand Down