Skip to content

Commit

Permalink
Merge pull request #169 from pfischermx/master
Browse files Browse the repository at this point in the history
Allow consumer configs to set the numWorkers and use full set of byte slices to check the partition number (for fixedpartiioner)
  • Loading branch information
serejja committed Nov 25, 2015
2 parents f8e0846 + d19056c commit 33e781a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mirror_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ func (this *MirrorMaker) startConsumers() {
if err != nil {
panic(err)
}
config.NumWorkers = 1
//Let the NumWorkers be set via consumer configs
//config.NumWorkers = 1
config.AutoOffsetReset = SmallestOffset
config.Coordinator = NewZookeeperCoordinator(zkConfig)
config.WorkerFailureCallback = func(_ *WorkerManager) FailedDecision {
Expand Down
9 changes: 6 additions & 3 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ func (this *FixedPartitioner) Partition(key []byte, numPartitions int32) (int32,
if key == nil {
panic("FixedPartitioner does not work without keys.")
}
partition, err := binary.ReadUvarint(bytes.NewBuffer(key))
if err != nil {
return -1, err

var partition int32
buf := bytes.NewBuffer(key)
binary.Read(buf, binary.LittleEndian, &partition)
if (partition < 0) {
return -1, errors.New("Partition turned to be -1 (too big to be int32 little endian?)")
}

return int32(partition) % numPartitions, nil
Expand Down

0 comments on commit 33e781a

Please sign in to comment.