[ 
https://issues.apache.org/jira/browse/KAFKA-1926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14362111#comment-14362111
 ] 

Jun Rao commented on KAFKA-1926:
--------------------------------

[~tongli], thanks the for patch. I made a pass of all methods in CoreUtils. I 
recommend that we do the following.

1. The following methods are general purpose and should be moved to 
o.a.k.common.utils.
readBytes
loadProps
stackTrace
daemonThread
newThread
croak

2. The following methods don't seem to be used and can be removed: 
daemonThread(runnable: Runnable)
newThread(runnable: Runnable, daemon: Boolean)
readUnsignedInt(buffer: ByteBuffer)
writetUnsignedInt(buffer: ByteBuffer, value: Long)
equal
groupby
notNull
nullOrEmpty
createFile
asString
readProps

3. readString(): The only non-test usage is in DefaultEventHandler. The usage 
is actually incorrect since the payload may not be convertible to a string. 
Instead of using readString(), we should just use message.message.toString. We 
should also change Message.toString to the same as in Record.toString. Then, we 
can move readString() to TestUtils.

4. hashCode(): The only place that it's used is in Broker. Broker is defined as 
a case class, which will do the right thing for equal() and hashCode(). So, we 
don't need to overwrite equal() and hashCode() there. After that, we can remove 
hashCode().

> Replace kafka.utils.Utils with o.a.k.common.utils.Utils
> -------------------------------------------------------
>
>                 Key: KAFKA-1926
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1926
>             Project: Kafka
>          Issue Type: Improvement
>    Affects Versions: 0.8.2.0
>            Reporter: Jay Kreps
>              Labels: newbie, patch
>         Attachments: KAFKA-1926.patch, KAFKA-1926.patch, KAFKA-1926.patch
>
>
> There is currently a lot of duplication between the Utils class in common and 
> the one in core.
> Our plan has been to deprecate duplicate code in the server and replace it 
> with the new common code.
> As such we should evaluate each method in the scala Utils and do one of the 
> following:
> 1. Migrate it to o.a.k.common.utils.Utils if it is a sensible general purpose 
> utility in active use that is not Kafka-specific. If we migrate it we should 
> really think about the API and make sure there is some test coverage. A few 
> things in there are kind of funky and we shouldn't just blindly copy them 
> over.
> 2. Create a new class ServerUtils or ScalaUtils in kafka.utils that will hold 
> any utilities that really need to make use of Scala features to be convenient.
> 3. Delete it if it is not used, or has a bad api.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to