Merge changes I38dad052,Ibc26d865
[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                                         logger.error("Exception occurred is " +e);
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                                                  Thread.currentThread().interrupt();
217                                         }
218                                         mirrorMakers.getListMirrorMaker().set(i, mm);
219                                 } else {
220                                         logger.info("MirrorMaker " + mm.name + " is running");
221                                         mm.setStatus("RUNNING");
222                                         mirrorMakers.getListMirrorMaker().set(i, mm);
223                                 }
224                         }
225                 }
226                 // Gson g = new Gson();
227                 // System.out.println(g.toJson(mirrorMakers));
228         }
229
230         private String subscribeTopic(String timeout) {
231                 String response = "";
232                 try {
233                         String requestURL = this.topicURL + "/events/" + this.topicname + "/mirrormakeragent/1?timeout=" + timeout
234                                         + "&limit=1";
235                         String authString = this.mechid + ":" + this.password;
236                         String authStringEnc = Base64.encode(authString.getBytes());
237                         URL url = new URL(requestURL);
238                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
239                         connection.setRequestMethod("GET");
240                         connection.setDoOutput(true);
241                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
242                         connection.setRequestProperty("Content-Type", "application/json");
243                         InputStream content = (InputStream) connection.getInputStream();
244                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
245                         String line;
246
247                         while ((line = in.readLine()) != null) {
248                                 response = response + line;
249                         }
250                         Gson g = new Gson();
251                         // get message as JSON String Array
252                         String[] topicMessage = g.fromJson(response, String[].class);
253                         if (topicMessage.length != 0) {
254                                 return topicMessage[0];
255                         }
256                 } catch (Exception e) {
257                         return "ERROR:" + e.getMessage() + " Server Response is:" + response;
258                 }
259                 return null;
260         }
261
262         private String publishTopic(String message) {
263                 try {
264                         String requestURL = this.topicURL + "/events/" + this.topicname;
265                         String authString = this.mechid + ":" + this.password;
266                         String authStringEnc = Base64.encode(authString.getBytes());
267                         URL url = new URL(requestURL);
268                         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
269                         connection.setRequestMethod("POST");
270                         connection.setDoOutput(true);
271                         connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
272                         connection.setRequestProperty("Content-Type", "application/json");
273                         connection.setRequestProperty("Content-Length", Integer.toString(message.length()));
274                         DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
275                         wr.write(message.getBytes());
276
277                         InputStream content = (InputStream) connection.getInputStream();
278                         BufferedReader in = new BufferedReader(new InputStreamReader(content));
279                         String line;
280                         String response = "";
281                         while ((line = in.readLine()) != null) {
282                                 response = response + line;
283                         }
284                         return response;
285
286                 } catch (Exception e) {
287                         return "ERROR:" + e.getLocalizedMessage();
288                 }
289         }
290
291         private void readAgentTopic() {
292                 try {
293                         int connectionattempt = 0;
294                         while (true) {
295                                 logger.info("--------------------------------");
296                                 logger.info("Waiting for Messages for 60 secs");
297                                 String topicMessage = subscribeTopic("60000");
298                                 Gson g = new Gson();
299                                 LinkedTreeMap<?, ?> object = null;
300                                 if (topicMessage != null) {
301                                         try {
302                                                 object = g.fromJson(topicMessage, LinkedTreeMap.class);
303
304                                                 // Cast the 1st item (since limit=1 and see the type of
305                                                 // object
306                                                 if (object.get("createMirrorMaker") != null) {
307                                                         logger.info("Received createMirrorMaker request from topic");
308                                                         CreateMirrorMaker m = g.fromJson(topicMessage, CreateMirrorMaker.class);
309                                                         createMirrorMaker(m.getCreateMirrorMaker());
310                                                         checkAgentProcess();
311                                                         mirrorMakers.setMessageID(m.getMessageID());
312                                                         publishTopic(g.toJson(mirrorMakers));
313                                                         mirrorMakers.setMessageID("");
314                                                 } else if (object.get("updateMirrorMaker") != null) {
315                                                         logger.info("Received updateMirrorMaker request from topic");
316                                                         UpdateMirrorMaker m = g.fromJson(topicMessage, UpdateMirrorMaker.class);
317                                                         updateMirrorMaker(m.getUpdateMirrorMaker());
318                                                         checkAgentProcess();
319                                                         mirrorMakers.setMessageID(m.getMessageID());
320                                                         publishTopic(g.toJson(mirrorMakers));
321                                                         mirrorMakers.setMessageID("");
322                                                 } else if (object.get("deleteMirrorMaker") != null) {
323                                                         logger.info("Received deleteMirrorMaker request from topic");
324                                                         DeleteMirrorMaker m = g.fromJson(topicMessage, DeleteMirrorMaker.class);
325                                                         deleteMirrorMaker(m.getDeleteMirrorMaker());
326                                                         checkAgentProcess();
327                                                         mirrorMakers.setMessageID(m.getMessageID());
328                                                         publishTopic(g.toJson(mirrorMakers));
329                                                         mirrorMakers.setMessageID("");
330                                                 } else if (object.get("listAllMirrorMaker") != null) {
331                                                         logger.info("Received listALLMirrorMaker request from topic");
332                                                         checkAgentProcess();
333                                                         mirrorMakers.setMessageID((String) object.get("messageID"));
334                                                         publishTopic(g.toJson(mirrorMakers));
335                                                         mirrorMakers.setMessageID("");
336                                                 } else if (object.get("updateWhiteList") != null) {
337                                                         logger.info("Received updateWhiteList request from topic");
338                                                         UpdateWhiteList m = g.fromJson(topicMessage, UpdateWhiteList.class);
339                                                         updateWhiteList(m.getUpdateWhiteList());
340                                                         checkAgentProcess();
341                                                         mirrorMakers.setMessageID(m.getMessageID());
342                                                         publishTopic(g.toJson(mirrorMakers));
343                                                         mirrorMakers.setMessageID("");
344                                                 } else if (object.get("listMirrorMaker") != null) {
345                                                         logger.info("Received listMirrorMaker from topic, skipping messages");
346                                                 } else {
347                                                         logger.info("Received unknown request from topic");
348                                                 }
349                                         } catch (Exception ex) {
350                                                 connectionattempt++;
351                                                 if (connectionattempt > 5) {
352                                                         logger.info("Can't connect to the topic, mmagent shutting down , " + topicMessage);
353                                                         return;
354                                                 }
355                                                 logger.info("Can't connect to the topic, " + topicMessage + " Retrying " + connectionattempt
356                                                                 + " of 5 times in 1 minute" + " Error:" + ex.getLocalizedMessage());
357                                                 Thread.sleep(60000);
358                                         }
359                                 } else {
360                                         // Check all MirrorMaker every min
361                                         connectionattempt = 0;
362                                         checkAgentProcess();
363                                 }
364
365                         }
366                 } catch (Exception e) {
367                         logger.error("Exception is : " +e);
368                 }
369
370         }
371
372         protected void createMirrorMaker(MirrorMaker newMirrorMaker) {
373                 boolean exists = false;
374                 if (mirrorMakers != null) {
375                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
376                         for (int i = 0; i < mirrorMakersCount; i++) {
377                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
378                                 if (mm.name.equals(newMirrorMaker.name)) {
379                                         exists = true;
380                                         logger.info("MirrorMaker already exist for:" + newMirrorMaker.name);
381                                         return;
382                                 }
383                         }
384                 }
385                 logger.info("Adding new MirrorMaker:" + newMirrorMaker.name);
386                 if (exists == false && mirrorMakers != null) {
387                         mirrorMakers.getListMirrorMaker().add(newMirrorMaker);
388                 } else if (exists == false && mirrorMakers == null) {
389                         mirrorMakers = new ListMirrorMaker();
390                         ArrayList<MirrorMaker> list = mirrorMakers.getListMirrorMaker();
391                         list = new ArrayList<MirrorMaker>();
392                         list.add(newMirrorMaker);
393                         mirrorMakers.setListMirrorMaker(list);
394                 }
395                 checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
396                 checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
397
398                 Gson g = new Gson();
399                 mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
400                 OutputStream out = null;
401                 try {
402                         out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
403                         mirrorMakerProperties.store(out, "");
404                 } catch (IOException ex) {
405                         ex.printStackTrace();
406                 } finally {
407                         if (out != null) {
408                                 try {
409                                         out.close();
410                                 } catch (IOException e) {
411                                         e.printStackTrace();
412                                 }
413                         }
414                 }
415         }
416
417         private void updateMirrorMaker(MirrorMaker newMirrorMaker) {
418                 boolean exists = false;
419                 if (mirrorMakers != null) {
420                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
421                         for (int i = 0; i < mirrorMakersCount; i++) {
422                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
423                                 if (mm.name.equals(newMirrorMaker.name)) {
424                                         exists = true;
425                                         mm.setConsumer(newMirrorMaker.getConsumer());
426                                         mm.setProducer(newMirrorMaker.getProducer());
427                                         mirrorMakers.getListMirrorMaker().set(i, mm);
428                                         logger.info("Updating MirrorMaker:" + newMirrorMaker.name);
429                                 }
430                         }
431                 }
432                 if (exists) {
433                         checkPropertiesFile(newMirrorMaker.name, "consumer", newMirrorMaker.consumer, true);
434                         checkPropertiesFile(newMirrorMaker.name, "producer", newMirrorMaker.producer, true);
435
436                         Gson g = new Gson();
437                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
438                         OutputStream out = null;
439                         try {
440                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
441                                 mirrorMakerProperties.store(out, "");
442                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
443                                 try {
444                                         Thread.sleep(1000);
445                                 } catch (InterruptedException e) {
446                                         logger.log(Level.WARN, "Interrupted!", e);
447                                         Thread.currentThread().interrupt();
448                                 }
449                         } catch (IOException ex) {
450                                 logger.error(" IOException Occered " + ex);
451                         } finally {
452                                 if (out != null) {
453                                         try {
454                                                 out.close();
455                                         } catch (IOException e) {
456                                                 logger.error(" IOException Occered " + e);
457                                         }
458                                 }
459                         }
460                 } else {
461                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
462                 }
463         }
464
465         private void updateWhiteList(MirrorMaker newMirrorMaker) {
466                 boolean exists = false;
467                 if (mirrorMakers != null) {
468                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
469                         for (int i = 0; i < mirrorMakersCount; i++) {
470                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
471                                 if (mm.name.equals(newMirrorMaker.name)) {
472                                         exists = true;
473                                         mm.setWhitelist(newMirrorMaker.whitelist);
474                                         mirrorMakers.getListMirrorMaker().set(i, mm);
475                                         logger.info("Updating MirrorMaker WhiteList:" + newMirrorMaker.name + " WhiteList:"
476                                                         + newMirrorMaker.whitelist);
477                                 }
478                         }
479                 }
480                 if (exists) {
481                         Gson g = new Gson();
482                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
483                         OutputStream out = null;
484                         try {
485                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
486                                 mirrorMakerProperties.store(out, "");
487                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
488                                 try {
489                                         Thread.sleep(1000);
490                                 } catch (InterruptedException e) {
491                                 }
492                         } catch (IOException ex) {
493                                 ex.printStackTrace();
494                         } finally {
495                                 if (out != null) {
496                                         try {
497                                                 out.close();
498                                         } catch (IOException e) {
499                                                 e.printStackTrace();
500                                                 logger.error("IOException occered " + e);
501                                         }
502                                 }
503                         }
504                 } else {
505                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
506                 }
507         }
508
509         private void deleteMirrorMaker(MirrorMaker newMirrorMaker) {
510                 boolean exists = false;
511                 if (mirrorMakers != null) {
512                         int mirrorMakersCount = mirrorMakers.getListMirrorMaker().size();
513                         for (int i = 0; i < mirrorMakersCount; i++) {
514                                 MirrorMaker mm = mirrorMakers.getListMirrorMaker().get(i);
515                                 if (mm.name.equals(newMirrorMaker.name)) {
516                                         exists = true;
517                                         mirrorMakers.getListMirrorMaker().remove(i);
518                                         logger.info("Removing MirrorMaker:" + newMirrorMaker.name);
519                                         i = mirrorMakersCount;
520                                 }
521                         }
522                 }
523                 if (exists) {
524                         try {
525                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "consumer" + ".properties";
526                                 File file = new File(path);
527                                 file.delete();
528                         } catch (Exception ex) {
529                         }
530                         try {
531                                 String path = mmagenthome + "/etc/" + newMirrorMaker.name + "producer" + ".properties";
532                                 File file = new File(path);
533                                 file.delete();
534                         } catch (Exception ex) {
535                         }
536                         Gson g = new Gson();
537                         mirrorMakerProperties.setProperty("mirrormakers", g.toJson(this.mirrorMakers));
538                         OutputStream out = null;
539                         try {
540                                 out = new FileOutputStream(mmagenthome + "/etc/mmagent.config");
541                                 mirrorMakerProperties.store(out, "");
542                                 MirrorMakerProcessHandler.stopMirrorMaker(newMirrorMaker.name);
543                         } catch (IOException ex) {
544                                 ex.printStackTrace();
545                         } finally {
546                                 if (out != null) {
547                                         try {
548                                                 out.close();
549                                         } catch (IOException e) {
550                                                 e.printStackTrace();
551                                         }
552                                 }
553                         }
554                 } else {
555                         logger.info("MirrorMaker Not found for:" + newMirrorMaker.name);
556                 }
557         }
558
559         private void loadProperties() {
560                 InputStream input = null;
561                 try {
562
563                         input = new FileInputStream(mmagenthome + "/etc/mmagent.config");
564                         mirrorMakerProperties.load(input);
565                         Gson g = new Gson();
566                         if (mirrorMakerProperties.getProperty("mirrormakers") == null) {
567                                 this.mirrorMakers = new ListMirrorMaker();
568                                 ArrayList<MirrorMaker> list = this.mirrorMakers.getListMirrorMaker();
569                                 list = new ArrayList<MirrorMaker>();
570                                 this.mirrorMakers.setListMirrorMaker(list);
571                         } else {
572                                 this.mirrorMakers = g.fromJson(mirrorMakerProperties.getProperty("mirrormakers"),
573                                                 ListMirrorMaker.class);
574                         }
575
576                         this.kafkahome = mirrorMakerProperties.getProperty("kafkahome");
577                         this.topicURL = mirrorMakerProperties.getProperty("topicURL");
578                         this.topicname = mirrorMakerProperties.getProperty("topicname");
579                         this.mechid = mirrorMakerProperties.getProperty("mechid");
580
581                         BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
582                         textEncryptor.setPassword(secret);
583                         //this.password = textEncryptor.decrypt(mirrorMakerProperties.getProperty("password"));
584                         this.password = mirrorMakerProperties.getProperty("password");
585                 } catch (IOException ex) {
586                         // ex.printStackTrace();
587                 } finally {
588                         if (input != null) {
589                                 try {
590                                         input.close();
591                                 } catch (IOException e) {
592                                         // e.printStackTrace();
593                                 }
594                         }
595                 }
596
597         }
598 }

© 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