use of org.apache.nifi.registry.VariableDescriptor in project nifi by apache.
the class StandardProcessGroup method getComponentsAffectedByVariable.
@Override
public Set<ConfiguredComponent> getComponentsAffectedByVariable(final String variableName) {
final Set<ConfiguredComponent> affected = new HashSet<>();
// Determine any Processors that references the variable
for (final ProcessorNode processor : getProcessors()) {
for (final VariableImpact impact : getVariableImpact(processor)) {
if (impact.isImpacted(variableName)) {
affected.add(processor);
}
}
}
// find any references to that service and add it.
for (final ControllerServiceNode service : getControllerServices(false)) {
for (final VariableImpact impact : getVariableImpact(service)) {
if (impact.isImpacted(variableName)) {
affected.add(service);
final ControllerServiceReference reference = service.getReferences();
affected.addAll(reference.findRecursiveReferences(ConfiguredComponent.class));
}
}
}
// is overriding the variable and its components are actually referencing a different variable.
for (final ProcessGroup childGroup : getProcessGroups()) {
final ComponentVariableRegistry childRegistry = childGroup.getVariableRegistry();
final VariableDescriptor descriptor = childRegistry.getVariableKey(variableName);
final boolean overridden = childRegistry.getVariableMap().containsKey(descriptor);
if (!overridden) {
affected.addAll(childGroup.getComponentsAffectedByVariable(variableName));
}
}
return affected;
}
use of org.apache.nifi.registry.VariableDescriptor in project nifi by apache.
the class StandardComponentVariableRegistry method getVariableValue.
@Override
public String getVariableValue(final String name) {
if (name == null) {
return null;
}
final VariableDescriptor descriptor = new VariableDescriptor(name);
final String value = getVariableMap().get(descriptor);
if (value != null) {
return value;
}
return parent.getVariableValue(descriptor);
}
use of org.apache.nifi.registry.VariableDescriptor in project nifi by apache.
the class StandardFlowSerializer method addProcessGroup.
private void addProcessGroup(final Element parentElement, final ProcessGroup group, final String elementName, final ScheduledStateLookup scheduledStateLookup) {
final Document doc = parentElement.getOwnerDocument();
final Element element = doc.createElement(elementName);
parentElement.appendChild(element);
addTextElement(element, "id", group.getIdentifier());
addTextElement(element, "versionedComponentId", group.getVersionedComponentId());
addTextElement(element, "name", group.getName());
addPosition(element, group.getPosition());
addTextElement(element, "comment", group.getComments());
final VersionControlInformation versionControlInfo = group.getVersionControlInformation();
if (versionControlInfo != null) {
final Element versionControlInfoElement = doc.createElement("versionControlInformation");
addTextElement(versionControlInfoElement, "registryId", versionControlInfo.getRegistryIdentifier());
addTextElement(versionControlInfoElement, "bucketId", versionControlInfo.getBucketIdentifier());
addTextElement(versionControlInfoElement, "bucketName", versionControlInfo.getBucketName());
addTextElement(versionControlInfoElement, "flowId", versionControlInfo.getFlowIdentifier());
addTextElement(versionControlInfoElement, "flowName", versionControlInfo.getFlowName());
addTextElement(versionControlInfoElement, "flowDescription", versionControlInfo.getFlowDescription());
addTextElement(versionControlInfoElement, "version", versionControlInfo.getVersion());
element.appendChild(versionControlInfoElement);
}
for (final ProcessorNode processor : group.getProcessors()) {
addProcessor(element, processor, scheduledStateLookup);
}
if (group.isRootGroup()) {
for (final Port port : group.getInputPorts()) {
addRootGroupPort(element, (RootGroupPort) port, "inputPort", scheduledStateLookup);
}
for (final Port port : group.getOutputPorts()) {
addRootGroupPort(element, (RootGroupPort) port, "outputPort", scheduledStateLookup);
}
} else {
for (final Port port : group.getInputPorts()) {
addPort(element, port, "inputPort", scheduledStateLookup);
}
for (final Port port : group.getOutputPorts()) {
addPort(element, port, "outputPort", scheduledStateLookup);
}
}
for (final Label label : group.getLabels()) {
addLabel(element, label);
}
for (final Funnel funnel : group.getFunnels()) {
addFunnel(element, funnel);
}
for (final ProcessGroup childGroup : group.getProcessGroups()) {
addProcessGroup(element, childGroup, "processGroup", scheduledStateLookup);
}
for (final RemoteProcessGroup remoteRef : group.getRemoteProcessGroups()) {
addRemoteProcessGroup(element, remoteRef, scheduledStateLookup);
}
for (final Connection connection : group.getConnections()) {
addConnection(element, connection);
}
for (final ControllerServiceNode service : group.getControllerServices(false)) {
addControllerService(element, service);
}
for (final Template template : group.getTemplates()) {
addTemplate(element, template);
}
final VariableRegistry variableRegistry = group.getVariableRegistry();
for (final Map.Entry<VariableDescriptor, String> entry : variableRegistry.getVariableMap().entrySet()) {
addVariable(element, entry.getKey().getName(), entry.getValue());
}
}
use of org.apache.nifi.registry.VariableDescriptor in project nifi by apache.
the class TestFileBasedVariableRegistry method testCreateCustomVariableRegistry.
@Test
public void testCreateCustomVariableRegistry() {
final Path fooPath = Paths.get("src/test/resources/TestVariableRegistry/foobar.properties");
final Path testPath = Paths.get("src/test/resources/TestVariableRegistry/test.properties");
Path[] paths = { fooPath, testPath };
final String vendorUrl = System.getProperty("java.vendor.url");
VariableRegistry variableRegistry = new FileBasedVariableRegistry(paths);
final Map<VariableDescriptor, String> variables = variableRegistry.getVariableMap();
assertTrue(variables.containsKey(new VariableDescriptor("fake.property.3")));
assertEquals(vendorUrl, variableRegistry.getVariableValue("java.vendor.url"));
assertEquals("test me out 3, test me out 4", variableRegistry.getVariableValue("fake.property.3"));
}
Aggregations