You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "krisztina-zsihovszki (via GitHub)" <gi...@apache.org> on 2023/06/29 18:49:17 UTC

[GitHub] [nifi] krisztina-zsihovszki commented on a diff in pull request #7449: NIFI-11334: PutIceberg processor instance interference due same class loader usage

krisztina-zsihovszki commented on code in PR #7449:
URL: https://github.com/apache/nifi/pull/7449#discussion_r1246974701


##########
nifi-nar-bundles/nifi-iceberg-bundle/nifi-iceberg-processors/src/main/java/org/apache/nifi/processors/iceberg/catalog/IcebergCatalogFactory.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.nifi.processors.iceberg.catalog;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.iceberg.CatalogProperties;
+import org.apache.iceberg.catalog.Catalog;
+import org.apache.iceberg.hadoop.HadoopCatalog;
+import org.apache.iceberg.hive.HiveCatalog;
+import org.apache.nifi.services.iceberg.IcebergCatalogProperties;
+import org.apache.nifi.services.iceberg.IcebergCatalogService;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.apache.nifi.processors.iceberg.IcebergUtils.getConfigurationFromFiles;
+
+public class IcebergCatalogFactory {
+
+    private final IcebergCatalogService catalogService;
+
+    public IcebergCatalogFactory(IcebergCatalogService catalogService) {
+        this.catalogService = catalogService;
+    }
+
+    public Catalog create() {
+        return switch (catalogService.getCatalogServiceType()) {

Review Comment:
   Using arrow operator is not supported in Java 8, since this processor is also targeted for 1.x, please use Java 8 compatible syntax. 



##########
nifi-nar-bundles/nifi-iceberg-bundle/nifi-iceberg-services/src/main/java/org/apache/nifi/services/iceberg/HiveCatalogService.java:
##########
@@ -69,28 +65,43 @@ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
         return PROPERTIES;
     }
 
-    private HiveCatalog catalog;
-
     @Override
     protected Collection<ValidationResult> customValidate(ValidationContext validationContext) {
 
         final List<ValidationResult> problems = new ArrayList<>();
-        String configMetastoreUri = null;
-        String configWarehouseLocation = null;
+        boolean configMetastoreUriPresent = false;
+        boolean configWarehouseLocationPresent = false;

Review Comment:
   Not related to the actual change just noticed now that the expression language support related config of the properties can be enchanced.
   
   In my view both METASTORE_URI and WAREHOUSE_LOCATION can use
   
       .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
       
     since flow files are not used when they are evaluated.
     (The same comment applies for WAREHOUSE_PATH in HadoopCatalogService.)
     
     
   
   
   



##########
nifi-nar-bundles/nifi-iceberg-bundle/nifi-iceberg-services/src/main/java/org/apache/nifi/services/iceberg/AbstractCatalogService.java:
##########
@@ -44,24 +55,30 @@ public abstract class AbstractCatalogService extends AbstractControllerService i
             .dynamicallyModifiesClasspath(true)
             .build();
 
-    /**
-     * Loads configuration files from the provided paths.
-     *
-     * @param configFiles list of config file paths separated with comma
-     * @return merged configuration
-     */
-    protected Configuration getConfigurationFromFiles(String configFiles) {
-        final Configuration conf = new Configuration();
-        if (StringUtils.isNotBlank(configFiles)) {
+    protected List<Document> parseConfigFile(String configFiles) {
+        List<Document> documentList = new ArrayList<>();
+        if (configFiles != null && !configFiles.trim().isEmpty()) {
             for (final String configFile : configFiles.split(",")) {
-                conf.addResource(new Path(configFile.trim()));
+                File file = new File(configFile.trim());
+                try (final InputStream fis = new FileInputStream(file);
+                     final InputStream in = new BufferedInputStream(fis)) {
+                    final StandardDocumentProvider documentProvider = new StandardDocumentProvider();
+                    documentList.add(documentProvider.parse(in));
+                } catch (IOException e) {
+                    throw new RuntimeException(e);

Review Comment:
   I'd rather use ProcessException and add some error message as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org