Skip to content

Commit 4b5f1be

Browse files
committed
first commit
0 parents  commit 4b5f1be

File tree

8 files changed

+226
-0
lines changed

8 files changed

+226
-0
lines changed

.idea/compiler.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/scala_compiler.xml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pom.xml

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>com.sparkapp.scala</groupId>
4+
<artifactId>sparkCode</artifactId>
5+
<packaging>jar</packaging>
6+
7+
8+
<version>1.0-SNAPSHOT</version>
9+
<inceptionYear>2008</inceptionYear>
10+
<properties>
11+
<scala.version>2.11.6</scala.version>
12+
</properties>
13+
14+
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.scala-lang</groupId>
19+
<artifactId>scala-library</artifactId>
20+
<version>${scala.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>junit</groupId>
24+
<artifactId>junit</artifactId>
25+
<version>4.4</version>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.specs</groupId>
30+
<artifactId>specs</artifactId>
31+
<version>1.2.5</version>
32+
<scope>test</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.scala-tools</groupId>
36+
<artifactId>maven-scala-plugin</artifactId>
37+
<version>2.11</version>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>org.apache.spark</groupId>
42+
<artifactId>spark-core_2.11</artifactId>
43+
<version>2.1.1</version>
44+
</dependency>
45+
46+
47+
<!-- <dependency>
48+
<groupId>org.apache.spark</groupId>
49+
<artifactId>spark-sql_2.11</artifactId>
50+
<version>2.1.1</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>com.databricks</groupId>
55+
<artifactId>spark-xml_2.11</artifactId>
56+
<version>0.5.0</version>
57+
</dependency>
58+
-->
59+
60+
61+
<dependency>
62+
<groupId>org.apache.kafka</groupId>
63+
<artifactId>kafka-clients</artifactId>
64+
<version>0.10.2.1</version>
65+
</dependency>
66+
67+
</dependencies>
68+
69+
<build>
70+
<sourceDirectory>src/main/scala</sourceDirectory>
71+
<testSourceDirectory>src/test/scala</testSourceDirectory>
72+
<plugins>
73+
<plugin>
74+
<groupId>org.scala-tools</groupId>
75+
<artifactId>maven-scala-plugin</artifactId>
76+
<executions>
77+
<execution>
78+
<goals>
79+
<goal>compile</goal>
80+
<goal>testCompile</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
<configuration>
85+
<scalaVersion>${scala.version}</scalaVersion>
86+
<args>
87+
<arg>-target:jvm-1.5</arg>
88+
</args>
89+
</configuration>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.apache.maven.plugins</groupId>
93+
<artifactId>maven-eclipse-plugin</artifactId>
94+
<configuration>
95+
<downloadSources>true</downloadSources>
96+
<buildcommands>
97+
<buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
98+
</buildcommands>
99+
<additionalProjectnatures>
100+
<projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
101+
</additionalProjectnatures>
102+
<classpathContainers>
103+
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
104+
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
105+
</classpathContainers>
106+
</configuration>
107+
</plugin>
108+
109+
<plugin>
110+
<artifactId>maven-assembly-plugin</artifactId>
111+
<executions>
112+
<execution>
113+
<phase>package</phase>
114+
<goals>
115+
<goal>single</goal>
116+
</goals>
117+
</execution>
118+
</executions>
119+
<configuration>
120+
<descriptorRefs>
121+
<descriptorRef>jar-with-dependencies</descriptorRef>
122+
</descriptorRefs>
123+
<archive>
124+
<manifest>
125+
<mainClass>pakageName.MainClassName</mainClass>
126+
</manifest>
127+
</archive>
128+
</configuration>
129+
</plugin>
130+
</plugins>
131+
</build>
132+
<reporting>
133+
<plugins>
134+
<plugin>
135+
<groupId>org.scala-tools</groupId>
136+
<artifactId>maven-scala-plugin</artifactId>
137+
<configuration>
138+
<scalaVersion>${scala.version}</scalaVersion>
139+
</configuration>
140+
</plugin>
141+
</plugins>
142+
</reporting>
143+
</project>

prj1.iml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.sparkapp.scala
2+
3+
4+
import java.util.Properties
5+
import org.apache.kafka.clients.producer.{ProducerRecord, KafkaProducer}
6+
import org.apache.kafka.common.serialization.{StringSerializer, StringDeserializer}
7+
8+
import org.apache.spark.SparkContext
9+
object myWorld {
10+
11+
def main(args: Array[String]) {
12+
13+
val props = new Properties()
14+
props.put("bootstrap.servers", "wn01.itversity.com:6667 ")
15+
//props.put("acks", "1")
16+
props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
17+
props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
18+
19+
val producer = new KafkaProducer[String, String](props)
20+
21+
val topic = "kafkaNik"
22+
23+
24+
for (i <- 1 to 50) {
25+
import org.apache.kafka.clients.producer.RecordMetadata
26+
27+
val record = new ProducerRecord(topic, "key" + i, "value" + i)
28+
val metadata = producer.send(record).get
29+
producer.send(record)
30+
println("sent record(key=%s value=%s) " + "meta(partition=%d, offset=%d) time=%d\n", record.key, record.value, metadata.partition, metadata.offset) }
31+
32+
producer.close()
33+
}
34+
}

0 commit comments

Comments
 (0)