public LocalBroker CreateBroker(int brokerId) { var broker = new LocalBroker(this.CommanderPath, brokerId); this.WriteFile(broker.PropertiesFile, broker.PropertiesContent); return(broker); }
public void StopBroker(LocalBroker broker) { Console.WriteLine("Stop broker {0}", broker.BrokerId); //Shell.LaunchBat(this.KafkaRootPath, string.Format("kafka-server-stop.bat {0}", broker.PropertiesFile), // Drop, // Drop, // i => Console.WriteLine("StopBroker {0} exited with: {1}", broker.BrokerId, i)); if (broker.Process == null) { return; } Shell.KillProcessAndChildren(broker.Process); broker.Process = null; }
public async Task StartBroker(LocalBroker broker) { Console.WriteLine("Start broker {0}", broker.BrokerId); broker.Process = Shell.LaunchBat(this.KafkaRootPath, string.Format("kafka-server-start.bat {0}", broker.PropertiesFile), Drop, //s => Console.WriteLine("BROKER {0} : {1}", broker.BrokerId, s), Drop, //s => Console.WriteLine("ERR BROKER {0} : {1}", broker.BrokerId, s), i => Console.WriteLine("StartBroker {0} exited with: {1}", broker.BrokerId, i)); var timeout = Task.Delay(TimeSpan.FromSeconds(10)); var res = await Task.WhenAny( new[] { new TcpClient().ConnectAsync(LocalBroker.ListenHost, broker.ListenPort), timeout }); if (res == timeout) { throw new Exception(string.Format("Broker {0} doesn't seem to be started on {1}", broker.BrokerId, broker.ListenPort)); } }