@@ -0,0 +1,1620 @@
+from kafka import KafkaClient, create_message%0Afrom kafka.protocol import KafkaProtocol%0Afrom kafka.common import ProduceRequest%0Aimport random%0Aimport logging%0A%0Aclass KafkaSampleWriter(object):%0A    %22%22%22%0A    KafkaSampleWriter can be used to write sample messages into Kafka for%0A    benchmark purposes%0A    %22%22%22%0A%0A    def __init__(self, config, batches = 1000, batch_size = 1000):%0A        self.config = config%0A        self.batches = batches%0A        self.batch_size = batch_size%0A        # Sample messages for benchmark%0A        self.sample_messages = %5B%0A            %22%22%2226f2fc918f50.load.load.shortterm 0.05 1436357630%0A            26f2fc918f50.load.load.midterm 0.05 1436357630%0A            26f2fc918f50.load.load.longterm 0.05 1436357630%22%22%22,%0A            %2226f2fc918f50.cpu-0.cpu-user 30364 1436357630%22,%0A            %2226f2fc918f50.memory.memory-buffered 743657472 1436357630%22%0A        %5D%0A%0A    def produce_messages(self):%0A        %22%22%22%0A        Produce sample messages%0A        %22%22%22%0A        # TODO: Support different kafka port%0A        kafka = KafkaClient(self.config.kafka_host)%0A%0A        total_messages = self.batches * self.batch_size%0A        messages_batch = %5Bcreate_message(random.choice(self.sample_messages)) for r in range(self.batch_size)%5D%0A%0A        for i in range(self.batches):%0A            req = ProduceRequest(topic=self.config.kafka_topic, partition=0, messages=messages_batch)%0A            resps = kafka.send_produce_request(payloads=%5Breq%5D, fail_on_error=True)%0A            sent_messages = i * self.batch_size%0A            logging.info('Created %7B%7D out of %7B%7D sample messages'.format(sent_messages, total_messages))%0A        kafka.close()%0A

Add kafka writer for benchmarks