-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Make metrics reporter serializable #7370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| import org.apache.iceberg.hadoop.HadoopConfigurable; | ||
| import org.apache.iceberg.io.FileIO; | ||
| import org.apache.iceberg.io.LocationProvider; | ||
| import org.apache.iceberg.metrics.MetricsReporter; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
| import org.apache.iceberg.util.SerializableMap; | ||
| import org.apache.iceberg.util.SerializableSupplier; | ||
|
|
@@ -62,6 +63,7 @@ public class SerializableTable implements Table, Serializable { | |
| private final EncryptionManager encryption; | ||
| private final LocationProvider locationProvider; | ||
| private final Map<String, SnapshotRef> refs; | ||
| private final MetricsReporter metricsReporter; | ||
|
|
||
| private transient volatile Table lazyTable = null; | ||
| private transient volatile Schema lazySchema = null; | ||
|
|
@@ -83,6 +85,7 @@ protected SerializableTable(Table table) { | |
| this.encryption = table.encryption(); | ||
| this.locationProvider = table.locationProvider(); | ||
| this.refs = SerializableMap.copyOf(table.refs()); | ||
| this.metricsReporter = table.metricsReporter(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we expose this through |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -136,7 +139,7 @@ private Table lazyTable() { | |
| } | ||
|
|
||
| protected Table newTable(TableOperations ops, String tableName) { | ||
| return new BaseTable(ops, tableName); | ||
| return new BaseTable(ops, tableName, metricsReporter()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -247,6 +250,11 @@ public Map<String, SnapshotRef> refs() { | |
| return refs; | ||
| } | ||
|
|
||
| @Override | ||
| public MetricsReporter metricsReporter() { | ||
| return metricsReporter; | ||
| } | ||
|
|
||
| @Override | ||
| public void refresh() { | ||
| throw new UnsupportedOperationException(errorMsg("refresh")); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import org.apache.iceberg.CatalogUtil; | ||
| import org.apache.iceberg.exceptions.ValidationException; | ||
| import org.apache.iceberg.hadoop.HadoopConfigurable; | ||
| import org.apache.iceberg.hadoop.HadoopFileIO; | ||
| import org.apache.iceberg.hadoop.SerializableConfiguration; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Joiner; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; | ||
|
|
@@ -131,6 +132,9 @@ private FileIO io(String location) { | |
| String impl = implFromLocation(location); | ||
| FileIO io = ioInstances.get(impl); | ||
| if (io != null) { | ||
| if (io instanceof HadoopFileIO && ((HadoopFileIO) io).conf() == null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need to change IO classes?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ((HadoopFileIO) io).setConf(hadoopConf.get()); | ||
| } | ||
| return io; | ||
| } | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we support both? I don't think we can make this change if it is a breaking one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can support both because there's no place where we could just cast from
FunctiontoSerializableFunctionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rdblue if we don't want to break the API with the
Function->SerializableFunctionchange, then the other alternative would be to makeHTTPClientserializable. I've opened #8032 to do that