private final static Log log = LogFactory.getLog(CustomContainer.class);
@Override
protected void runInternal() {
MindAppmasterServiceClient client = (MindAppmasterServiceClient) getIntegrationServiceClient();
Random random = new Random();
Long job = null;
boolean die = false;
// run loop, we exit if appmaster asks or randomly
// in approximately once every 10 runs
do {
JobRequest request = new JobRequest();
if(job == null) {
request.setState(JobRequest.State.WHATTODO);
} else {
// we send job failed message approximately once in 4 runs
request.setState(random.nextInt(4) == 0 ? JobRequest.State.JOBFAILED : JobRequest.State.JOBDONE);
request.job = job;
}
JobResponse response = (JobResponse) client.doMindRequest(request);
if (response == null) {
die = true;
break;
}
log.info("Response state=" + response.getState());