public KafkaManager(final LoggerContext loggerContext, final String name, final String topic, final boolean syncSend, final Property[] properties) { super(loggerContext, name); this.topic = Objects.requireNonNull(topic, "topic"); this.syncSend = syncSend; config.setProperty("key.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("value.serializer", "org.apache.kafka.common.serialization.ByteArraySerializer"); config.setProperty("batch.size", "0"); for (final Property property : properties) { config.setProperty(property.getName(), property.getValue()); } this.timeoutMillis = Integer.parseInt(config.getProperty("timeout.ms", DEFAULT_TIMEOUT_MILLIS)); }
@Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append(" {"); boolean first = true; for (final Map.Entry<Property, Boolean> entry : properties.entrySet()) { if (!first) { sb.append(", "); } final Property prop = entry.getKey(); sb.append(prop.getName()).append('=').append(prop.getValue()); first = false; } sb.append('}'); return sb.toString(); }
/** * Copies key-value pairs from the specified property list into the specified {@code StringMap}. * * @param properties list of configuration properties, may be {@code null} * @param result the {@code StringMap} object to add the key-values to. Must be non-{@code null}. */ public static void copyProperties(final List<Property> properties, final StringMap result) { if (properties != null) { for (int i = 0; i < properties.size(); i++) { final Property prop = properties.get(i); result.putValue(prop.getName(), prop.getValue()); } } } }
private static void putProperties(Collection<Property> properties, StringMap stringMap) { for (Property property : properties) { stringMap.putValue(property.getName(), property.getValue()); } }
header.getName(), header.isValueNeedsLookup() ? getConfiguration().getStrSubstitutor().replace(event, header.getValue()) : header.getValue());
/** * Rewrite the event. * @param source a logging event that may be returned or * used to create a new logging event. * @return The LogEvent after rewriting. */ @Override public LogEvent rewrite(final LogEvent source) { final Map<String, String> props = new HashMap<>(source.getContextData().toMap()); for (final Map.Entry<Property, Boolean> entry : properties.entrySet()) { final Property prop = entry.getKey(); props.put(prop.getName(), entry.getValue().booleanValue() ? config.getStrSubstitutor().replace(prop.getValue()) : prop.getValue()); } final LogEvent result = new Log4jLogEvent.Builder(source).setContextMap(props).build(); return result; }
/** * Creates the Properties component. * @param properties An array of Property elements. * @param config The Configuration. * @return An Interpolator that includes the configuration properties. */ @PluginFactory public static StrLookup configureSubstitutor(@PluginElement("Properties") final Property[] properties, @PluginConfiguration final Configuration config) { if (properties == null) { return new Interpolator(config.getProperties()); } final Map<String, String> map = new HashMap<>(config.getProperties()); for (final Property prop : properties) { map.put(prop.getName(), prop.getValue()); } return new Interpolator(new MapLookup(map), config.getPluginPackages()); } }
props.add(Property.createProperty(prop.getName(), value));
endpoints = new ArrayList<>(properties.length); for (final Property property : properties) { if ("endpoint".equalsIgnoreCase(property.getName())) { final String value = property.getValue(); if (Strings.isNotEmpty(value)) {