[ 
https://issues.apache.org/jira/browse/CAMEL-27603?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-27603:
--------------------------------
    Fix Version/s: 4.24.0
                       (was: 4.25.0)

> camel-file-watch: events parsing, pollThreads re-hashes tree, 
> recursive=false, metadata gaps
> --------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27603
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27603
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-file-watch
>            Reporter: Claus Ibsen
>            Assignee: shashank
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> Found while improving the option descriptions of camel-file-watch for 
> CAMEL-23832 (PR https://github.com/apache/camel/pull/30938).
> These are separate problems of the component; the descriptions PR only 
> documents the current behavior.
> h4. 1. A space or lower case in the events option fails the consumer
> {{FileWatchConsumer.doInit()}} splits {{events}} on {{,}} and passes each 
> part to {{FileEventEnum.valueOf(String)}} without trimming or upper-casing it.
> So {{events=CREATE, MODIFY}} or {{events=create}} throws 
> {{IllegalArgumentException: No enum constant ... FileEventEnum. MODIFY}} and 
> the route does not start.
> Proposed change: trim each value and ignore case, and fail with a message 
> that lists the accepted values.
> h4. 2. pollThreads greater than 1 registers and hashes the whole directory 
> tree once per thread
> {{FileWatchConsumer.doStart()}} calls 
> {{watcher.watchAsync(watchDirExecutorService)}} {{pollThreads}} times on the 
> same {{DirectoryWatcher}}.
> In directory-watcher 0.19.1 each {{watchAsync}} call runs 
> {{registerPaths()}}, which walks the tree, registers every directory again 
> and, with file hashing on, hashes every file again (the default Murmur3F 
> hasher reads each file in full).
> With a large tree, the start time and I/O grow with {{pollThreads}}, and the 
> extra event loops all read the same {{WatchService}}.
> Proposed change: call {{watchAsync}} once, or document that {{pollThreads}} 
> only adds event loops on one watcher and check that it helps with OVERFLOW at 
> all.
> h4. 3. recursive=false still watches and hashes all subdirectories
> {{FileWatchConsumer.doStart()}} builds the {{DirectoryWatcher}} the same way 
> for both values of {{recursive}}, and directory-watcher always registers the 
> whole tree. {{FileWatchConsumer.matchFilters()}} then drops the events whose 
> parent is not the base directory.
> So a non-recursive watch of a directory with a large subtree still registers 
> every subdirectory (inotify watches on Linux) and hashes every file at start.
> Proposed change: when {{recursive=false}}, pass a {{FileTreeVisitor}} to the 
> builder that visits only the base directory and its direct entries.
> h4. 4. The no-argument constructor of FileWatchEndpoint leaves options at 0 
> and false
> {{FileWatchEndpoint()}} does not initialize {{concurrentConsumers}}, 
> {{pollThreads}}, {{queueSize}} and {{useFileHashing}}, so they are 0, 0, 0 
> and false, while the metadata says 1, 1, {{Integer.MAX_VALUE}} and true. Only 
> {{FileWatchEndpoint(String, FileWatchComponent)}} copies the component values.
> The component always uses that constructor, so a route does not see it, but 
> an endpoint created with {{new FileWatchEndpoint()}} starts no poll thread 
> and no consumer thread.
> Proposed change: initialize the fields with the documented defaults.
> h4. 5. The CamelMessageTimestamp header is not documented
> {{FileWatchConsumer.prepareExchange()}} sets {{Exchange.MESSAGE_TIMESTAMP}} 
> to the time the listener received the event ({{FileEvent.getEventDate()}}), 
> and the examples in {{file-watch-component.adoc}} use 
> {{$\{header.CamelMessageTimestamp\}}}. {{FileWatchConstants}} has no constant 
> for it, so the header list of the doc page and the catalog do not show it.
> Proposed change: add a {{@Metadata}} constant for {{CamelMessageTimestamp}} 
> to {{FileWatchConstants}}.
> h4. 6. The events option has no enum metadata
> {{events}} is a plain {{String}} {{@UriParam}} without {{enums = 
> "CREATE,MODIFY,DELETE"}} and {{multiValue}}, so tooling cannot offer or 
> validate the values (see item 1).
> Proposed change: add the enum values to the metadata.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to