8f189b3b16278d926c73f0ed4ccc327ec1a2082c
[dmaap/messagerouter/mirroragent.git] / src / main / java / com / att / nsa / dmaapMMAgent / MirrorMakerAgent.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  *  ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22
23 package com.att.nsa.dmaapMMAgent;
24
25 import java.io.BufferedReader;
26 import java.io.DataOutputStream;
27 import java.io.File;
28 import java.io.FileInputStream;
29 import java.io.FileOutputStream;
30 import java.io.IOException;
31 import java.io.InputStream;
32 import java.io.InputStreamReader;
33 import java.io.OutputStream;
34 import java.net.HttpURLConnection;
35 import java.net.URL;
36 import java.util.ArrayList;
37 import java.util.Properties;
38
39 import org.apache.log4j.Level;
40 import org.apache.log4j.Logger;
41 import org.jasypt.util.text.BasicTextEncryptor;
42
43 import com.att.nsa.dmaapMMAgent.dao.CreateMirrorMaker;
44 import com.att.nsa.dmaapMMAgent.dao.DeleteMirrorMaker;
45 import com.att.nsa.dmaapMMAgent.dao.ListMirrorMaker;
46 import com.att.nsa.dmaapMMAgent.dao.MirrorMaker;
47 import com.att.nsa.dmaapMMAgent.dao.UpdateMirrorMaker;
48 import com.att.nsa.dmaapMMAgent.dao.UpdateWhiteList;
49 import com.att.nsa.dmaapMMAgent.utils.MirrorMakerProcessHandler;
50 import com.google.gson.Gson;
51 import com.google.gson.internal.LinkedTreeMap;
52 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
53 import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
54
55 public class MirrorMakerAgent {
56         static final Logger logger = Logger.getLogger(MirrorMakerAgent.class);
57         Properties mirrorMakerProperties = new Properties();
58         ListMirrorMaker mirrorMakers = null;
59         String mmagenthome = "";
60         String kafkahome = "";
61         String topicURL = "";
62         String topicname = "";
63         String mechid = "";
64         String password = "";
65         private static String secret = "utdfpWlgyDQ2ZB8SLVRtmN834I1JcT9J";
66
67         public static void main(String[] args) {
68                 if (args != null && args.length == 2) {
69                         if (args[0].equals("-encrypt")) {
70                                 BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
71                                 textEncryptor.setPassword(secret);
72                                 String plainText = textEncryptor.encrypt(args[1]);
73                                 System.out.println("Encrypted Password is :" + plainText);
74                                 return;
75                         }
76                 } else if (args != null && args.length > 0) {
77                         System.out.println(
78                                         "Usage: ./mmagent to run with the configuration \n -encrypt <password> to Encrypt Password for config ");
79                         return;
80                 }
81                 MirrorMakerAgent agent = new MirrorMakerAgent();
82                 if (agent.checkStartup()) {
83                         logger.info("mmagent started, loading properties");
84                         agent.checkAgentProcess();
85                         agent.readAgentTopic();
86                 } else {
87                         System.out.println(
88                                         "ERROR: mmagent startup unsuccessful, please make sure the mmagenthome /etc/mmagent.config is set and mechid have the rights to the topic");
89                 }
90         }
91
92         private boolean checkStartup() {
93                 FileInputStream input = null;
94                 try {
95                         this.mmagenthome = System.getProperty("MMAGENTHOME");
96                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
97                         logger.info("mmagenthome is set :" + mmagenthome + " loading properties at /etc/mmagent.config");
98                 } catch (IOException ex) {
99                         logger.error(mmagenthome + "/etc/mmagent.config not found.  Set -DMMAGENTHOME and check the config file" + ex);
100                         return false;
101                 } finally {
102                         if (input != null) {
103                                 try {
104                                         input.close();
105                                 } catch (IOException e) {
106                                         logger.error(" IOException occers " + e);
107                                 }
108                         }
109                 }
110                 loadProperties();
111                 input = null;
112                 try {
113                         /*input = new FileInputStream(kafkahome + "/bin/kafka-run-class.sh");*/
114                         if(false) {
115                                 throw new IOException();
116                         }
117                         logger.info("kakahome is set :" + kafkahome);
118                 } catch (IOException ex) {
119                         logger.error(kafkahome + "/bin/kafka-run-class.sh not found.  Make sure kafka home is set correctly" + ex);
120                         return false;
121                 } finally {
122                         if (input != null) {
123                                 try {
124                                         input.close();
125                                 } catch (IOException e) {
126                                         logger.error("IOException" + e);
127                                 }
128                         }
129                 }
130                 String response = publishTopic("{\"test\":\"test\"}");
131                 if (response.startsWith("ERROR:")) {
132                         logger.error("Problem publishing to topic, please verify the config " + this.topicname + " MR URL is:"
133                                         + this.topicURL + " Error is:  " + response);
134                         return false;
135                 }
136                 logger.info("Published to Topic :" + this.topicname + " Successfully");
137                 response = subscribeTopic("1");
138                 if (response != null && response.startsWith("ERROR:")) {
139                         logger.error("Problem subscribing to topic, please verify the config " + this.topicname + " MR URL is:"
140                                         + this.topicURL + " Error is:  " + response);
141                         return false;
142                 }
143                 logger.info("Subscribed to Topic :" + this.topicname + " Successfully");
144                 return true;
145         }
146
147         private void checkPropertiesFile(String agentName, String propName, String info, boolean refresh) {
148                 InputStream input = null;
149                 OutputStream out = null;
150                 try {
151                         if (refresh) {
152                                 throw new IOException();
153                         }
154                         input = new FileInputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
155                 } catch (IOException ex) {
156                         logger.error(" IOException will be handled " + ex);
157                         try {
158                                 input = new FileInputStream(mmagenthome + "/etc/" + propName + ".properties");
159                                 Properties prop = new Properties();
160                                 prop.load(input);
161                                 if (propName.equals("consumer")) {
162                                         prop.setProperty("group.id", agentName);
163                                         prop.setProperty("zookeeper.connect", info);
164                                 } else {
165                                         prop.setProperty("metadata.broker.list", info);
166                                 }
167                                 out = new FileOutputStream(mmagenthome + "/etc/" + agentName + propName + ".properties");
168                                 prop.store(out, "");
169
170                         } catch (Exception e) {
171                                 logger.error("Exception at checkPropertiesFile " +e);
172                         }
173                 } finally {
174                         if (input != null) {
175                                 try {
176                                         input.close();
177                                 } catch (IOException e) {
178                                         e.printStackTrace();
179                                 }
180                         }
181                         if (out != null) {
182                                 try {
183                                         out.close();
184                                 } catch (IOException e) {
185                                         e.printStackTrace();
186                                         logger.error("IOException" + e);
187                                 }
188                         }
189                 }
190         }
191
192         private void checkAgentProcess() {
193                 logger.info("Checking MirrorMaker Process");
194                 if (mirrorMakers != null) {
195                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
196                         for (int i = 0; i < mirrorMakersCount; i++) {
197                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
198                                 if (MirrorMakerProcessHandler.checkMirrorMakerProcess(mm.name) == false) {
199                                         checkPropertiesFile(mm.name, "consumer", mm.consumer, false);
200                                         checkPropertiesFile(mm.name, "producer", mm.producer, false);
201
202                                         if (mm.whitelist != null && !mm.whitelist.equals("")) {
203                                                 logger.info("MirrorMaker " + mm.name + " is not running, restarting.  Check Logs for more Details");
204                                                 MirrorMakerProcessHandler.startMirrorMaker(this.mmagenthome, this.kafkahome, mm.name,
205                                                                 mmagenthome + "/etc/" + mm.name + "consumer.properties",
206                                                                 mmagenthome + "/etc/" + mm.name + "producer.properties", mm.whitelist);
207                                                 mm.setStatus("RESTARTING");
208
209                                         } else {
210                                                 logger.info("MirrorMaker " + mm.name + " is STOPPED");
211                                                 mm.setStatus("STOPPED");
212                                         }
213                                         try {
214                                                 Thread.sleep(1000);
215                                         } catch (InterruptedException e) {
216                                         }
217                                         mirrorMakers.getListMirrorMaker().set(i, mm);
218                                 } else {
219                                         logger.info("MirrorMaker " + mm.name + " is running");
220                                         mm.setStatus("RUNNING");
221                                         mirrorMakers.getListMirrorMaker().set(i, mm);
222                                 }
223                         }
224                 }
225                 // Gson g = new Gson();
226                 // System.out.println(g.toJson(mirrorMakers));
227         }
228
229         private String subscribeTopic(String timeout) {
230                 String response = "";
231                 try {
232                         String requestURL = this.topicURL + "/events/" + this.topicname + "/mirrormakeragent/1?timeout=" + timeout
233                                         + "&limit=1";
234                         String authString = this.mechid + ":" + this.password;
235                         String authStringEnc = Base64.encode(authString.getBytes());
236                         URL url = new URL(requestURL);
237                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
238                         connection.setRequestMethod("GET");
239                         connection.setDoOutput(true);
240                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
241                         connection.setRequestProperty("Content-Type", "application/json");
242                         InputStream content = (InputStream) connection.getInputStream();
243                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
244                         String line;
245
246                         while ((line = in.readLine()) != null) {
247                                 response = response + line;
248                         }
249                         Gson g = new Gson();
250                         // get message as JSON String Array
251                         String[] topicMessage = g.fromJson(response, String[].class);
252                         if (topicMessage.length != 0) {
253                                 return topicMessage[0];
254                         }
255                 } catch (Exception e) {
256                         return "ERROR:" + e.getMessage() + " Server Response is:" + response;
257                 }
258                 return null;
259         }
260
261         private String publishTopic(String message) {
262                 try {
263                         String requestURL = this.topicURL + "/events/" + this.topicname;
264                         String authString = this.mechid + ":" + this.password;
265                         String authStringEnc = Base64.encode(authString.getBytes());
266                         URL url = new URL(requestURL);
267                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
268                         connection.setRequestMethod("POST");
269                         connection.setDoOutput(true);
270                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
271                         connection.setRequestProperty("Content-Type", "application/json");
272                         connection.setRequestProperty("Content-Length", Integer.toString(message.length()));
273                         DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
274                         wr.write(message.getBytes());
275
276                         InputStream content = (InputStream) connection.getInputStream();
277                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
278                         String line;
279                         String response = "";
280                         while ((line = in.readLine()) != null) {
281                                 response = response + line;
282                         }
283                         return response;
284
285                 } catch (Exception e) {
286                         return "ERROR:" + e.getLocalizedMessage();
287                 }
288         }
289
290         private void readAgentTopic() {
291                 try {
292                         int connectionattempt = 0;
293                         while (true) {
294                                 logger.info("--------------------------------");
295                                 logger.info("Waiting for Messages for 60 secs");
296                                 String topicMessage = subscribeTopic("60000");
297                                 Gson g = new Gson();
298                                 LinkedTreeMap<?, ?> object = null;
299                                 if (topicMessage != null) {
300                                         try {
301                                                 object = g.fromJson(topicMessage, LinkedTreeMap.class);
302
303                                                 // Cast the 1st item (since limit=1 and see the type of
304                                                 // object
305                                                 if (object.get("createMirrorMaker") != null) {
306                                                         logger.info("Received createMirrorMaker request from topic");
307                                                         CreateMirrorMaker m = g.fromJson(topicMessage, CreateMirrorMaker.class);
308                                                         createMirrorMaker(m.getCreateMirrorMaker());
309                                                         checkAgentProcess();
310                                                         mirrorMakers.setMessageID(m.getMessageID());
311                                                         publishTopic(g.toJson(mirrorMakers));
312                                                         mirrorMakers.setMessageID("");
313                                                 } else if (object.get("updateMirrorMaker") != null) {
314                                                         logger.info("Received updateMirrorMaker request from topic");
315                                                         UpdateMirrorMaker m = g.fromJson(topicMessage, UpdateMirrorMaker.class);
316                                                         updateMirrorMaker(m.getUpdateMirrorMaker());
317                                                         checkAgentProcess();
318                                                         mirrorMakers.setMessageID(m.getMessageID());
319                                                         publishTopic(g.toJson(mirrorMakers));
320                                                         mirrorMakers.setMessageID("");
321                                                 } else if (object.get("deleteMirrorMaker") != null) {
322                                                         logger.info("Received deleteMirrorMaker request from topic");
323                                                         DeleteMirrorMaker m = g.fromJson(topicMessage, DeleteMirrorMaker.class);
324                                                         deleteMirrorMaker(m.getDeleteMirrorMaker());
325                                                         checkAgentProcess();
326                                                         mirrorMakers.setMessageID(m.getMessageID());
327                                                         publishTopic(g.toJson(mirrorMakers));
328                                                         mirrorMakers.setMessageID("");
329                                                 } else if (object.get("listAllMirrorMaker") != null) {
330                                                         logger.info("Received listALLMirrorMaker request from topic");
331                                                         checkAgentProcess();
332                                                         mirrorMakers.setMessageID((String) object.get("messageID"));
333                                                         publishTopic(g.toJson(mirrorMakers));
334                                                         mirrorMakers.setMessageID("");
335                                                 } else if (object.get("updateWhiteList") != null) {
336                                                         logger.info("Received updateWhiteList request from topic");
337                                                         UpdateWhiteList m = g.fromJson(topicMessage, UpdateWhiteList.class);
338                                                         updateWhiteList(m.getUpdateWhiteList());
339                                                         checkAgentProcess();
340                                                         mirrorMakers.setMessageID(m.getMessageID());
341                                                         publishTopic(g.toJson(mirrorMakers));
342                                                         mirrorMakers.setMessageID("");
343                                                 } else if (object.get("listMirrorMaker") != null) {
344                                                         logger.info("Received listMirrorMaker from topic, skipping messages");
345                                                 } else {
346                                                         logger.info("Received unknown request from topic");
347                                                 }
348                                         } catch (Exception ex) {
349                                                 connectionattempt++;
350                                                 if (connectionattempt > 5) {
351                                                         logger.info("Can't connect to the topic, mmagent shutting down , " + topicMessage);
352                                                         return;
353                                                 }
354                                                 logger.info("Can't connect to the topic, " + topicMessage + " Retrying " + connectionattempt
355                                                                 + " of 5 times in 1 minute" + " Error:" + ex.getLocalizedMessage());
356                                                 Thread.sleep(60000);
357                                         }
358                                 } else {
359                                         // Check all MirrorMaker every min
360                                         connectionattempt = 0;
361                                         checkAgentProcess();
362                                 }
363
364                         }
365                 } catch (Exception e) {
366                         e.printStackTrace();
367                 }
368
369         }
370
371         protected void createMirrorMaker(MirrorMaker newMirrorMaker) {
372                 boolean exists = false;
373                 if (mirrorMakers != null) {
374                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
375                         for (int i = 0; i < mirrorMakersCount; i++) {
376                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
377                                 if (mm.name.equals(newMirrorMaker.name)) {
378                                         exists = true;
379                                         logger.info("MirrorMaker already exist for:" + newMirrorMaker.name);
380                                         return;
381                                 }
382                         }
383                 }
384                 logger.info("Adding new MirrorMaker:" + newMirrorMaker.name);
385                 if (exists == false && mirrorMakers != null) {
386                         mirrorMakers.getListMirrorMaker().add(newMirrorMaker);
387                 } else if (exists == false && mirrorMakers == null) {
388                         mirrorMakers = new ListMirrorMaker();
389                         ArrayList<MirrorMaker> list = mirrorMakers.getListMirrorMaker();
390                         list = new ArrayList<MirrorMaker>();
391                         list.add(newMirrorMaker);
392                         mirrorMakers.setListMirrorMaker(list);
393                 }
394                 checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
395                 checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
396
397                 Gson g = new Gson();
398                 mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
399                 OutputStream out = null;
400                 try {
401                         out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
402                         mirrorMakerProperties.store(out, "");
403                 } catch (IOException ex) {
404                         ex.printStackTrace();
405                 } finally {
406                         if (out != null) {
407                                 try {
408                                         out.close();
409                                 } catch (IOException e) {
410                                         e.printStackTrace();
411                                 }
412                         }
413                 }
414         }
415
416         private void updateMirrorMaker(MirrorMaker newMirrorMaker) {
417                 boolean exists = false;
418                 if (mirrorMakers != null) {
419                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
420                         for (int i = 0; i < mirrorMakersCount; i++) {
421                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
422                                 if (mm.name.equals(newMirrorMaker.name)) {
423                                         exists = true;
424                                         mm.setConsumer(newMirrorMaker.getConsumer());
425                                         mm.setProducer(newMirrorMaker.getProducer());
426                                         mirrorMakers.getListMirrorMaker().set(i, mm);
427                                         logger.info("Updating MirrorMaker:" + newMirrorMaker.name);
428                                 }
429                         }
430                 }
431                 if (exists) {
432                         checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
433                         checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
434
435                         Gson g = new Gson();
436                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
437                         OutputStream out = null;
438                         try {
439                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
440                                 mirrorMakerProperties.store(out, "");
441                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
442                                 try {
443                                         Thread.sleep(1000);
444                                 } catch (InterruptedException e) {
445                                         logger.log(Level.WARN, "Interrupted!", e);
446                                         Thread.currentThread().interrupt();
447                                 }
448                         } catch (IOException ex) {
449                                 ex.printStackTrace();
450                         } finally {
451                                 if (out != null) {
452                                         try {
453                                                 out.close();
454                                         } catch (IOException e) {
455                                                 e.printStackTrace();
456                                         }
457                                 }
458                         }
459                 } else {
460                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
461                 }
462         }
463
464         private void updateWhiteList(MirrorMaker newMirrorMaker) {
465                 boolean exists = false;
466                 if (mirrorMakers != null) {
467                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
468                         for (int i = 0; i < mirrorMakersCount; i++) {
469                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
470                                 if (mm.name.equals(newMirrorMaker.name)) {
471                                         exists = true;
472                                         mm.setWhitelist(newMirrorMaker.whitelist);
473                                         mirrorMakers.getListMirrorMaker().set(i, mm);
474                                         logger.info("Updating MirrorMaker WhiteList:" + newMirrorMaker.name + " WhiteList:"
475                                                         + newMirrorMaker.whitelist);
476                                 }
477                         }
478                 }
479                 if (exists) {
480                         Gson g = new Gson();
481                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
482                         OutputStream out = null;
483                         try {
484                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
485                                 mirrorMakerProperties.store(out, "");
486                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
487                                 try {
488                                         Thread.sleep(1000);
489                                 } catch (InterruptedException e) {
490                                 }
491                         } catch (IOException ex) {
492                                 ex.printStackTrace();
493                         } finally {
494                                 if (out != null) {
495                                         try {
496                                                 out.close();
497                                         } catch (IOException e) {
498                                                 e.printStackTrace();
499                                                 logger.error("IOException occered " + e);
500                                         }
501                                 }
502                         }
503                 } else {
504                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
505                 }
506         }
507
508         private void deleteMirrorMaker(MirrorMaker newMirrorMaker) {
509                 boolean exists = false;
510                 if (mirrorMakers != null) {
511                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
512                         for (int i = 0; i < mirrorMakersCount; i++) {
513                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
514                                 if (mm.name.equals(newMirrorMaker.name)) {
515                                         exists = true;
516                                         mirrorMakers.getListMirrorMaker().remove(i);
517                                         logger.info("Removing MirrorMaker:" + newMirrorMaker.name);
518                                         i = mirrorMakersCount;
519                                 }
520                         }
521                 }
522                 if (exists) {
523                         try {
524                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "consumer" + ".properties";
525                                 File file = new File(path);
526                                 file.delete();
527                         } catch (Exception ex) {
528                         }
529                         try {
530                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
531                                 File file = new File(path);
532                                 file.delete();
533                         } catch (Exception ex) {
534                         }
535                         Gson g = new Gson();
536                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
537                         OutputStream out = null;
538                         try {
539                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
540                                 mirrorMakerProperties.store(out, "");
541                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
542                         } catch (IOException ex) {
543                                 ex.printStackTrace();
544                         } finally {
545                                 if (out != null) {
546                                         try {
547                                                 out.close();
548                                         } catch (IOException e) {
549                                                 e.printStackTrace();
550                                         }
551                                 }
552                         }
553                 } else {
554                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
555                 }
556         }
557
558         private void loadProperties() {
559                 InputStream input = null;
560                 try {
561
562                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
563                         mirrorMakerProperties.load(input);
564                         Gson g = new Gson();
565                         if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
566                                 this.mirrorMakers = new ListMirrorMaker();
567                                 ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
568                                 list = new ArrayList<MirrorMaker>();
569                                 this.mirrorMakers.setListMirrorMaker(list);
570                         } else {
571                                 this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
572                                                 ListMirrorMaker.class);
573                         }
574
575                         this.kafkahome = mirrorMakerProperties.getProperty("kafkahome");
576                         this.topicURL = mirrorMakerProperties.getProperty("topicURL");
577                         this.topicname = mirrorMakerProperties.getProperty("topicname");
578                         this.mechid = mirrorMakerProperties.getProperty("mechid");
579
580                         BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
581                         textEncryptor.setPassword(secret);
582                         //this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
583                         this.password = mirrorMakerProperties.getProperty("password");
584                 } catch (IOException ex) {
585                         // ex.printStackTrace();
586                 } finally {
587                         if (input != null) {
588                                 try {
589                                         input.close();
590                                 } catch (IOException e) {
591                                         // e.printStackTrace();
592                                 }
593                         }
594                 }
595
596         }
597 }

© 2017 ONAP. Copyright © The Linux Foundation ®. All Rights Reserved.
The Linux Foundation has registered trademarks and uses trademarks.
For a list of trademarks of The Linux Foundation, please see our Trademark Usage page.
Linux is a registered trademark of Linus Torvalds.
Privacy Policy and Terms of Use