Esempio n. 1
0
 public static void encode(Member member, ClientMessage clientMessage) {
   AddressCodec.encode(member.getAddress(), clientMessage);
   clientMessage.set(member.getUuid());
   Map<String, Object> attributes = new HashMap<String, Object>(member.getAttributes());
   clientMessage.set(attributes.size());
   for (Map.Entry<String, Object> entry : attributes.entrySet()) {
     clientMessage.set(entry.getKey());
     Object value = entry.getValue();
     clientMessage.set(value.toString());
   }
 }
Esempio n. 2
0
 public static int calculateDataSize(Member member) {
   int dataSize = AddressCodec.calculateDataSize(member.getAddress());
   dataSize += ParameterUtil.calculateDataSize(member.getUuid());
   dataSize += Bits.INT_SIZE_IN_BYTES;
   Map<String, Object> attributes = member.getAttributes();
   for (Map.Entry<String, Object> entry : attributes.entrySet()) {
     dataSize += ParameterUtil.calculateDataSize(entry.getKey());
     Object value = entry.getValue();
     // TODO: this is costly to use toString
     dataSize += ParameterUtil.calculateDataSize(value.toString());
   }
   return dataSize;
 }
Esempio n. 3
0
  public static Member decode(ClientMessage clientMessage) {
    final Address address = AddressCodec.decode(clientMessage);
    String uuid = clientMessage.getStringUtf8();
    int attributeSize = clientMessage.getInt();
    Map<String, Object> attributes = new HashMap<String, Object>();
    for (int i = 0; i < attributeSize; i++) {
      String key = clientMessage.getStringUtf8();
      String value = clientMessage.getStringUtf8();
      attributes.put(key, value);
    }

    return new com.hazelcast.client.impl.MemberImpl(address, uuid, attributes);
  }