Java Code Examples for org.apache.storm.utils.Utils#DEFAULT_STREAM_ID

The following examples show how to use org.apache.storm.utils.Utils#DEFAULT_STREAM_ID . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventCorrelatingOutputCollectorTest.java    From streamline with Apache License 2.0 6 votes vote down vote up
@Test
public void testAck() throws Exception {
    setupExpectationsForTuple();
    setupExpectationsForTopologyContextNoEmit();

    EventCorrelatingOutputCollector sut = getSystemUnderTest();

    Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(PARENT_STREAMLINE_EVENT), TASK_0,
            Utils.DEFAULT_STREAM_ID);

    sut.ack(anchor);

    new Verifications() {{
        mockedOutputCollector.ack(anchor); times = 1;
    }};
}
 
Example 2
Source File: EventCorrelatingOutputCollectorTest.java    From streamline with Apache License 2.0 6 votes vote down vote up
@Test
public void testFail() throws Exception {
    setupExpectationsForTuple();
    setupExpectationsForTopologyContextNoEmit();

    EventCorrelatingOutputCollector sut = getSystemUnderTest();

    Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(PARENT_STREAMLINE_EVENT), TASK_0,
            Utils.DEFAULT_STREAM_ID);

    sut.fail(anchor);

    new Verifications() {{
        mockedOutputCollector.fail(anchor); times = 1;
    }};
}
 
Example 3
Source File: EventCorrelatingOutputCollectorTest.java    From streamline with Apache License 2.0 6 votes vote down vote up
@Test
public void testResetTimeout() throws Exception {
    setupExpectationsForTuple();
    setupExpectationsForTopologyContextNoEmit();

    EventCorrelatingOutputCollector sut = getSystemUnderTest();

    Tuple anchor = new TupleImpl(mockedTopologyContext, new Values(PARENT_STREAMLINE_EVENT), TASK_0,
            Utils.DEFAULT_STREAM_ID);

    sut.resetTimeout(anchor);

    new Verifications() {{
        mockedOutputCollector.resetTimeout(anchor); times = 1;
    }};
}
 
Example 4
Source File: DynamicSpout.java    From storm-dynamic-spout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the stream that tuples will be emitted out.
 * @return stream that tuples will be emitted out
 */
String getOutputStreamId() {
    if (outputStreamId == null) {
        if (spoutConfig == null) {
            throw new IllegalStateException("Missing required configuration! SpoutConfig not defined!");
        }
        outputStreamId = (String) getSpoutConfigItem(SpoutConfig.OUTPUT_STREAM_ID);
        if (Strings.isNullOrEmpty(outputStreamId)) {
            outputStreamId = Utils.DEFAULT_STREAM_ID;
        }
    }
    return outputStreamId;
}
 
Example 5
Source File: SidelineSpoutTest.java    From storm-dynamic-spout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Provides various StreamIds to test emitting out of.
 */
public static Object[][] provideStreamIds() {
    return new Object[][]{
        // No explicitly defined streamId should use the default streamId.
        { null, Utils.DEFAULT_STREAM_ID },

        // Explicitly defined streamId should get used as is.
        { "SpecialStreamId", "SpecialStreamId" }
    };
}
 
Example 6
Source File: DynamicSpoutTest.java    From storm-dynamic-spout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Provides various StreamIds to test emitting out of.
 */
public static Object[][] provideStreamIds() {
    return new Object[][]{
            // No explicitly defined streamId should use the default streamId.
            { null, Utils.DEFAULT_STREAM_ID },

            // Explicitly defined streamId should get used as is.
            { "SpecialStreamId", "SpecialStreamId" }
    };
}
 
Example 7
Source File: KafkaConsumerSpoutTest.java    From storm-dynamic-spout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Provides various StreamIds to test emitting out of.
 */
public static Object[][] provideStreamIds() {
    return new Object[][]{
        // No explicitly defined streamId should use the default streamId.
        { null, Utils.DEFAULT_STREAM_ID },

        // Explicitly defined streamId should get used as is.
        { "SpecialStreamId", "SpecialStreamId" }
    };
}
 
Example 8
Source File: FixedTuple.java    From incubator-heron with Apache License 2.0 4 votes vote down vote up
public FixedTuple(List<Object> values) {
  this.stream = Utils.DEFAULT_STREAM_ID;
  this.values = values;
}
 
Example 9
Source File: StreamBuilder.java    From incubator-heron with Apache License 2.0 4 votes vote down vote up
protected void buildStreams(EcoExecutionContext executionContext, TopologyBuilder builder,
                            ObjectBuilder objectBuilder)
    throws IllegalAccessException, InstantiationException, ClassNotFoundException,
    NoSuchFieldException, InvocationTargetException {
  EcoTopologyDefinition topologyDefinition = executionContext.getTopologyDefinition();
  Map<String, ComponentStream> componentStreams = new HashMap<>();

  HashMap<String, BoltDeclarer> declarers = new HashMap<>();
  for (StreamDefinition stream : topologyDefinition.getStreams()) {
    Object boltObj = executionContext.getBolt(stream.getTo());
    BoltDeclarer declarer = declarers.get(stream.getTo());
    if (boltObj instanceof IRichBolt) {
      if (declarer == null) {
        declarer = builder.setBolt(stream.getTo(),
            (IRichBolt) boltObj,
            topologyDefinition.parallelismForBolt(stream.getTo()));
        declarers.put(stream.getTo(), declarer);
      }
    } else if (boltObj instanceof IBasicBolt) {
      if (declarer == null) {
        declarer = builder.setBolt(
            stream.getTo(),
            (IBasicBolt) boltObj,
            topologyDefinition.parallelismForBolt(stream.getTo()));
        declarers.put(stream.getTo(), declarer);
      }
    } else if (boltObj instanceof IWindowedBolt) {
      if (declarer == null) {
        declarer = builder.setBolt(
            stream.getTo(),
            (IWindowedBolt) boltObj,
            topologyDefinition.parallelismForBolt(stream.getTo()));
        declarers.put(stream.getTo(), declarer);
      }
    }  else {
      throw new IllegalArgumentException("Class does not appear to be a bolt: "
          + boltObj.getClass().getName());
    }

    GroupingDefinition grouping = stream.getGrouping();
    // if the streamId is defined, use it for the grouping,
    // otherwise assume default stream
    String streamId = grouping.getStreamId() == null
        ? Utils.DEFAULT_STREAM_ID : grouping.getStreamId();


    switch (grouping.getType()) {
      case SHUFFLE:
        declarer.shuffleGrouping(stream.getFrom(), streamId);
        break;
      case FIELDS:
        List<String> groupingArgs = grouping.getArgs();
        if (groupingArgs == null) {
          throw new IllegalArgumentException("You must supply arguments for Fields grouping");
        }
        declarer.fieldsGrouping(stream.getFrom(), streamId, new Fields(groupingArgs));
        break;
      case ALL:
        declarer.allGrouping(stream.getFrom(), streamId);
        break;
      case GLOBAL:
        declarer.globalGrouping(stream.getFrom(), streamId);
        break;
      case NONE:
        declarer.noneGrouping(stream.getFrom(), streamId);
        break;
      case CUSTOM:
        declarer.customGrouping(stream.getFrom(), streamId,
            buildCustomStreamGrouping(stream.getGrouping().getCustomClass(),
                executionContext,
                objectBuilder));
        break;
      default:
        throw new UnsupportedOperationException("unsupported grouping type: " + grouping);
    }
  }
  executionContext.setStreams(componentStreams);
}