未验证 提交 9471ac75 编写于 作者: B Boyang Jerry Peng 提交者: GitHub

Add hostname to consumer/producer properties in Pulsar Functions (#7897)

Co-authored-by: NJerry Peng <jerryp@splunk.com>
上级 8c91197d
......@@ -23,6 +23,7 @@ import static org.apache.commons.lang3.StringUtils.isEmpty;
import lombok.experimental.UtilityClass;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.functions.api.SerDe;
......@@ -33,9 +34,12 @@ import org.apache.pulsar.common.util.Reflections;
import net.jodah.typetools.TypeResolver;
import org.apache.pulsar.functions.utils.FunctionCommon;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@UtilityClass
public class InstanceUtils {
public static SerDe<?> initializeSerDe(String serdeClassName, ClassLoader clsLoader, Class<?> typeArg,
......@@ -134,6 +138,11 @@ public class InstanceUtils {
}
properties.put("id", fullyQualifiedName);
properties.put("instance_id", String.valueOf(instanceId));
try {
properties.put("instance_hostname", InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException e) {
log.warn("[{}:{}] Failed to get hostname of instance", fullyQualifiedName, instanceId, e);
}
return properties;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册