Created
October 20, 2019 03:48
-
-
Save kelapure/77954a9de988c2e511ec27675ee7e0a1 to your computer and use it in GitHub Desktop.
How to print the Topology of a KStream or a KTable when you have no access to the topology
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void print(Object stream) throws IllegalAccessException { | |
Field field = ReflectionUtils.findField(KStreamImpl.class, "builder"); | |
ReflectionUtils.makeAccessible(field); | |
InternalStreamsBuilder builder = (InternalStreamsBuilder) field.get(stream); | |
field = ReflectionUtils.findField(InternalStreamsBuilder.class, "internalTopologyBuilder"); | |
ReflectionUtils.makeAccessible(field); | |
InternalTopologyBuilder internalTopologyBuilder = (InternalTopologyBuilder)field.get(builder); | |
TopologyDescription topologyDescription = internalTopologyBuilder.describe(); | |
logger.info("<TOPOLOGY> for "+ stream); | |
logger.info(topologyDescription.toString()); | |
logger.info("</TOPOLOGY>"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment