/** * @param config client configs * @return configured ChannelBuilder based on the configs. */ public static ChannelBuilder createChannelBuilder(AbstractConfig config, Time time) { SecurityProtocol securityProtocol = SecurityProtocol.forName(config.getString(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)); String clientSaslMechanism = config.getString(SaslConfigs.SASL_MECHANISM); return ChannelBuilders.clientChannelBuilder(securityProtocol, JaasContext.Type.CLIENT, config, null, clientSaslMechanism, time, true); }
/** * @return The name of the RYA instance that will be connected to. */ public String getRyaInstanceName() { return super.getString(RYA_INSTANCE_NAME); } }
/** * Method is used to return a File checking to ensure that it is an absolute path. * * @param config config to read the value from * @param key key for the value * @return File for the config value. */ public static File getAbsoluteFile(AbstractConfig config, String key) { Preconditions.checkNotNull(config, "config cannot be null"); String path = config.getString(key); File file = new File(path); Preconditions.checkState(file.isAbsolute(), "'%s' must be an absolute path.", key); return new File(path); }
/** * Method is used to return a File checking to ensure that it is an absolute path. * * @param config config to read the value from * @param key key for the value * @return File for the config value. */ public static File getAbsoluteFile(AbstractConfig config, String key) { Preconditions.checkNotNull(config, "config cannot be null"); String path = config.getString(key); File file = new File(path); Preconditions.checkState(file.isAbsolute(), "'%s' must be an absolute path.", key); return new File(path); }
/** * Method is used to retrieve a URI from a configuration key. * * @param config Config to read * @param key Key to read * @return URI for the value. */ public static URI uri(AbstractConfig config, String key) { final String value = config.getString(key); return uri(key, value); }
/** * Method is used to return an enum value from a given string. * * @param enumClass Class for the resulting enum value * @param config config to read the value from * @param key key for the value * @param <T> Enum class to return type for. * @return enum value for the given key. * @see ValidEnum */ public static <T extends Enum<T>> T getEnum(Class<T> enumClass, AbstractConfig config, String key) { Preconditions.checkNotNull(enumClass, "enumClass cannot be null"); Preconditions.checkState(enumClass.isEnum(), "enumClass must be an enum."); String textValue = config.getString(key); return Enum.valueOf(enumClass, textValue); }
/** * Method is used to return an enum value from a given string. * * @param enumClass Class for the resulting enum value * @param config config to read the value from * @param key key for the value * @param <T> Enum class to return type for. * @return enum value for the given key. * @see ValidEnum */ public static <T extends Enum<T>> T getEnum(Class<T> enumClass, AbstractConfig config, String key) { Preconditions.checkNotNull(enumClass, "enumClass cannot be null"); Preconditions.checkState(enumClass.isEnum(), "enumClass must be an enum."); String textValue = config.getString(key); return Enum.valueOf(enumClass, textValue); }
/** * Method is used to return an InetSocketAddress from a hostname:port string. * * @param config config to read the value from * @param key key for the value * @return InetSocketAddress for the supplied string. */ public static InetSocketAddress inetSocketAddress(AbstractConfig config, String key) { Preconditions.checkNotNull(config, "config cannot be null"); String value = config.getString(key); return parseInetSocketAddress(value); }
/** * Method is used to retrieve a URL from a configuration key. * * @param config Config to read * @param key Key to read * @return URL for the value. */ public static URL url(AbstractConfig config, String key) { final String value = config.getString(key); return url(key, value); }
/** * Method is used to parse a string ConfigDef item to a HostAndPort * * @param config Config to read from * @param key ConfigItem to get the host string from. * @param defaultPort The default port to use if a port was not specified. Can be null. * @return HostAndPort based on the ConfigItem. */ public static HostAndPort hostAndPort(AbstractConfig config, String key, Integer defaultPort) { final String input = config.getString(key); return hostAndPort(input, defaultPort); }
@Override public void start(Map<String, String> props) { AbstractConfig parsedConfig = new AbstractConfig(CONFIG_DEF, props); filename = parsedConfig.getString(FILE_CONFIG); }
/** * Method is used to create a pattern based on the config element. * * @param config * @param key * @return */ public static Pattern pattern(AbstractConfig config, String key) { String pattern = config.getString(key); try { return Pattern.compile(pattern); } catch (PatternSyntaxException e) { throw new ConfigException( key, pattern, String.format( "Could not compile regex '%s'.", pattern ) ); } } }
@Override public void start(Map<String, String> props) { AbstractConfig parsedConfig = new AbstractConfig(CONFIG_DEF, props); filename = parsedConfig.getString(FILE_CONFIG); List<String> topics = parsedConfig.getList(TOPIC_CONFIG); if (topics.size() != 1) { throw new ConfigException("'topic' in FileStreamSourceConnector configuration requires definition of a single topic"); } topic = topics.get(0); batchSize = parsedConfig.getInt(TASK_BATCH_SIZE_CONFIG); }