[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-21 Thread patricker
Github user patricker closed the pull request at:

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


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-14 Thread patricker
Github user patricker commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r101093314
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 ---
@@ -284,7 +251,7 @@ public boolean isRunning() {
 
 @Override
 public void start() throws LifeCycleStartException {
-writeLock.lock();
+   dao.writeProtectFlow();
--- End diff --

Thanks @joewitt, I'll move responsibility back over to the caller, along 
with your other feedback, and push an update.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100959147
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java
 ---
@@ -25,11 +25,41 @@
 import org.apache.nifi.controller.UninheritableFlowException;
 import org.apache.nifi.controller.serialization.FlowSerializationException;
 import 
org.apache.nifi.controller.serialization.FlowSynchronizationException;
+import org.apache.nifi.encrypt.StringEncryptor;
+import org.apache.nifi.util.NiFiProperties;
 
 /**
  * Interface to define service methods for FlowController configuration.
  */
 public interface FlowConfigurationDAO {
+/**
+ * Performs any initialization needed. This should be called only by 
the
+ * framework.
+ * @param encryptor protected property encryptor/decryptor
+ * @param nifiProperties collection of NiFi properties
+ * @throws IOException thrown if Flow Configuration fails to initialize
+ */
+void initialize(StringEncryptor encryptor, NiFiProperties 
nifiProperties) throws IOException;
+
+/**
+ * Locks the Flow to prevent cross-thread Writeing
+ */
+void writeProtectFlow();
+
+/**
+ * Unlocks a Write locked flow
+ */
+void unWriteProtectFlow();
+
+/**
+ * Locks the Flow to prevent cross-thread Writeing
+ */
+void readProtectFlow();
--- End diff --

copy/paste error on the read/unread protection javadocs.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100958463
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 ---
@@ -225,33 +208,17 @@ private StandardFlowService(
 
 @Override
 public void saveFlowChanges() throws IOException {
-writeLock.lock();
-try {
-dao.save(controller);
-} finally {
-writeLock.unlock();
-}
+dao.save(controller);
 }
 
 @Override
 public void saveFlowChanges(final OutputStream outStream) throws 
IOException {
-writeLock.lock();
-try {
-dao.save(controller, outStream);
-} finally {
-writeLock.unlock();
-}
+dao.save(controller, outStream);
--- End diff --

this no longer has write lock protection


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100958475
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 ---
@@ -225,33 +208,17 @@ private StandardFlowService(
 
 @Override
 public void saveFlowChanges() throws IOException {
-writeLock.lock();
-try {
-dao.save(controller);
-} finally {
-writeLock.unlock();
-}
+dao.save(controller);
 }
 
 @Override
 public void saveFlowChanges(final OutputStream outStream) throws 
IOException {
-writeLock.lock();
-try {
-dao.save(controller, outStream);
-} finally {
-writeLock.unlock();
-}
+dao.save(controller, outStream);
 }
 
 @Override
 public void overwriteFlow(final InputStream is) throws IOException {
-writeLock.lock();
-try (final OutputStream output = Files.newOutputStream(flowXml, 
StandardOpenOption.WRITE, StandardOpenOption.CREATE);
-final OutputStream gzipOut = new 
GZIPOutputStream(output);) {
-FileUtils.copy(is, gzipOut);
-} finally {
-writeLock.unlock();
-}
+dao.overwriteFlow(is);
--- End diff --

this no longer has write lock protection


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100959126
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/persistence/FlowConfigurationDAO.java
 ---
@@ -25,11 +25,41 @@
 import org.apache.nifi.controller.UninheritableFlowException;
 import org.apache.nifi.controller.serialization.FlowSerializationException;
 import 
org.apache.nifi.controller.serialization.FlowSynchronizationException;
+import org.apache.nifi.encrypt.StringEncryptor;
+import org.apache.nifi.util.NiFiProperties;
 
 /**
  * Interface to define service methods for FlowController configuration.
  */
 public interface FlowConfigurationDAO {
+/**
+ * Performs any initialization needed. This should be called only by 
the
+ * framework.
+ * @param encryptor protected property encryptor/decryptor
+ * @param nifiProperties collection of NiFi properties
+ * @throws IOException thrown if Flow Configuration fails to initialize
+ */
+void initialize(StringEncryptor encryptor, NiFiProperties 
nifiProperties) throws IOException;
+
+/**
+ * Locks the Flow to prevent cross-thread Writeing
+ */
+void writeProtectFlow();
--- End diff --

i mentioned it in a previous comment but the need to make locking calls 
available by callers into this class indicates something a bit awkward 
happening.  See previous comments.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100958448
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 ---
@@ -225,33 +208,17 @@ private StandardFlowService(
 
 @Override
 public void saveFlowChanges() throws IOException {
-writeLock.lock();
-try {
-dao.save(controller);
-} finally {
-writeLock.unlock();
-}
+dao.save(controller);
--- End diff --

this no longer appears to have write lock protection


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-13 Thread joewitt
Github user joewitt commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100958624
  
--- Diff: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
 ---
@@ -284,7 +251,7 @@ public boolean isRunning() {
 
 @Override
 public void start() throws LifeCycleStartException {
-writeLock.lock();
+   dao.writeProtectFlow();
--- End diff --

this is leaking responsibilities.  The 'dao' should either be said to be 
thread safe or not.  The previous approach was not thread safe and thus we had 
locking around it as was in the previous implementation.  Here we have some 
cases guarded and some not but we're actually invoking a lock within the 
non-thread safe class now.  This approach is harder to reason over in my 
opinion.  We should either make the class thread safe and the caller does not 
need to do anything special or it should be not thread safe and the calling 
class should protect it (as it was).  Though this method shows we need to have 
some of that logic external so it makes sense to keep the locking as it was 
(controlled by the caller with the callee/dao being not thread safe by design)


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-11 Thread pvillard31
Github user pvillard31 commented on a diff in the pull request:

https://github.com/apache/nifi/pull/1478#discussion_r100668964
  
--- Diff: 
nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
 ---
@@ -48,6 +48,7 @@
 
 // core properties
 public static final String PROPERTIES_FILE_PATH = 
"nifi.properties.file.path";
+public static final String FLOW_CONFIGURATION_IMPLEMENTATION = 
"nifi.flow.configuration.implementation";
--- End diff --

This needs to be added in nifi.properties file in nifi-resources.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] nifi pull request #1478: NIFI-3446 FlowConfigurationDAO Changes

2017-02-06 Thread patricker
GitHub user patricker opened a pull request:

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

NIFI-3446 FlowConfigurationDAO Changes

Allows for Flow Configuration (flow.xml.gz) to be pluggable. There should 
be no "functional" changes as a result of this code change.

### 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- where  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?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] 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)? 
- [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
- [ ] 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:
- [ ] 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/patricker/nifi NIFI-3446

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

https://github.com/apache/nifi/pull/1478.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 #1478


commit e346336161c6c5220661d2ae31e91391c40c54d3
Author: patricker 
Date:   2017-02-07T03:49:28Z

FlowConfigurationDAO Changes




---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---