Skip to content

Instantly share code, notes, and snippets.

View LearningJournal's full-sized avatar
🎯
Focusing

Prashant Kumar Pandey LearningJournal

🎯
Focusing
View GitHub Profile
import java.util.*;
import org.apache.kafka.clients.producer.*;
public class SimpleProducer {
public static void main(String[] args) throws Exception{
String key = "Key1";
String value = "Value-1";
String topicName = "SimpleProducerTopic";
Properties props = new Properties();
spark.range(100).repartition(1).write.mode("overwrite").csv("/tmp/test-1")
@LearningJournal
LearningJournal / KT01.sh
Last active January 8, 2022 15:21
Kafka Tutorial Code Samples for Learning Journal Website
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
sudo yum -y install java-1.8.0-openjdk
#!/bin/bash
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
java $SBT_OPTS -jar `dirname $0`/sbt-launch.jar "$@"
def doubler(i: Int) = { i * 2 }
(i: Int) => { i * 2 }
wget -c --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm
yum localinstall jdk-8u121-linux-x64.rpm
//load a text file from current directory
val flistRDD = sc.textFile("flist.txt")
//Check number of defaults partitions
flistRDD.getNumPartitions
//Reload with five partitions
val flistRDD = sc.textFile("flist.txt", 5)
//Count the number of elements in each partition
flistRDD.foreachPartition(
p => println("Items in partition-" + p.count(y => true))
)
import java.util.Scanner
<p>
Let me take you to <a href="https://www.google.com">Google</a>.
<p>