Package com.taobao.top.analysis.node.event

Examples of com.taobao.top.analysis.node.event.MasterNodeEvent


  }

  @Test
  public void test() throws InterruptedException {
   
    MasterNodeEvent eventMock = new MasterNodeEvent();
    eventMock.setEventCreateTime(System.currentTimeMillis());
    eventMock.setMaxEventHoldTime(2);
    eventMock.setSequence("1");
   
    MasterNodeEvent eventMock2 = new MasterNodeEvent();
    eventMock2.setEventCreateTime(System.currentTimeMillis());
    eventMock2.setMaxEventHoldTime(5);
    eventMock2.setSequence("2");
   
    MasterNodeEvent eventMock3 = new MasterNodeEvent();
    eventMock3.setEventCreateTime(System.currentTimeMillis());
    eventMock3.setMaxEventHoldTime(0);
    eventMock3.setSequence("3");
   
    MasterNodeEvent eventMock4 = new MasterNodeEvent();
    eventMock4.setEventCreateTime(System.currentTimeMillis());
    eventMock4.setMaxEventHoldTime(10);
    eventMock4.setSequence("4");
   
    timeOutQueue.add(eventMock);
    timeOutQueue.add(eventMock2);
    timeOutQueue.add(eventMock3);
    timeOutQueue.add(eventMock4);
   
    Assert.assertEquals(timeOutQueue.size(), 4);
   
    Thread.sleep(2002);
   
    Assert.assertEquals(timeOutQueue.size(), 3);
   
    Thread.sleep(3000);
   
    Assert.assertEquals(timeOutQueue.size(), 2);
   
    MasterNodeEvent eventMockTmp = timeOutQueue.poll();
   
    Assert.assertEquals(eventMockTmp.getSequence(), "4");
   
    eventMockTmp = timeOutQueue.poll();
   
    Assert.assertEquals(eventMockTmp.getSequence(), "3");
   
  }
View Full Code Here


   
    while(running)
    {
      try
      {
        MasterNodeEvent nodeEvent = tunnel.getMasterSide().poll(1, TimeUnit.SECONDS);
       
        if (nodeEvent != null)
        {
          if (nodeEvent.getEventCode().equals(MasterEventCode.GET_TASK) ||
              nodeEvent.getEventCode().equals(MasterEventCode.SEND_RESULT))
          {
            masterNode.addEvent(nodeEvent);
          }
        }
       
View Full Code Here

            log.error("node'config is modified, reloading executed, please have a check");
        }
        if(!(nodeConfig instanceof MasterConfig) || jobBuilder == null)
            return;
        if (jobBuilder.isModified()) {
            MasterNodeEvent e = new MasterNodeEvent();
            e.setEventCode(MasterEventCode.RELOAD_JOBS);
            ((MasterNode)node).addEvent(e);
            log.error("job'config is modified, reloading executed, please have a check");
            String content = null;
            try {
                content = "Host:"
View Full Code Here

  @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());
          }
      }
    }
   
View Full Code Here

TOP

Related Classes of com.taobao.top.analysis.node.event.MasterNodeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.