nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickysaltzer <...@git.apache.org>
Subject [GitHub] nifi pull request #2020: [NiFi-3973] Add PutKudu Processor for ingesting dat...
Date Thu, 03 Aug 2017 19:57:53 GMT
Github user rickysaltzer commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2020#discussion_r131244333
  
    --- Diff: nifi-nar-bundles/nifi-kudu-bundle/nifi-kudu-processors/src/main/java/org/apache/nifi/processors/kudu/AbstractKudu.java
---
    @@ -0,0 +1,233 @@
    +/*
    + * 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.kudu;
    +
    +import java.io.BufferedInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +
    +import org.apache.commons.io.IOUtils;
    +import org.apache.kudu.client.KuduClient;
    +import org.apache.kudu.client.KuduException;
    +import org.apache.kudu.client.KuduSession;
    +import org.apache.kudu.client.KuduTable;
    +import org.apache.kudu.client.Insert;
    +import org.apache.kudu.client.Upsert;
    +
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.exception.FlowFileAccessException;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.apache.nifi.processors.hadoop.exception.RecordReaderFactoryException;
    +
    +import org.apache.nifi.serialization.RecordReader;
    +import org.apache.nifi.serialization.RecordReaderFactory;
    +import org.apache.nifi.serialization.record.RecordSet;
    +import org.apache.nifi.serialization.record.Record;
    +
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.atomic.AtomicReference;
    +
    +public abstract class AbstractKudu extends AbstractProcessor {
    +
    +    protected static final PropertyDescriptor KUDU_MASTERS = new PropertyDescriptor.Builder()
    +            .name("KUDU Masters")
    +            .description("List all kudu masters's ip with port (e.g. 7051), comma separated")
    +            .required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder()
    +            .name("Table Name")
    +            .description("The name of the Kudu Table to put data into")
    +            .required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor RECORD_READER = new PropertyDescriptor.Builder()
    +            .name("record-reader")
    +            .displayName("Record Reader")
    +            .description("The service for reading records from incoming flow files.")
    +            .identifiesControllerService(RecordReaderFactory.class)
    +            .required(true)
    +            .build();
    +
    +    protected static final PropertyDescriptor SKIP_HEAD_LINE = new PropertyDescriptor.Builder()
    +            .name("Skip head line")
    +            .description("Set it to true if your first line is the header line e.g. column
names")
    +            .allowableValues("true", "false")
    +            .defaultValue("true")
    +            .required(true)
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    protected static final PropertyDescriptor INSERT_OPERATION = new PropertyDescriptor.Builder()
    +            .name("Insert Operation")
    +            .description("Specify operation for this processor. Insert-Ignore will ignore
duplicated rows")
    +            .allowableValues(OperationType.INSERT.toString(), OperationType.INSERT_IGNORE.toString(),
OperationType.UPSERT.toString())
    +            .defaultValue("Insert")
    +            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
    +            .build();
    +
    +    protected static final Relationship REL_SUCCESS = new Relationship.Builder()
    +            .name("success")
    +            .description("A FlowFile is routed to this relationship after it has been
successfully stored in Kudu")
    +            .build();
    +    protected static final Relationship REL_FAILURE = new Relationship.Builder()
    +            .name("failure")
    +            .description("A FlowFile is routed to this relationship if it cannot be sent
to Kudu")
    +            .build();
    +
    +    public static final String RECORD_COUNT_ATTR = "record.count";
    +
    +    protected String kuduMasters;
    +    protected String tableName;
    +    protected boolean skipHeadLine;
    +    protected String operation;
    +
    +    protected KuduClient kuduClient;
    +    protected KuduTable kuduTable;
    +
    +    @OnScheduled
    --- End diff --
    
    I still think we should be doing this `OnEnabled` since Kudu manages the connections for
us. If we do it `OnSchedule`, then we end up creating the client **every time** a record is
passed through. 


---
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