Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
import org.apache.paimon.annotation.Public;
import org.apache.paimon.fs.FileIOLoader;
import org.apache.paimon.fs.Path;
import org.apache.paimon.hadoop.SerializableConfiguration;
import org.apache.paimon.options.Options;

import org.apache.hadoop.conf.Configuration;

import javax.annotation.Nullable;

import java.io.Serializable;

import static org.apache.paimon.options.CatalogOptions.WAREHOUSE;
import static org.apache.paimon.utils.HadoopUtils.getHadoopConfiguration;
import static org.apache.paimon.utils.Preconditions.checkNotNull;
Expand All @@ -37,10 +40,12 @@
* @since 0.4.0
*/
@Public
public class CatalogContext {
public class CatalogContext implements Serializable {

private static final long serialVersionUID = 1L;

private final Options options;
private final Configuration hadoopConf;
private final SerializableConfiguration hadoopConf;
@Nullable private final FileIOLoader preferIOLoader;
@Nullable private final FileIOLoader fallbackIOLoader;

Expand All @@ -50,7 +55,9 @@ private CatalogContext(
@Nullable FileIOLoader preferIOLoader,
@Nullable FileIOLoader fallbackIOLoader) {
this.options = checkNotNull(options);
this.hadoopConf = hadoopConf == null ? getHadoopConfiguration(options) : hadoopConf;
this.hadoopConf =
new SerializableConfiguration(
hadoopConf == null ? getHadoopConfiguration(options) : hadoopConf);
this.preferIOLoader = preferIOLoader;
this.fallbackIOLoader = fallbackIOLoader;
}
Expand Down Expand Up @@ -92,7 +99,7 @@ public Options options() {

/** Return hadoop {@link Configuration}. */
public Configuration hadoopConf() {
return hadoopConf;
return hadoopConf.get();
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.options.Options;
import org.apache.paimon.table.CatalogTableType;
import org.apache.paimon.utils.HadoopUtilsITCase.TestFileIOLoader;
import org.apache.paimon.utils.InstantiationUtil;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.HdfsConfiguration;
Expand Down Expand Up @@ -84,4 +86,15 @@ public void testContextDefaultHadoopConf(@TempDir java.nio.file.Path path) {
assertThat(conf.get("fs.defaultFS")).isEqualTo(defaultFS);
assertThat(conf.get("dfs.replication")).isEqualTo(replication);
}

@Test
public void testContextSerializable() throws IOException, ClassNotFoundException {
Configuration conf = new Configuration(false);
conf.set("my_key", "my_value");
CatalogContext context =
CatalogContext.create(
new Options(), conf, new TestFileIOLoader(), new TestFileIOLoader());
context = InstantiationUtil.clone(context);
assertThat(context.hadoopConf().get("my_key")).isEqualTo(conf.get("my_key"));
}
}

This file was deleted.

Loading