Package com.taobao.zeus.socket.protocol.Protocol

Examples of com.taobao.zeus.socket.protocol.Protocol.HeartBeatMessage


public class MasterBeHeartBeat {
  public void beHeartBeat(MasterContext context,Channel channel,Request request) {
    MasterWorkerHolder worker=context.getWorkers().get(channel);
    HeartBeatInfo newbeat=worker.new HeartBeatInfo();
    HeartBeatMessage hbm;
    try {
      hbm = HeartBeatMessage.newBuilder().mergeFrom(request.getBody()).build();
      newbeat.memRate=hbm.getMemRate();
      newbeat.runnings=hbm.getRunningsList();
      newbeat.debugRunnings=hbm.getDebugRunningsList();
      newbeat.manualRunnings=hbm.getManualRunningsList();
      newbeat.timestamp=new Date(hbm.getTimestamp());
      if(worker.heart==null || newbeat.timestamp.getTime()>worker.heart.timestamp.getTime()){
        worker.heart=newbeat;
      }
    } catch (InvalidProtocolBufferException e) {
      e.printStackTrace();
View Full Code Here


        jobContext.putData("mem", 1.0);
      }
    } catch (Exception e) {
      ScheduleInfoLog.error("memratejob", e);
    }
    HeartBeatMessage hbm=HeartBeatMessage.newBuilder().setMemRate(((Double)jobContext.getData("mem")).floatValue())
      .addAllDebugRunnings(context.getDebugRunnings().keySet())
      .addAllManualRunnings(context.getManualRunnings().keySet())
      .addAllRunnings(context.getRunnings().keySet())
      .setTimestamp(new Date().getTime()).build();
    Request req=Request.newBuilder().setRid(AtomicIncrease.getAndIncrement()).setOperate(Operate.HeartBeat).setBody(hbm.toByteString()).build();
   
    SocketMessage sm=SocketMessage.newBuilder().setKind(Kind.REQUEST).setBody(req.toByteString()).build();
    return context.getServerChannel().write(sm);
  }
View Full Code Here

TOP

Related Classes of com.taobao.zeus.socket.protocol.Protocol.HeartBeatMessage

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.