Ejemplo n.º 1
0
 public static void load(
     final Iterator<ProcedureWALFile> logs,
     final ProcedureStoreTracker tracker,
     final Loader loader)
     throws IOException {
   ProcedureWALFormatReader reader = new ProcedureWALFormatReader(tracker);
   tracker.setKeepDeletes(true);
   try {
     while (logs.hasNext()) {
       ProcedureWALFile log = logs.next();
       log.open();
       try {
         reader.read(log, loader);
       } finally {
         log.close();
       }
     }
     reader.finalize(loader);
     // The tracker is now updated with all the procedures read from the logs
     tracker.setPartialFlag(false);
     tracker.resetUpdates();
   } finally {
     tracker.setKeepDeletes(false);
   }
 }
Ejemplo n.º 2
0
 public void readTracker(ProcedureStoreTracker tracker) throws IOException {
   ProcedureWALTrailer trailer = readTrailer();
   try {
     stream.seek(trailer.getTrackerPos());
     tracker.readFrom(stream);
   } finally {
     stream.seek(startPos);
   }
 }
Ejemplo n.º 3
0
  /*
   * +-----------------+
   * | END OF WAL DATA | <---+
   * +-----------------+     |
   * |                 |     |
   * |     Tracker     |     |
   * |                 |     |
   * +-----------------+     |
   * |     version     |     |
   * +-----------------+     |
   * |  TRAILER_MAGIC  |     |
   * +-----------------+     |
   * |      offset     |-----+
   * +-----------------+
   */
  public static long writeTrailer(FSDataOutputStream stream, ProcedureStoreTracker tracker)
      throws IOException {
    long offset = stream.getPos();

    // Write EOF Entry
    ProcedureWALEntry.newBuilder()
        .setType(ProcedureWALEntry.Type.PROCEDURE_WAL_EOF)
        .build()
        .writeDelimitedTo(stream);

    // Write Tracker
    tracker.writeTo(stream);

    stream.write(TRAILER_VERSION);
    StreamUtils.writeLong(stream, TRAILER_MAGIC);
    StreamUtils.writeLong(stream, offset);
    return stream.getPos() - offset;
  }