Server IP : 184.154.167.98 / Your IP : 3.144.87.18 Web Server : Apache System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 User : puertode ( 1767) PHP Version : 8.2.26 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/pcp/examples/pcp2spark/ |
Upload File : |
#!/usr/bin/env pmpython # pylint: disable=invalid-name """ PCP2Spark Stream Collector example """ import sys from pyspark import SparkContext from pyspark.streaming import StreamingContext if __name__ == "__main__": sc = SparkContext(appName="PCP2SparkStreamCollector") # 5 is the batch interval: 5 seconds ssc = StreamingContext(sc, 5) # Checkpoint for backups ssc.checkpoint("file:///tmp/spark") # Define the socket where pcp2spark is listening for a connection. # metrics is not an RDD but a sequence of constantly changing RDDs # argv1 = address of pcp2spark, argv2 = port of pcp2spark metrics = ssc.socketTextStream(sys.argv[1], int(sys.argv[2])) # Display the metrics we have streamed # Start the program # The program will run until manual termination metrics.pprint() ssc.start() ssc.awaitTermination()