NIFI-3446 FlowConfigurationDAO Changes#1478
Conversation
pvillard31
left a comment
There was a problem hiding this comment.
Hey @patricker, a minor comment but it LGTM.
|
|
||
| // core properties | ||
| public static final String PROPERTIES_FILE_PATH = "nifi.properties.file.path"; | ||
| public static final String FLOW_CONFIGURATION_IMPLEMENTATION = "nifi.flow.configuration.implementation"; |
There was a problem hiding this comment.
This needs to be added in nifi.properties file in nifi-resources.
joewitt
left a comment
There was a problem hiding this comment.
Left several comments but they're all around the same theme. The locking logic is now needing to be cleaned up. If that is restored to work as it did before where the caller handled ensuring thread safety since the dao itself is said to be non-thread safe then I think this is fairly clean and easy to reason over and improves putting logic back in one place over our previous implementation. The rest of it seems good including using default implementation if not specified and so on.
| } finally { | ||
| writeLock.unlock(); | ||
| } | ||
| dao.save(controller); |
There was a problem hiding this comment.
this no longer appears to have write lock protection
| } finally { | ||
| writeLock.unlock(); | ||
| } | ||
| dao.save(controller, outStream); |
There was a problem hiding this comment.
this no longer has write lock protection
| } finally { | ||
| writeLock.unlock(); | ||
| } | ||
| dao.overwriteFlow(is); |
There was a problem hiding this comment.
this no longer has write lock protection
| @Override | ||
| public void start() throws LifeCycleStartException { | ||
| writeLock.lock(); | ||
| dao.writeProtectFlow(); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Thanks @joewitt, I'll move responsibility back over to the caller, along with your other feedback, and push an update.
| /** | ||
| * Locks the Flow to prevent cross-thread Writeing | ||
| */ | ||
| void writeProtectFlow(); |
There was a problem hiding this comment.
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.
| /** | ||
| * Locks the Flow to prevent cross-thread Writeing | ||
| */ | ||
| void readProtectFlow(); |
There was a problem hiding this comment.
copy/paste error on the read/unread protection javadocs.
|
@joewitt @pvillard31 I made the changes and squashed the commits since about 50% of my changes were basically rolled back to the original code. One issue... it doesn't work, NiFI can't find and load the class on startup. I dug around in the code some more and found that all Class Loading is done using I tried registering |
|
I'm going to just close it as unworkable right now. If someone wants to salvage this later feel free to use my code or start over. |
|
thanks peter. i think this will be much easier and better aligned with the intent as the flow registry work progresses. |
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:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
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.
Has your PR been rebased against the latest commit within the target branch (typically master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
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.