![JAR search and dependency download from the Maven repository](/logo.png)
com.github.ltsopensource.jobtracker.processor.JobSubmitProcessor Maven / Gradle / Ivy
package com.github.ltsopensource.jobtracker.processor;
import com.github.ltsopensource.core.exception.JobReceiveException;
import com.github.ltsopensource.core.logger.Logger;
import com.github.ltsopensource.core.logger.LoggerFactory;
import com.github.ltsopensource.core.protocol.JobProtos;
import com.github.ltsopensource.core.protocol.command.JobSubmitRequest;
import com.github.ltsopensource.core.protocol.command.JobSubmitResponse;
import com.github.ltsopensource.jobtracker.domain.JobTrackerAppContext;
import com.github.ltsopensource.remoting.Channel;
import com.github.ltsopensource.remoting.exception.RemotingCommandException;
import com.github.ltsopensource.remoting.protocol.RemotingCommand;
/**
* @author Robert HG ([email protected]) on 7/24/14.
* 客户端提交任务的处理器
*/
public class JobSubmitProcessor extends AbstractRemotingProcessor {
private static final Logger LOGGER = LoggerFactory.getLogger(JobSubmitProcessor.class);
public JobSubmitProcessor(JobTrackerAppContext appContext) {
super(appContext);
}
@Override
public RemotingCommand processRequest(Channel channel, RemotingCommand request) throws RemotingCommandException {
JobSubmitRequest jobSubmitRequest = request.getBody();
JobSubmitResponse jobSubmitResponse = appContext.getCommandBodyWrapper().wrapper(new JobSubmitResponse());
RemotingCommand response;
try {
appContext.getJobReceiver().receive(jobSubmitRequest);
response = RemotingCommand.createResponseCommand(
JobProtos.ResponseCode.JOB_RECEIVE_SUCCESS.code(), "job submit success!", jobSubmitResponse);
} catch (JobReceiveException e) {
LOGGER.error("Receive job failed , jobs = " + jobSubmitRequest.getJobs(), e);
jobSubmitResponse.setSuccess(false);
jobSubmitResponse.setMsg(e.getMessage());
jobSubmitResponse.setFailedJobs(e.getJobs());
response = RemotingCommand.createResponseCommand(
JobProtos.ResponseCode.JOB_RECEIVE_FAILED.code(), e.getMessage(), jobSubmitResponse);
}
return response;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy