org.apache.flink.core.fs.LimitedConnectionsFileSystem Java Examples

The following examples show how to use org.apache.flink.core.fs.LimitedConnectionsFileSystem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HadoopFsFactory.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static FileSystem limitIfConfigured(HadoopFileSystem fs, String scheme, Configuration config) {
	final ConnectionLimitingSettings limitSettings = ConnectionLimitingSettings.fromConfig(config, scheme);

	// decorate only if any limit is configured
	if (limitSettings == null) {
		// no limit configured
		return fs;
	}
	else {
		return new LimitedConnectionsFileSystem(
				fs,
				limitSettings.limitTotal,
				limitSettings.limitOutput,
				limitSettings.limitInput,
				limitSettings.streamOpenTimeout,
				limitSettings.streamInactivityTimeout);
	}
}
 
Example #2
Source File: HadoopFsFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
private static FileSystem limitIfConfigured(HadoopFileSystem fs, String scheme, Configuration config) {
	final ConnectionLimitingSettings limitSettings = ConnectionLimitingSettings.fromConfig(config, scheme);

	// decorate only if any limit is configured
	if (limitSettings == null) {
		// no limit configured
		return fs;
	}
	else {
		return new LimitedConnectionsFileSystem(
				fs,
				limitSettings.limitTotal,
				limitSettings.limitOutput,
				limitSettings.limitInput,
				limitSettings.streamOpenTimeout,
				limitSettings.streamInactivityTimeout);
	}
}
 
Example #3
Source File: HadoopFsFactory.java    From flink with Apache License 2.0 6 votes vote down vote up
private static FileSystem limitIfConfigured(HadoopFileSystem fs, String scheme, Configuration config) {
	final ConnectionLimitingSettings limitSettings = ConnectionLimitingSettings.fromConfig(config, scheme);

	// decorate only if any limit is configured
	if (limitSettings == null) {
		// no limit configured
		return fs;
	}
	else {
		return new LimitedConnectionsFileSystem(
				fs,
				limitSettings.limitTotal,
				limitSettings.limitOutput,
				limitSettings.limitInput,
				limitSettings.streamOpenTimeout,
				limitSettings.streamInactivityTimeout);
	}
}
 
Example #4
Source File: LimitedConnectionsConfigurationTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfiguration() throws Exception {

	// nothing configured, we should get a regular file system
	FileSystem hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
	FileSystem ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

	assertFalse(hdfs instanceof LimitedConnectionsFileSystem);
	assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

	// configure some limits, which should cause "fsScheme" to be limited

	final Configuration config = new Configuration();
	config.setInteger("fs.hdfs.limit.total", 40);
	config.setInteger("fs.hdfs.limit.input", 39);
	config.setInteger("fs.hdfs.limit.output", 38);
	config.setInteger("fs.hdfs.limit.timeout", 23456);
	config.setInteger("fs.hdfs.limit.stream-timeout", 34567);

	try {
		FileSystem.initialize(config);

		hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
		ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

		assertTrue(hdfs instanceof LimitedConnectionsFileSystem);
		assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

		LimitedConnectionsFileSystem limitedFs = (LimitedConnectionsFileSystem) hdfs;
		assertEquals(40, limitedFs.getMaxNumOpenStreamsTotal());
		assertEquals(39, limitedFs.getMaxNumOpenInputStreams());
		assertEquals(38, limitedFs.getMaxNumOpenOutputStreams());
		assertEquals(23456, limitedFs.getStreamOpenTimeout());
		assertEquals(34567, limitedFs.getStreamInactivityTimeout());
	}
	finally {
		// clear all settings
		FileSystem.initialize(new Configuration());
	}
}
 
Example #5
Source File: LimitedConnectionsConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfiguration() throws Exception {

	// nothing configured, we should get a regular file system
	FileSystem hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
	FileSystem ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

	assertFalse(hdfs instanceof LimitedConnectionsFileSystem);
	assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

	// configure some limits, which should cause "fsScheme" to be limited

	final Configuration config = new Configuration();
	config.setInteger("fs.hdfs.limit.total", 40);
	config.setInteger("fs.hdfs.limit.input", 39);
	config.setInteger("fs.hdfs.limit.output", 38);
	config.setInteger("fs.hdfs.limit.timeout", 23456);
	config.setInteger("fs.hdfs.limit.stream-timeout", 34567);

	try {
		FileSystem.initialize(config);

		hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
		ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

		assertTrue(hdfs instanceof LimitedConnectionsFileSystem);
		assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

		LimitedConnectionsFileSystem limitedFs = (LimitedConnectionsFileSystem) hdfs;
		assertEquals(40, limitedFs.getMaxNumOpenStreamsTotal());
		assertEquals(39, limitedFs.getMaxNumOpenInputStreams());
		assertEquals(38, limitedFs.getMaxNumOpenOutputStreams());
		assertEquals(23456, limitedFs.getStreamOpenTimeout());
		assertEquals(34567, limitedFs.getStreamInactivityTimeout());
	}
	finally {
		// clear all settings
		FileSystem.initialize(new Configuration());
	}
}
 
Example #6
Source File: LimitedConnectionsConfigurationTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfiguration() throws Exception {

	// nothing configured, we should get a regular file system
	FileSystem hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
	FileSystem ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

	assertFalse(hdfs instanceof LimitedConnectionsFileSystem);
	assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

	// configure some limits, which should cause "fsScheme" to be limited

	final Configuration config = new Configuration();
	config.setInteger("fs.hdfs.limit.total", 40);
	config.setInteger("fs.hdfs.limit.input", 39);
	config.setInteger("fs.hdfs.limit.output", 38);
	config.setInteger("fs.hdfs.limit.timeout", 23456);
	config.setInteger("fs.hdfs.limit.stream-timeout", 34567);

	try {
		FileSystem.initialize(config);

		hdfs = FileSystem.get(URI.create("hdfs://localhost:12345/a/b/c"));
		ftpfs = FileSystem.get(URI.create("ftp://localhost:12345/a/b/c"));

		assertTrue(hdfs instanceof LimitedConnectionsFileSystem);
		assertFalse(ftpfs instanceof LimitedConnectionsFileSystem);

		LimitedConnectionsFileSystem limitedFs = (LimitedConnectionsFileSystem) hdfs;
		assertEquals(40, limitedFs.getMaxNumOpenStreamsTotal());
		assertEquals(39, limitedFs.getMaxNumOpenInputStreams());
		assertEquals(38, limitedFs.getMaxNumOpenOutputStreams());
		assertEquals(23456, limitedFs.getStreamOpenTimeout());
		assertEquals(34567, limitedFs.getStreamInactivityTimeout());
	}
	finally {
		// clear all settings
		FileSystem.initialize(new Configuration());
	}
}