Open Kilda Java Documentation
OutputCollectorMock.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.wfm.topology;
17 
18 import org.apache.storm.task.IOutputCollector;
19 import org.apache.storm.tuple.Tuple;
20 
21 import java.util.Arrays;
22 import java.util.Collection;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.concurrent.ConcurrentHashMap;
26 import java.util.concurrent.atomic.AtomicInteger;
27 
31 public class OutputCollectorMock implements IOutputCollector {
32  private Map<String, AtomicInteger> messages = new ConcurrentHashMap<>();
33 
34  @Override
35  public List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple) {
36  AtomicInteger count = messages.computeIfAbsent(streamId, k -> new AtomicInteger(0));
37  count.incrementAndGet();
38  return null;
39  }
40 
41  @Override
42  public void emitDirect(int taskId, String streamId, Collection<Tuple> anchors, List<Object> tuple) {
43 
44  }
45 
46  @Override
47  public void ack(Tuple input) {
48 
49  }
50 
51  @Override
52  public void fail(Tuple input) {
53 
54  }
55 
56  @Override
57  public void resetTimeout(Tuple input) {
58 
59  }
60 
61  @Override
62  public void reportError(Throwable error) {
63 
64  }
65 
66  public int getMessagesCount(String streamId) {
67  return messages.get(streamId).get();
68  }
69 
70  public List<Integer> emit(String streamId, Tuple anchor, List<Object> tuple) {
71  return emit(streamId, Arrays.asList(anchor), tuple);
72  }
73 }
void emitDirect(int taskId, String streamId, Collection< Tuple > anchors, List< Object > tuple)
List< Integer > emit(String streamId, Collection< Tuple > anchors, List< Object > tuple)
int count
Definition: generator.py:19
List< Integer > emit(String streamId, Tuple anchor, List< Object > tuple)