Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/365#discussion_r199220156
  
    --- Diff: libminifi/src/controllers/UpdatePolicyControllerService.cpp ---
    @@ -0,0 +1,106 @@
    +/**
    + *
    + * 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.
    + */
    +#include "controllers/UpdatePolicyControllerService.h"
    +#include <cstdio>
    +#include <utility>
    +#include <limits>
    +#include <string>
    +#include <vector>
    +#include <sys/ioctl.h>
    +#include <ifaddrs.h>
    +#include <net/if.h>
    +#include <netinet/in.h>
    +#include <string.h>
    +#include <sys/socket.h>
    +#include <netdb.h>
    +#include <stdlib.h>
    +#include <unistd.h>
    +#include <set>
    +#include "utils/StringUtils.h"
    +#if ( defined(__APPLE__) || defined(__MACH__) || defined(BSD))
    +#include <net/if_dl.h>
    +#include <net/if_types.h>
    +#endif
    +#include "core/state/UpdatePolicy.h"
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace controllers {
    +
    +core::Property UpdatePolicyControllerService::EnableAllProperties("Enable 
All Properties", "Enables all properties", "false");
    +core::Property UpdatePolicyControllerService::AllowedProperties("Allowed 
Properties", "Properties for which we will allow updates");
    +core::Property 
UpdatePolicyControllerService::DisallowedProperties("Disallowed Properties", 
"Properties for which we will not allow updates");
    +core::Property UpdatePolicyControllerService::PersistUpdates("Persist 
Updates", "Property that dictates whether updates should persist a restart");
    +
    +void UpdatePolicyControllerService::initialize() {
    +  std::set<core::Property> supportedProperties;
    +  supportedProperties.insert(EnableAllProperties);
    +  supportedProperties.insert(AllowedProperties);
    +  supportedProperties.insert(DisallowedProperties);
    +  supportedProperties.insert(PersistUpdates);
    +  setSupportedProperties(supportedProperties);
    +}
    +
    +void UpdatePolicyControllerService::yield() {
    +}
    +
    +bool UpdatePolicyControllerService::isRunning() {
    +  return getState() == core::controller::ControllerServiceState::ENABLED;
    +}
    +
    +bool UpdatePolicyControllerService::isWorkAvailable() {
    +  return false;
    +}
    +
    +void UpdatePolicyControllerService::onEnable() {
    +  std::string enableStr, persistStr;
    +
    +  bool enable_all = false;
    +  if (getProperty(EnableAllProperties.getName(), enableStr)) {
    +    enable_all = utils::StringUtils::StringToBool(enableStr, enable_all);
    +  }
    +
    +  if (getProperty(PersistUpdates.getName(), persistStr)) {
    --- End diff --
    
    "I assume the policy service would get precedence but am uncertain of 
conditions such as I request allowing permanent but the instance is not 
configured to persist config changes."
    
    I'm not sure I follow...but perhaps I should explain this a little better 
before adding a comment for the code to ensure it makes sense. Updates can be 
controlled via the flow via the controller service. There may be cases where 
you do not want configuration updates to be persisted. An easy case would be 
one in which there is no volatile storage. That's a bit trite as it over 
exemplifies the argument; however, a less whimsical example may be one in which 
you only want updates to persist through transferring the minifi.properties 
file. This ONLY controls updates performed through mechanisms that use the 
controller service. Does that make sense? If so I'd like to document that on 
the wiki and in the code as your question points out that it's a point of 
confusion. 


---

Reply via email to