org.apache.storm.tuple.ITuple Java Examples

The following examples show how to use org.apache.storm.tuple.ITuple. 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: StreamlineJdbcMapper.java    From streamline with Apache License 2.0 6 votes vote down vote up
@Override
public List<Column> getColumns(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    List<Column> res = new ArrayList<>();
    if (fieldsToColumns.isEmpty()) {
        initFieldsToColumns();
    }
    for(String field: fields) {
        Column<?> column = getColumn(field);
        String columnName = column.getColumnName();
        Integer columnSqlType = column.getSqlType();
        Object value = Util.getJavaType(columnSqlType).cast(event.get(field));
        res.add(new Column<>(columnName, value, columnSqlType));
    }
    return res;
}
 
Example #2
Source File: StreamlineSolrJsonMapper.java    From streamline with Apache License 2.0 5 votes vote down vote up
private String getJsonFromTuple(ITuple tuple) throws SolrMapperException {
    final StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    try {
        return objectMapper.writeValueAsString(event);
    } catch (JsonProcessingException e) {
        throw new SolrMapperException(e.getMessage());
    }
}
 
Example #3
Source File: StreamlineSolrJsonMapper.java    From streamline with Apache License 2.0 5 votes vote down vote up
private String getJsonFromTuples(List<? extends ITuple> tuples) throws SolrMapperException {
    final StringBuilder jsonListBuilder = new StringBuilder("[");
    for (ITuple tuple : tuples) {
        final String json = getJsonFromTuple(tuple);
        jsonListBuilder.append(json).append(",");
    }
    jsonListBuilder.setCharAt(jsonListBuilder.length() - 1, ']');
    return jsonListBuilder.toString();
}
 
Example #4
Source File: OpenTsdbTupleDatapointMapper.java    From streamline with Apache License 2.0 5 votes vote down vote up
@Override
public OpenTsdbMetricDatapoint getMetricPoint(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    return new OpenTsdbMetricDatapoint(
            (String) event.get(metricField),
            (Map<String, String>) event.get(tagsField),
            (Long) event.get(timestampField),
            (Number) event.get(valueField));
}
 
Example #5
Source File: LocalWordCountRedisStormTopology.java    From 163-bigdate-note with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getKeyFromTuple(ITuple tuple) {
    return tuple.getStringByField("word");
}
 
Example #6
Source File: LocalWordCountRedisStormTopology.java    From 163-bigdate-note with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String getValueFromTuple(ITuple tuple) {
    return tuple.getIntegerByField("count") + "";
}
 
Example #7
Source File: StreamlineFieldSelector.java    From streamline with Apache License 2.0 4 votes vote down vote up
protected Object getFieldValue(ITuple tuple) {
    StreamlineEvent streamlineEvent = (StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT);
    return streamlineEvent.get(field);
}
 
Example #8
Source File: StreamlineSolrJsonMapper.java    From streamline with Apache License 2.0 4 votes vote down vote up
@Override
public SolrRequest toSolrRequest(List<? extends ITuple> tupleList) throws SolrMapperException {
    return createSolrRequest(getJsonFromTuples(tupleList));
}
 
Example #9
Source File: StreamlineSolrJsonMapper.java    From streamline with Apache License 2.0 4 votes vote down vote up
@Override
public SolrRequest toSolrRequest(ITuple tuple) throws SolrMapperException {
    final String json = getJsonFromTuple(tuple);
    return createSolrRequest(json);
}
 
Example #10
Source File: DruidEventMapper.java    From streamline with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Object> getEvent(ITuple tuple) {
    StreamlineEvent event = (StreamlineEvent) tuple.getValueByField(eventFiledName);
    return new DruidEvent(event.addFieldAndValue(DruidBeamFactoryImpl.PROCESSING_TIME, System.currentTimeMillis()));
}
 
Example #11
Source File: WordCountToBolt.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
@Override
public String getKeyFromTuple(ITuple tuple) {
    return tuple.getStringByField("key");
}
 
Example #12
Source File: WordCountToBolt.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
@Override
public String getValueFromTuple(ITuple tuple) {
    return String.valueOf(tuple.getLongByField("value"));
}