/** Reads all data from the database and send it to the sink. */
  public void run() {
    try {
      new SchemaVersionValidator(loginCredentials, preferences)
          .validateVersion(MySqlVersionConstants.SCHEMA_VERSION);

      sink.process(new BoundContainer(new Bound("Osmosis " + OsmosisConstants.VERSION)));
      processNodes();
      processWays();
      processRelations();

      sink.complete();

    } finally {
      sink.release();
    }
  }
  /** Reads all ways from the database and sends to the sink. */
  private void processWays() {
    ReleasableIterator<Way> reader;

    reader =
        new EntitySnapshotReader<Way>(
            new PeekableIterator<EntityHistory<Way>>(new WayReader(loginCredentials, readAllUsers)),
            snapshotInstant,
            new EntityHistoryComparator<Way>());

    try {
      while (reader.hasNext()) {
        sink.process(new WayContainer(reader.next()));
      }

    } finally {
      reader.release();
    }
  }