@@ -5,26 +5,55 @@ import org.apache.zookeeper.server.ServerCnxnFactory
5
5
6
6
import scala .reflect .io .Directory
7
7
8
+ /**
9
+ * Represents a running server with a method of stopping the instance.
10
+ */
8
11
sealed trait EmbeddedServer {
9
12
10
13
def stop (clearLogs : Boolean ): Unit
11
14
}
12
15
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
+ */
13
23
case class EmbeddedZ (factory : ServerCnxnFactory ,
14
24
logsDirs : Directory )(
15
25
implicit config : EmbeddedKafkaConfig ) extends EmbeddedServer {
16
26
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
+ */
17
32
override def stop (clearLogs : Boolean ) = {
18
33
factory.shutdown()
19
34
if (clearLogs) logsDirs.deleteRecursively()
20
35
}
21
36
}
22
37
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
+ */
23
46
case class EmbeddedK (factory : Option [EmbeddedZ ],
24
47
broker : KafkaServer ,
25
48
logsDirs : Directory )(
26
49
implicit config : EmbeddedKafkaConfig ) extends EmbeddedServer {
27
50
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
+ */
28
57
override def stop (clearLogs : Boolean ) = {
29
58
broker.shutdown()
30
59
broker.awaitShutdown()
0 commit comments