Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public static Properties addDeserializerToConfig(Properties properties,
return newProperties;
}

ConsumerConfig(Map<? extends Object, ? extends Object> props) {
ConsumerConfig(Map<?, ?> props) {
super(CONFIG, props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Iterable<ConsumerRecord<K, V>> records(String topic) {
throw new IllegalArgumentException("Topic must be non-null.");
List<List<ConsumerRecord<K, V>>> recs = new ArrayList<List<ConsumerRecord<K, V>>>();
for (Map.Entry<TopicPartition, List<ConsumerRecord<K, V>>> entry : records.entrySet()) {
if (entry.getKey().equals(topic))
if (entry.getKey().topic().equals(topic))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch :)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intellij helped me. :) Once we eliminate all the existing issues, I would like to configure abide as part of the build (https://github.com/scala/scala-abide) so that they are prevented in the future.

recs.add(entry.getValue());
}
return new ConcatenatedIterable<K, V>(recs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static Properties addSerializerToConfig(Properties properties,
return newProperties;
}

ProducerConfig(Map<? extends Object, ? extends Object> props) {
ProducerConfig(Map<?, ?> props) {
super(CONFIG, props);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void clear() {

@Override
public String toString() {
StringBuilder b = new StringBuilder('{');
StringBuilder b = new StringBuilder("{");
for (int i = 0; i < this.hist.length - 1; i++) {
b.append(String.format("%.10f", binScheme.fromBin(i)));
b.append(':');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private SecurityProtocol(int id, String name) {
}

public static String getName(int id) {
return CODE_TO_SECURITY_PROTOCOL.get(id).name;
return CODE_TO_SECURITY_PROTOCOL.get((short) id).name;
}

public static List<String> getNames() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static class TestConfig extends AbstractConfig {
METRIC_REPORTER_CLASSES_DOC);
}

public TestConfig(Map<? extends Object, ? extends Object> props) {
public TestConfig(Map<?, ?> props) {
super(CONFIG, props);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void setup() {
new Field("struct", new Schema(new Field("field", Type.INT32))));
this.struct = new Struct(this.schema).set("int8", (byte) 1)
.set("int16", (short) 1)
.set("int32", (int) 1)
.set("int64", (long) 1)
.set("int32", 1)
.set("int64", 1L)
.set("string", "1")
.set("bytes", "1".getBytes())
.set("array", new Object[] {1});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public boolean fetchMore () throws IOException {
_response = _consumer.fetch(fetchRequest);
if(_response != null) {
_respIterator = new ArrayList<ByteBufferMessageSet>(){{
add((ByteBufferMessageSet) _response.messageSet(_request.getTopic(), _request.getPartition()));
add(_response.messageSet(_request.getTopic(), _request.getPartition()));
}}.iterator();
}
_requestTime += (System.currentTimeMillis() - tempTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object ReassignPartitionsCommand extends Logging {
}
val reassignPartitionsCommand = new ReassignPartitionsCommand(zkClient, partitionsToBeReassigned.toMap)
// before starting assignment, output the current replica assignment to facilitate rollback
val currentPartitionReplicaAssignment = ZkUtils.getReplicaAssignmentForTopics(zkClient, partitionsToBeReassigned.map(_._1.topic).toSeq)
val currentPartitionReplicaAssignment = ZkUtils.getReplicaAssignmentForTopics(zkClient, partitionsToBeReassigned.map(_._1.topic))
println("Current partition replica assignment\n\n%s\n\nSave this to use as the --reassignment-json-file option during rollback"
.format(ZkUtils.getPartitionReassignmentZkData(currentPartitionReplicaAssignment)))
// start the reassignment
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/admin/TopicCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object TopicCommand {
topics.foreach { topic =>
try {
if (Topic.InternalTopics.contains(topic)) {
throw new AdminOperationException("Topic %s is a kafka internal topic and is not allowed to be marked for deletion.".format(topic));
throw new AdminOperationException("Topic %s is a kafka internal topic and is not allowed to be marked for deletion.".format(topic))
} else {
ZkUtils.createPersistentPath(zkClient, ZkUtils.getDeleteTopicPath(topic))
println("Topic %s is marked for deletion.".format(topic))
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/kafka/api/ControlledShutdownRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ object ControlledShutdownRequest extends Logging {
}
}

case class ControlledShutdownRequest(val versionId: Short,
val correlationId: Int,
val brokerId: Int)
case class ControlledShutdownRequest(versionId: Short,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These class of changes are good. I am guessing that val in a case class is redundant due to the public visibility of the constructor arguments even without the val?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. val has no effect on the first constructor parameter list of case classes. The parameters will be publicly visible, will be exposed in pattern matching and will be used in hashCode, toString and equals. Note that this does not apply to parameters in subsequent parameter lists (e.g. c and d in case class Foo(a: Int, b: Int)(c: String, d: Double).

correlationId: Int,
brokerId: Int)
extends RequestOrResponse(Some(RequestKeys.ControlledShutdownKey)){

def this(correlationId: Int, brokerId: Int) =
Expand Down Expand Up @@ -74,4 +74,4 @@ case class ControlledShutdownRequest(val versionId: Short,
controlledShutdownRequest.append("; BrokerId: " + brokerId)
controlledShutdownRequest.toString()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ object ControlledShutdownResponse {
}


case class ControlledShutdownResponse(val correlationId: Int,
val errorCode: Short = ErrorMapping.NoError,
val partitionsRemaining: Set[TopicAndPartition])
case class ControlledShutdownResponse(correlationId: Int,
errorCode: Short = ErrorMapping.NoError,
partitionsRemaining: Set[TopicAndPartition])
extends RequestOrResponse() {
def sizeInBytes(): Int ={
var size =
Expand All @@ -68,4 +68,4 @@ case class ControlledShutdownResponse(val correlationId: Int,

override def describe(details: Boolean):String = { toString }

}
}
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/api/GenericRequestAndHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private[kafka] abstract class GenericRequestAndHeader(val versionId: Short,
2 /* version id */ +
4 /* correlation id */ +
(2 + clientId.length) /* client id */ +
body.sizeOf();
body.sizeOf()
}

override def toString(): String = {
Expand All @@ -52,4 +52,4 @@ private[kafka] abstract class GenericRequestAndHeader(val versionId: Short,
strBuffer.append("; Body: " + body.toString)
strBuffer.toString()
}
}
}
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/api/GenericResponseAndHeader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private[kafka] abstract class GenericResponseAndHeader(val correlationId: Int,

def sizeInBytes(): Int = {
4 /* correlation id */ +
body.sizeOf();
body.sizeOf()
}

override def toString(): String = {
Expand All @@ -43,4 +43,4 @@ private[kafka] abstract class GenericResponseAndHeader(val correlationId: Int,
strBuffer.append("; Body: " + body.toString)
strBuffer.toString()
}
}
}
6 changes: 3 additions & 3 deletions core/src/main/scala/kafka/api/LeaderAndIsrRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ object PartitionStateInfo {
}
}

case class PartitionStateInfo(val leaderIsrAndControllerEpoch: LeaderIsrAndControllerEpoch,
val allReplicas: Set[Int]) {
case class PartitionStateInfo(leaderIsrAndControllerEpoch: LeaderIsrAndControllerEpoch,
allReplicas: Set[Int]) {
def replicationFactor = allReplicas.size

def writeTo(buffer: ByteBuffer) {
Expand Down Expand Up @@ -200,4 +200,4 @@ case class LeaderAndIsrRequest (versionId: Short,
leaderAndIsrRequest.append(";PartitionState:" + partitionStateInfos.mkString(","))
leaderAndIsrRequest.toString()
}
}
}
8 changes: 4 additions & 4 deletions core/src/main/scala/kafka/api/StopReplicaResponse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ object StopReplicaResponse {
}


case class StopReplicaResponse(val correlationId: Int,
val responseMap: Map[TopicAndPartition, Short],
val errorCode: Short = ErrorMapping.NoError)
case class StopReplicaResponse(correlationId: Int,
responseMap: Map[TopicAndPartition, Short],
errorCode: Short = ErrorMapping.NoError)
extends RequestOrResponse() {
def sizeInBytes(): Int ={
var size =
Expand Down Expand Up @@ -72,4 +72,4 @@ case class StopReplicaResponse(val correlationId: Int,
}

override def describe(details: Boolean):String = { toString }
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/api/TopicMetadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ object PartitionMetadata {
}

case class PartitionMetadata(partitionId: Int,
val leader: Option[BrokerEndPoint],
leader: Option[BrokerEndPoint],
replicas: Seq[BrokerEndPoint],
isr: Seq[BrokerEndPoint] = Seq.empty,
errorCode: Short = ErrorMapping.NoError) extends Logging {
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/scala/kafka/api/TopicMetadataRequest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ object TopicMetadataRequest extends Logging {
}
}

case class TopicMetadataRequest(val versionId: Short,
val correlationId: Int,
val clientId: String,
val topics: Seq[String])
case class TopicMetadataRequest(versionId: Short,
correlationId: Int,
clientId: String,
topics: Seq[String])
extends RequestOrResponse(Some(RequestKeys.MetadataKey)){

def this(topics: Seq[String], correlationId: Int) =
Expand Down Expand Up @@ -93,4 +93,4 @@ case class TopicMetadataRequest(val versionId: Short,
topicMetadataRequest.append("; Topics: " + topics.mkString(","))
topicMetadataRequest.toString()
}
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/client/ClientUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object ClientUtils extends Logging{
} else {
debug("Successfully fetched metadata for %d topic(s) %s".format(topics.size, topics))
}
return topicMetadataResponse
topicMetadataResponse
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/cluster/EndPoint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ case class EndPoint(host: String, port: Int, protocolType: SecurityProtocol) {
def writeTo(buffer: ByteBuffer): Unit = {
buffer.putInt(port)
writeShortString(buffer, host)
buffer.putShort(protocolType.id.toShort)
buffer.putShort(protocolType.id)
}

def sizeInBytes: Int =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ class ControllerBrokerRequestBatch(controller: KafkaController) extends Logging
}
updateMetadataRequestMap.clear()
stopReplicaRequestMap foreach { case(broker, replicaInfoList) =>
val stopReplicaWithDelete = replicaInfoList.filter(p => p.deletePartition == true).map(i => i.replica).toSet
val stopReplicaWithoutDelete = replicaInfoList.filter(p => p.deletePartition == false).map(i => i.replica).toSet
val stopReplicaWithDelete = replicaInfoList.filter(_.deletePartition).map(_.replica).toSet
val stopReplicaWithoutDelete = replicaInfoList.filterNot(_.deletePartition).map(_.replica).toSet
debug("The stop replica request (delete = true) sent to broker %d is %s"
.format(broker, stopReplicaWithDelete.mkString(",")))
debug("The stop replica request (delete = false) sent to broker %d is %s"
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/controller/KafkaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ class KafkaController(val config : KafkaConfig, zkClient: ZkClient, val brokerSt
*/
def startup() = {
inLock(controllerContext.controllerLock) {
info("Controller starting up");
info("Controller starting up")
registerSessionExpirationListener()
isRunning = true
controllerElector.startup
Expand Down Expand Up @@ -1326,7 +1326,7 @@ case class PartitionAndReplica(topic: String, partition: Int, replica: Int) {
}
}

case class LeaderIsrAndControllerEpoch(val leaderAndIsr: LeaderAndIsr, controllerEpoch: Int) {
case class LeaderIsrAndControllerEpoch(leaderAndIsr: LeaderAndIsr, controllerEpoch: Int) {
override def toString(): String = {
val leaderAndIsrInfo = new StringBuilder
leaderAndIsrInfo.append("(Leader:" + leaderAndIsr.leader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ReplicaStateMachine(controller: KafkaController) extends Logging {
val replicasForTopic = controller.controllerContext.replicasForTopic(topic)
val replicaStatesForTopic = replicasForTopic.map(r => (r, replicaState(r))).toMap
debug("Are all replicas for topic %s deleted %s".format(topic, replicaStatesForTopic))
replicaStatesForTopic.foldLeft(true)((deletionState, r) => deletionState && r._2 == ReplicaDeletionSuccessful)
replicaStatesForTopic.forall(_._2 == ReplicaDeletionSuccessful)
}

def isAtLeastOneReplicaInDeletionStartedState(topic: String): Boolean = {
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/scala/kafka/coordinator/DelayedRebalance.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class DelayedRebalance(sessionTimeout: Long,

/* check if all known consumers have requested to re-join group */
override def tryComplete(): Boolean = {
allConsumersJoinedGroup.set(groupRegistry.memberRegistries.values.foldLeft
(true) ((agg, cur) => agg && cur.joinGroupReceived.get()))
allConsumersJoinedGroup.set(groupRegistry.memberRegistries.values.forall(_.joinGroupReceived.get()))

if (allConsumersJoinedGroup.get())
forceComplete()
Expand Down
5 changes: 0 additions & 5 deletions core/src/main/scala/kafka/javaapi/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@ private[javaapi] object Implicits extends Logging {
}
}

// used explicitly by ByteBufferMessageSet constructor as due to SI-4141 which affects Scala 2.8.1, implicits are not visible in constructors
implicit def javaListToScalaBuffer[A](l: java.util.List[A]) = {
import scala.collection.JavaConversions._
l: collection.mutable.Buffer[A]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ package kafka.javaapi.message
import java.util.concurrent.atomic.AtomicLong
import java.nio.ByteBuffer
import kafka.message._
import kafka.javaapi.Implicits.javaListToScalaBuffer

import scala.collection.JavaConverters._

class ByteBufferMessageSet(val buffer: ByteBuffer) extends MessageSet {
private val underlying: kafka.message.ByteBufferMessageSet = new kafka.message.ByteBufferMessageSet(buffer)

def this(compressionCodec: CompressionCodec, messages: java.util.List[Message]) {
// due to SI-4141 which affects Scala 2.8.1, implicits are not visible in constructors and must be used explicitly
this(new kafka.message.ByteBufferMessageSet(compressionCodec, new AtomicLong(0), javaListToScalaBuffer(messages).toSeq : _*).buffer)
this(new kafka.message.ByteBufferMessageSet(compressionCodec, new AtomicLong(0), messages.asScala: _*).buffer)
}

def this(messages: java.util.List[Message]) {
Expand Down
20 changes: 10 additions & 10 deletions core/src/main/scala/kafka/log/CleanerConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ package kafka.log
* @param enableCleaner Allows completely disabling the log cleaner
* @param hashAlgorithm The hash algorithm to use in key comparison.
*/
case class CleanerConfig(val numThreads: Int = 1,
val dedupeBufferSize: Long = 4*1024*1024L,
val dedupeBufferLoadFactor: Double = 0.9d,
val ioBufferSize: Int = 1024*1024,
val maxMessageSize: Int = 32*1024*1024,
val maxIoBytesPerSecond: Double = Double.MaxValue,
val backOffMs: Long = 15 * 1000,
val enableCleaner: Boolean = true,
val hashAlgorithm: String = "MD5") {
}
case class CleanerConfig(numThreads: Int = 1,
dedupeBufferSize: Long = 4*1024*1024L,
dedupeBufferLoadFactor: Double = 0.9d,
ioBufferSize: Int = 1024*1024,
maxMessageSize: Int = 32*1024*1024,
maxIoBytesPerSecond: Double = Double.MaxValue,
backOffMs: Long = 15 * 1000,
enableCleaner: Boolean = true,
hashAlgorithm: String = "MD5") {
}
4 changes: 2 additions & 2 deletions core/src/main/scala/kafka/log/LogCleaner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class LogCleaner(val config: CleanerConfig,
time: Time = SystemTime) extends Logging with KafkaMetricsGroup {

/* for managing the state of partitions being cleaned. package-private to allow access in tests */
private[log] val cleanerManager = new LogCleanerManager(logDirs, logs);
private[log] val cleanerManager = new LogCleanerManager(logDirs, logs)

/* a throttle used to limit the I/O of all the cleaner threads to a user-specified maximum rate */
private val throttler = new Throttler(desiredRatePerSec = config.maxIoBytesPerSecond,
Expand Down Expand Up @@ -622,4 +622,4 @@ private case class LogToClean(topicPartition: TopicAndPartition, log: Log, first
val cleanableRatio = dirtyBytes / totalBytes.toDouble
def totalBytes = cleanBytes + dirtyBytes
override def compare(that: LogToClean): Int = math.signum(this.cleanableRatio - that.cleanableRatio).toInt
}
}
Loading