kafka
共 19 篇文章
kafka 获取metadata
问题: <Failed to update metadata after 3000 ms.> sender类的发送数据时候,会 List<ClientResponse> responses = this.client.poll(requests, pollTimeout, now);//nio 发送数据 NetworkClient类,方法poll,检查metadata是否需要更新 方法: /** * Add a metadata request to the list of sends if we can make one */ private void maybeUpdateMetadat…
2015-10-14 18:48 · kafka · metadata · kafka
kafka leader balance
Balancing leadership Whenever a broker stops or crashes leadership for that broker's partitions transfers to other replicas. This means that by default when the broker is restarted it will only be a follower for all its partitions, meaning it will not be used for client reads and writes. To avoid t…
2015-10-14 13:23 · kafka · leader · balance · kafka
kafka broker宕机&leader选举
broker change是由BrokerChangeListener监听类,监听/brokers/ids下得brokerid BrokerChangeListener的handleChildChange 将新的死的broker交由controller管理 class BrokerChangeListener() extends IZkChildListener with Logging { this.logIdent = "[BrokerChangeListener on Controller " + controller.config.brokerId + "]: " def handl…
2015-10-09 16:40 · kafka · kafka
kafka producer服务端
producer服务端: 1.nio接受请求 http://blackproof.iteye.com/blog/2239949 2.handler从请求队列中获取,调用KafkaApis http://blackproof.iteye.com/blog/2239953 3.KafkaApis类,调用handleProducerOrOffsetCommitRequest方法: def handle(request: RequestChannel.Request) { try{ trace("Handling request: " + request.requestObj + " from cl…
2015-09-01 15:56 · kafka · producer · 服务端 · kafka
kafka KafkaRequestHandlerPool类
KafkaRequestHandlerPool是KafkaRequestHandler的handler池,处理所有请求队列 具体的处理,会交由KafkaApis类 for(i <- 0 until numThreads) { runnables(i) = new KafkaRequestHandler(i, brokerId, aggregateIdleMeter, numThreads, requestChannel, apis) threads(i) = Utils.daemonThread("kafka-request-handler-" + i, runnables(i)) thre…
2015-09-01 15:12 · kafka · kafka
kafka SocketServer类
SocketServer是kafka nio,包含一个accept线程,接受socket连接,并把连接(平均)放入processors中,多个processor线程接受nio的处理请求和相应 processor请求只是将request放入requestchannel queue中(由KafkaRequestHandlerPool中handler完成) processor响应是在requestchannel上注册对应的processor,processor将response发送给client /** * Start the socket server */ def startup() { va…
2015-09-01 15:09 · kafka · kafka
kafka TopicConfigManager类
topicconfigManager类 主要流程为 1.监控config/change节点,那个topic的config变化了 2.从zk上的topic的config目录,获取最新config信息 3.更新logmanager里指定topic的tplog(每个topic每个partition对应一个log)配置 /** * 注册config change的listener * Begin watching for config changes */ def startup() { ZkUtils.makeSurePersistentPathExists(zkClient, ZkUtils.T…
2015-08-27 11:24 · kafka · kafka
kafka logManager类 kafka存储机制
logManager类:管理kafka数据log的类,包括数据clean,flush等操作 Log类:每个tplog的对象 logSegment:每个tplog目录下的文件对象 filemessageSet:每个log file的管道类 base offset:在topic中的绝对offset值 offsetindex:每个log index的管道map类,存储相对offset值和文件position 按照partition分区topic,分发到各个机子上 partition上有多个log文件,每个log文件一个索引文件 log文件是实际的数据,索引文件是log文件里数据的相对偏移量和在lo…
2015-08-26 17:31 · kafka · kafka
kafka 重新分配leader kafka-preferred-replica-election.sh
bin/kafka-preferred-replica-election.sh --zookeeper hostzk/kafka-real bin/kafka-preferred-replica-election.sh --zookeeper localhost:12913/kafka --path-to-json-file topicPartitionList.json topicPartitionList.json: {"partitions":[{"topic":"topic","partition": 0},{"topic":"topic","partition": 1},{"top…
2015-07-17 17:45 · kafka · leader · kafka
kafka接口协议二 详细
kafka没有直接将消息发给某个topic的partition,所以product必须发送partition的broker client可以从任意broker获得cluster metadata信息,获得paritition的leader broker,当leader broker处理数据有误时,有两种情况1.broker死了,2broker不在包含此partition; 所以需要循环处理过程,当返回有误,则刷新metadata,在执行 官网: Cycle through a list of "bootstrap" kafka urls until we find one we can co…
2015-07-10 11:12 · kafka · kafka
kafka接口协议
The Kafka protocol is fairly simple, there are only six client requests APIs. Metadata - Describes the currently available brokers, their host and port information, and gives information about which broker hosts which partitions.获得活着的broker,他们的host和port,broker包含的partition Send - Send messages to a …
2015-07-10 11:06 · kafka · kafka
kafka参数配置
kafka参数配置 server.properties ############################# Server Basics ############################# # The id of the broker. This must be set to a unique integer for each broker. broker.id=0341 ############################# Socket Server Settings ############################# # The port the socket…
2015-07-08 16:30 · kafka · 配置 · 参数 · kafka
kafka Reassign Partitions Tool
kafka 0.8增加了重新分配partition功能,进行扩容,增加减少replica,移动partition kafka-reassign-partitions.sh脚本 Option Description ------ ----------- --broker-list <brokerlist> The list of brokers to which the partitions need to be reassigned in the form "0,1,2". This is required if --topics-to-move-json-file is used to g…
2015-07-02 20:37 · kafka · kafka
kafka topic命令
kafka topic可以定制执行brokerid和partition的topic,还有增加partition kafka topic Create, delete, describe, or change a topic. Option Description ------ ----------- --alter Alter the configuration for the topic. --config <name=value> A topic configuration override for the topic being created or altered.The follo…
2015-07-02 20:31 · kafka · 命令 · Topic · kafka
kafka replication tools
kafka工具 replication tool工作步骤(异步过程,执行完1就结束): 1.更新zk上的/admin/preferred_replica_election节点,内容为副本的几个位置(不包含已经奔溃的leader) 2.controller中的zk的listener读取topic partition的副本的几个位置 3.controller获取每个topic partition的副本的几个replica中的第一个,作为referred replica; 如果这个preferred replica不是leader且在isr中,则controller发出request到这个pref…
2015-07-01 17:20 · kafka · replication · kafka
kafka client端 producer
kafka producer客户端 KafkaProducer的send方法: 1.等待kafka要发送的topic的partition都在线 2.序列化key,value; key:org.apache.kafka.common.serialization.IntegerSerializer value:org.apache.kafka.common.serialization.StringSerializer 3.根据发送数据计算索要发送的topic的partition 使用record记录中的partition,若为空,用paritition类计算 partition:org.apac…
2015-06-19 14:57 · kafka · producer · kafka
kafka源码编译
git clone http://git-wip-us.apache.org/repos/asf/kafka.git D:\git\kafka https://kafka.apache.org/downloads.html 安装gradle 到kafka目录下 运行gradle wrapper,解决找不到类 If you just checked out the code, you don't have the gradle wrapper library and you'll get an error message after running `./gradlew`: "Error: C…
2015-06-06 14:11 · kafka · Eclipse · kafka
kafka获得最新partition offset
kafka获得partition下标,需要用到kafka的simpleconsumer import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.TreeMap; import java.util.Map.Entry; import kafka.api.Par…
2015-06-05 17:45 · kafka · partition · 最新 · offset · kafka
kafka参数转
转 http://damacheng009.iteye.com/blog/2087996 metadata.broker.list 默认值:无,必填 格式为host1:port1,host2:port2,这是一个broker列表,用于获得元数据(topics,partitions和replicas),建立起来的socket连接用于发送实际数据,这个列表可以是broker的一个子集,或者一个VIP,指向broker的一个子集。 request.required.acks 默认值:0 用来控制一个produce请求怎样才能算完成,准确的说,是有多少broker必须已经提交数据到log文件,并向l…
2015-06-05 17:41 · kafka · 参数 · kafka