Search in sources :

Example 6 with Scheme

use of org.apache.storm.spout.Scheme in project storm by apache.

the class SocketDataSourcesProvider method constructStreams.

@Override
public ISqlStreamsDataSource constructStreams(URI uri, String inputFormatClass, String outputFormatClass, Properties properties, List<FieldInfo> fields) {
    String host = uri.getHost();
    int port = uri.getPort();
    if (port == -1) {
        throw new RuntimeException("Port information is not available. URI: " + uri);
    }
    List<String> fieldNames = FieldInfoUtils.getFieldNames(fields);
    Scheme scheme = SerdeUtils.getScheme(inputFormatClass, properties, fieldNames);
    IOutputSerializer serializer = SerdeUtils.getSerializer(outputFormatClass, properties, fieldNames);
    return new SocketDataSourcesProvider.SocketStreamsDataSource(host, port, scheme, serializer);
}
Also used : IOutputSerializer(org.apache.storm.sql.runtime.IOutputSerializer) Scheme(org.apache.storm.spout.Scheme)

Example 7 with Scheme

use of org.apache.storm.spout.Scheme in project storm by apache.

the class RocketMqUtils method createScheme.

/**
 * Create Scheme by Properties.
 * @param props Properties
 * @return Scheme
 */
public static Scheme createScheme(Properties props) {
    String schemeString = props.getProperty(SpoutConfig.SCHEME, SpoutConfig.DEFAULT_SCHEME);
    Scheme scheme;
    try {
        Class clazz = Class.forName(schemeString);
        scheme = (Scheme) clazz.newInstance();
    } catch (Exception e) {
        throw new IllegalArgumentException("Cannot create Scheme for " + schemeString + " due to " + e.getMessage());
    }
    return scheme;
}
Also used : KeyValueScheme(org.apache.storm.rocketmq.spout.scheme.KeyValueScheme) Scheme(org.apache.storm.spout.Scheme)

Aggregations

Scheme (org.apache.storm.spout.Scheme)7 IOutputSerializer (org.apache.storm.sql.runtime.IOutputSerializer)4 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 FieldInfo (org.apache.storm.sql.runtime.FieldInfo)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 ConsumerConnector (kafka.javaapi.consumer.ConsumerConnector)1 ByteBufferDeserializer (org.apache.kafka.common.serialization.ByteBufferDeserializer)1 ZkHosts (org.apache.storm.kafka.ZkHosts)1 KafkaSpoutConfig (org.apache.storm.kafka.spout.KafkaSpoutConfig)1 TridentKafkaConfig (org.apache.storm.kafka.trident.TridentKafkaConfig)1 KeyValueScheme (org.apache.storm.rocketmq.spout.scheme.KeyValueScheme)1 RawScheme (org.apache.storm.spout.RawScheme)1 SchemeAsMultiScheme (org.apache.storm.spout.SchemeAsMultiScheme)1 SpoutOutputCollector (org.apache.storm.spout.SpoutOutputCollector)1 OutputFieldsDeclarer (org.apache.storm.topology.OutputFieldsDeclarer)1 Fields (org.apache.storm.tuple.Fields)1 Before (org.junit.Before)1