代码拉取完成,页面将自动刷新
同步操作将从 巨轮/LearnKafka 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*
# 本文件应该放置在Kafka的安装主目录
import os, time, subprocess
startZooKeeperServerCmd = 'start bin\windows\zookeeper-server-start.bat config\zookeeper.properties'
startKafkaServerCmd = 'start bin\windows\kafka-server-start.bat config\%s'
print('Starting ZooKeeper Server...')
subprocess.Popen(startZooKeeperServerCmd, shell=True)
time.sleep(10)
zooKeeperPortNumber = 2181
kafkaPortNumber = 9092
kafkaPortNumber2 = 9093
kafkaPortNumber3 = 9094
def polling(portNumber, interval = 5, count = 10):
while count > 0:
tmpFile = os.popen('netstat -na','r')
portNumberStr = str(portNumber)
print("Polling the port: " + portNumberStr)
for line in tmpFile.readlines():
if line.startswith(' TCP 0.0.0.0:' + portNumberStr) or line.startswith(' TCP 127.0.0.1:' + portNumberStr):
return True
print("Not yet. " + str(portNumber))
count -= 1
time.sleep(interval)
print("Polling the port: " + portNumberStr + " unsuccessfully.")
return False
if polling(zooKeeperPortNumber):
print("Starting the Kafka cluster...")
subprocess.Popen(startKafkaServerCmd % 'server.properties', shell=True)
if polling(kafkaPortNumber):
subprocess.Popen(startKafkaServerCmd % 'server-1.properties', shell=True)
if polling(kafkaPortNumber2):
subprocess.Popen(startKafkaServerCmd % 'server-2.properties', shell=True)
else:
print("Something wrong ...")
input()#raw_input()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。