Search in sources :

Example 1 with SpoutDef

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);
    }
}
Also used : IRichSpout(org.apache.storm.topology.IRichSpout) SpoutDeclarer(org.apache.storm.topology.SpoutDeclarer) SpoutDef(org.apache.storm.flux.model.SpoutDef)

Example 2 with SpoutDef

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;
}
Also used : PropertyDef(org.apache.storm.flux.model.PropertyDef) SpoutDeclarer(org.apache.storm.topology.SpoutDeclarer) SpoutDef(org.apache.storm.flux.model.SpoutDef)

Example 3 with SpoutDef

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("--------------------------------------");
    }
}
Also used : TopologyDef(org.apache.storm.flux.model.TopologyDef) StreamDef(org.apache.storm.flux.model.StreamDef) BoltDef(org.apache.storm.flux.model.BoltDef) SpoutDef(org.apache.storm.flux.model.SpoutDef)

Aggregations

SpoutDef (org.apache.storm.flux.model.SpoutDef)3 SpoutDeclarer (org.apache.storm.topology.SpoutDeclarer)2 BoltDef (org.apache.storm.flux.model.BoltDef)1 PropertyDef (org.apache.storm.flux.model.PropertyDef)1 StreamDef (org.apache.storm.flux.model.StreamDef)1 TopologyDef (org.apache.storm.flux.model.TopologyDef)1 IRichSpout (org.apache.storm.topology.IRichSpout)1