Open Kilda Java Documentation
KafkaRecordTranslator.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.utils;
17 
18 
19 import org.apache.kafka.clients.consumer.ConsumerRecord;
20 import org.apache.storm.kafka.spout.RecordTranslator;
21 import org.apache.storm.tuple.Fields;
22 import org.apache.storm.tuple.Values;
23 
24 import java.util.List;
25 
26 public class KafkaRecordTranslator <K, V> implements RecordTranslator<K, V> {
27  private static final long serialVersionUID = 1L;
28  public static final Fields FIELDS = new Fields("message");
29  @Override
30  public List<Object> apply(ConsumerRecord<K, V> record) {
31  return new Values(record.value());
32  }
33 
34  @Override
35  public Fields getFieldsFor(String stream) {
36  return FIELDS;
37  }
38 
39  @Override
40  public List<String> streams() {
41  return DEFAULT_STREAM;
42  }
43 }
List< Object > apply(ConsumerRecord< K, V > record)