use of org.apache.storm.flux.model.SpoutDef in project storm by apache.
the class FluxBuilder method buildSpouts.
private static void buildSpouts(ExecutionContext context, TopologyBuilder builder) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
for (SpoutDef sd : context.getTopologyDef().getSpouts()) {
IRichSpout spout = buildSpout(sd, context);
SpoutDeclarer declarer = builder.setSpout(sd.getId(), spout, sd.getParallelism());
if (sd.getOnHeapMemoryLoad() > -1) {
if (sd.getOffHeapMemoryLoad() > -1) {
declarer.setMemoryLoad(sd.getOnHeapMemoryLoad(), sd.getOffHeapMemoryLoad());
} else {
declarer.setMemoryLoad(sd.getOnHeapMemoryLoad());
}
}
if (sd.getCpuLoad() > -1) {
declarer.setCPULoad(sd.getCpuLoad());
}
if (sd.getNumTasks() > -1) {
declarer.setNumTasks(sd.getNumTasks());
}
context.addSpout(sd.getId(), spout);
}
}
use of org.apache.storm.flux.model.SpoutDef in project open-kilda by telstra.
the class AbstractTopology method declareSpout.
protected SpoutDeclarer declareSpout(TopologyBuilder builder, IRichSpout spout, String spoutId) {
Integer spoutParallelism = null;
Integer spoutNumTasks = null;
Integer spoutMaxSpoutPending = null;
if (topologyDef != null) {
SpoutDef spoutDef = topologyDef.getSpoutDef(spoutId);
if (spoutDef != null) {
spoutParallelism = spoutDef.getParallelism();
if (spoutDef.getNumTasks() > 0) {
spoutNumTasks = spoutDef.getNumTasks();
}
if (spoutDef.getProperties() != null) {
for (PropertyDef propertyDef : spoutDef.getProperties()) {
if (MAX_SPOUT_PENDING_SPOUT_DEF_KEY.equals(propertyDef.getName())) {
spoutMaxSpoutPending = (Integer) propertyDef.getValue();
break;
}
}
}
}
}
if (spoutParallelism == null) {
if (topologyDef != null && topologyDef.getConfig() != null) {
spoutParallelism = (Integer) topologyDef.getConfig().get(SPOUT_PARALLELISM_TOPOLOGY_DEF_KEY);
}
if (spoutParallelism == null) {
spoutParallelism = getTopologyParallelism().orElse(null);
}
}
SpoutDeclarer spoutDeclarer = builder.setSpout(spoutId, spout, spoutParallelism);
if (spoutNumTasks != null) {
spoutDeclarer.setNumTasks(spoutNumTasks);
}
if (spoutMaxSpoutPending != null) {
spoutDeclarer.setMaxSpoutPending(spoutMaxSpoutPending);
}
return spoutDeclarer;
}
use of org.apache.storm.flux.model.SpoutDef in project storm by apache.
the class Flux method printTopologyInfo.
static void printTopologyInfo(ExecutionContext ctx) {
TopologyDef t = ctx.getTopologyDef();
if (t.isDslTopology()) {
print("---------- TOPOLOGY DETAILS ----------");
printf("Topology Name: %s", t.getName());
print("--------------- SPOUTS ---------------");
for (SpoutDef s : t.getSpouts()) {
printf("%s [%d] (%s)", s.getId(), s.getParallelism(), s.getClassName());
}
print("---------------- BOLTS ---------------");
for (BoltDef b : t.getBolts()) {
printf("%s [%d] (%s)", b.getId(), b.getParallelism(), b.getClassName());
}
print("--------------- STREAMS ---------------");
for (StreamDef sd : t.getStreams()) {
printf("%s --%s--> %s", sd.getFrom(), sd.getGrouping().getType(), sd.getTo());
}
print("--------------------------------------");
}
}
Aggregations