Search code examples
spring-integrationapache-zookeeperspring-integration-sftp

Exception while running spring integration with zookeeper


when i am running spring integration SFTP with zookeeper: Facing issue while file metada put in metadatastore. i have mention below code. Below is my configuration

<beans:bean id="compositeFilter"
        class="org.springframework.integration.file.filters.ChainFileListFilter">

        <beans:constructor-arg >
        <beans:set>
          <beans:bean
                    class="org.springframework.integration.sftp.filters.SftpRegexPatternFileListFilter">
                        <beans:constructor-arg value="^.*\.(dat|DAT)$" />
                </beans:bean>
            <beans:bean
                    class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter">
                    <beans:constructor-arg name="store"
                        ref="metadataStore" />
                    <beans:constructor-arg value="filterprefix" />
                </beans:bean>
          </beans:set>

        </beans:constructor-arg>

    </beans:bean>

    <beans:bean id="zookeeperClient"
        class="org.springframework.integration.zookeeper.config.CuratorFrameworkFactoryBean">
        <beans:constructor-arg value="${zookeeper.server.uri}" />
    </beans:bean>

    <beans:bean id="metadataStore"
        class="org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore">
        <beans:constructor-arg ref="zookeeperClient" />
        <beans:property name="root" value="/metaDataStore" />
    </beans:bean>

Below are the exception trace which I am getting. when i run above program i am getting following error.

Caused by: 
Caused by: java.lang.IllegalArgumentException: Invalid path string "/AtdFaureciaMetaDataStore/.." caused by relative paths not allowed @27
    at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:102)
    at org.apache.curator.utils.PathUtils.validatePath(PathUtils.java:37)
    at org.apache.curator.utils.ZKPaths.fixForNamespace(ZKPaths.java:105)
    at org.apache.curator.framework.imps.NamespaceImpl.fixForNamespace(NamespaceImpl.java:104)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.fixForNamespace(CuratorFrameworkImpl.java:599)
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:458)
    at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:44)
    at org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore.createNode(ZookeeperMetadataStore.java:257)
    at org.springframework.integration.zookeeper.metadata.ZookeeperMetadataStore.putIfAbsent(ZookeeperMetadataStore.java:119)

Solution

  • Consider to use ChainFileListFilter instead of CompositeFileListFilter:

    **
     * The {@link CompositeFileListFilter} extension which chains the result
     * of the previous filter to the next one. If a filter in the chain returns
     * an empty list, the remaining filters are not invoked.
     *
     * @param <F> The type that will be filtered.
     *
     * @author Artem Bilan
     * @author Gary Russell
     *
     * @since 4.3.7
     *
     */
    public class ChainFileListFilter<F> extends CompositeFileListFilter<F> {
    

    It doesn’t pass discarded files to the next filters in chain.

    On the other hand really consider some non-empty prefix for the SftpPersistentAcceptOnceFileListFilter to avoid that relative path error.