Exemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public void writeExternal(ObjectOutput out) throws IOException {
    out.writeInt(id);

    boolean writable = innerSplit instanceof Writable;

    out.writeUTF(writable ? innerSplit.getClass().getName() : null);

    if (writable) ((Writable) innerSplit).write(out);
    else out.writeObject(innerSplit);
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    id = in.readInt();

    String clsName = in.readUTF();

    if (clsName == null) innerSplit = in.readObject();
    else {
      // Split wrapper only used when classes available in our classpath, so Class.forName is ok
      // here.
      Class<Writable> cls = (Class<Writable>) Class.forName(clsName);

      try {
        innerSplit = U.newInstance(cls);
      } catch (GridException e) {
        throw new IOException(e);
      }

      ((Writable) innerSplit).readFields(in);
    }
  }