Java Code Examples for org.apache.flink.configuration.CoreOptions#fileSystemConnectionLimitIn()

The following examples show how to use org.apache.flink.configuration.CoreOptions#fileSystemConnectionLimitIn() . 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: LimitedConnectionsFileSystem.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Parses and returns the settings for connection limiting, for the file system with
 * the given file system scheme.
 *
 * @param config The configuration to check.
 * @param fsScheme The file system scheme.
 *
 * @return The parsed configuration, or null, if no connection limiting is configured.
 */
@Nullable
public static ConnectionLimitingSettings fromConfig(Configuration config, String fsScheme) {
	checkNotNull(fsScheme, "fsScheme");
	checkNotNull(config, "config");

	final ConfigOption<Integer> totalLimitOption = CoreOptions.fileSystemConnectionLimit(fsScheme);
	final ConfigOption<Integer> limitInOption = CoreOptions.fileSystemConnectionLimitIn(fsScheme);
	final ConfigOption<Integer> limitOutOption = CoreOptions.fileSystemConnectionLimitOut(fsScheme);

	final int totalLimit = config.getInteger(totalLimitOption);
	final int limitIn = config.getInteger(limitInOption);
	final int limitOut = config.getInteger(limitOutOption);

	checkLimit(totalLimit, totalLimitOption);
	checkLimit(limitIn, limitInOption);
	checkLimit(limitOut, limitOutOption);

	// create the settings only, if at least one limit is configured
	if (totalLimit <= 0 && limitIn <= 0 && limitOut <= 0) {
		// no limit configured
		return null;
	}
	else {
		final ConfigOption<Long> openTimeoutOption =
				CoreOptions.fileSystemConnectionLimitTimeout(fsScheme);
		final ConfigOption<Long> inactivityTimeoutOption =
				CoreOptions.fileSystemConnectionLimitStreamInactivityTimeout(fsScheme);

		final long openTimeout = config.getLong(openTimeoutOption);
		final long inactivityTimeout = config.getLong(inactivityTimeoutOption);

		checkTimeout(openTimeout, openTimeoutOption);
		checkTimeout(inactivityTimeout, inactivityTimeoutOption);

		return new ConnectionLimitingSettings(
				totalLimit == -1 ? 0 : totalLimit,
				limitIn == -1 ? 0 : limitIn,
				limitOut == -1 ? 0 : limitOut,
				openTimeout,
				inactivityTimeout);
	}
}
 
Example 2
Source File: LimitedConnectionsFileSystem.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Parses and returns the settings for connection limiting, for the file system with
 * the given file system scheme.
 *
 * @param config The configuration to check.
 * @param fsScheme The file system scheme.
 *
 * @return The parsed configuration, or null, if no connection limiting is configured.
 */
@Nullable
public static ConnectionLimitingSettings fromConfig(Configuration config, String fsScheme) {
	checkNotNull(fsScheme, "fsScheme");
	checkNotNull(config, "config");

	final ConfigOption<Integer> totalLimitOption = CoreOptions.fileSystemConnectionLimit(fsScheme);
	final ConfigOption<Integer> limitInOption = CoreOptions.fileSystemConnectionLimitIn(fsScheme);
	final ConfigOption<Integer> limitOutOption = CoreOptions.fileSystemConnectionLimitOut(fsScheme);

	final int totalLimit = config.getInteger(totalLimitOption);
	final int limitIn = config.getInteger(limitInOption);
	final int limitOut = config.getInteger(limitOutOption);

	checkLimit(totalLimit, totalLimitOption);
	checkLimit(limitIn, limitInOption);
	checkLimit(limitOut, limitOutOption);

	// create the settings only, if at least one limit is configured
	if (totalLimit <= 0 && limitIn <= 0 && limitOut <= 0) {
		// no limit configured
		return null;
	}
	else {
		final ConfigOption<Long> openTimeoutOption =
				CoreOptions.fileSystemConnectionLimitTimeout(fsScheme);
		final ConfigOption<Long> inactivityTimeoutOption =
				CoreOptions.fileSystemConnectionLimitStreamInactivityTimeout(fsScheme);

		final long openTimeout = config.getLong(openTimeoutOption);
		final long inactivityTimeout = config.getLong(inactivityTimeoutOption);

		checkTimeout(openTimeout, openTimeoutOption);
		checkTimeout(inactivityTimeout, inactivityTimeoutOption);

		return new ConnectionLimitingSettings(
				totalLimit == -1 ? 0 : totalLimit,
				limitIn == -1 ? 0 : limitIn,
				limitOut == -1 ? 0 : limitOut,
				openTimeout,
				inactivityTimeout);
	}
}
 
Example 3
Source File: LimitedConnectionsFileSystem.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Parses and returns the settings for connection limiting, for the file system with
 * the given file system scheme.
 *
 * @param config The configuration to check.
 * @param fsScheme The file system scheme.
 *
 * @return The parsed configuration, or null, if no connection limiting is configured.
 */
@Nullable
public static ConnectionLimitingSettings fromConfig(Configuration config, String fsScheme) {
	checkNotNull(fsScheme, "fsScheme");
	checkNotNull(config, "config");

	final ConfigOption<Integer> totalLimitOption = CoreOptions.fileSystemConnectionLimit(fsScheme);
	final ConfigOption<Integer> limitInOption = CoreOptions.fileSystemConnectionLimitIn(fsScheme);
	final ConfigOption<Integer> limitOutOption = CoreOptions.fileSystemConnectionLimitOut(fsScheme);

	final int totalLimit = config.getInteger(totalLimitOption);
	final int limitIn = config.getInteger(limitInOption);
	final int limitOut = config.getInteger(limitOutOption);

	checkLimit(totalLimit, totalLimitOption);
	checkLimit(limitIn, limitInOption);
	checkLimit(limitOut, limitOutOption);

	// create the settings only, if at least one limit is configured
	if (totalLimit <= 0 && limitIn <= 0 && limitOut <= 0) {
		// no limit configured
		return null;
	}
	else {
		final ConfigOption<Long> openTimeoutOption =
				CoreOptions.fileSystemConnectionLimitTimeout(fsScheme);
		final ConfigOption<Long> inactivityTimeoutOption =
				CoreOptions.fileSystemConnectionLimitStreamInactivityTimeout(fsScheme);

		final long openTimeout = config.getLong(openTimeoutOption);
		final long inactivityTimeout = config.getLong(inactivityTimeoutOption);

		checkTimeout(openTimeout, openTimeoutOption);
		checkTimeout(inactivityTimeout, inactivityTimeoutOption);

		return new ConnectionLimitingSettings(
				totalLimit == -1 ? 0 : totalLimit,
				limitIn == -1 ? 0 : limitIn,
				limitOut == -1 ? 0 : limitOut,
				openTimeout,
				inactivityTimeout);
	}
}