Search in sources :

Example 1 with WEvtApi

use of org.apache.nifi.processors.windows.event.log.jna.WEvtApi in project nifi by apache.

the class ConsumeWindowsEventLog method subscribe.

/**
 * Register subscriber via native call
 *
 * @param context the process context
 */
private String subscribe(ProcessContext context) throws URISyntaxException {
    String channel = context.getProperty(CHANNEL).getValue();
    String query = context.getProperty(QUERY).getValue();
    renderedXMLs = new LinkedBlockingQueue<>(context.getProperty(MAX_EVENT_QUEUE_SIZE).asInteger());
    provenanceUri = new URI("winlog", name, "/" + channel, query, null).toASCIIString();
    evtSubscribeCallback = new EventSubscribeXmlRenderingCallback(getLogger(), s -> {
        try {
            renderedXMLs.put(s);
        } catch (InterruptedException e) {
            throw new IllegalStateException("Got interrupted while waiting to add to queue.", e);
        }
    }, context.getProperty(MAX_BUFFER_SIZE).asInteger(), wEvtApi, kernel32, errorLookup);
    subscriptionHandle = wEvtApi.EvtSubscribe(null, null, channel, query, null, null, evtSubscribeCallback, WEvtApi.EvtSubscribeFlags.SUBSCRIBE_TO_FUTURE | WEvtApi.EvtSubscribeFlags.EVT_SUBSCRIBE_STRICT);
    if (!isSubscribed()) {
        return UNABLE_TO_SUBSCRIBE + errorLookup.getLastError();
    }
    return null;
}
Also used : StandardValidators(org.apache.nifi.processor.util.StandardValidators) Arrays(java.util.Arrays) CapabilityDescription(org.apache.nifi.annotation.documentation.CapabilityDescription) ValidationContext(org.apache.nifi.components.ValidationContext) URISyntaxException(java.net.URISyntaxException) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) ProcessException(org.apache.nifi.processor.exception.ProcessException) WEvtApi(org.apache.nifi.processors.windows.event.log.jna.WEvtApi) ArrayList(java.util.ArrayList) WinNT(com.sun.jna.platform.win32.WinNT) HashSet(java.util.HashSet) Kernel32Util(com.sun.jna.platform.win32.Kernel32Util) ErrorLookup(org.apache.nifi.processors.windows.event.log.jna.ErrorLookup) WritesAttributes(org.apache.nifi.annotation.behavior.WritesAttributes) Relationship(org.apache.nifi.processor.Relationship) AbstractSessionFactoryProcessor(org.apache.nifi.processor.AbstractSessionFactoryProcessor) URI(java.net.URI) TriggerSerially(org.apache.nifi.annotation.behavior.TriggerSerially) ValidationResult(org.apache.nifi.components.ValidationResult) Charsets(org.apache.commons.io.Charsets) FlowFile(org.apache.nifi.flowfile.FlowFile) Collection(java.util.Collection) ProcessContext(org.apache.nifi.processor.ProcessContext) Set(java.util.Set) ProcessSession(org.apache.nifi.processor.ProcessSession) BlockingQueue(java.util.concurrent.BlockingQueue) WritesAttribute(org.apache.nifi.annotation.behavior.WritesAttribute) ProcessSessionFactory(org.apache.nifi.processor.ProcessSessionFactory) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) InputRequirement(org.apache.nifi.annotation.behavior.InputRequirement) OnScheduled(org.apache.nifi.annotation.lifecycle.OnScheduled) List(java.util.List) Kernel32(com.sun.jna.platform.win32.Kernel32) EventSubscribeXmlRenderingCallback(org.apache.nifi.processors.windows.event.log.jna.EventSubscribeXmlRenderingCallback) Tags(org.apache.nifi.annotation.documentation.Tags) CoreAttributes(org.apache.nifi.flowfile.attributes.CoreAttributes) OnStopped(org.apache.nifi.annotation.lifecycle.OnStopped) Collections(java.util.Collections) EventSubscribeXmlRenderingCallback(org.apache.nifi.processors.windows.event.log.jna.EventSubscribeXmlRenderingCallback) URI(java.net.URI)

Aggregations

Kernel32 (com.sun.jna.platform.win32.Kernel32)1 Kernel32Util (com.sun.jna.platform.win32.Kernel32Util)1 WinNT (com.sun.jna.platform.win32.WinNT)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 Charsets (org.apache.commons.io.Charsets)1 InputRequirement (org.apache.nifi.annotation.behavior.InputRequirement)1 TriggerSerially (org.apache.nifi.annotation.behavior.TriggerSerially)1 WritesAttribute (org.apache.nifi.annotation.behavior.WritesAttribute)1 WritesAttributes (org.apache.nifi.annotation.behavior.WritesAttributes)1 CapabilityDescription (org.apache.nifi.annotation.documentation.CapabilityDescription)1