flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmetzger <...@git.apache.org>
Subject [GitHub] flink pull request: FLINK-2740 Adding flink-connector-nifi module ...
Date Thu, 01 Oct 2015 10:29:42 GMT
Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1198#discussion_r40899251
  
    --- Diff: flink-staging/flink-streaming/flink-streaming-connectors/flink-connector-nifi/src/main/java/org/apache/flink/streaming/connectors/nifi/NiFiSource.java
---
    @@ -0,0 +1,119 @@
    +/*
    + * 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.flink.streaming.connectors.nifi;
    +
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;
    +import org.apache.nifi.remote.Transaction;
    +import org.apache.nifi.remote.TransferDirection;
    +import org.apache.nifi.remote.client.SiteToSiteClient;
    +import org.apache.nifi.remote.client.SiteToSiteClientConfig;
    +import org.apache.nifi.remote.protocol.DataPacket;
    +import org.apache.nifi.stream.io.StreamUtils;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * A source that pulls data from Apache NiFi using the NiFi Site-to-Site client. This
source
    + * produces NiFiDataPackets which encapsulate the content and attributes of a NiFi FlowFile.
    + */
    +public class NiFiSource extends RichParallelSourceFunction<NiFiDataPacket> {
    +
    +	private static final Logger LOG = LoggerFactory.getLogger(NiFiSource.class);
    +
    +	private SiteToSiteClient client;
    +	private SiteToSiteClientConfig clientConfig;
    +	private transient volatile boolean running;
    +
    +	public NiFiSource(SiteToSiteClientConfig clientConfig) {
    +		this.clientConfig = clientConfig;
    +	}
    +
    +	@Override
    +	public void open(Configuration parameters) throws Exception {
    +		super.open(parameters);
    +		client = new SiteToSiteClient.Builder().fromConfig(clientConfig).build();
    +		running = true;
    +	}
    +
    +	@Override
    +	public void run(SourceContext<NiFiDataPacket> ctx) throws Exception {
    +		while (running) {
    +			final Transaction transaction = client.createTransaction(TransferDirection.RECEIVE);
    --- End diff --
    
    the trxn returned here can be null.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message