/** * Trim the topology definition for storing into state manager. This is because the user generated * spouts and bolts might be huge. * * @return trimmed topology */ 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().clearJavaObject(); } // clear the state of user spout java objects - which can be potentially huge for (TopologyAPI.Bolt.Builder bolt : builder.getBoltsBuilderList()) { bolt.getCompBuilder().clearJavaObject(); } return builder.build(); }
public void dump(TopologyAPI.Topology.Builder bldr) { TopologyAPI.Spout.Builder spoutBldr = TopologyAPI.Spout.newBuilder(); TopologyAPI.Component.Builder compBldr = TopologyAPI.Component.newBuilder(); super.dump(compBldr); spoutBldr.setComp(compBldr); Map<String, TopologyAPI.StreamSchema.Builder> outs = output.getFieldsDeclaration(); for (Map.Entry<String, TopologyAPI.StreamSchema.Builder> entry : outs.entrySet()) { TopologyAPI.OutputStream.Builder obldr = TopologyAPI.OutputStream.newBuilder(); TopologyAPI.StreamId.Builder sbldr = TopologyAPI.StreamId.newBuilder(); sbldr.setId(entry.getKey()); sbldr.setComponentName(getName()); obldr.setStream(sbldr); obldr.setSchema(entry.getValue()); spoutBldr.addOutputs(obldr); } bldr.addSpouts(spoutBldr); }