@ -59,11 +59,11 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -59,11 +59,11 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
server1 . shutdown ( )
assertTrue ( verifyBrokerMetadata ( config1 . logDirs , 1001 ) )
// restart the server check to see if it uses the brokerId generated previously
server1 = TestUtils . createServer ( config1 )
server1 = TestUtils . createServer ( config1 , threadNamePrefix = Option ( this . getClass . getName ) )
servers = Seq ( server1 )
assertEquals ( server1 . config . brokerId , 1001 )
server1 . shutdown ( )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
@Test
@ -72,7 +72,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -72,7 +72,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
val server1 = new KafkaServer ( config1 , threadNamePrefix = Option ( this . getClass . getName ) )
val server2 = new KafkaServer ( config2 , threadNamePrefix = Option ( this . getClass . getName ) )
val props3 = TestUtils . createBrokerConfig ( - 1 , zkConnect )
val server3 = new KafkaServer ( KafkaConfig . fromProps ( props3 ) )
val server3 = new KafkaServer ( KafkaConfig . fromProps ( props3 ) , threadNamePrefix = Option ( this . getClass . getName ) )
server1 . startup ( )
assertEquals ( server1 . config . brokerId , 1001 )
server2 . startup ( )
@ -84,7 +84,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -84,7 +84,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
assertTrue ( verifyBrokerMetadata ( server1 . config . logDirs , 1001 ) )
assertTrue ( verifyBrokerMetadata ( server2 . config . logDirs , 0 ) )
assertTrue ( verifyBrokerMetadata ( server3 . config . logDirs , 1002 ) )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
@Test
@ -94,12 +94,12 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -94,12 +94,12 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
// Set reserve broker ids to cause collision and ensure disabling broker id generation ignores the setting
props3 . put ( KafkaConfig . MaxReservedBrokerIdProp , "0" )
val config3 = KafkaConfig . fromProps ( props3 )
val server3 = TestUtils . createServer ( config3 )
val server3 = TestUtils . createServer ( config3 , threadNamePrefix = Option ( this . getClass . getName ) )
servers = Seq ( server3 )
assertEquals ( server3 . config . brokerId , 3 )
server3 . shutdown ( )
assertTrue ( verifyBrokerMetadata ( server3 . config . logDirs , 3 ) )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
@Test
@ -123,7 +123,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -123,7 +123,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
servers = Seq ( server1 )
server1 . shutdown ( )
assertTrue ( verifyBrokerMetadata ( config1 . logDirs , 1001 ) )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
@Test
@ -140,7 +140,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -140,7 +140,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
case _ : kafka . common . InconsistentBrokerIdException => // success
}
server1 . shutdown ( )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
@Test
@ -148,12 +148,12 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -148,12 +148,12 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
// Start a good server
val propsA = TestUtils . createBrokerConfig ( 1 , zkConnect )
val configA = KafkaConfig . fromProps ( propsA )
val serverA = TestUtils . createServer ( configA )
val serverA = TestUtils . createServer ( configA , threadNamePrefix = Option ( this . getClass . getName ) )
// Start a server that collides on the broker id
val propsB = TestUtils . createBrokerConfig ( 1 , zkConnect )
val configB = KafkaConfig . fromProps ( propsB )
val serverB = new KafkaServer ( configB )
val serverB = new KafkaServer ( configB , threadNamePrefix = Option ( this . getClass . getName ) )
intercept [ NodeExistsException ] {
serverB . startup ( )
}
@ -168,7 +168,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -168,7 +168,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
// adjust the broker config and start again
propsB . setProperty ( KafkaConfig . BrokerIdProp , "2" )
val newConfigB = KafkaConfig . fromProps ( propsB )
val newServerB = TestUtils . createServer ( newConfigB )
val newServerB = TestUtils . createServer ( newConfigB , threadNamePrefix = Option ( this . getClass . getName ) )
servers = Seq ( serverA , newServerB )
serverA . shutdown ( )
@ -177,7 +177,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
@@ -177,7 +177,7 @@ class ServerGenerateBrokerIdTest extends ZooKeeperTestHarness {
// verify correct broker metadata was written
assertTrue ( verifyBrokerMetadata ( serverA . config . logDirs , 1 ) )
assertTrue ( verifyBrokerMetadata ( newServerB . config . logDirs , 2 ) )
TestUtils . verifyNonDaemonThreadsStatu s( this . getClass . getName )
TestUtils . assertNoNonDaemonThread s( this . getClass . getName )
}
def verifyBrokerMetadata ( logDirs : Seq [ String ] , brokerId : Int ) : Boolean = {