org.apache.storm.starter.tools.Rankings Java Examples

The following examples show how to use org.apache.storm.starter.tools.Rankings. 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: AbstractRankerBolt.java    From storm_spring_boot_demo with MIT License 5 votes vote down vote up
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) {
  if (topN < 1) {
    throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")");
  }
  if (emitFrequencyInSeconds < 1) {
    throw new IllegalArgumentException(
        "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)");
  }
  count = topN;
  this.emitFrequencyInSeconds = emitFrequencyInSeconds;
  rankings = new Rankings(count);
}
 
Example #2
Source File: WordCountTopNToRedisBolt.java    From storm_spring_boot_demo with MIT License 5 votes vote down vote up
@Override
public void execute(Tuple input, BasicOutputCollector basicOutputCollector) {
    Rankings rankings = (Rankings) input.getValueByField("rankings");
    /**
     * TODO:此处2个步骤的操作应该合并成一个lua操作,不过考虑到更新频率低,并且设置了globalGrouping,已经不存在并发状况了
     */
    hashOperations.getOperations().delete(WORD_COUNT_TOP_N_REAL_TIME_KEY);
    rankings.getRankings().forEach(rankable -> {
        String word = (String) rankable.getObject();
        long count = rankable.getCount();
        hashOperations.put(WORD_COUNT_TOP_N_REAL_TIME_KEY, word, count);
    });

}
 
Example #3
Source File: AbstractRankerBolt.java    From storm-net-adapter with Apache License 2.0 5 votes vote down vote up
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) {
    if (topN < 1) {
        throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")");
    }
    if (emitFrequencyInSeconds < 1) {
        throw new IllegalArgumentException(
            "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)");
    }
    count = topN;
    this.emitFrequencyInSeconds = emitFrequencyInSeconds;
    rankings = new Rankings(count);
}
 
Example #4
Source File: AbstractRankerBolt.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public AbstractRankerBolt(int topN, int emitFrequencyInSeconds) {
    if (topN < 1) {
        throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")");
    }
    if (emitFrequencyInSeconds < 1) {
        throw new IllegalArgumentException(
                "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)");
    }
    count = topN;
    this.emitFrequencyInSeconds = emitFrequencyInSeconds;
    rankings = new Rankings(count);
}
 
Example #5
Source File: WindowTestTotalRankingsBolt.java    From jstorm with Apache License 2.0 5 votes vote down vote up
@Override
void updateRankingsWithTuple(Tuple tuple) {
    Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0);
    super.getRankings().updateWith(rankingsToBeMerged);
    super.getRankings().pruneZeroCounts();

    LOG.info("TotalRankingsBolt updateRankingsWithTuple " + getRankings());
}
 
Example #6
Source File: WindowTestAbstractRankingBolt.java    From jstorm with Apache License 2.0 5 votes vote down vote up
public WindowTestAbstractRankingBolt(int topN, int emitFrequencyInSeconds) {
    if (topN < 1) {
        throw new IllegalArgumentException("topN must be >= 1 (you requested " + topN + ")");
    }
    if (emitFrequencyInSeconds < 1) {
        throw new IllegalArgumentException(
                "The emit frequency must be >= 1 seconds (you requested " + emitFrequencyInSeconds + " seconds)");
    }
    count = topN;
    this.emitFrequencyInSeconds = emitFrequencyInSeconds;
    rankings = new Rankings(count);
}
 
Example #7
Source File: TotalRankingsBolt.java    From storm_spring_boot_demo with MIT License 4 votes vote down vote up
@Override
void updateRankingsWithTuple(Tuple tuple) {
  Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0);
  super.getRankings().updateWith(rankingsToBeMerged);
  super.getRankings().pruneZeroCounts();
}
 
Example #8
Source File: AbstractRankerBolt.java    From storm_spring_boot_demo with MIT License 4 votes vote down vote up
protected Rankings getRankings() {
  return rankings;
}
 
Example #9
Source File: TotalRankingsBolt.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
@Override
void updateRankingsWithTuple(Tuple tuple) {
    Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0);
    super.getRankings().updateWith(rankingsToBeMerged);
    super.getRankings().pruneZeroCounts();
}
 
Example #10
Source File: AbstractRankerBolt.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
protected Rankings getRankings() {
    return rankings;
}
 
Example #11
Source File: TotalRankingsBoltTest.java    From storm-net-adapter with Apache License 2.0 4 votes vote down vote up
private Tuple mockRankingsTuple(Object obj, long count) {
    Tuple tuple = MockTupleHelpers.mockTuple(ANY_NON_SYSTEM_COMPONENT_ID, ANY_NON_SYSTEM_STREAM_ID);
    Rankings rankings = mock(Rankings.class);
    when(tuple.getValue(0)).thenReturn(rankings);
    return tuple;
}
 
Example #12
Source File: TotalRankingsBolt.java    From jstorm with Apache License 2.0 4 votes vote down vote up
@Override
void updateRankingsWithTuple(Tuple tuple) {
    Rankings rankingsToBeMerged = (Rankings) tuple.getValue(0);
    super.getRankings().updateWith(rankingsToBeMerged);
    super.getRankings().pruneZeroCounts();
}
 
Example #13
Source File: AbstractRankerBolt.java    From jstorm with Apache License 2.0 4 votes vote down vote up
protected Rankings getRankings() {
    return rankings;
}
 
Example #14
Source File: WindowTestAbstractRankingBolt.java    From jstorm with Apache License 2.0 4 votes vote down vote up
protected Rankings getRankings() {
    return rankings;
}