Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/223#discussion_r10961644
--- Diff:
external/AmazonKinesis/src/main/scala/org/apache/spark/streaming/kinesis/KinesisInputDStream.scala
---
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.streaming.kinesis
+
+import org.apache.spark.streaming.StreamingContext
+import scala.reflect.ClassTag
+import org.apache.spark.storage.StorageLevel
+import org.apache.spark.streaming.dstream.NetworkReceiver
+import com.amazonaws.auth.AWSCredentialsProvider
+import java.util.UUID
+import com.amazonaws.auth.InstanceProfileCredentialsProvider
+import com.amazonaws.auth.AWSCredentials
+import com.amazonaws.auth.BasicAWSCredentials
+import java.net.UnknownHostException
+import java.net.InetAddress
+import
com.amazonaws.services.kinesis.clientlibrary.lib.worker.KinesisClientLibConfiguration
+import java.nio.charset.Charset
+import
com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorFactory
+import
com.amazonaws.services.kinesis.clientlibrary.exceptions.ShutdownException
+import
com.amazonaws.services.kinesis.clientlibrary.exceptions.ThrottlingException
+import
com.amazonaws.services.kinesis.clientlibrary.exceptions.InvalidStateException
+import
com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer
+import com.amazonaws.services.kinesis.clientlibrary.lib.worker.Worker
+import com.amazonaws.services.kinesis.clientlibrary.types.ShutdownReason
+import com.amazonaws.services.kinesis.model.Record
+import
com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessor
+import org.apache.spark.streaming.dstream.NetworkInputDStream
+import scala.collection.JavaConversions._
+import java.util.List
+
+
+private[streaming]
+class KinesisInputDStream[T: ClassTag](
+ @transient ssc_ : StreamingContext,
+ accesskey:String,
+ accessSecretKey:String,
+ kinesisStream:String,
+ kinesisEndpoint:String,
+ storageLevel: StorageLevel
+ ) extends NetworkInputDStream[String](ssc_) {
+
+
+ override def getReceiver(): NetworkReceiver[String] = {
+ new
KinesisReceiver(accesskey,accessSecretKey,kinesisStream,kinesisEndpoint,storageLevel)
+ }
+}
+
+
+object AllDone extends Exception { }
+
+private[streaming]
+class KinesisReceiver[T: ClassTag](
+ accesskey:String,
+ accessSecretKey:String,
+ kinesisStream:String,
+ kinesisEndpoint:String,
+ storageLevel: StorageLevel
+ ) extends NetworkReceiver[String] {
+
+ val NUM_RETRIES =5
+ val BACKOFF_TIME_IN_MILLIS =2000
+ var workerId = UUID.randomUUID().toString()
+
+ lazy val credentialsProvider = new AWSCredentialsProvider {
+
+ def getCredentials():AWSCredentials = {
+ if (accesskey.isEmpty()||accessSecretKey.isEmpty) {
+ new InstanceProfileCredentialsProvider().getCredentials()
+ }else{
+ new BasicAWSCredentials(accesskey,accessSecretKey)
+ }
+ }
+
+ def refresh() {}
+ }
+
+ try {
+ workerId = InetAddress.getLocalHost().getCanonicalHostName() + ":" +
UUID.randomUUID()
+ } catch {
+ case e:UnknownHostException => e.printStackTrace()
+ }
+
+ private lazy val decoder = Charset.forName("UTF-8").newDecoder();
+ private lazy val kinesisClientLibConfiguration = new
KinesisClientLibConfiguration(kinesisStream, kinesisStream,
credentialsProvider,workerId).withKinesisEndpoint(kinesisEndpoint)
+ private lazy val blockGenerator = new BlockGenerator(storageLevel)
+
+ protected override def onStart() {
+
+ blockGenerator.start()
+ lazy val recordProcessorFactory:IRecordProcessorFactory = new
IRecordProcessorFactory{
+ def createProcessor():IRecordProcessor= new IRecordProcessor {
--- End diff --
Please fix indenting. Refer to Spark style guide
https://cwiki.apache.org/confluence/display/SPARK/Spark+Code+Style+Guide
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---