Skip to content

Commit b46dbf7

Browse files
author
Ryan Murray
committed
respond to code review comments
1 parent 6652f9c commit b46dbf7

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

nessie/src/main/java/org/apache/iceberg/nessie/NessieCatalog.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
import org.apache.iceberg.io.FileIO;
5454
import org.apache.iceberg.relocated.com.google.common.base.Joiner;
5555
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
56+
import org.slf4j.Logger;
57+
import org.slf4j.LoggerFactory;
5658

5759
/**
5860
* Nessie implementation of Iceberg Catalog.
@@ -64,7 +66,7 @@
6466
* </p>
6567
*/
6668
public class NessieCatalog extends BaseMetastoreCatalog implements AutoCloseable, SupportsNamespaces, Configurable {
67-
69+
private static final Logger logger = LoggerFactory.getLogger(NessieCatalog.class);
6870
private static final Joiner SLASH = Joiner.on("/");
6971
public static final String NESSIE_WAREHOUSE_DIR = "nessie.warehouse.dir";
7072
private NessieClient client;
@@ -74,9 +76,6 @@ public class NessieCatalog extends BaseMetastoreCatalog implements AutoCloseable
7476
private String name;
7577
private FileIO fileIO;
7678

77-
/**
78-
* Try to avoid passing parameters via hadoop config. Dynamic catalog expects Map instead
79-
*/
8079
public NessieCatalog() {
8180
}
8281

@@ -85,14 +84,13 @@ public void initialize(String inputName, Map<String, String> options) {
8584
String fileIOImpl = options.get(CatalogProperties.FILE_IO_IMPL);
8685
this.fileIO = fileIOImpl == null ? new HadoopFileIO(config) : CatalogUtil.loadFileIO(fileIOImpl, options, config);
8786
this.name = inputName == null ? "nessie" : inputName;
88-
this.client = NessieClient.withConfig(s -> options.getOrDefault(s, config.get(s)));
87+
this.client = NessieClient.withConfig(options::get);
8988

90-
this.warehouseLocation = options.getOrDefault(NESSIE_WAREHOUSE_DIR, config.get(NESSIE_WAREHOUSE_DIR));
89+
this.warehouseLocation = options.get(NESSIE_WAREHOUSE_DIR);
9190
if (warehouseLocation == null) {
9291
throw new IllegalStateException("Parameter nessie.warehouse.dir not set, nessie can't store data.");
9392
}
94-
final String requestedRef = options.getOrDefault(NessieClient.CONF_NESSIE_REF,
95-
config.get(NessieClient.CONF_NESSIE_REF));
93+
final String requestedRef = options.get(NessieClient.CONF_NESSIE_REF);
9694
this.reference = loadReference(requestedRef);
9795
}
9896

@@ -148,11 +146,13 @@ public boolean dropTable(TableIdentifier identifier, boolean purge) {
148146
} catch (NessieConflictException e) {
149147
// pass for retry
150148
} catch (NessieNotFoundException e) {
151-
throw new RuntimeException("Cannot drop table: ref is no longer valid.", e);
149+
logger.error("Cannot drop table: ref is no longer valid.", e);
150+
return false;
152151
}
153152
}
154153
if (count >= 5) {
155-
throw new RuntimeException("Cannot drop table: failed after retry (update hash and retry)");
154+
logger.error("Cannot drop table: failed after retry (update hash and retry)");
155+
return false;
156156
}
157157
return true;
158158
}

nessie/src/main/java/org/apache/iceberg/nessie/NessieTableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void doRefresh() {
6464
try {
6565
reference.refresh();
6666
} catch (NessieNotFoundException e) {
67-
throw new RuntimeException("Failed to drop table as ref is no longer valid.", e);
67+
throw new RuntimeException("Failed to refresh as ref is no longer valid.", e);
6868
}
6969
String metadataLocation = null;
7070
try {

nessie/src/test/java/org/apache/iceberg/nessie/BaseTestIceberg.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public abstract class BaseTestIceberg {
6161
protected ContentsApi contents;
6262
protected Configuration hadoopConfig;
6363
protected final String branch;
64+
private String path;
6465

6566
public BaseTestIceberg(String branch) {
6667
this.branch = branch;
@@ -80,7 +81,7 @@ private void resetData() throws NessieConflictException, NessieNotFoundException
8081
@Before
8182
public void beforeEach() throws IOException {
8283
String port = System.getProperty("quarkus.http.test-port", "19120");
83-
String path = String.format("http://localhost:%s/api/v1", port);
84+
path = String.format("http://localhost:%s/api/v1", port);
8485
this.client = NessieClient.none(path);
8586
tree = client.getTreeApi();
8687
contents = client.getContentsApi();
@@ -94,17 +95,17 @@ public void beforeEach() throws IOException {
9495
}
9596

9697
hadoopConfig = new Configuration();
97-
hadoopConfig.set(NessieClient.CONF_NESSIE_URL, path);
98-
hadoopConfig.set(NessieClient.CONF_NESSIE_REF, branch);
99-
hadoopConfig.set(NessieClient.CONF_NESSIE_AUTH_TYPE, "NONE");
100-
hadoopConfig.set("nessie.warehouse.dir", temp.getRoot().toURI().toString());
10198
catalog = initCatalog(branch);
10299
}
103100

104101
NessieCatalog initCatalog(String ref) {
105102
NessieCatalog newCatalog = new NessieCatalog();
106103
newCatalog.setConf(hadoopConfig);
107-
newCatalog.initialize(null, ImmutableMap.of(NessieClient.CONF_NESSIE_REF, ref));
104+
newCatalog.initialize(null, ImmutableMap.of(NessieClient.CONF_NESSIE_REF, ref,
105+
NessieClient.CONF_NESSIE_URL, path,
106+
NessieClient.CONF_NESSIE_AUTH_TYPE, "NONE",
107+
"nessie.warehouse.dir", temp.getRoot().toURI().toString()
108+
));
108109
return newCatalog;
109110
}
110111

0 commit comments

Comments
 (0)