This is an automated email from the ASF dual-hosted git repository.

wlo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/gobblin.git


The following commit(s) were added to refs/heads/master by this push:
     new f4f996f99 [GOBBLIN-1789] Create Generic Iceberg Data Node to Support 
Different Types of Catalogs (#3646)
f4f996f99 is described below

commit f4f996f99d70ecc73d65cedd42d095faf698b643
Author: meethngala <[email protected]>
AuthorDate: Tue Feb 21 09:25:35 2023 -0800

    [GOBBLIN-1789] Create Generic Iceberg Data Node to Support Different Types 
of Catalogs (#3646)
    
    * create generic iceberg data node
    
    * updated javadoc
    
    ---------
    
    Co-authored-by: Meeth Gala <[email protected]>
---
 .../datanodes/iceberg/IcebergDataNode.java         | 70 ++++++++++++++++++++++
 .../datanodes/iceberg/IcebergDataNodeTest.java     | 25 +++-----
 ...odeTest.java => IcebergOnHiveDataNodeTest.java} |  2 +-
 3 files changed, 80 insertions(+), 17 deletions(-)

diff --git 
a/gobblin-service/src/main/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNode.java
 
b/gobblin-service/src/main/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNode.java
new file mode 100644
index 000000000..1c9c0ccd6
--- /dev/null
+++ 
b/gobblin-service/src/main/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNode.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.service.modules.flowgraph.datanodes.iceberg;
+
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+
+import joptsimple.internal.Strings;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+
+import org.apache.gobblin.annotation.Alpha;
+import org.apache.gobblin.data.management.copy.iceberg.IcebergHiveCatalog;
+import org.apache.gobblin.service.modules.dataset.IcebergDatasetDescriptor;
+import org.apache.gobblin.service.modules.flowgraph.BaseDataNode;
+import org.apache.gobblin.service.modules.flowgraph.FlowGraphConfigurationKeys;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+/**
+ * Specifies iceberg platform and uniquely identifies an Iceberg Catalog based 
on the URI.
+ * See {@link IcebergHiveCatalog} for more information
+ */
+@Alpha
+@EqualsAndHashCode(callSuper = true)
+public class IcebergDataNode extends BaseDataNode {
+  public static final String CATALOG_URI_KEY = 
FlowGraphConfigurationKeys.DATA_NODE_PREFIX + "iceberg.catalog.uri";
+  public static final String PLATFORM = "iceberg";
+
+  @Getter
+  private String catalogUri;
+  /**
+   * Constructor. An IcebergDataNode must have iceberg.catalog.uri property 
specified to get information about specific catalog. eg. {@link 
IcebergHiveCatalog}
+   * @param nodeProps
+   */
+  public IcebergDataNode(Config nodeProps) throws DataNodeCreationException {
+    super(nodeProps);
+    try {
+      this.catalogUri = ConfigUtils.getString(nodeProps, CATALOG_URI_KEY, "");
+      Preconditions.checkArgument(!Strings.isNullOrEmpty(this.catalogUri), 
"iceberg.catalog.uri cannot be null or empty.");
+    } catch (Exception e) {
+      throw new DataNodeCreationException(e);
+    }
+  }
+
+  @Override
+  public String getDefaultDatasetDescriptorClass() {
+    return IcebergDatasetDescriptor.class.getCanonicalName();
+  }
+
+  @Override
+  public String getDefaultDatasetDescriptorPlatform() {
+    return PLATFORM;
+  }
+}
diff --git 
a/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
 
b/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
index a3955a7fd..7d676f404 100644
--- 
a/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
+++ 
b/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
@@ -17,9 +17,6 @@
 
 package org.apache.gobblin.service.modules.flowgraph.datanodes.iceberg;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -41,31 +38,27 @@ public class IcebergDataNodeTest {
   public void setUp() {
     String sampleNodeId = "some-iceberg-node-id";
     String sampleAdlFsUri = "hdfs://data.hdfs.core.windows.net";
-    String sampleHiveMetastoreUri = "thrift://hcat.company.com:7552";
+    String sampleCatalogUri = 
"https://xyz.company.com/clusters/db/catalog:443";;
 
     config = ConfigFactory.empty()
         .withValue(FlowGraphConfigurationKeys.DATA_NODE_ID_KEY, 
ConfigValueFactory.fromAnyRef(sampleNodeId))
         .withValue(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + "fs.uri", 
ConfigValueFactory.fromAnyRef(sampleAdlFsUri))
-        .withValue(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"hive.metastore.uri", ConfigValueFactory.fromAnyRef(sampleHiveMetastoreUri));
+        .withValue(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"iceberg.catalog.uri", ConfigValueFactory.fromAnyRef(sampleCatalogUri));
   }
 
   @AfterMethod
   public void tearDown() {
   }
-
   @Test
-  public void testIcebergDataNodeWithValidMetastoreUri() throws 
DataNode.DataNodeCreationException, URISyntaxException {
-    IcebergOnHiveDataNode icebergDataNode = new IcebergOnHiveDataNode(config);
-    URI uri = new 
URI(config.getString(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"hive.metastore.uri"));
-    Assert.assertTrue(icebergDataNode.isMetastoreUriValid(uri));
+  public void testIcebergDataNodeWithValidCatalogUri() throws 
DataNode.DataNodeCreationException {
+    IcebergDataNode icebergDataNode = new IcebergDataNode(config);
+    Assert.assertNotNull(icebergDataNode);
   }
 
   @Test(expectedExceptions = DataNode.DataNodeCreationException.class)
-  public void testIcebergDataNodeWithInvalidMetastoreUri() throws 
DataNode.DataNodeCreationException, URISyntaxException {
-    String bogusHiveMetastoreUri = "not-thrift://hcat.company.com:7552";
-    config = config.withValue(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"hive.metastore.uri", ConfigValueFactory.fromAnyRef(bogusHiveMetastoreUri));
-    IcebergOnHiveDataNode icebergDataNode = new IcebergOnHiveDataNode(config);
-    URI uri = new 
URI(config.getString(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"hive.metastore.uri"));
-    icebergDataNode.isMetastoreUriValid(uri);
+  public void testIcebergDataNodeWithInvalidCatalogUri() throws 
DataNode.DataNodeCreationException {
+    String emptyCatalogUri = "";
+    config = config.withValue(FlowGraphConfigurationKeys.DATA_NODE_PREFIX + 
"iceberg.catalog.uri", ConfigValueFactory.fromAnyRef(emptyCatalogUri));
+    IcebergDataNode icebergDataNode = new IcebergDataNode(config);
   }
 }
diff --git 
a/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
 
b/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergOnHiveDataNodeTest.java
similarity index 98%
copy from 
gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
copy to 
gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergOnHiveDataNodeTest.java
index a3955a7fd..43d15830e 100644
--- 
a/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergDataNodeTest.java
+++ 
b/gobblin-service/src/test/java/org/apache/gobblin/service/modules/flowgraph/datanodes/iceberg/IcebergOnHiveDataNodeTest.java
@@ -33,7 +33,7 @@ import org.apache.gobblin.service.modules.flowgraph.DataNode;
 import org.apache.gobblin.service.modules.flowgraph.FlowGraphConfigurationKeys;
 
 
-public class IcebergDataNodeTest {
+public class IcebergOnHiveDataNodeTest {
 
   Config config = null;
 

Reply via email to