Пример #1
0
 @Override
 public void readFrom(StreamInput in) throws IOException {
   nodeName = in.readUTF().intern();
   nodeId = in.readUTF().intern();
   address = TransportAddressSerializers.addressFromStream(in);
   int size = in.readVInt();
   ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
   for (int i = 0; i < size; i++) {
     builder.put(in.readUTF().intern(), in.readUTF().intern());
   }
   attributes = builder.build();
   version = Version.readVersion(in);
 }
Пример #2
0
 /**
  * Creates a new {@link DiscoveryNode} by reading from the stream provided as argument
  *
  * @param in the stream
  * @throws IOException if there is an error while reading from the stream
  */
 public DiscoveryNode(StreamInput in) throws IOException {
   this.nodeName = in.readString().intern();
   this.nodeId = in.readString().intern();
   this.ephemeralId = in.readString().intern();
   this.hostName = in.readString().intern();
   this.hostAddress = in.readString().intern();
   this.address = TransportAddressSerializers.addressFromStream(in);
   int size = in.readVInt();
   this.attributes = new HashMap<>(size);
   for (int i = 0; i < size; i++) {
     this.attributes.put(in.readString(), in.readString());
   }
   int rolesSize = in.readVInt();
   this.roles = EnumSet.noneOf(Role.class);
   for (int i = 0; i < rolesSize; i++) {
     int ordinal = in.readVInt();
     if (ordinal < 0 || ordinal >= Role.values().length) {
       throw new IOException("Unknown Role ordinal [" + ordinal + "]");
     }
     this.roles.add(Role.values()[ordinal]);
   }
   this.version = Version.readVersion(in);
 }