static Map<InetAddress, EndPointState> deserialize(DataInputStream dis) throws IOException {
    int size = dis.readInt();
    Map<InetAddress, EndPointState> epStateMap = new HashMap<InetAddress, EndPointState>();

    for (int i = 0; i < size; ++i) {
      if (dis.available() == 0) {
        logger_.info("Remaining bytes zero. Stopping deserialization in EndPointState.");
        break;
      }
      // int length = dis.readInt();
      InetAddress ep = CompactEndPointSerializationHelper.deserialize(dis);
      EndPointState epState = EndPointState.serializer().deserialize(dis);
      epStateMap.put(ep, epState);
    }
    return epStateMap;
  }
  static boolean serialize(Map<InetAddress, EndPointState> epStateMap, DataOutputStream dos)
      throws IOException {
    boolean bVal = true;
    int estimate = 0;
    int size = epStateMap.size();
    dos.writeInt(size);

    for (Entry<InetAddress, EndPointState> entry : epStateMap.entrySet()) {
      InetAddress ep = entry.getKey();
      if (Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate) {
        logger_.info(
            "@@@@ Breaking out to respect the MTU size in EPS. Estimate is " + estimate + " @@@@");
        bVal = false;
        break;
      }

      int pre = dos.size();
      CompactEndPointSerializationHelper.serialize(ep, dos);
      EndPointState.serializer().serialize(entry.getValue(), dos);
      int post = dos.size();
      estimate = post - pre;
    }
    return bVal;
  }