public boolean loadCheckpoint(InputBuffer buffer) throws IOException {
   if (buffer.readInt() != 31173) throw new RuntimeException("invalid checkpoint");
   nextSendTime = buffer.readLong();
   if (buffer.readBoolean()) {
     dest = new HandleSerializer().deserialize(buffer);
   }
   if (logger.level <= Logger.FINER) logger.log("loadCheckpoint " + nextSendTime);
   byte[] bytes = new byte[buffer.readInt()];
   buffer.read(bytes);
   ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
   try {
     rand = (Random) new ObjectInputStream(bais).readObject();
   } catch (ClassNotFoundException cnfe) {
     IOException ioe = new IOException("Error reading random number from checkpoint");
     ioe.initCause(cnfe);
     throw ioe;
   }
   if (nextSendTime > 0) {
     scheduleMessageToBeSent(nextSendTime, true);
   }
   return true;
 }
Ejemplo n.º 2
0
 /**
  * Protected because it should only be called from an extending class, to get version numbers
  * correct.
  */
 protected ScribeMessage(InputBuffer buf, Endpoint endpoint) throws IOException {
   if (buf.readBoolean()) source = endpoint.readNodeHandle(buf);
   topic = new Topic(buf, endpoint);
 }