[ 
https://issues.apache.org/jira/browse/NIFI-3709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16292649#comment-16292649
 ] 

ASF GitHub Bot commented on NIFI-3709:
--------------------------------------

Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2335#discussion_r157220655
  
    --- Diff: 
nifi-nar-bundles/nifi-atlas-bundle/nifi-atlas-reporting-task/src/main/java/org/apache/nifi/atlas/NiFiAtlasClient.java
 ---
    @@ -0,0 +1,537 @@
    +/*
    + * 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.atlas;
    +
    +import com.sun.jersey.api.client.UniformInterfaceException;
    +import com.sun.jersey.core.util.MultivaluedMapImpl;
    +import org.apache.atlas.ApplicationProperties;
    +import org.apache.atlas.AtlasClientV2;
    +import org.apache.atlas.AtlasServiceException;
    +import org.apache.atlas.model.SearchFilter;
    +import org.apache.atlas.model.instance.AtlasEntity;
    +import org.apache.atlas.model.instance.AtlasObjectId;
    +import org.apache.atlas.model.instance.EntityMutationResponse;
    +import org.apache.atlas.model.typedef.AtlasEntityDef;
    +import org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef;
    +import org.apache.atlas.model.typedef.AtlasTypesDef;
    +import org.apache.nifi.atlas.security.AtlasAuthN;
    +import org.apache.nifi.util.StringUtils;
    +import org.apache.nifi.util.Tuple;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import javax.ws.rs.core.MultivaluedMap;
    +import java.io.File;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Objects;
    +import java.util.Properties;
    +import java.util.Set;
    +import java.util.concurrent.atomic.AtomicBoolean;
    +import java.util.function.Function;
    +import java.util.regex.Matcher;
    +import java.util.regex.Pattern;
    +import java.util.stream.Collectors;
    +
    +import static org.apache.nifi.atlas.AtlasUtils.findIdByQualifiedName;
    +import static 
org.apache.nifi.atlas.AtlasUtils.getComponentIdFromQualifiedName;
    +import static org.apache.nifi.atlas.AtlasUtils.toStr;
    +import static org.apache.nifi.atlas.NiFiFlow.EntityChangeType.AS_IS;
    +import static org.apache.nifi.atlas.NiFiFlow.EntityChangeType.CREATED;
    +import static org.apache.nifi.atlas.NiFiFlow.EntityChangeType.DELETED;
    +import static org.apache.nifi.atlas.NiFiFlow.EntityChangeType.UPDATED;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_DESCRIPTION;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_FLOW_PATHS;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_GUID;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_INPUTS;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_INPUT_PORTS;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_NAME;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_OUTPUTS;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_OUTPUT_PORTS;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUALIFIED_NAME;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_QUEUES;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_TYPENAME;
    +import static org.apache.nifi.atlas.NiFiTypes.ATTR_URL;
    +import static org.apache.nifi.atlas.NiFiTypes.ENTITIES;
    +import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_FLOW;
    +import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_FLOW_PATH;
    +import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
    +import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
    +import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
    +
    +public class NiFiAtlasClient {
    +
    +    private static final Logger logger = 
LoggerFactory.getLogger(NiFiAtlasClient.class);
    +
    +    private static NiFiAtlasClient nifiClient;
    +    private AtlasClientV2 atlasClient;
    +
    +    private NiFiAtlasClient() {
    +        super();
    +    }
    +
    +    public static NiFiAtlasClient getInstance() {
    +        if (nifiClient == null) {
    +            synchronized (NiFiAtlasClient.class) {
    +                if (nifiClient == null) {
    +                    nifiClient = new NiFiAtlasClient();
    +                }
    +            }
    +        }
    +        return nifiClient;
    +    }
    +
    +    public void initialize(final String[] baseUrls, final AtlasAuthN 
authN, final File atlasConfDir) {
    +
    +        synchronized (NiFiAtlasClient.class) {
    +
    +            if (atlasClient != null) {
    +                logger.info("{} had been setup but replacing it with new 
one.", atlasClient);
    +                ApplicationProperties.forceReload();
    +            }
    +
    +            if (atlasConfDir != null) {
    +                // If atlasConfDir is not set, 
atlas-application.properties will be searched under classpath.
    +                Properties props = System.getProperties();
    +                final String atlasConfProp = "atlas.conf";
    +                props.setProperty(atlasConfProp, 
atlasConfDir.getAbsolutePath());
    +                logger.debug("{} has been set to: {}", atlasConfProp, 
props.getProperty(atlasConfProp));
    +            }
    +
    +            atlasClient = authN.createClient(baseUrls);
    +
    +        }
    +    }
    +
    +    /**
    +     * This is an utility method to delete unused types.
    +     * Should be used during development or testing only.
    +     * @param typeNames to delete
    +     */
    +    void deleteTypeDefs(String ... typeNames) throws AtlasServiceException 
{
    +        final AtlasTypesDef existingTypeDef = getTypeDefs(typeNames);
    +        try {
    +            atlasClient.deleteAtlasTypeDefs(existingTypeDef);
    +        } catch (UniformInterfaceException e) {
    +            if (e.getResponse().getStatus() == 204) {
    +                // 204 is a successful response.
    +                // NOTE: However after executing this, Atlas should be 
restarted to work properly.
    --- End diff --
    
    I reported several findings to Atlas project while I work on this 
integration. However, I think I haven't share this particular issue yet. 
Thanks, I will do. This method is only used by ITTest class, though.


> Export NiFi flow dataset lineage to Apache Atlas
> ------------------------------------------------
>
>                 Key: NIFI-3709
>                 URL: https://issues.apache.org/jira/browse/NIFI-3709
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>            Reporter: Koji Kawamura
>            Assignee: Koji Kawamura
>
> While Apache NiFi has provenance and event level lineage support within its 
> data flow, Apache Atlas also does manage lineage between dataset and process 
> those interacting with such data. 
> It would be beneficial for users who use both NiFi and Atlas and if they can 
> see end-to-end data lineage on Atlas lineage graph, as some type of dataset 
> are processed by both NiFi and technologies around Atlas such as Storm, 
> Falcon or Sqoop. For example, Kafka topics and Hive tables.
> In order to make this integration happen, I propose a NiFi reporting task 
> that analyzes NiFi flow then creates DataSet and Process entities in Atlas.
> The challenge is how to design NiFi flow dataset level lineage within Atlas 
> lineage graph.
> If we just add a single NiFi process and connect every DataSet from/to it, it 
> would be too ambiguous since it won't be clear which part of a NiFi flow 
> actually interact with certain dataset.
> But if we put every NiFi processor as independent process in Atlas, it would 
> be too granular, too. Also, we already have detailed event level lineage in 
> NiFi, we wouldn't need the same level in Atlas.
> If we can group certain processors in a NiFI flow as a process in Atlas, it 
> would be a nice granularity.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to