final int limitOut = config.getInteger(limitOutOption); checkLimit(totalLimit, totalLimitOption); checkLimit(limitIn, limitInOption); checkLimit(limitOut, limitOutOption); final long inactivityTimeout = config.getLong(inactivityTimeoutOption); checkTimeout(openTimeout, openTimeoutOption); checkTimeout(inactivityTimeout, inactivityTimeoutOption); return new ConnectionLimitingSettings( totalLimit == -1 ? 0 : totalLimit, limitIn == -1 ? 0 : limitIn,
final int limitOut = config.getInteger(limitOutOption); checkLimit(totalLimit, totalLimitOption); checkLimit(limitIn, limitInOption); checkLimit(limitOut, limitOutOption); final long inactivityTimeout = config.getLong(inactivityTimeoutOption); checkTimeout(openTimeout, openTimeoutOption); checkTimeout(inactivityTimeout, inactivityTimeoutOption); return new ConnectionLimitingSettings( totalLimit == -1 ? 0 : totalLimit, limitIn == -1 ? 0 : limitIn,
final int limitOut = config.getInteger(limitOutOption); checkLimit(totalLimit, totalLimitOption); checkLimit(limitIn, limitInOption); checkLimit(limitOut, limitOutOption); final long inactivityTimeout = config.getLong(inactivityTimeoutOption); checkTimeout(openTimeout, openTimeoutOption); checkTimeout(inactivityTimeout, inactivityTimeoutOption); return new ConnectionLimitingSettings( totalLimit == -1 ? 0 : totalLimit, limitIn == -1 ? 0 : limitIn,
/** * Decorates the given factory for a {@code ConnectionLimitingFactory}, if the given * configuration configured connection limiting for the given file system scheme. * Otherwise, it returns the given factory as is. * * @param factory The factory to potentially decorate. * @param scheme The file scheme for which to check the configuration. * @param config The configuration * * @return The decorated factors, if connection limiting is configured, the original factory otherwise. */ public static FileSystemFactory decorateIfLimited(FileSystemFactory factory, String scheme, Configuration config) { checkNotNull(factory, "factory"); final ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(config, scheme); // decorate only if any limit is configured if (settings == null) { // no limit configured return factory; } else { return new ConnectionLimitingFactory(factory, settings); } } }
/** * Decorates the given factory for a {@code ConnectionLimitingFactory}, if the given * configuration configured connection limiting for the given file system scheme. * Otherwise, it returns the given factory as is. * * @param factory The factory to potentially decorate. * @param scheme The file scheme for which to check the configuration. * @param config The configuration * * @return The decorated factors, if connection limiting is configured, the original factory otherwise. */ public static FileSystemFactory decorateIfLimited(FileSystemFactory factory, String scheme, Configuration config) { checkNotNull(factory, "factory"); final ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(config, scheme); // decorate only if any limit is configured if (settings == null) { // no limit configured return factory; } else { return new ConnectionLimitingFactory(factory, settings); } } }
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); } } }
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); } } }
assertNull(ConnectionLimitingSettings.fromConfig(new Configuration(), scheme)); conf.setInteger(CoreOptions.fileSystemConnectionLimit(scheme), 10); ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(conf, scheme); assertNotNull(settings); assertEquals(10, settings.limitTotal); conf.setInteger(CoreOptions.fileSystemConnectionLimitIn(scheme), 10); ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(conf, scheme); assertNotNull(settings); assertEquals(0, settings.limitTotal); conf.setInteger(CoreOptions.fileSystemConnectionLimitOut(scheme), 10); ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(conf, scheme); assertNotNull(settings); assertEquals(0, settings.limitTotal);
/** * Decorates the given factory for a {@code ConnectionLimitingFactory}, if the given * configuration configured connection limiting for the given file system scheme. * Otherwise, it returns the given factory as is. * * @param factory The factory to potentially decorate. * @param scheme The file scheme for which to check the configuration. * @param config The configuration * * @return The decorated factors, if connection limiting is configured, the original factory otherwise. */ public static FileSystemFactory decorateIfLimited(FileSystemFactory factory, String scheme, Configuration config) { checkNotNull(factory, "factory"); final ConnectionLimitingSettings settings = ConnectionLimitingSettings.fromConfig(config, scheme); // decorate only if any limit is configured if (settings == null) { // no limit configured return factory; } else { return new ConnectionLimitingFactory(factory, settings); } } }
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); } } }