Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Throw exception
  • Loading branch information
Dexter Lee committed Jun 29, 2021
commit 9cb3a87464ea8d9f8782abdab9dacf6963c91051
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.linkedin.datahub.upgrade.restorebackup.backupreader;

import com.linkedin.datahub.upgrade.UpgradeContext;
import java.util.Optional;
import javax.annotation.Nonnull;


/**
Expand All @@ -11,5 +11,6 @@
public interface BackupReader {
String getName();

Optional<EbeanAspectBackupIterator> getBackupIterator(UpgradeContext context);
@Nonnull
EbeanAspectBackupIterator getBackupIterator(UpgradeContext context);
Copy link
Collaborator

@jjoyce0510 jjoyce0510 Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish this interface didn't have to know about UpgradeContext... does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was mainly because of the logging. If we can just log.info, then we don't need to pass in the context.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot about this -- we should be able to just use the logger as well

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.linkedin.datahub.upgrade.UpgradeContext;
import java.io.IOException;
import java.util.Optional;
import javax.annotation.Nonnull;
import lombok.extern.slf4j.Slf4j;
import org.apache.avro.generic.GenericRecord;
import org.apache.hadoop.fs.Path;
Expand All @@ -28,20 +29,21 @@ public String getName() {
return "LOCAL_PARQUET";
}

@Nonnull
@Override
public Optional<EbeanAspectBackupIterator> getBackupIterator(UpgradeContext context) {
public EbeanAspectBackupIterator getBackupIterator(UpgradeContext context) {
Optional<String> path = context.parsedArgs().get("BACKUP_FILE_PATH");
if (!path.isPresent()) {
context.report().addLine("BACKUP_FILE_PATH must be set to run RestoreBackup through local parquet file");
return Optional.empty();
throw new IllegalArgumentException(
"BACKUP_FILE_PATH must be set to run RestoreBackup through local parquet file");
}

try {
ParquetReader<GenericRecord> reader = AvroParquetReader.<GenericRecord>builder(new Path(path.get())).build();
return Optional.of(new ParquetEbeanAspectBackupIterator(reader));
return new ParquetEbeanAspectBackupIterator(reader);
} catch (IOException e) {
context.report().addLine(String.format("Failed to build ParquetReader: %s", e));
return Optional.empty();
throw new RuntimeException(String.format("Failed to build ParquetReader: %s", e));
}
}
}