zoukankan      html  css  js  c++  java
  • int ping = 11; 限流 客户端验证与服务端是连接的

            int ping = 11;

    ZooKeeper Programmer's Guide https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html

    The session is kept alive by requests sent by the client. If the session is idle for a period of time that would timeout the session, the client will send a PING request to keep the session alive. This PING request not only allows the ZooKeeper server to know that the client is still active, but it also allows the client to verify that its connection to the ZooKeeper server is still active. The timing of the PING is conservative enough to ensure reasonable time to detect a dead connection and reconnect to a new server.

    https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/server/Request.java#L124

    public boolean isThrottlable() {
      return this.type != OpCode.ping
      && this.type != OpCode.closeSession
      && this.type != OpCode.createSession;
      }
     

    zookeeper/ZooDefs.java at master · apache/zookeeper https://github.com/apache/zookeeper/blob/master/zookeeper-server/src/main/java/org/apache/zookeeper/ZooDefs.java

    public interface OpCode {
       
      int notification = 0;
       
      int create = 1;
       
      int delete = 2;
       
      int exists = 3;
       
      int getData = 4;
       
      int setData = 5;
       
      int getACL = 6;
       
      int setACL = 7;
       
      int getChildren = 8;
       
      int sync = 9;
       
      int ping = 11;
       
      int getChildren2 = 12;
       
      int check = 13;
       
      int multi = 14;
       
      int create2 = 15;
       
      int reconfig = 16;
       
      int checkWatches = 17;
       
      int removeWatches = 18;
       
      int createContainer = 19;
       
      int deleteContainer = 20;
       
      int createTTL = 21;
       
      int multiRead = 22;
       
      int auth = 100;
       
      int setWatches = 101;
       
      int sasl = 102;
       
      int getEphemerals = 103;
       
      int getAllChildrenNumber = 104;
       
      int setWatches2 = 105;
       
      int addWatch = 106;
       
      int createSession = -10;
       
      int closeSession = -11;
       
      int error = -1;
       
      }
  • 相关阅读:
    面向对象设计原则之二:开放封闭原则
    面向对象设计原则之一:单一职责原则
    设计模式之四:适配器模式(Adapter Pattern)
    面向对象设计原则之六:合成/聚合复用原则
    设计模式之三:迭代器模式(IteratorPattern)
    面向对象设计原则之五:迪米特法则
    设计模式之二:观察者模式(Observer Pattern)
    五分钟搭建 Flash 视频直播站
    Flash Media Server 3 开发版供下载
    不掉线的路由器路由特殊技术分析
  • 原文地址:https://www.cnblogs.com/rsapaper/p/12846842.html
Copyright © 2011-2022 走看看