Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Spark-Processor/src/main/scala/com/powerpanel/kso/Consumer.scala
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
32 lines (24 sloc)
1.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.powerpanel.kso; | |
import com.powerpanel.kso._ | |
import org.apache.spark.streaming.StreamingContext | |
import org.apache.log4j.Logger; | |
object Consumer { | |
private[this] val logger = Logger.getLogger(getClass().getName()); | |
def main(args: Array[String]) { | |
val props = AppConfig.loadProperties(); | |
val appName = props.getProperty("component.application") | |
val checkpointDirectory = props.getProperty("app.checkpoint_path"); | |
val batchSizeSeconds = Integer.parseInt(props.getProperty("app.batch_size_seconds")); | |
val pipeline = new KafkaPipeline() | |
// Create the streaming context, or load a saved one from disk | |
val ssc = if (checkpointDirectory.length() > 0) StreamingContext.getOrCreate(checkpointDirectory, pipeline.create) else pipeline.create(); | |
sys.ShutdownHookThread { | |
logger.info("Gracefully stopping Spark Streaming Application") | |
ssc.stop(true, true) | |
logger.info("Application stopped") | |
} | |
logger.info("Starting spark streaming execution") | |
ssc.start() | |
ssc.awaitTermination() | |
} | |
} |