Example #1
0
    /** 5) Release the snapshot object for RocksDB and clean up. */
    public void releaseSnapshotResources(boolean canceled) {
      if (null != kvStateIterators) {
        for (Tuple2<RocksIterator, Integer> kvStateIterator : kvStateIterators) {
          kvStateIterator.f0.close();
        }
        kvStateIterators = null;
      }

      if (null != snapshot) {
        if (null != stateBackend.db) {
          stateBackend.db.releaseSnapshot(snapshot);
        }
        snapshot.close();
        snapshot = null;
      }

      if (null != readOptions) {
        readOptions.close();
        readOptions = null;
      }

      if (canceled) {
        try {
          if (null != snapshotResultStateHandle) {
            snapshotResultStateHandle.discardState();
          }
        } catch (Exception ignored) {
          LOG.warn("Exception occurred during snapshot state handle cleanup: " + ignored);
        }
      }
    }