2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef LIBMINIFI_INCLUDE_PROCESSOR_PROCESSORNODE_H_
19 #define LIBMINIFI_INCLUDE_PROCESSOR_PROCESSORNODE_H_
21 #include "ConfigurableComponent.h"
22 #include "Connectable.h"
32 * Processor node functions as a pass through to the implementing Connectables
33 * ProcessorNode can be used by itself or with a pass through object, in which case
34 * we need to function as a passthrough or not.
36 class ProcessorNode
: public ConfigurableComponent
, public Connectable
{
38 explicit ProcessorNode(const std
::shared_ptr
<Connectable
> &processor
);
40 explicit ProcessorNode(const ProcessorNode
&other
);
42 explicit ProcessorNode(const ProcessorNode
&&other
);
45 * Get property using the provided name.
46 * @param name property name.
47 * @param value value passed in by reference
48 * @return result of getting property.
50 std
::shared_ptr
<Connectable
> getProcessor() const {
59 * Get property using the provided name.
60 * @param name property name.
61 * @param value value passed in by reference
62 * @return result of getting property.
64 bool getProperty(const std
::string
&name
, std
::string
&value
) {
65 const std
::shared_ptr
<ConfigurableComponent
> processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
66 if (nullptr != processor_cast
)
67 return processor_cast
->getProperty(name
, value
);
69 return ConfigurableComponent
::getProperty(name
, value
);
73 * Sets the property using the provided name
74 * @param property name
75 * @param value property value.
76 * @return result of setting property.
78 bool setProperty(const std
::string
&name
, std
::string value
) {
79 const std
::shared_ptr
<ConfigurableComponent
> processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
80 bool ret
= ConfigurableComponent
::setProperty(name
, value
);
81 if (nullptr != processor_cast
)
82 ret
= processor_cast
->setProperty(name
, value
);
89 * Get dynamic property using the provided name.
90 * @param name property name.
91 * @param value value passed in by reference
92 * @return result of getting property.
94 bool getDynamicProperty(const std
::string name
, std
::string
&value
) {
95 const auto &processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
97 return processor_cast
->getDynamicProperty(name
, value
);
99 return ConfigurableComponent
::getDynamicProperty(name
, value
);
104 * Sets the dynamic property using the provided name
105 * @param property name
106 * @param value property value.
107 * @return result of setting property.
109 bool setDynamicProperty(const std
::string name
, std
::string value
) {
110 const auto &processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
111 auto ret
= ConfigurableComponent
::setDynamicProperty(name
, value
);
113 if (processor_cast
) {
114 ret
= processor_cast
->setDynamicProperty(name
, value
);
121 * Gets list of dynamic property keys
122 * @param name property name.
123 * @param value value passed in by reference
124 * @return result of getting property.
126 std
::vector
<std
::string
> getDynamicPropertyKeys() {
127 const auto &processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
128 if (processor_cast
) {
129 return processor_cast
->getDynamicPropertyKeys();
131 return ConfigurableComponent
::getDynamicPropertyKeys();
136 * Sets the property using the provided name
137 * @param property name
138 * @param value property value.
139 * @return whether property was set or not
141 bool setProperty(Property
&prop
, std
::string value
) {
142 const std
::shared_ptr
<ConfigurableComponent
> processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
143 bool ret
= ConfigurableComponent
::setProperty(prop
, value
);
144 if (nullptr != processor_cast
)
145 ret
= processor_cast
->setProperty(prop
, value
);
151 * Sets supported properties for the ConfigurableComponent
152 * @param supported properties
153 * @return result of set operation.
155 bool setSupportedProperties(std
::set
<Property
> properties
) {
156 const std
::shared_ptr
<ConfigurableComponent
> processor_cast
= std
::dynamic_pointer_cast
<ConfigurableComponent
>(processor_
);
157 bool ret
= ConfigurableComponent
::setSupportedProperties(properties
);
158 if (nullptr != processor_cast
)
159 ret
= processor_cast
->setSupportedProperties(properties
);
164 * Sets supported properties for the ConfigurableComponent
165 * @param supported properties
166 * @return result of set operation.
169 bool setAutoTerminatedRelationships(std
::set
<Relationship
> relationships
) {
170 return processor_
->setAutoTerminatedRelationships(relationships
);
173 bool isAutoTerminated(Relationship relationship
) {
174 return processor_
->isAutoTerminated(relationship
);
177 bool setSupportedRelationships(std
::set
<Relationship
> relationships
) {
178 return processor_
->setSupportedRelationships(relationships
);
181 bool isSupportedRelationship(Relationship relationship
) {
182 return processor_
->isSupportedRelationship(relationship
);
189 void setName(const std
::string
&name
) {
190 Connectable
::setName(name
);
191 processor_
->setName(name
);
195 * Set UUID in this instance
196 * @param uuid uuid to apply to the internal representation.
198 void setUUID(uuid_t uuid
) {
199 Connectable
::setUUID(uuid
);
200 processor_
->setUUID(uuid
);
203 // Get Processor penalization period in MilliSecond
204 uint64_t getPenalizationPeriodMsec(void) {
205 return processor_
->getPenalizationPeriodMsec();
209 * Get outgoing connection based on relationship
210 * @return set of outgoing connections.
212 std
::set
<std
::shared_ptr
<Connectable
>> getOutGoingConnections(std
::string relationship
) {
213 return processor_
->getOutGoingConnections(relationship
);
217 * Get next incoming connection
218 * @return next incoming connection
220 std
::shared_ptr
<Connectable
> getNextIncomingConnection() {
221 return processor_
->getNextIncomingConnection();
225 * @return true if incoming connections > 0
227 bool hasIncomingConnections() {
228 return processor_
->hasIncomingConnections();
232 * Returns the UUID through the provided object.
233 * @param uuid uuid struct to which we will copy the memory
234 * @return success of request
236 bool getUUID(uuid_t uuid
) {
237 return processor_
->getUUID(uuid
);
240 unsigned const char *getUUID() {
241 return processor_
->getUUID();
244 * Return the UUID string
245 * @param constant reference to the UUID str
247 const std
::string
& getUUIDStr() const {
248 return processor_
->getUUIDStr();
252 std
::string
getName() const {
253 return processor_
->getName();
256 uint8_t getMaxConcurrentTasks() {
257 return processor_
->getMaxConcurrentTasks();
260 void setMaxConcurrentTasks(const uint8_t tasks
) {
261 processor_
->setMaxConcurrentTasks(tasks
);
264 virtual bool supportsDynamicProperties() {
268 virtual bool isRunning();
270 virtual bool isWorkAvailable();
272 virtual ~ProcessorNode();
276 virtual bool canEdit() {
277 return !processor_
->isRunning();
281 * internal connectable.
283 std
::shared_ptr
<Connectable
> processor_
;
288 } /* namespace core */
289 } /* namespace minifi */
290 } /* namespace nifi */
291 } /* namespace apache */
292 } /* namespace org */
294 #endif /* LIBMINIFI_INCLUDE_PROCESSOR_PROCESSORNODE_H_ */