Examples of BoltDeclarer


Examples of backtype.storm.topology.BoltDeclarer

    boolean isEnableSplit = JStormUtils.parseBoolean(
        conf.get("enable.split"), false);

    if (isEnableSplit == false) {
      BoltDeclarer boltDeclarer = builder.setBolt(
          SequenceTopologyDef.TOTAL_BOLT_NAME, new TotalCount(),
          bolt_Parallelism_hint);

      // localFirstGrouping is only for jstorm
      // boltDeclarer.localFirstGrouping(SequenceTopologyDef.SEQUENCE_SPOUT_NAME);
      boltDeclarer
          .localOrShuffleGrouping(SequenceTopologyDef.SEQUENCE_SPOUT_NAME);
    } else {

      builder.setBolt(SequenceTopologyDef.SPLIT_BOLT_NAME,
          new SplitRecord(), bolt_Parallelism_hint)
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

        new BatchSpoutTrigger(), 1);
  }

  public BoltDeclarer setSpout(String id, IBatchSpout spout, int paralel) {

    BoltDeclarer boltDeclarer = this
        .setBolt(id, (IBatchSpout) spout, paralel);
    boltDeclarer.allGrouping(BatchDef.SPOUT_TRIGGER,
        BatchDef.COMPUTING_STREAM_ID);

    return boltDeclarer;
  }
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

  }

  public BoltDeclarer setBolt(String id, IBasicBolt bolt, int paralel) {
    CoordinatedBolt coordinatedBolt = new CoordinatedBolt(bolt);

    BoltDeclarer boltDeclarer = topologyBuilder.setBolt(id,
        coordinatedBolt, paralel);

    if (bolt instanceof IPrepareCommit) {
      boltDeclarer.allGrouping(BatchDef.SPOUT_TRIGGER,
          BatchDef.PREPARE_STREAM_ID);
    }

    if (bolt instanceof ICommitter) {
      boltDeclarer.allGrouping(BatchDef.SPOUT_TRIGGER,
          BatchDef.COMMIT_STREAM_ID);
      boltDeclarer.allGrouping(BatchDef.SPOUT_TRIGGER,
          BatchDef.REVERT_STREAM_ID);
    }

    if (bolt instanceof IPostCommit) {
      boltDeclarer.allGrouping(BatchDef.SPOUT_TRIGGER,
          BatchDef.POST_STREAM_ID);
    }

    return boltDeclarer;
  }
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

    _bolts.put(id, component);
    return new BoltDeclarerImpl(component);
  }

  public void extendTopology(TopologyBuilder builder) {
    BoltDeclarer declarer = builder.setBolt(_masterId, new CoordinatedBolt(
        _masterBolt.bolt), _masterBolt.parallelism);
    for (InputDeclaration decl : _masterBolt.declarations) {
      decl.declare(declarer);
    }
    for (Map conf : _masterBolt.componentConfs) {
      declarer.addConfigurations(conf);
    }
    for (String id : _bolts.keySet()) {
      Component component = _bolts.get(id);
      Map<String, SourceArgs> coordinatedArgs = new HashMap<String, SourceArgs>();
      for (String c : componentBoltSubscriptions(component)) {
        SourceArgs source;
        if (c.equals(_masterId)) {
          source = SourceArgs.single();
        } else {
          source = SourceArgs.all();
        }
        coordinatedArgs.put(c, source);
      }

      BoltDeclarer input = builder.setBolt(id, new CoordinatedBolt(
          component.bolt, coordinatedArgs, null),
          component.parallelism);
      for (Map conf : component.componentConfs) {
        input.addConfigurations(conf);
      }
      for (String c : componentBoltSubscriptions(component)) {
        input.directGrouping(c, Constants.COORDINATED_STREAM_ID);
      }
      for (InputDeclaration d : component.declarations) {
        d.declare(input);
      }
    }
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

      if (i == _components.size() - 1
          && component.bolt instanceof FinishedCallback) {
        idSpec = IdStreamSpec.makeDetectSpec(PREPARE_ID,
            PrepareRequest.ID_STREAM);
      }
      BoltDeclarer declarer = builder.setBolt(boltId(i),
          new CoordinatedBolt(component.bolt, source, idSpec),
          component.parallelism);

      for (Map conf : component.componentConfs) {
        declarer.addConfigurations(conf);
      }

      if (idSpec != null) {
        declarer.fieldsGrouping(idSpec.getGlobalStreamId()
            .get_componentId(), PrepareRequest.ID_STREAM,
            new Fields("request"));
      }
      if (i == 0 && component.declarations.isEmpty()) {
        declarer.noneGrouping(PREPARE_ID, PrepareRequest.ARGS_STREAM);
      } else {
        String prevId;
        if (i == 0) {
          prevId = PREPARE_ID;
        } else {
          prevId = boltId(i - 1);
        }
        for (InputDeclaration declaration : component.declarations) {
          declaration.declare(prevId, declarer);
        }
      }
      if (i > 0) {
        declarer.directGrouping(boltId(i - 1),
            Constants.COORDINATED_STREAM_ID);
      }
    }

    IRichBolt lastBolt = _components.get(_components.size() - 1).bolt;
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

       
        for(Group g: mergedGroups) {
            if(!isSpoutGroup(g)) {
                Integer p = parallelisms.get(g);
                Map<String, String> streamToGroup = getOutputStreamBatchGroups(g, batchGroupMap);
                BoltDeclarer d = builder.setBolt(boltIds.get(g), new SubtopologyBolt(graph, g.nodes, batchGroupMap), p,
                        committerBatches(g, batchGroupMap), streamToGroup);
                Collection<PartitionNode> inputs = uniquedSubscriptions(externalGroupInputs(g));
                for(PartitionNode n: inputs) {
                    Node parent = TridentUtils.getParent(graph, n);
                    String componentId;
                    if(parent instanceof SpoutNode) {
                        componentId = spoutIds.get(parent);
                    } else {
                        componentId = boltIds.get(grouper.nodeGroup(parent));
                    }
                    d.grouping(new GlobalStreamId(componentId, n.streamId), n.thriftGrouping);
                }
            }
        }
       
        return builder.buildTopology();
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

                    batchesToSpouts.put(batchGroup, new ArrayList<ITridentSpout>());
                }
                batchesToSpouts.get(batchGroup).add((ITridentSpout) c.spout);
               
               
                BoltDeclarer scd =
                      builder.setBolt(spoutCoordinator(id), new TridentSpoutCoordinator(c.commitStateId, (ITridentSpout) c.spout))
                        .globalGrouping(masterCoordinator(c.batchGroupId), MasterBatchCoordinator.BATCH_STREAM_ID)
                        .globalGrouping(masterCoordinator(c.batchGroupId), MasterBatchCoordinator.SUCCESS_STREAM_ID);
               
                for(Map m: c.componentConfs) {
                    scd.addConfigurations(m);
                }
               
                Map<String, TridentBoltExecutor.CoordSpec> specs = new HashMap();
                specs.put(c.batchGroupId, new CoordSpec());
                BoltDeclarer bd = builder.setBolt(id,
                        new TridentBoltExecutor(
                          new TridentSpoutExecutor(
                            c.commitStateId,
                            c.streamName,
                            ((ITridentSpout) c.spout)),
                            batchIdsForSpouts,
                            specs),
                        c.parallelism);
                bd.allGrouping(spoutCoordinator(id), MasterBatchCoordinator.BATCH_STREAM_ID);
                bd.allGrouping(masterCoordinator(batchGroup), MasterBatchCoordinator.SUCCESS_STREAM_ID);
                if(c.spout instanceof ICommitterTridentSpout) {
                    bd.allGrouping(masterCoordinator(batchGroup), MasterBatchCoordinator.COMMIT_STREAM_ID);
                    if (commitBatchGroup.contains(batchGroup) == false) commitBatchGroup.add(batchGroup);
                }
                for(Map m: c.componentConfs) {
                    bd.addConfigurations(m);
                }
            }
        }
       
        for(String id: _batchPerTupleSpouts.keySet()) {
            SpoutComponent c = _batchPerTupleSpouts.get(id);
            SpoutDeclarer d = builder.setSpout(id, new RichSpoutBatchTriggerer((IRichSpout) c.spout, c.streamName, c.batchGroupId), c.parallelism);
           
            for(Map conf: c.componentConfs) {
                d.addConfigurations(conf);
            }
        }
               
        for(String id: _bolts.keySet()) {
            Component c = _bolts.get(id);
           
            Map<String, CoordSpec> specs = new HashMap();
           
            for(GlobalStreamId s: getBoltSubscriptionStreams(id)) {
                String batch = batchIdsForBolts.get(s);
                if(!specs.containsKey(batch)) specs.put(batch, new CoordSpec());
                CoordSpec spec = specs.get(batch);
                CoordType ct;
                if(_batchPerTupleSpouts.containsKey(s.get_componentId())) {
                    ct = CoordType.single();
                } else {
                    ct = CoordType.all();
                }
                spec.coords.put(s.get_componentId(), ct);
            }
           
            for(String b: c.committerBatches) {
                specs.get(b).commitStream = new GlobalStreamId(masterCoordinator(b), MasterBatchCoordinator.COMMIT_STREAM_ID);
            }
           
            BoltDeclarer d = builder.setBolt(id, new TridentBoltExecutor(c.bolt, batchIdsForBolts, specs), c.parallelism);
            for(Map conf: c.componentConfs) {
                d.addConfigurations(conf);
            }
           
            for(InputDeclaration inputDecl: c.declarations) {
               inputDecl.declare(d);
            }
           
            Map<String, Set<String>> batchToComponents = getBoltBatchToComponentSubscriptions(id);
            for(String b: batchToComponents.keySet()) {
                for(String comp: batchToComponents.get(b)) {
                    d.directGrouping(comp, TridentBoltExecutor.COORD_STREAM(b));
                }
            }
           
            for(String b: c.committerBatches) {
                d.allGrouping(masterCoordinator(b), MasterBatchCoordinator.COMMIT_STREAM_ID);
                if (commitBatchGroup.contains(b) == false) commitBatchGroup.add(b);
            }
        }
       
        for(String batch: batchesToCommitIds.keySet()) {
View Full Code Here

Examples of backtype.storm.topology.BoltDeclarer

    BatchTopologyBuilder batchTopologyBuilder = new BatchTopologyBuilder(
        topologyName);

    MetaSpoutConfig metaSpoutConfig = getMetaSpoutConfig(conf);

    BoltDeclarer rebalanceDeclarer = batchTopologyBuilder.setBolt(
        BatchMetaRebalance.BOLT_NAME, new BatchMetaRebalance(), 1);

    IBatchSpout batchSpout = new BatchMetaSpout(metaSpoutConfig);
    int spoutParal = JStormUtils.parseInt(
        conf.get("topology.spout.parallel"), 1);
    BoltDeclarer spoutDeclarer = batchTopologyBuilder.setSpout(
        BatchMetaSpout.SPOUT_NAME, batchSpout, spoutParal);
    spoutDeclarer.allGrouping(BatchMetaRebalance.BOLT_NAME,
        BatchMetaRebalance.REBALANCE_STREAM_ID);

    int boltParallel = JStormUtils.parseInt(
        conf.get("topology.bolt.parallel"), 1);
    BoltDeclarer transformDeclarer = batchTopologyBuilder.setBolt(
        TransformBolt.BOLT_NAME, new TransformBolt(), boltParallel);
    transformDeclarer.shuffleGrouping(BatchMetaSpout.SPOUT_NAME);

    BoltDeclarer countDeclarer = batchTopologyBuilder.setBolt(
        CountBolt.COUNT_BOLT_NAME, new CountBolt(), boltParallel);
    countDeclarer.shuffleGrouping(TransformBolt.BOLT_NAME);

    BoltDeclarer sumDeclarer = batchTopologyBuilder.setBolt(
        CountBolt.SUM_BOLT_NAME, new CountBolt(), boltParallel);
    sumDeclarer.shuffleGrouping(TransformBolt.BOLT_NAME);

    BoltDeclarer dbDeclarer = batchTopologyBuilder.setBolt(
        DBBolt.BOLT_NAME, new DBBolt(), 1);
    dbDeclarer.shuffleGrouping(CountBolt.COUNT_BOLT_NAME).shuffleGrouping(
        CountBolt.SUM_BOLT_NAME);

    return batchTopologyBuilder.getTopologyBuilder();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.