public void writeObject(final ObjectDataOutput out, final Object obj) { final boolean isNull = obj == null; try { out.writeBoolean(isNull); if (isNull) { return; } final SerializerAdapter serializer = serializerFor(obj.getClass()); if (serializer == null) { if (active) { throw new HazelcastSerializationException( "There is no suitable serializer for " + obj.getClass()); } throw new HazelcastInstanceNotActiveException(); } out.writeInt(serializer.getTypeId()); if (obj instanceof Portable) { final Portable portable = (Portable) obj; ClassDefinition classDefinition = serializationContext.lookupOrRegisterClassDefinition(portable); classDefinition.writeData(out); } serializer.write(out, obj); } catch (Throwable e) { handleException(e); } }
@Override public void writeData(ObjectDataOutput out) throws IOException { out.writeInt(port); out.write(type); if (host != null) { byte[] address = stringToBytes(host); out.writeInt(address.length); out.write(address); } else { out.writeInt(0); } }