bump the version
[dmaap/messagerouter/msgrtr.git] / src / test / java / com / att / nsa / cambria / embed / KafkaLocal.java
1 /*-\r
2  * ============LICENSE_START=======================================================\r
3  * ONAP Policy Engine\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ============LICENSE_END=========================================================\r
19  */\r
20 \r
21 package com.att.nsa.cambria.embed;\r
22 \r
23 import java.io.IOException;\r
24 import java.util.Properties;\r
25 \r
26 import kafka.server.KafkaConfig;\r
27 import kafka.server.KafkaServerStartable;\r
28  \r
29  \r
30 public class KafkaLocal {\r
31  \r
32         public KafkaServerStartable kafka;\r
33         public ZooKeeperLocal zookeeper;\r
34         \r
35         public KafkaLocal(Properties kafkaProperties, Properties zkProperties) throws IOException, InterruptedException{\r
36                 KafkaConfig kafkaConfig = new KafkaConfig(kafkaProperties);\r
37                 \r
38                 //start local zookeeper\r
39                 System.out.println("starting local zookeeper...");\r
40                 zookeeper = new ZooKeeperLocal(zkProperties);\r
41                 System.out.println("done");\r
42                 \r
43                 //start local kafka broker\r
44                 kafka = new KafkaServerStartable(kafkaConfig);\r
45                 System.out.println("starting local kafka broker...");\r
46                 kafka.startup();\r
47                 System.out.println("done");\r
48         }\r
49         \r
50         \r
51         public void stop(){\r
52                 //stop kafka broker\r
53                 System.out.println("stopping kafka...");\r
54                 kafka.shutdown();\r
55                 System.out.println("done");\r
56         }\r
57         \r
58 }