public TopologyAPI . Topology trimTopology ( TopologyAPI . Topology topology ) { // create a copy of the topology physical plan TopologyAPI . Topology . Builder builder = TopologyAPI . Topology . newBuilder ( ) . mergeFrom ( topology ) ; // clear the state of user spout java objects - which can be potentially huge for ( TopologyAPI . Spout . Builder spout : builder . getSpoutsBuilderList ( ) ) { spout . getCompBuilder ( ) . clearSerializedObject ( ) ; } // clear the state of user spout java objects - which can be potentially huge for ( TopologyAPI . Bolt . Builder bolt : builder . getBoltsBuilderList ( ) ) { bolt . getCompBuilder ( ) . clearSerializedObject ( ) ; } return builder . build ( ) ; }
Trim the topology definition for storing into state manager . This is because the user generated spouts and bolts might be huge .