public static void ensureRequiredNonNull(Context context, String... keys) { for (String key : keys) { if (!context.getParameters().containsKey(key) || context.getParameters().get(key) == null) { throw new IllegalArgumentException("Required parameter " + key + " must exist and may not be null"); } } }
public static void ensureOptionalNonNull(Context context, String... keys) { for (String key : keys) { if (context.getParameters().containsKey(key) && context.getParameters().get(key) == null) { throw new IllegalArgumentException("Optional parameter " + key + " may not be null"); } } }
private void runFiltersOnContextMaps(Map<String, Context>... maps) { for (Map<String, Context> map: maps) { for (Context context : map.values()) { for (String key : context.getParameters().keySet()) { filterValue(context, key); } } } }
@Override public void configure(Context context) { clientProps = new Properties(); hostname = context.getString("hostname"); port = context.getInteger("port"); Preconditions.checkState(hostname != null, "No hostname specified"); Preconditions.checkState(port != null, "No port specified"); clientProps.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1"); clientProps.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", hostname + ":" + port); for (Entry<String, String> entry: context.getParameters().entrySet()) { clientProps.setProperty(entry.getKey(), entry.getValue()); } batchSize = AbstractRpcClient.parseBatchSize(clientProps); if (sinkCounter == null) { sinkCounter = new SinkCounter(getName()); } cxnResetInterval = context.getInteger("reset-connection-interval", DEFAULT_CXN_RESET_INTERVAL); if (cxnResetInterval == DEFAULT_CXN_RESET_INTERVAL) { logger.info("Connection reset is set to " + String.valueOf(DEFAULT_CXN_RESET_INTERVAL) + ". Will not reset connection to next hop"); } }
Preconditions.checkNotNull(sinks); Preconditions.checkArgument(!sinks.isEmpty()); Map<String, String> params = context.getParameters(); SinkProcessor processor; String typeStr = params.get(TYPE);
private void createConfigFilters() { for (String name: configFilterSet) { Context context = configFilterContextMap.get(name); ComponentConfiguration componentConfiguration = configFilterConfigMap.get(name); try { if (context != null) { ConfigFilter configFilter = ConfigFilterFactory.create( name, context.getString(BasicConfigurationConstants.CONFIG_TYPE) ); configFilter.initializeWithConfiguration(context.getParameters()); configFiltersInstances.add(configFilter); configFilterPatternCache.put(configFilter.getName(), createConfigFilterPattern(configFilter)); } else if (componentConfiguration != null) { ConfigFilter configFilter = ConfigFilterFactory.create( componentConfiguration.getComponentName(), componentConfiguration.getType() ); configFiltersInstances.add(configFilter); configFilterPatternCache.put(configFilter.getName(), createConfigFilterPattern(configFilter)); } } catch (Exception e) { LOGGER.error("Error while creating config filter {}", name, e); } } }
public static void ensureRequiredNonNull(Context context, String... keys) { for (String key : keys) { if (!context.getParameters().containsKey(key) || context.getParameters().get(key) == null) { throw new IllegalArgumentException("Required parameter " + key + " must exist and may not be null"); } } }
public static void ensureOptionalNonNull(Context context, String... keys) { for (String key : keys) { if (context.getParameters().containsKey(key) && context.getParameters().get(key) == null) { throw new IllegalArgumentException("Optional parameter " + key + " may not be null"); } } }
private void runFiltersOnContextMaps(Map<String, Context>... maps) { for (Map<String, Context> map: maps) { for (Context context : map.values()) { for (String key : context.getParameters().keySet()) { filterValue(context, key); } } } }
@Override public void configure(Context context) { clientProps = new Properties(); hostname = context.getString("hostname"); port = context.getInteger("port"); Preconditions.checkState(hostname != null, "No hostname specified"); Preconditions.checkState(port != null, "No port specified"); clientProps.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "h1"); clientProps.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "h1", hostname + ":" + port); for (Entry<String, String> entry: context.getParameters().entrySet()) { clientProps.setProperty(entry.getKey(), entry.getValue()); } batchSize = AbstractRpcClient.parseBatchSize(clientProps); if (sinkCounter == null) { sinkCounter = new SinkCounter(getName()); } cxnResetInterval = context.getInteger("reset-connection-interval", DEFAULT_CXN_RESET_INTERVAL); if (cxnResetInterval == DEFAULT_CXN_RESET_INTERVAL) { logger.info("Connection reset is set to " + String.valueOf(DEFAULT_CXN_RESET_INTERVAL) + ". Will not reset connection to next hop"); } }
Map<String, String> params = context.getParameters(); producerProps = new Properties(); for (String key : params.keySet()) {
Preconditions.checkNotNull(sinks); Preconditions.checkArgument(!sinks.isEmpty()); Map<String, String> params = context.getParameters(); SinkProcessor processor; String typeStr = params.get(TYPE);
private void createConfigFilters() { for (String name: configFilterSet) { Context context = configFilterContextMap.get(name); ComponentConfiguration componentConfiguration = configFilterConfigMap.get(name); try { if (context != null) { ConfigFilter configFilter = ConfigFilterFactory.create( name, context.getString(BasicConfigurationConstants.CONFIG_TYPE) ); configFilter.initializeWithConfiguration(context.getParameters()); configFiltersInstances.add(configFilter); configFilterPatternCache.put(configFilter.getName(), createConfigFilterPattern(configFilter)); } else if (componentConfiguration != null) { ConfigFilter configFilter = ConfigFilterFactory.create( componentConfiguration.getComponentName(), componentConfiguration.getType() ); configFiltersInstances.add(configFilter); configFilterPatternCache.put(configFilter.getName(), createConfigFilterPattern(configFilter)); } } catch (Exception e) { LOGGER.error("Error while creating config filter {}", name, e); } } }