Beispiel #1
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   sid, offset = read_long(data, offset)
   protocol_version, offset = read_number(data, offset)
   config_version, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              sid, protocol_version, config_version)
Beispiel #2
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   sid, offset = read_long(data, offset)
   protocol_version, offset = read_number(data, offset)
   config_version, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              sid, protocol_version, config_version)
Beispiel #3
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   req_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see server_message.py and client_message.py
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, cxid, req_type)
Beispiel #4
0
  def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
    data_len, offset = read_number(data, offset)
    session_id, offset = read_long(data, offset)
    cxid, offset = read_number(data, offset)
    req_type, offset = read_number(data, offset)

    # TODO: dissect the remaining data, see server_message.py and client_message.py

    # Note: zxid=-1 because requests don't have a zxid
    return cls(timestamp, src, dst, ptype, -1, len(data), session_id, cxid, req_type)
Beispiel #5
0
  def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
    data_len, offset = read_number(data, offset)
    session_id, offset = read_long(data, offset)
    cxid, offset = read_number(data, offset)
    req_type, offset = read_number(data, offset)

    # TODO: dissect the remaining data, see server_message.py and client_message.py

    # Note: zxid=-1 because requests don't have a zxid
    return cls(timestamp, src, dst, ptype, -1, len(data), session_id, cxid, req_type)
Beispiel #6
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   client_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              suggested_leader_id,
              client_id, cxid, txn_zxid, txn_time, txn_type)
Beispiel #7
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   client_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see org.apache.zookeeper.server.util.SerializeUtils.deserializeTxn()
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              client_id, cxid, txn_zxid, txn_time, txn_type)
Beispiel #8
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see org.apache.zookeeper.server.util.SerializeUtils.deserializeTxn()
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, cxid, txn_zxid, txn_time, txn_type)
Beispiel #9
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              suggested_leader_id,
              session_id, cxid, txn_zxid, txn_time, txn_type)
Beispiel #10
0
    def from_payload(cls, data, src, dst, timestamp):
        if len(data) < 16:
            raise BadPacket("Too small")

        proto, offset = read_long(data, 0)
        if proto == cls.PROTO_VER:
            server_id, offset = read_long(data, offset)
            election_addr, _ = read_string(data, offset)

            return Initial(timestamp, src, dst, server_id, election_addr)

        if len(data) >= cls.OLD_LEN:
            state, offset = read_number(data, 0)
            if PeerState.invalid(state):
                raise BadPacket("Invalid state: %d" % state)

            leader, offset = read_long(data, offset)
            zxid, offset = read_long(data, offset)
            election_epoch, offset = read_long(data, offset)
            peer_epoch, offset = read_long(
                data, offset) if len(data) > cls.OLD_LEN else (-1, offset)
            config = data[cls.WITH_CONFIG_LEN:] if len(
                data) > cls.WITH_CONFIG_LEN else ""

            return Notification(timestamp, src, dst, state, leader, zxid,
                                election_epoch, peer_epoch, config)

        raise BadPacket("Unknown unknown")
Beispiel #11
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < 16:
      raise BadPacket("Too small")

    proto, offset = read_long(data, 0)
    if proto == cls.PROTO_VER:
      server_id, offset = read_long(data, offset)
      election_addr, _ = read_string(data, offset)

      return Initial(timestamp, src, dst, server_id, election_addr)

    if len(data) >= cls.OLD_LEN:
      state, offset = read_number(data, 0)
      if PeerState.invalid(state):
        raise BadPacket("Invalid state: %d" % state)

      leader, offset = read_long(data, offset)
      zxid, offset = read_long(data, offset)
      election_epoch, offset = read_long(data, offset)
      peer_epoch, offset = read_long(data, offset) if len(data) > cls.OLD_LEN else (-1, offset)
      config = data[cls.WITH_CONFIG_LEN:] if len(data) > cls.WITH_CONFIG_LEN else ""

      return Notification(
        timestamp,
        src,
        dst,
        state,
        leader,
        zxid,
        election_epoch,
        peer_epoch,
        config
      )

    raise BadPacket("Unknown unknown")
Beispiel #12
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, offset = read_long(data, offset)
    handler = QuorumPacketBase.get(ptype, cls)
    return handler.with_params(timestamp, src, dst, ptype, zxid, data, offset)
Beispiel #13
0
    def from_payload(cls, data, src, dst, timestamp):
        if len(data) < cls.MIN_SIZE:
            raise BadPacket("Too small")

        ptype, offset = read_number(data, 0)
        if PacketType.invalid(ptype):
            raise BadPacket("Invalid type")

        zxid, _ = read_long(data, offset)

        return cls(timestamp, src, dst, ptype, zxid, len(data))
Beispiel #14
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, offset = read_long(data, offset)
    handler = QuorumPacketBase.get(ptype, cls)
    return handler.with_params(timestamp, src, dst, ptype, zxid, data, offset)
Beispiel #15
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, _ = read_long(data, offset)

    return cls(timestamp, src, dst, ptype, zxid, len(data))
Beispiel #16
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   epoch, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              epoch)
Beispiel #17
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   epoch, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data), epoch)
Beispiel #18
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data), suggested_leader_id)
Beispiel #19
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   timeout, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, timeout)
Beispiel #20
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   timeout, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data), session_id, timeout)