Skip to content

Commit 0dc4ea7

Browse files
author
Thomas Heslin
committed
Added javadoc to EmbeddedServer.scala
1 parent d4272de commit 0dc4ea7

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

embedded-kafka/src/main/scala/net/manub/embeddedkafka/EmbeddedServer.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,55 @@ import org.apache.zookeeper.server.ServerCnxnFactory
55

66
import scala.reflect.io.Directory
77

8+
/**
9+
* Represents a running server with a method of stopping the instance.
10+
*/
811
sealed trait EmbeddedServer {
912

1013
def stop(clearLogs: Boolean): Unit
1114
}
1215

16+
/**
17+
* An instance of an embedded Zookeeper server.
18+
*
19+
* @param factory the server.
20+
* @param logsDirs the [[Directory]] logs are to be written to.
21+
* @param config the [[EmbeddedKafkaConfig]] used to start the factory.
22+
*/
1323
case class EmbeddedZ(factory: ServerCnxnFactory,
1424
logsDirs: Directory)(
1525
implicit config: EmbeddedKafkaConfig) extends EmbeddedServer {
1626

27+
/**
28+
* Shuts down the factory and then optionally deletes the log directory.
29+
*
30+
* @param clearLogs pass `true` to recursively delete the log directory.
31+
*/
1732
override def stop(clearLogs: Boolean) = {
1833
factory.shutdown()
1934
if (clearLogs) logsDirs.deleteRecursively()
2035
}
2136
}
2237

38+
/**
39+
* An instance of an embedded Kafka serer.
40+
*
41+
* @param factory the optional [[EmbeddedZ]] server which Kafka relies upon.
42+
* @param broker the Kafka server.
43+
* @param logsDirs the [[Directory]] logs are to be written to.
44+
* @param config the [[EmbeddedKafkaConfig]] used to start the broker.
45+
*/
2346
case class EmbeddedK(factory: Option[EmbeddedZ],
2447
broker: KafkaServer,
2548
logsDirs: Directory)(
2649
implicit config: EmbeddedKafkaConfig) extends EmbeddedServer {
2750

51+
/**
52+
* Shuts down the broker and the factory it relies upon, if defined.
53+
* Optionally deletes the log directory.
54+
*
55+
* @param clearLogs pass `true` to recursively delete the log directory.
56+
*/
2857
override def stop(clearLogs: Boolean) = {
2958
broker.shutdown()
3059
broker.awaitShutdown()

0 commit comments

Comments
 (0)