Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/807#discussion_r13835028
  
    --- Diff: 
external/flume-sink/src/main/scala/org/apache/spark/flume/sink/SparkSink.scala 
---
    @@ -0,0 +1,432 @@
    +/*
    + * 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.flume.sink
    +
    +import java.net.InetSocketAddress
    +import java.nio.ByteBuffer
    +import java.util
    +import java.util.concurrent._
    +import java.util.concurrent.atomic.AtomicLong
    +
    +import scala.util.control.Breaks
    +
    +import com.google.common.util.concurrent.ThreadFactoryBuilder
    +import org.apache.avro.ipc.NettyServer
    +import org.apache.avro.ipc.specific.SpecificResponder
    +import org.apache.commons.lang.RandomStringUtils
    +import org.apache.flume.Sink.Status
    +import org.apache.flume.conf.{ConfigurationException, Configurable}
    +import org.apache.flume.sink.AbstractSink
    +import org.apache.flume.{Channel, Transaction, FlumeException, Context}
    +import org.slf4j.LoggerFactory
    +
    +import org.apache.spark.flume.{SparkSinkEvent, EventBatch, 
SparkFlumeProtocol}
    +
    +/**
    + * A sink that uses Avro RPC to run a server that can be polled by Spark's
    + * FlumePollingInputDStream. This sink has the following configuration 
parameters:
    + *
    + * hostname - The hostname to bind to. Default: 0.0.0.0
    + * port - The port to bind to. (No default - mandatory)
    + * timeout - Time in seconds after which a transaction is rolled back,
    + * if an ACK is not received from Spark within that time
    + * threads - Number of threads to use to receive requests from Spark 
(Default: 10)
    + *
    + */
    +// Flume forces transactions to be thread-local. So each transaction 
*must* be committed, or
    +// rolled back from the thread it was originally created in. So each 
getEvents call from Spark
    +// creates a TransactionProcessor which runs in a new thread, in which the 
transaction is created
    +// and events are pulled off the channel. Once the events are sent to 
spark,
    +// that thread is blocked and the TransactionProcessor is saved in a map,
    +// until an ACK or NACK comes back or the transaction times out (after the 
specified timeout).
    +// When the response comes, the TransactionProcessor is retrieved and then 
unblocked,
    +// at which point the transaction is committed or rolled back.
    +class SparkSink extends AbstractSink with Configurable {
    --- End diff --
    
    Since these are separate classes, its probably better to split these into 
separate files.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to