Ejemplo n.º 1
0
        public void Persist(StorageLevelType storageLevelType)
        {
            var jstorageLevel = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);

            SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(
                jvmDataFrameReference, "persist", new object[] { jstorageLevel });
        }
Ejemplo n.º 2
0
        public IDStreamProxy SocketTextStream(string hostname, int port, StorageLevelType storageLevelType)
        {
            JvmObjectReference jlevel = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
            var jstream = new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(jvmJavaStreamingReference, "socketTextStream", hostname, port, jlevel).ToString());

            return(new DStreamIpcProxy(jstream));
        }
Ejemplo n.º 3
0
 public static JvmObjectReference GetJavaStorageLevel(StorageLevelType storageLevelType)
 {
     return(new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallStaticJavaMethod("org.apache.spark.api.java.StorageLevels", "create",
                                                                                   new object[]
     {
         StorageLevel.storageLevel[storageLevelType].useDisk,
         StorageLevel.storageLevel[storageLevelType].useMemory,
         StorageLevel.storageLevel[storageLevelType].useOffHeap,
         StorageLevel.storageLevel[storageLevelType].deserialized,
         StorageLevel.storageLevel[storageLevelType].replication
     }).ToString()));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create an input stream that pulls messages from a Kafka Broker.
        /// </summary>
        /// <param name="zkQuorum">Zookeeper quorum (hostname:port,hostname:port,..).</param>
        /// <param name="groupId">The group id for this consumer.</param>
        /// <param name="topics">Dict of (topic_name -> numPartitions) to consume. Each partition is consumed in its own thread.</param>
        /// <param name="kafkaParams">Additional params for Kafka</param>
        /// <param name="storageLevelType">RDD storage level.</param>
        /// <returns>A DStream object</returns>
        public static DStream<KeyValuePair<byte[], byte[]>> CreateStream(StreamingContext ssc, string zkQuorum, string groupId, Dictionary<string, int> topics, Dictionary<string, string> kafkaParams, StorageLevelType storageLevelType)
        {
            if (kafkaParams == null)
                kafkaParams = new Dictionary<string, string>();

            if (!string.IsNullOrEmpty(zkQuorum))
                kafkaParams["zookeeper.connect"] = zkQuorum;
            if (groupId != null)
                kafkaParams["group.id"] = groupId;
            if (kafkaParams.ContainsKey("zookeeper.connection.timeout.ms"))
                kafkaParams["zookeeper.connection.timeout.ms"] = "10000";

            return new DStream<KeyValuePair<byte[], byte[]>>(ssc.streamingContextProxy.KafkaStream(topics, kafkaParams, storageLevelType), ssc);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create an input stream that pulls messages from a Kafka Broker.
        /// </summary>
        /// <param name="zkQuorum">Zookeeper quorum (hostname:port,hostname:port,..).</param>
        /// <param name="groupId">The group id for this consumer.</param>
        /// <param name="topics">Dict of (topic_name -> numPartitions) to consume. Each partition is consumed in its own thread.</param>
        /// <param name="kafkaParams">Additional params for Kafka</param>
        /// <param name="storageLevelType">RDD storage level.</param>
        /// <returns>A DStream object</returns>
        public DStream <KeyValuePair <byte[], byte[]> > KafkaStream(string zkQuorum, string groupId, Dictionary <string, int> topics, Dictionary <string, string> kafkaParams, StorageLevelType storageLevelType)
        {
            if (kafkaParams == null)
            {
                kafkaParams = new Dictionary <string, string>();
            }

            if (!string.IsNullOrEmpty(zkQuorum))
            {
                kafkaParams["zookeeper.connect"] = zkQuorum;
            }
            if (groupId != null)
            {
                kafkaParams["group.id"] = groupId;
            }
            if (kafkaParams.ContainsKey("zookeeper.connection.timeout.ms"))
            {
                kafkaParams["zookeeper.connection.timeout.ms"] = "10000";
            }

            return(new DStream <KeyValuePair <byte[], byte[]> >(this.streamingContextProxy.KafkaStream(topics, kafkaParams, storageLevelType), this));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Create an input from TCP source hostname:port. Data is received using
 /// a TCP socket and receive byte is interpreted as UTF8 encoded ``\\n`` delimited
 /// lines.
 /// </summary>
 /// <param name="hostname">Hostname to connect to for receiving data</param>
 /// <param name="port">Port to connect to for receiving data</param>
 /// <param name="storageLevelType">Storage level to use for storing the received objects</param>
 /// <returns></returns>
 public DStream <string> SocketTextStream(string hostname, int port, StorageLevelType storageLevelType = StorageLevelType.MEMORY_AND_DISK_SER_2)
 {
     return(new DStream <string>(streamingContextProxy.SocketTextStream(hostname, port, storageLevelType), this, SerializedMode.String));
 }
Ejemplo n.º 7
0
 public void Persist(StorageLevelType storageLevelType)
 {
     Validate();
 }
Ejemplo n.º 8
0
        public IDStreamProxy KafkaStream(Dictionary <string, int> topics, Dictionary <string, string> kafkaParams, StorageLevelType storageLevelType)
        {
            JvmObjectReference jtopics      = JvmBridgeUtils.GetJavaMap <string, int>(topics);
            JvmObjectReference jkafkaParams = JvmBridgeUtils.GetJavaMap <string, string>(kafkaParams);
            JvmObjectReference jlevel       = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
            // KafkaUtilsPythonHelper: external/kafka/src/main/scala/org/apache/spark/streaming/kafka/KafkaUtils.scala
            JvmObjectReference jhelper = SparkCLRIpcProxy.JvmBridge.CallConstructor("org.apache.spark.streaming.kafka.KafkaUtilsPythonHelper", new object[] { });
            var jstream = new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(jhelper, "createStream", new object[] { jvmJavaStreamingReference, jkafkaParams, jtopics, jlevel }).ToString());

            return(new DStreamIpcProxy(jstream));
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Persist the RDDs of this DStream with the given storage level
 /// </summary>
 /// <param name="storageLevelType"></param>
 /// <returns></returns>
 public DStream <T> Persist(StorageLevelType storageLevelType)
 {
     isCached = true;
     DStreamProxy.Persist(storageLevelType);
     return(this);
 }
Ejemplo n.º 10
0
 public void Persist(StorageLevelType storageLevelType)
 {
     var jstorageLevel = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
     SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(jvmRddReference, "persist", new object[] { jstorageLevel });
 }
Ejemplo n.º 11
0
 public IDStreamProxy EventHubsUnionStream(Dictionary<string, string> eventHubsParams, StorageLevelType storageLevelType)
 {
     JvmObjectReference eventHubsParamsReference = JvmBridgeUtils.GetScalaMutableMap<string, string>(eventHubsParams);
     JvmObjectReference storageLevelTypeReference = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
     return
         new DStreamIpcProxy(
             new JvmObjectReference(
                 SparkCLRIpcProxy.JvmBridge.CallStaticJavaMethod(
                     "org.apache.spark.streaming.api.csharp.EventHubsUtils", "createUnionStream",
                     new object[] { jvmJavaStreamingReference, eventHubsParamsReference, storageLevelTypeReference })
                     .ToString()));
 }
Ejemplo n.º 12
0
 public void Persist(StorageLevelType storageLevelType)
 {
     Validate();
 }
Ejemplo n.º 13
0
 public void Persist(StorageLevelType storageLevelType)
 {
 }
Ejemplo n.º 14
0
 public IDStreamProxy EventHubsUnionStream(IEnumerable <Tuple <string, string> > eventHubsParams, StorageLevelType storageLevelType)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Create an input stream that pulls messages from a Kafka Broker.
        /// </summary>
        /// <param name="ssc">Spark Streaming Context</param>
        /// <param name="zkQuorum">Zookeeper quorum (hostname:port,hostname:port,..).</param>
        /// <param name="groupId">The group id for this consumer.</param>
        /// <param name="topics">Dict of (topic_name -> numPartitions) to consume. Each partition is consumed in its own thread.</param>
        /// <param name="kafkaParams">Additional params for Kafka</param>
        /// <param name="storageLevelType">RDD storage level.</param>
        /// <returns>A DStream object</returns>
        public static DStream <Tuple <byte[], byte[]> > CreateStream(StreamingContext ssc, string zkQuorum, string groupId, IEnumerable <Tuple <string, int> > topics, IEnumerable <Tuple <string, string> > kafkaParams, StorageLevelType storageLevelType)
        {
            if (kafkaParams == null)
            {
                kafkaParams = new List <Tuple <string, string> >();
            }

            var kafkaParamsMap = kafkaParams.ToDictionary(x => x.Item1, x => x.Item2);

            if (!string.IsNullOrEmpty(zkQuorum))
            {
                kafkaParamsMap["zookeeper.connect"] = zkQuorum;
            }
            if (groupId != null)
            {
                kafkaParamsMap["group.id"] = groupId;
            }
            if (kafkaParamsMap.ContainsKey("zookeeper.connection.timeout.ms"))
            {
                kafkaParamsMap["zookeeper.connection.timeout.ms"] = "10000";
            }

            return(new DStream <Tuple <byte[], byte[]> >(ssc.streamingContextProxy.KafkaStream(topics, kafkaParamsMap.Select(x => Tuple.Create(x.Key, x.Value)), storageLevelType), ssc));
        }
Ejemplo n.º 16
0
 public void Persist(StorageLevelType storageLevelType)
 {
 }
Ejemplo n.º 17
0
 public IDStreamProxy EventHubsUnionStream(Dictionary<string, string> eventHubsParams, StorageLevelType storageLevelType)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Create a unioned EventHubs stream that receives data from Microsoft Azure Eventhubs
 /// The unioned stream will receive message from all partitions of the EventHubs
 /// </summary>
 /// <param name="ssc">Streaming context</param>
 /// <param name="eventhubsParams"> Parameters for EventHubs.
 ///  Required parameters are:
 ///  "eventhubs.policyname": EventHubs policy name
 ///  "eventhubs.policykey": EventHubs policy key
 ///  "eventhubs.namespace": EventHubs namespace
 ///  "eventhubs.name": EventHubs name
 ///  "eventhubs.partition.count": Number of partitions
 ///  "eventhubs.checkpoint.dir": checkpoint directory on HDFS
 ///
 ///  Optional parameters are:
 ///  "eventhubs.consumergroup": EventHubs consumer group name, default to "\$default"
 ///  "eventhubs.filter.offset": Starting offset of EventHubs, default to "-1"
 ///  "eventhubs.filter.enqueuetime": Unix time, millisecond since epoch, default to "0"
 ///  "eventhubs.default.credits": default AMQP credits, default to -1 (which is 1024)
 ///  "eventhubs.checkpoint.interval": checkpoint interval in second, default to 10
 /// </param>
 /// <param name="storageLevelType">Storage level, by default it is MEMORY_ONLY</param>
 /// <returns>DStream with byte[] representing events from EventHub</returns>
 public static DStream <byte[]> CreateUnionStream(StreamingContext ssc, Dictionary <string, string> eventhubsParams, StorageLevelType storageLevelType = StorageLevelType.MEMORY_ONLY)
 {
     return(new DStream <byte[]>(ssc.streamingContextProxy.EventHubsUnionStream(eventhubsParams, storageLevelType), ssc, SerializedMode.None));
 }
Ejemplo n.º 19
0
 public static JvmObjectReference GetJavaStorageLevel(StorageLevelType storageLevelType)
 {
     return new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallStaticJavaMethod("org.apache.spark.api.java.StorageLevels", "create",
         new object[]
         {
             StorageLevel.storageLevel[storageLevelType].useDisk,
             StorageLevel.storageLevel[storageLevelType].useMemory,
             StorageLevel.storageLevel[storageLevelType].useOffHeap,
             StorageLevel.storageLevel[storageLevelType].deserialized,
             StorageLevel.storageLevel[storageLevelType].replication
         }).ToString());
 }
 public IDStreamProxy SocketTextStream(string hostname, int port, StorageLevelType storageLevelType)
 {
     JvmObjectReference jlevel = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
     var jstream = new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(jvmJavaStreamingReference, "socketTextStream", hostname, port, jlevel).ToString());
     return new DStreamIpcProxy(jstream);
 }
 public IDStreamProxy KafkaStream(Dictionary<string, int> topics, Dictionary<string, string> kafkaParams, StorageLevelType storageLevelType)
 {
     JvmObjectReference jtopics = SparkContextIpcProxy.GetJavaMap<string, int>(topics);
     JvmObjectReference jkafkaParams = SparkContextIpcProxy.GetJavaMap<string, string>(kafkaParams);
     JvmObjectReference jlevel = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);
     JvmObjectReference jhelper = SparkCLRIpcProxy.JvmBridge.CallConstructor("org.apache.spark.streaming.kafka.KafkaUtilsPythonHelper", new object[] { });
     var jstream = new JvmObjectReference(SparkCLRIpcProxy.JvmBridge.CallNonStaticJavaMethod(jhelper, "createStream", new object[] { jvmJavaStreamingReference, jkafkaParams, jtopics, jlevel }).ToString());
     return new DStreamIpcProxy(jstream);
 }
 public IDStreamProxy EventHubsUnionStream(Dictionary <string, string> eventHubsParams, StorageLevelType storageLevelType)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 23
0
        public IDStreamProxy EventHubsUnionStream(Dictionary <string, string> eventHubsParams, StorageLevelType storageLevelType)
        {
            JvmObjectReference eventHubsParamsReference  = JvmBridgeUtils.GetScalaMutableMap <string, string>(eventHubsParams);
            JvmObjectReference storageLevelTypeReference = SparkContextIpcProxy.GetJavaStorageLevel(storageLevelType);

            return
                (new DStreamIpcProxy(
                     new JvmObjectReference(
                         SparkCLRIpcProxy.JvmBridge.CallStaticJavaMethod(
                             "org.apache.spark.streaming.api.csharp.EventHubsUtils", "createUnionStream",
                             new object[] { jvmJavaStreamingReference, eventHubsParamsReference, storageLevelTypeReference })
                         .ToString())));
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Create a unioned EventHubs stream that receives data from Microsoft Azure Eventhubs
 /// The unioned stream will receive message from all partitions of the EventHubs
 /// </summary>
 /// <param name="ssc">Streaming context</param>
 /// <param name="eventhubsParams"> Parameters for EventHubs.
 ///  Required parameters are:
 ///  "eventhubs.policyname": EventHubs policy name
 ///  "eventhubs.policykey": EventHubs policy key
 ///  "eventhubs.namespace": EventHubs namespace
 ///  "eventhubs.name": EventHubs name
 ///  "eventhubs.partition.count": Number of partitions
 ///  "eventhubs.checkpoint.dir": checkpoint directory on HDFS
 ///
 ///  Optional parameters are:
 ///  "eventhubs.consumergroup": EventHubs consumer group name, default to "\$default"
 ///  "eventhubs.filter.offset": Starting offset of EventHubs, default to "-1"
 ///  "eventhubs.filter.enqueuetime": Unix time, millisecond since epoch, default to "0"
 ///  "eventhubs.default.credits": default AMQP credits, default to -1 (which is 1024)
 ///  "eventhubs.checkpoint.interval": checkpoint interval in second, default to 10
 /// </param>
 /// <param name="storageLevelType">Storage level, by default it is MEMORY_ONLY</param>
 /// <returns>DStream with byte[] representing events from EventHub</returns>
 public static DStream<byte[]> CreateUnionStream(StreamingContext ssc, Dictionary<string, string> eventhubsParams, StorageLevelType storageLevelType = StorageLevelType.MEMORY_ONLY)
 {
     return new DStream<byte[]>(ssc.streamingContextProxy.EventHubsUnionStream(eventhubsParams, storageLevelType), ssc, SerializedMode.None);
 }