public boolean select(Member member) {
   String tags = (String) member.getAttributes().get(tagsAttribute);
   if (tags != null) {
     String[] existingsTags = tags.split(",");
     for (String existingTag : existingsTags)
       if (requiredTags.contains(existingTag)) return true;
   }
   return false;
 }
Exemple #2
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());
   }
 }
Exemple #3
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;
 }
  private Member getTaskMember(String tagsAttribute, String requiredTags) {
    String[] requiredTagsArray = requiredTags.split(",");
    Set<String> requiredTagsSet = new HashSet<String>();
    for (String tag : requiredTagsArray) requiredTagsSet.add(tag);

    for (Member member : getHazelcastTaskInstance().getCluster().getMembers()) {
      String tags = (String) member.getAttributes().get(tagsAttribute);
      if (tags != null) {
        String[] existingsTags = tags.split(",");
        for (String existingTag : existingsTags)
          if (requiredTagsSet.contains(existingTag)) return member;
      }
    }

    return null;
  }