You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by cherrera2001 <gi...@git.apache.org> on 2017/07/08 04:26:49 UTC

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

GitHub user cherrera2001 opened a pull request:

    https://github.com/apache/nifi/pull/1997

    NIFI-4164 Adding a realistic time simulator processor to NiFi

    This is the initial commit of the processor. It can be used by using the bundled basicConfig.json or unitTestConfig.json files found within /test/Resources of the processor. 
    
    Thank you for submitting a contribution to Apache NiFi.
    
    In order to streamline the review of the contribution we ask you
    to ensure the following steps have been taken:
    
    ### For all changes:
    - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
         in the commit message?
    
    - [X] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
    
    - [X] Has your PR been rebased against the latest commit within the target branch (typically master)?
    
    - [X] Is your initial contribution a single, squashed commit?
    
    ### For code changes:
    - [X] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
    - [X] Have you written or updated unit tests to verify your changes?
    - [X] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
    - [X] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
    - [X] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
    - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
    
    ### For documentation related changes:
    - [X] Have you ensured that format looks appropriate for the output in which it is rendered?
    
    ### Note:
    Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/hashmapinc/nifi NIFI-4164

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/nifi/pull/1997.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1997
    
----
commit e980796ed93b3053567f029f3d1ddb1b9c0ae46c
Author: Chris Herrera <ch...@hashmapinc.com>
Date:   2017-07-08T04:18:00Z

    Inital commit of the processor
    
    Inital commit of the processor

----


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

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165033444
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/scala/com/apache/nifi/processors/simulator/SimController.scala ---
    @@ -0,0 +1,59 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator
    +
    +import java.io.File
    +import be.cetic.tsimulus.config.Configuration
    +import be.cetic.tsimulus.timeseries._
    +import com.github.nscala_time.time.Imports._
    +import spray.json._
    +import scala.io.Source
    +
    +object SimController
    --- End diff --
    
    Since the Scala APIs can be called from Java, is there any reason to have this written in Scala?


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165036821
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    --- End diff --
    
    Ok great.



---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029072
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-nar/pom.xml ---
    @@ -0,0 +1,41 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-simulator-bundle</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165031960
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    +        if (simConfig == null){
    +            // Load the simulator configuration
    +            if (fileName.contains("/configs/unitTestConfig.json"))
    +                isTest = true;
    +            try{
    +                simConfig = SimController.getConfiguration(fileName);
    +            }catch (Exception ex){
    +                getLogger().error("Error loading configuration: " + ex.getMessage());
    +                throw ex;
    +            }
    +
    +        }
    +    }
    +
    +    // Actually do the data generation via TSimulus
    +    private String generateData(boolean printHeader){
    +        LocalDateTime queryTime = LocalDateTime.now();
    +        if(isTest)
    --- End diff --
    
    Testing logic should not be hard-coded in like this.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r166655562
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    +        if (simConfig == null){
    +            // Load the simulator configuration
    +            if (fileName.contains("/configs/unitTestConfig.json"))
    +                isTest = true;
    +            try{
    +                simConfig = SimController.getConfiguration(fileName);
    +            }catch (Exception ex){
    +                getLogger().error("Error loading configuration: " + ex.getMessage());
    +                throw ex;
    +            }
    +
    +        }
    +    }
    +
    +    // Actually do the data generation via TSimulus
    +    private String generateData(boolean printHeader){
    +        LocalDateTime queryTime = LocalDateTime.now();
    +        if(isTest)
    --- End diff --
    
    I completely agree, should have the commit later today.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165032723
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/pom.xml ---
    @@ -0,0 +1,35 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-nar-bundles</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165030487
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    --- End diff --
    
    Some additional details describing how this would impact the output, such as a minimalist sample might be really helpful to users.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by YolandaMDavis <gi...@git.apache.org>.
Github user YolandaMDavis commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r166648706
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    +        if (simConfig == null){
    +            // Load the simulator configuration
    +            if (fileName.contains("/configs/unitTestConfig.json"))
    +                isTest = true;
    +            try{
    +                simConfig = SimController.getConfiguration(fileName);
    +            }catch (Exception ex){
    +                getLogger().error("Error loading configuration: " + ex.getMessage());
    +                throw ex;
    +            }
    +
    +        }
    +    }
    +
    +    // Actually do the data generation via TSimulus
    +    private String generateData(boolean printHeader){
    +        LocalDateTime queryTime = LocalDateTime.now();
    +        if(isTest)
    --- End diff --
    
    I would agree would agree with Mike here. In the one odd chance a user happens to have the same file name and location things would break for them.  It looks as if you are seeding a particular time which I believe is being compared later within your unit test.  One suggestion would be if there is a particular use case where users may want to provide a seed value for queryTime, expose that as a property.  That way your unit test could leverage it as well as users, and it would eliminate a need to have test specific logic.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165031639
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    --- End diff --
    
    I think you can delete this and merge the logic into onScheduled without any issue.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165033644
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/test/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowfileTest.java ---
    @@ -0,0 +1,72 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +
    +public class GenerateTimeSeriesFlowfileTest {
    +
    +    private TestRunner testRunner;
    +
    +    @Before
    +    public void init() {
    --- End diff --
    
    Not used. It can be deleted.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165036667
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    --- End diff --
    
    Good Point, I think I will update the description as well as allow for the inclusion of the JSON directly in a property. This goes well with allowing someone to pass in a configuration as part of a flow.



---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029951
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    --- End diff --
    
    Are you sure that you don't want INPUT_ALLOWED so that users can provide input to dynamically change the behavior through EL or content in the flowfile? If not, that's fine.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165036464
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    --- End diff --
    
    Its a good point I think its a valuable addition. I will modify this.


---

[GitHub] nifi issue #1997: NIFI-4164 Adding a realistic time simulator processor to N...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/1997
  
    @cherrera2001 I haven't seen any activity here, but before we go for round two I would recommend reading the thread "Will you accept contributions in Scala" on nifi-dev. If you're not subscribed, go [here](https://mail-archives.apache.org/mod_mbox/nifi-dev/201802.mbox/browser). Most of the committers seem to be against contributions in Scala so that small Scala file should be rewritten in Java. (As a Groovy fan I can commiserate on not getting to use one's preferred language)


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165036864
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    --- End diff --
    
    Will Do


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029401
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-nar/resources/LICENSE ---
    @@ -0,0 +1,210 @@
    +                                 Apache License
    --- End diff --
    
    I don't think this file is necessary since all of the dependencies you listed are Apache 2.0 licensed.


---

[GitHub] nifi issue #1997: NIFI-4164 Adding a realistic time simulator processor to N...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on the issue:

    https://github.com/apache/nifi/pull/1997
  
    Thanks Mike I did see it, and as such it is getting re written :)


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165352409
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    --- End diff --
    
    I think you should consider creating your own validator that does a combination of file existence check and testing whether or not you can create a config that the API will accept from it.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165033604
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/test/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowfileTest.java ---
    @@ -0,0 +1,72 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +
    +public class GenerateTimeSeriesFlowfileTest {
    +
    +    private TestRunner testRunner;
    --- End diff --
    
    This can be deleted.


---

[GitHub] nifi issue #1997: NIFI-4164 Adding a realistic time simulator processor to N...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/1997
  
    @cherrera2001 Do you want me to take a stab at completing this ticket?


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165030668
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    --- End diff --
    
    AllowableValue objects are a better way to go here because they provide a value and a display label.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165030357
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    --- End diff --
    
    I think you're going to need to get a little more detailed here. Depending on how big the config file is, you might be better off trying to make it constructable from the processor's properties.


---

[GitHub] nifi issue #1997: NIFI-4164 Adding a realistic time simulator processor to N...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on the issue:

    https://github.com/apache/nifi/pull/1997
  
    @cherrera2001 Do you have any updates?


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029109
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-nar/pom.xml ---
    @@ -0,0 +1,41 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-simulator-bundle</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    +    </parent>
    +
    +    <artifactId>nifi-simulator-nar</artifactId>
    +    <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165031839
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    --- End diff --
    
    I would recommend doing away with this method as well and just doing the minimal loading logic in onScheduled.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165036757
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    --- End diff --
    
    Good Point.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165032066
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    +            .build();
    +
    +    private List<PropertyDescriptor> descriptors;
    +
    +    private Set<Relationship> relationships;
    +
    +    @Override
    +    protected void init(final ProcessorInitializationContext context) {
    +
    +        final List<PropertyDescriptor> descriptors = new ArrayList<>();
    +
    +        descriptors.add(SIMULATOR_CONFIG);
    +        descriptors.add(PRINT_HEADER);
    +
    +        this.descriptors = Collections.unmodifiableList(descriptors);
    +
    +        final Set<Relationship> relationships = new HashSet<>();
    +        relationships.add(SUCCESS);
    +        this.relationships = Collections.unmodifiableSet(relationships);
    +    }
    +
    +    @Override
    +    public Set<Relationship> getRelationships() {
    +        return this.relationships;
    +    }
    +
    +    @Override
    +    public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
    +        return descriptors;
    +    }
    +
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) {
    +        if (SIMULATOR_CONFIG.equals(descriptor))
    +            simConfig = null;
    +    }
    +
    +    @OnScheduled
    +    public void onScheduled(final ProcessContext context) {
    +        loadConfiguration(context.getProperty(SIMULATOR_CONFIG).getValue());
    +    }
    +
    +    @Override
    +    public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
    +        ComponentLog logger = getLogger();
    +        FlowFile flowFile = session.get();
    +
    +        // Create the flowfile, as it probably does not exist
    +        if (flowFile == null)
    +            flowFile = session.create();
    +
    +        // Get the data
    +        String data = generateData(context.getProperty(PRINT_HEADER).asBoolean());
    +
    +        // Write the results back out to flow file
    +        try{
    +            flowFile = session.write(flowFile, out -> out.write(data.getBytes()));
    +            session.getProvenanceReporter().create(flowFile);
    +            session.transfer(flowFile, SUCCESS);
    +        } catch (ProcessException ex) {
    +            logger.error("Unable to write generated data out to flowfile. Error: ", ex);
    +        }
    +    }
    +
    +    // Loads the configuration from the file
    +    private void loadConfiguration(String fileName){
    +        if (simConfig == null){
    +            // Load the simulator configuration
    +            if (fileName.contains("/configs/unitTestConfig.json"))
    +                isTest = true;
    +            try{
    +                simConfig = SimController.getConfiguration(fileName);
    +            }catch (Exception ex){
    +                getLogger().error("Error loading configuration: " + ex.getMessage());
    +                throw ex;
    +            }
    +
    +        }
    +    }
    +
    +    // Actually do the data generation via TSimulus
    +    private String generateData(boolean printHeader){
    +        LocalDateTime queryTime = LocalDateTime.now();
    +        if(isTest)
    +            queryTime = LocalDateTime.parse("2016-01-01T00:00:00.000");
    +
    +        // Get the time Values for the current time
    +        scala.collection.Iterable<Tuple3<String, LocalDateTime, Object>> data = SimController.getTimeValue(simConfig.timeSeries(), queryTime);
    +
    +        // Convert the Scala Iterable to a Java one
    +        Iterable<Tuple3<String, LocalDateTime, Object>> generatedValues = JavaConverters.asJavaIterableConverter(data).asJava();
    +
    +        // Build the flow file string
    +        StringBuilder dataValueString = new StringBuilder();
    +
    +        if (printHeader)
    --- End diff --
    
    Please wrap in curly brackets.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029448
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/pom.xml ---
    @@ -0,0 +1,109 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-simulator-bundle</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165030818
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/main/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowFile.java ---
    @@ -0,0 +1,180 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import be.cetic.tsimulus.config.Configuration;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.logging.ComponentLog;
    +import org.apache.nifi.processor.AbstractProcessor;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.ProcessorInitializationContext;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.util.StandardValidators;
    +import org.joda.time.LocalDateTime;
    +import scala.Some;
    +import scala.Tuple3;
    +import scala.collection.JavaConverters;
    +
    +import java.util.List;
    +import java.util.Set;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.ArrayList;
    +
    +@Tags({"Simulator, Timeseries, IOT, Testing"})
    +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN)
    +@CapabilityDescription("Generates realistic time series data using the TSimulus time series generator, and places the values into the flowfile in a CSV format.")
    +public class GenerateTimeSeriesFlowFile extends AbstractProcessor {
    +
    +    private Configuration simConfig = null;
    +    private boolean isTest = false;
    +
    +    public static final PropertyDescriptor SIMULATOR_CONFIG = new PropertyDescriptor
    +            .Builder().name("SIMULATOR_CONFIG")
    +            .displayName("Simulator Configuration File")
    +            .description("The JSON configuration file to use to configure TSimulus")
    +            .required(true)
    +            .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor PRINT_HEADER = new PropertyDescriptor
    +            .Builder().name("PRINT_HEADER")
    +            .displayName("Print Header")
    +            .description("Directs the processor whether to print a header line or not.")
    +            .required(true)
    +            .allowableValues("true", "false")
    +            .defaultValue("false")
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    +            .build();
    +
    +    public static final Relationship SUCCESS = new Relationship.Builder()
    +            .name("Success")
    +            .description("When the flowfile is successfully generated")
    --- End diff --
    
    Needs a little cleanup. Consider something like this:
    
    > "When the flowfile is successfully generated, it is transferred to this relationship."


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165032832
  
    --- Diff: pom.xml ---
    @@ -1300,6 +1300,12 @@
                     <version>1.4.0-SNAPSHOT</version>
                     <type>nar</type>
                 </dependency>
    +            <dependency>
    +                <groupId>org.apache.nifi</groupId>
    +                <artifactId>nifi-simulator-nar</artifactId>
    +                <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165032740
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/pom.xml ---
    @@ -0,0 +1,35 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-nar-bundles</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    +    </parent>
    +
    +    <groupId>org.apache.nifi</groupId>
    +    <artifactId>nifi-simulator-bundle</artifactId>
    +    <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165033904
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-processors/src/test/java/com/apache/nifi/processors/simulator/GenerateTimeSeriesFlowfileTest.java ---
    @@ -0,0 +1,72 @@
    +/*
    + * 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 com.apache.nifi.processors.simulator;
    +
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +
    +public class GenerateTimeSeriesFlowfileTest {
    +
    +    private TestRunner testRunner;
    +
    +    @Before
    +    public void init() {
    +        testRunner = TestRunners.newTestRunner(GenerateTimeSeriesFlowFile.class);
    +    }
    +
    +    @Test
    +    public void testGenerateTimeSeries() {
    +        TestRunner runner = TestRunners.newTestRunner(new GenerateTimeSeriesFlowFile());
    +        runner.setProperty(GenerateTimeSeriesFlowFile.SIMULATOR_CONFIG, getClass().getResource("/configs/basicConfig.json").getPath());
    +        runner.assertValid();
    +
    +        runner.run();
    +
    +        runner.assertTransferCount(GenerateTimeSeriesFlowFile.SUCCESS, 1);
    +    }
    +
    +    @Test
    +    public void testInvalidConfig() {
    +        TestRunner runner = TestRunners.newTestRunner(new GenerateTimeSeriesFlowFile());
    +        runner.setProperty(GenerateTimeSeriesFlowFile.SIMULATOR_CONFIG, "/my/invalid/path");
    +        runner.assertNotValid();
    +    }
    +
    +    @Test
    +    public void testFalseHeaderCreation() {
    +        TestRunner runner = TestRunners.newTestRunner(new GenerateTimeSeriesFlowFile());
    +        runner.setProperty(GenerateTimeSeriesFlowFile.PRINT_HEADER, "false");
    +        runner.setProperty(GenerateTimeSeriesFlowFile.SIMULATOR_CONFIG, getClass().getResource("/configs/unitTestConfig.json").getPath());
    +        runner.run();
    +        runner.assertTransferCount(GenerateTimeSeriesFlowFile.SUCCESS, 1);
    +        runner.getFlowFilesForRelationship(GenerateTimeSeriesFlowFile.SUCCESS).get(0).assertContentEquals("test,2016-01-01T00:00:00.000,17.5");
    --- End diff --
    
    You should subclass the processor if you need to inject that timestamp in there somehow.


---

[GitHub] nifi pull request #1997: NIFI-4164 Adding a realistic time simulator process...

Posted by MikeThomsen <gi...@git.apache.org>.
Github user MikeThomsen commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1997#discussion_r165029171
  
    --- Diff: nifi-nar-bundles/nifi-simulator-bundle/nifi-simulator-nar/pom.xml ---
    @@ -0,0 +1,41 @@
    +<?xml version="1.0" encoding="UTF-8"?>
    +<!--
    +  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.
    +-->
    +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    +    <modelVersion>4.0.0</modelVersion>
    +
    +    <parent>
    +        <groupId>org.apache.nifi</groupId>
    +        <artifactId>nifi-simulator-bundle</artifactId>
    +        <version>1.4.0-SNAPSHOT</version>
    +    </parent>
    +
    +    <artifactId>nifi-simulator-nar</artifactId>
    +    <version>1.4.0-SNAPSHOT</version>
    +    <packaging>nar</packaging>
    +    <properties>
    +        <maven.javadoc.skip>true</maven.javadoc.skip>
    +        <source.skip>true</source.skip>
    +    </properties>
    +
    +    <dependencies>
    +        <dependency>
    +            <groupId>org.apache.nifi</groupId>
    +            <artifactId>nifi-simulator-processors</artifactId>
    +            <version>1.4.0-SNAPSHOT</version>
    --- End diff --
    
    1.6.0-SNAPSHOT


---

[GitHub] nifi issue #1997: NIFI-4164 Adding a realistic time simulator processor to N...

Posted by cherrera2001 <gi...@git.apache.org>.
Github user cherrera2001 commented on the issue:

    https://github.com/apache/nifi/pull/1997
  
    Should be done by Tuesday night CST


---