INT-4095: Support Limiting (S)FTP Files Fetched

JIRA: https://jira.spring.io/browse/INT-4095

Limit the number of remote files fetched on each poll (when it is necessary to fetch files).

Polishing - PR Comments

Polishing - Decouple MaxFetchSize from Poller

Polishing - PR Comments

Schemas and Docs

More Polishing

* Polishing according PR comments
This commit is contained in:
Gary Russell
2016-08-18 18:15:04 -04:00
committed by Artem Bilan
parent 53237aa833
commit ea4763faa9
25 changed files with 534 additions and 33 deletions

View File

@@ -164,6 +164,7 @@
</xsd:annotation>
</xsd:attribute>
<xsd:attributeGroup ref="tempSuffixGroup" />
<xsd:attributeGroup ref="integration:maxFetchGroup" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

View File

@@ -27,6 +27,7 @@
local-filename-generator-expression="#this.toUpperCase() + '.a' + @fooString"
comparator="comparator"
temporary-file-suffix=".foo"
max-fetch-size="42"
local-filter="acceptAllFilter"
remote-directory-expression="'foo/bar'">
<int:poller fixed-rate="1000">

View File

@@ -122,6 +122,7 @@ public class FtpInboundChannelAdapterParserTests {
}
});
assertEquals("FOO.afoo", genMethod.get().invoke(fisync, "foo"));
assertEquals(42, inbound.getMaxFetchSize());
}
@Test
@@ -135,6 +136,7 @@ public class FtpInboundChannelAdapterParserTests {
assertEquals("/", remoteFileSeparator);
assertEquals("foo/bar", TestUtils.getPropertyValue(fisync, "remoteDirectoryExpression", Expression.class)
.getExpressionString());
assertEquals(Integer.MIN_VALUE, TestUtils.getPropertyValue(simpleAdapterWithCachedSessions, "source.maxFetchSize"));
}
@Test

View File

@@ -35,6 +35,14 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.List;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
@@ -51,14 +59,6 @@ import org.springframework.integration.metadata.PropertiesPersistingMetadataStor
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author Oleg Zhurakousky
* @author Gunnar Hillert
@@ -142,7 +142,7 @@ public class FtpInboundRemoteFileSystemSynchronizerTests {
assertNull(nothing);
// two times because on the third receive (above) the internal queue will be empty, so it will attempt
verify(synchronizer, times(2)).synchronizeToLocalDirectory(localDirectoy);
verify(synchronizer, times(2)).synchronizeToLocalDirectory(localDirectoy, Integer.MIN_VALUE);
assertTrue(new File("test/A.TEST.a").exists());
assertTrue(new File("test/B.TEST.a").exists());