@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws Exception {
MasterNodeEvent nodeEvent = (MasterNodeEvent)e.getMessage();
if (nodeEvent != null)
{
if (nodeEvent.getEventCode().equals(MasterEventCode.GET_TASK) ||
nodeEvent.getEventCode().equals(MasterEventCode.SEND_RESULT) || nodeEvent.getEventCode().equals(MasterEventCode.SEND_MONITOR_INFO))
{
nodeEvent.setChannel(channel);
masterNode.addEvent(nodeEvent);
} else {
if (logger.isInfoEnabled())
logger.info("receive message from slave : " + channel.getRemoteAddress() + ", squence : " + nodeEvent.getSequence());
}
if (nodeEvent.getEventCode().equals(MasterEventCode.GET_TASK)) {
//INFO信息记录M/S通信内容
if (logger.isInfoEnabled()) {
GetTaskRequestEvent requestEvent = (GetTaskRequestEvent) nodeEvent;
String jobName = requestEvent.getJobName();
int jobCount = requestEvent.getRequestJobCount();
StringBuffer stringBuffer = new StringBuffer("receive get_task event, jobName:");
if (jobName != null)
stringBuffer.append("jobName:").append(jobName).append(",");
stringBuffer.append("jobCount:").append(jobCount).append(",from:")
.append(channel.getRemoteAddress()).append(",squence:").append(nodeEvent.getSequence());
logger.info(stringBuffer.toString());
}
}
if(nodeEvent.getEventCode().equals(MasterEventCode.SEND_RESULT)) {
//INFO信息记录M/S通信内容
if(logger.isInfoEnabled()) {
SendResultsRequestEvent requestEvent = (SendResultsRequestEvent)nodeEvent;
StringBuffer stringBuffer = new StringBuffer("receive send_result event, result:{");
stringBuffer.append(requestEvent.getJobTaskResult().toString()).append("}");
stringBuffer.append("from slave:").append(channel.getRemoteAddress()).append(",squence:").append(nodeEvent.getSequence());
logger.info(stringBuffer.toString());
}
}
if(nodeEvent.getEventCode().equals(MasterEventCode.SEND_MONITOR_INFO)) {
//INFO信息记录M/S通信内容
if(logger.isInfoEnabled()) {
SendMonitorInfoEvent requestEvent = (SendMonitorInfoEvent)nodeEvent;
StringBuffer stringBuffer = new StringBuffer("receive send_monitor_info event, result:{");
stringBuffer.append(requestEvent.getSlaveMonitorInfo().toString()).append("}");
stringBuffer.append("from slave:").append(channel.getRemoteAddress()).append(",squence:").append(nodeEvent.getSequence());
logger.info(stringBuffer.toString());
}
}
}