Exemple #1
0
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   //		public String version;
   int len = in.readInt();
   byte[] bytes = new byte[len];
   in.read(bytes);
   version = new String(bytes);
   //		public Group group;
   group = new Group();
   group.readExternal(in);
   //		public ViewID id;
   id = new ViewID();
   id.readExternal(in);
   //		public ViewID[] previous;
   len = in.readInt();
   previous = new ViewID[len];
   for (int i = 0; i < len; i++) {
     previous[i] = new ViewID();
     previous[i].readExternal(in);
   }
   //		public Endpt[] view;
   len = in.readInt();
   view = new Endpt[len];
   for (int i = 0; i < len; i++) view[i].readExternal(in);
   //		public InetWithPort[] addresses;
   len = in.readInt();
   int addrLen = 0;
   addresses = new InetSocketAddress[len];
   for (int i = 0; i < len; i++) {
     addrLen = in.readInt();
     bytes = new byte[addrLen];
     in.read(bytes);
     addresses[i] = new InetSocketAddress(InetAddress.getByAddress(bytes), in.readInt());
   }
 }
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   reply = true;
   int length = in.readInt();
   uuid = new byte[length];
   in.read(uuid, 0, length);
   length = in.readInt();
   rpcId = new byte[length];
   in.read(rpcId, 0, length);
 }
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   reply = in.readBoolean();
   int length = in.readInt();
   uuid = new byte[length];
   in.read(uuid, 0, length);
   length = in.readInt();
   rpcId = new byte[length];
   in.read(rpcId, 0, length);
   message = (Serializable) in.readObject();
 }
  @Override
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    int len = in.readInt();
    byte[] b = new byte[len];

    // read fully
    int done = 0;
    while (done < len) {
      int got = in.read(b, done, len - done);
      if (got < 0) throw new IOException();
      done += got;
    }

    FileSystemProto.Directory proto = FileSystemProto.Directory.parseFrom(b);

    path = proto.getPath();
    lastModified = proto.getLastModified();
    List<FileSystemProto.File> files = proto.getFilesList();
    children = new CacheFileProto[files.size()];
    for (int i = 0; i < files.size(); i++) {
      FileSystemProto.File fp = files.get(i);
      CacheFileProto cf = new CacheFileProto();
      cf.setShortName(fp.getName());
      cf.setDirectory(fp.getIsDirectory());
      cf.setLastModified(fp.getLastModified());
      cf.setLength(fp.getLength());

      children[i] = cf;
    }
  }
Exemple #5
0
 /**
  * Read this in
  *
  * @exception IOException error reading from log stream
  * @exception ClassNotFoundException corrupted log stream
  */
 public synchronized void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   setPrevblk(in.readLong());
   setNextblk(in.readLong());
   setBytesused(in.readShort());
   setBytesinuse(in.readShort());
   setPageLSN(in.readLong());
   in.read(data);
   // if (in.read(data) != datasize) {
   //	throw new IOException(
   //		"Datablock read size invalid " + this.toString());
   // }
 }
Exemple #6
0
 private String readString(final int cn, final char[] ca, final ObjectInput in)
     throws IOException {
   int cr = 0;
   int position = 0;
   final int bToComplete;
   while (true) {
     position += in.read(this.ba, position, BA_LENGTH - position);
     if (position >= BB_PART) {
       final int icount = (position >> 1);
       final int bcount = (icount << 1);
       if (!this.bb.hasArray()) {
         this.bb.clear();
         this.bb.put(this.ba, 0, bcount);
       }
       this.cb.clear();
       this.cb.get(ca, cr, icount);
       cr += icount;
       if (position - bcount != 0) {
         this.ca[cr++] = (char) (((this.ba[bcount] & 0xff) << 8) | ((in.read() & 0xff)));
       }
       position = 0;
       if (cn - cr <= CB_LENGTH) {
         bToComplete = (cn - cr) << 1;
         break;
       }
     }
   }
   if (bToComplete > 0) {
     in.readFully(this.ba, position, bToComplete - position);
     if (!this.bb.hasArray()) {
       this.bb.clear();
       this.bb.put(this.ba, 0, bToComplete);
     }
     this.cb.clear();
     this.cb.get(ca, cr, bToComplete >> 1);
   }
   return new String(ca, 0, cn);
 }
 @Override
 public void readColumn(ObjectInput in, int col, List<List<Object>> batch, byte[] isNull)
     throws IOException, ClassNotFoundException {
   int currentByte = 0, mask = 0; // Initialize the mask so that it is reset in the loop
   boolean isNullVal;
   for (int row = 0; row < batch.size(); row++) {
     if (mask == 0) {
       // If we used up the byte, read the next one, and reset the mask
       currentByte = in.read();
       mask = 0x80;
     }
     isNullVal = (currentByte & mask) != 0;
     mask >>= 1; // Shift the mask to the next bit
     if (!isNullVal) {
       if (mask == 0) {
         currentByte = in.read();
         mask = 0x80;
       }
       batch.get(row).set(col, ((currentByte & mask) == 0) ? Boolean.FALSE : Boolean.TRUE);
       mask >>= 1;
     }
   }
 }
  private void read(ObjectInput dis, byte[] toFill) throws IOException {

    int idBytes = 0;
    int toFillLength = toFill.length;
    while (idBytes < toFillLength) {
      // idBytes += dis.read(toFill, idBytes, (toFillLength - idBytes));
      int dataRead = dis.read(toFill, idBytes, (toFillLength - idBytes));
      if (dataRead == -1) {
        throw new IOException(
            LocalizedStrings
                .ClientProxyMembershipID_UNEXPECTED_EOF_REACHED_DISTRIBUTED_MEMBERSHIPID_COULD_NOT_BE_READ
                .toLocalizedString());
      }
      idBytes += dataRead;
    }
  }
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
   boolean hasBuffer = in.readBoolean();
   if (hasBuffer) {
     int capacity = in.readInt();
     int limit = in.readInt();
     int position = in.readInt();
     byte[] bytes = new byte[capacity];
     int bytesRead = in.read(bytes);
     if (bytesRead != capacity) {
       throw new IOException(
           "Expected to read " + capacity + " bytes but only read " + bytesRead + " bytes.");
     }
     this.buffer = ByteBuffer.wrap(bytes, position, limit - position);
   } else {
     this.buffer = null;
   }
 }
Exemple #10
0
  public static byte[] readBytes(ObjectInput in) throws IOException {
    int newlength = in.readByte();
    if (newlength < 0) newlength += 256; // want full unsigned range
    if (newlength == MAGIC_LENGTH_INDICATING_32_BIT_SIZE) // magic to indicate four byte length
    newlength = in.readInt();

    // System.out.println("ByteArray.readExternal() with length " + newlength);
    if (newlength == 0) return ZERO_JAVA_BYTE_ARRAY;
    byte[] localBuffer = new byte[newlength];
    int done = 0;
    while (done < newlength) {
      int nRead =
          in.read(localBuffer, done, newlength - done); // may return less bytes than requested!
      if (nRead <= 0)
        throw new IOException(
            "deserialization of ByteArray returned "
                + nRead
                + " while expecting "
                + (newlength - done));
      done += nRead;
    }
    return localBuffer;
  }
Exemple #11
0
 public void readExternal(ObjectInput in) throws IOException {
   this.opcode = (byte) in.read();
 }