private static void Initializer(ProducePerfTestHelperOption producewrapperOption)
        {
            Logger.InfoFormat("prepare perf test, {0} ", DateTime.Now);
            listOfDataNeedSendInOneBatch = new List<ProducerData<byte[], Message>>();
            for (int i = 0; i < producewrapperOption.MessageCountPerBatch; i++)
            {
                String vKey = KafkaClientHelperUtils.GetRandomString(32);
                byte[] bKey = System.Text.Encoding.UTF8.GetBytes(vKey);

                String val = KafkaClientHelperUtils.GetRandomString(producewrapperOption.MessageSize);
                byte[] bVal = System.Text.Encoding.UTF8.GetBytes(val);

                Message message = new Message(bVal, bKey, producewrapperOption.CompressionCodec);
                listOfDataNeedSendInOneBatch.Add(new ProducerData<byte[], Message>(producewrapperOption.Topic, message));
            }
        }
        internal void Run(ProducePerfTestHelperOption option)
        {
            produceOption = option;
            ProducePerfTestKafkaSimpleManagerWrapper.produceOptions = option;

            Initializer(option);
            Thread[] threads = new Thread[option.ThreadCount];
            AutoResetEvent[] autos = new AutoResetEvent[option.ThreadCount];
            threadPareamaters = new PerfTestThreadParameter[option.ThreadCount];

            Logger.InfoFormat("start send {0} ", DateTime.Now);
            stopWatch.Restart();
            //[('p',   -1  random partition.      -2  by default or customized partitioner class. (you need specify PartitionerClass by -l)   >=0 to specific partition.
            for (int i = 0; i < option.ThreadCount; i++)
            {
                AutoResetEvent Auto = new AutoResetEvent(false);
                PerfTestThreadParameter p = new PerfTestThreadParameter();
                p.ThreadId = i;
                p.SpeedConstrolMBPerSecond = (option.SpeedConstrolMBPerSecond * 1.0) / option.ThreadCount;
                p.EventOfFinish = Auto;
                if (produceOption.PartitionId < 0)
                {
                    p.RandomReturnIfNotExist = true;
                }
                else
                    p.RandomReturnIfNotExist = false;
                p.PartitionId = produceOption.PartitionId;
                p.Topic = produceOption.Topic;

                Logger.InfoFormat("Thread:{0} PartitionID:{1} RandomReturnIfNotExist:{2} ", p.ThreadId, p.PartitionId, p.RandomReturnIfNotExist);
                Thread t = new Thread(new ParameterizedThreadStart(RunOneThread));
                t.Start(p);
                autos[i] = Auto;
                threadPareamaters[i] = p;
            }

            WaitHandle.WaitAll(autos);
            stopWatch.Stop();
            Statistics();
        }
 internal void Parse(string[] args)
 {
     if (args == null || args.Length <= 0)
     {
         throw new ArgumentException("Please provide verb.");
     }
     Verb = args[0].ToLowerInvariant();
     if ("topic" == Verb.ToLowerInvariant())
         ActiveSubOption = new TopicHelperArguments();
     else if ("dumpdata" == Verb.ToLowerInvariant()
          || KafkaNETExampleType.ConsumeSimple.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ConsumeDataHelperArguments();
     else if ("dumpdataasconsumergroup" == Verb.ToLowerInvariant()
         || KafkaNETExampleType.ConsumeGroup.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ConsumeGroupHelperOptions();
     else if ("latestoffsetofconsumergroup" == Verb.ToLowerInvariant()
         || "consumegroupm" == Verb.ToLowerInvariant()
         || "consumem" == Verb.ToLowerInvariant()
         || KafkaNETExampleType.ConsumeGroupMonitor.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ConsumeGroupMonitorHelperOptions();
     else if ("produceroundrobin" == Verb.ToLowerInvariant()
         || KafkaNETExampleType.ProduceSimple.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ProduceSimpleHelperOption();
     else if ("test" == Verb.ToLowerInvariant())
         ActiveSubOption = new TestHelperOptions();
     else if ("producewrapper" == Verb.ToLowerInvariant()
         || KafkaNETExampleType.ProducePerfTest.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ProducePerfTestHelperOption();
     else if ("producem" == Verb.ToLowerInvariant()
         || KafkaNETExampleType.ProduceMonitor.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new ProduceMonitorHelperOptions();
     else if (KafkaNETExampleType.EventServerPerfTest.ToString().ToLowerInvariant() == Verb.ToLowerInvariant())
         ActiveSubOption = new JavaEventServerPerfTestHelperOptions();
     else
     {
         throw new ArgumentException(string.Format("The command verb {0} is not recoganized.", Verb));
     }
 }