Ejemplo n.º 1
0
 /**
  * Appends data to the tail (end) of the log.
  *
  * @param data The object to append to tail of the log.
  * @return A timestamp representing the address the data was written to.
  * @throws OutOfSpaceException If there is no space remaining on the log.
  */
 @Override
 public ITimestamp append(Serializable data) throws OutOfSpaceException {
   while (true) {
     try {
       long token = sequencer.getNext();
       woas.write(token, data);
       return new SimpleTimestamp(token);
     } catch (Exception e) {
       log.warn("Issue appending to stream, getting new sequence number...", e);
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Reads data from an address in the log.
  *
  * @param address A timestamp representing the location to read from.
  * @return The object at that address.
  * @throws UnwrittenException If the address was unwritten.
  * @throws TrimmedException If the address has been trimmed.
  */
 @Override
 public Object read(ITimestamp address)
     throws UnwrittenException, TrimmedException, ClassNotFoundException, IOException {
   SimpleTimestamp s = (SimpleTimestamp) address;
   return woas.readObject(s.address);
 }