Get ProcessGroup from processorHow to use NiFi ExecuteScript processor with Python?NiFi fetchFile processor doesn't allow dynamic attributesHow to update the “Replacement Value” in ReplaceText Processor using Rest API?Is it possible to get the ID of a processor/connector in apache NiFi using the rest API?Stopping processor in secure NiFiNifi: Route on Attribute processor to wrong processorHow to start ALL processorsNifi Processor to run multiple instanceNiFi getHTTP or invokeHTTP which processor to use?How to configure ExecuteScript processor in NIfi to use JyNI package to enable libraries using numpy?
One verb to replace 'be a member of' a club
Was the old ablative pronoun "med" or "mēd"?
Venezuelan girlfriend wants to travel the USA to be with me. What is the process?
How can I deal with my CEO asking me to hire someone with a higher salary than me, a co-founder?
Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?
What is the most common color to indicate the input-field is disabled?
Can a virus destroy the BIOS of a modern computer?
Ambiguity in the definition of entropy
Can someone clarify Hamming's notion of important problems in relation to modern academia?
Description list Formatting using enumitem
Is there an online compendium of Rav Moshe teshuvos in English that exists?
Is this answer explanation correct?
How to stretch the corners of this image so that it looks like a perfect rectangle?
How to install cross-compiler on Ubuntu 18.04?
In the UK, is it possible to get a referendum by a court decision?
How obscure is the use of 令 in 令和?
Do creatures with a listed speed of "0 ft., fly 30 ft. (hover)" ever touch the ground?
Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)
How can saying a song's name be a copyright violation?
Expand and Contract
Processor speed limited at 0.4 Ghz
How could indestructible materials be used in power generation?
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
How seriously should I take size and weight limits of hand luggage?
Get ProcessGroup from processor
How to use NiFi ExecuteScript processor with Python?NiFi fetchFile processor doesn't allow dynamic attributesHow to update the “Replacement Value” in ReplaceText Processor using Rest API?Is it possible to get the ID of a processor/connector in apache NiFi using the rest API?Stopping processor in secure NiFiNifi: Route on Attribute processor to wrong processorHow to start ALL processorsNifi Processor to run multiple instanceNiFi getHTTP or invokeHTTP which processor to use?How to configure ExecuteScript processor in NIfi to use JyNI package to enable libraries using numpy?
Is there an API to get a ProcessGroup by id from a custom processor or an ExecuteScript processor?
I know that it is possible by using the REST-API, but for security reasons, I don't have the chance to use the credentials to invoke the API from a service.
Regards
apache-nifi
add a comment |
Is there an API to get a ProcessGroup by id from a custom processor or an ExecuteScript processor?
I know that it is possible by using the REST-API, but for security reasons, I don't have the chance to use the credentials to invoke the API from a service.
Regards
apache-nifi
add a comment |
Is there an API to get a ProcessGroup by id from a custom processor or an ExecuteScript processor?
I know that it is possible by using the REST-API, but for security reasons, I don't have the chance to use the credentials to invoke the API from a service.
Regards
apache-nifi
Is there an API to get a ProcessGroup by id from a custom processor or an ExecuteScript processor?
I know that it is possible by using the REST-API, but for security reasons, I don't have the chance to use the credentials to invoke the API from a service.
Regards
apache-nifi
apache-nifi
asked Mar 21 at 20:46
AndrésAndrés
161
161
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
If you use a InvokeScriptedProcessor using groovy you can use
context.procNode.processGroup
from the ProcessContext
If you want to extract all the parents in a breadcrum way, you can use this:
import groovy.json.*;
import org.apache.nifi.groups.*;
class GroovyProcessor implements Processor
def REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here').build()
def ComponentLog log
@Override
void initialize(ProcessorInitializationContext context)
log = context.logger
@Override
Set<Relationship> getRelationships()
return [REL_SUCCESS] as Set
void executeScript(ProcessSession session, ProcessContext context)
def flowFile = session.get()
if (!flowFile) return
def breadcrumb = getBreadCrumb(context.procNode.processGroup) + '->' + context.getName()
flowFile = session.putAttribute(flowFile, 'breadcrumb', breadcrumb)
// transfer
session.transfer(flowFile, this.REL_SUCCESS)
// Recursive funtion that gets the breadcrumb
String getBreadCrumb(processGroup)
def breadCrumb = ''
if(processGroup.parent != null)
breadCrumb = getBreadCrumb(processGroup.parent) + '->'
return breadCrumb + processGroup.name
@Override
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
def session = sessionFactory.createSession()
try
executeScript( session, context)
session.commit()
catch (final Throwable t)
log.error(' failed to process due to ; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
@Override
PropertyDescriptor getPropertyDescriptor(String name) null
@Override
List<PropertyDescriptor> getPropertyDescriptors()
return [] as List
@Override
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
@Override
Collection<ValidationResult> validate(ValidationContext context) null
@Override
String getIdentifier() null
processor = new GroovyProcessor()
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288989%2fget-processgroup-from-processor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you use a InvokeScriptedProcessor using groovy you can use
context.procNode.processGroup
from the ProcessContext
If you want to extract all the parents in a breadcrum way, you can use this:
import groovy.json.*;
import org.apache.nifi.groups.*;
class GroovyProcessor implements Processor
def REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here').build()
def ComponentLog log
@Override
void initialize(ProcessorInitializationContext context)
log = context.logger
@Override
Set<Relationship> getRelationships()
return [REL_SUCCESS] as Set
void executeScript(ProcessSession session, ProcessContext context)
def flowFile = session.get()
if (!flowFile) return
def breadcrumb = getBreadCrumb(context.procNode.processGroup) + '->' + context.getName()
flowFile = session.putAttribute(flowFile, 'breadcrumb', breadcrumb)
// transfer
session.transfer(flowFile, this.REL_SUCCESS)
// Recursive funtion that gets the breadcrumb
String getBreadCrumb(processGroup)
def breadCrumb = ''
if(processGroup.parent != null)
breadCrumb = getBreadCrumb(processGroup.parent) + '->'
return breadCrumb + processGroup.name
@Override
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
def session = sessionFactory.createSession()
try
executeScript( session, context)
session.commit()
catch (final Throwable t)
log.error(' failed to process due to ; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
@Override
PropertyDescriptor getPropertyDescriptor(String name) null
@Override
List<PropertyDescriptor> getPropertyDescriptors()
return [] as List
@Override
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
@Override
Collection<ValidationResult> validate(ValidationContext context) null
@Override
String getIdentifier() null
processor = new GroovyProcessor()
add a comment |
If you use a InvokeScriptedProcessor using groovy you can use
context.procNode.processGroup
from the ProcessContext
If you want to extract all the parents in a breadcrum way, you can use this:
import groovy.json.*;
import org.apache.nifi.groups.*;
class GroovyProcessor implements Processor
def REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here').build()
def ComponentLog log
@Override
void initialize(ProcessorInitializationContext context)
log = context.logger
@Override
Set<Relationship> getRelationships()
return [REL_SUCCESS] as Set
void executeScript(ProcessSession session, ProcessContext context)
def flowFile = session.get()
if (!flowFile) return
def breadcrumb = getBreadCrumb(context.procNode.processGroup) + '->' + context.getName()
flowFile = session.putAttribute(flowFile, 'breadcrumb', breadcrumb)
// transfer
session.transfer(flowFile, this.REL_SUCCESS)
// Recursive funtion that gets the breadcrumb
String getBreadCrumb(processGroup)
def breadCrumb = ''
if(processGroup.parent != null)
breadCrumb = getBreadCrumb(processGroup.parent) + '->'
return breadCrumb + processGroup.name
@Override
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
def session = sessionFactory.createSession()
try
executeScript( session, context)
session.commit()
catch (final Throwable t)
log.error(' failed to process due to ; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
@Override
PropertyDescriptor getPropertyDescriptor(String name) null
@Override
List<PropertyDescriptor> getPropertyDescriptors()
return [] as List
@Override
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
@Override
Collection<ValidationResult> validate(ValidationContext context) null
@Override
String getIdentifier() null
processor = new GroovyProcessor()
add a comment |
If you use a InvokeScriptedProcessor using groovy you can use
context.procNode.processGroup
from the ProcessContext
If you want to extract all the parents in a breadcrum way, you can use this:
import groovy.json.*;
import org.apache.nifi.groups.*;
class GroovyProcessor implements Processor
def REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here').build()
def ComponentLog log
@Override
void initialize(ProcessorInitializationContext context)
log = context.logger
@Override
Set<Relationship> getRelationships()
return [REL_SUCCESS] as Set
void executeScript(ProcessSession session, ProcessContext context)
def flowFile = session.get()
if (!flowFile) return
def breadcrumb = getBreadCrumb(context.procNode.processGroup) + '->' + context.getName()
flowFile = session.putAttribute(flowFile, 'breadcrumb', breadcrumb)
// transfer
session.transfer(flowFile, this.REL_SUCCESS)
// Recursive funtion that gets the breadcrumb
String getBreadCrumb(processGroup)
def breadCrumb = ''
if(processGroup.parent != null)
breadCrumb = getBreadCrumb(processGroup.parent) + '->'
return breadCrumb + processGroup.name
@Override
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
def session = sessionFactory.createSession()
try
executeScript( session, context)
session.commit()
catch (final Throwable t)
log.error(' failed to process due to ; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
@Override
PropertyDescriptor getPropertyDescriptor(String name) null
@Override
List<PropertyDescriptor> getPropertyDescriptors()
return [] as List
@Override
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
@Override
Collection<ValidationResult> validate(ValidationContext context) null
@Override
String getIdentifier() null
processor = new GroovyProcessor()
If you use a InvokeScriptedProcessor using groovy you can use
context.procNode.processGroup
from the ProcessContext
If you want to extract all the parents in a breadcrum way, you can use this:
import groovy.json.*;
import org.apache.nifi.groups.*;
class GroovyProcessor implements Processor
def REL_SUCCESS = new Relationship.Builder()
.name("success")
.description('FlowFiles that were successfully processed are routed here').build()
def ComponentLog log
@Override
void initialize(ProcessorInitializationContext context)
log = context.logger
@Override
Set<Relationship> getRelationships()
return [REL_SUCCESS] as Set
void executeScript(ProcessSession session, ProcessContext context)
def flowFile = session.get()
if (!flowFile) return
def breadcrumb = getBreadCrumb(context.procNode.processGroup) + '->' + context.getName()
flowFile = session.putAttribute(flowFile, 'breadcrumb', breadcrumb)
// transfer
session.transfer(flowFile, this.REL_SUCCESS)
// Recursive funtion that gets the breadcrumb
String getBreadCrumb(processGroup)
def breadCrumb = ''
if(processGroup.parent != null)
breadCrumb = getBreadCrumb(processGroup.parent) + '->'
return breadCrumb + processGroup.name
@Override
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException
def session = sessionFactory.createSession()
try
executeScript( session, context)
session.commit()
catch (final Throwable t)
log.error(' failed to process due to ; rolling back session', [this, t] as Object[])
session.rollback(true)
throw t
@Override
PropertyDescriptor getPropertyDescriptor(String name) null
@Override
List<PropertyDescriptor> getPropertyDescriptors()
return [] as List
@Override
void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue)
@Override
Collection<ValidationResult> validate(ValidationContext context) null
@Override
String getIdentifier() null
processor = new GroovyProcessor()
answered Mar 22 at 8:04
Óscar AndreuÓscar Andreu
1,146728
1,146728
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55288989%2fget-processgroup-from-processor%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown