Fix keystore alais config and TC 49/31749/1
authorVENKATESH KUMAR <vv770d@att.com>
Wed, 14 Feb 2018 17:45:04 +0000 (17:45 +0000)
committerVENKATESH KUMAR <vv770d@att.com>
Wed, 14 Feb 2018 17:50:13 +0000 (12:50 -0500)
Change-Id: I8e0349f411dc05625b14536afc0acb1fac9a55c2
Signed-off-by: VENKATESH KUMAR <vv770d@att.com>
Issue-ID: DCAEGEN2-227

17 files changed:
dpo/spec/vescollector-componentspec.json
src/main/java/org/onap/dcae/commonFunction/CommonStartup.java
src/main/java/org/onap/dcae/controller/FetchDynamicConfig.java
src/main/java/org/onap/dcae/controller/LoadDynamicConfig.java
src/main/scripts/VESrestfulCollector.sh
src/test/java/org/onap/dcae/vestest/TestDmaapPropertyReader.java
src/test/java/org/onap/dcae/vestest/TestEventProcessor.java
src/test/java/org/onap/dcae/vestest/TestFetchConfig.java [new file with mode: 0644]
src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java
src/test/java/org/onap/dcae/vestest/TestSchemaValidation.java
src/test/java/org/onap/dcae/vestest/TestVESLogger.java [new file with mode: 0644]
src/test/resources/controller-config.json [deleted file]
src/test/resources/controller-config_dmaap_ip.json [new file with mode: 0644]
src/test/resources/controller-config_singleline_ip.json [new file with mode: 0644]
src/test/resources/testDmaapConfig_ip.json [moved from src/test/resources/testDmaapConfig.json with 100% similarity]
src/test/resources/test_collector_ip_op.properties [new file with mode: 0644]
src/test/resources/testcollector.properties

index 1973e81..32144e2 100644 (file)
                                "version": "5.28.4",
                                "type": "message router",
                                "config_key": "ves-sipsignaling"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-fault-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-measurement-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-syslog-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-heartbeat-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-other-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-mobileflow-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-statechange-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-thresholdCrossingAlert-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-voicequality-secondary"
-                       },
-                       {
-                               "format": "VES_specification",
-                               "version": "5.28.4",
-                               "type": "message router",
-                               "config_key": "ves-sipsignaling-secondary"
                        }
                ]
        },
                },
                {
                        "name": "collector.dmaap.streamid",
-                       "value": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary",
+                       "value": "fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling",
                        "description": "domain-streamid mapping"
                },
                {
                                        "bind": "/opt/app/VESCollector/logs"
                                },
                                "host": {
-                                       "path": "/opt/data/DCAE/VESCollector/logs"
+                                       "path": "/opt/logs/DCAE/VESCollector/logs"
                                }
                        }
                ],
        "artifacts": [
                {
                        "type": "docker image",
-                       "uri": "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:1.1"
-
-
+                       "uri": "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:1.1"
                }
        ]
 }
-
index d1dbca9..70da774 100644 (file)
-/*-
- * ============LICENSE_START=======================================================
- * PROJECT
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcae.commonFunction;
-
-import com.att.nsa.apiServer.ApiServer;
-import com.att.nsa.apiServer.ApiServerConnector;
-import com.att.nsa.apiServer.endpoints.NsaBaseEndpoint;
-import com.att.nsa.cmdLine.NsaCommandLineUtil;
-import com.att.nsa.drumlin.service.framework.DrumlinServlet;
-import com.att.nsa.drumlin.till.nv.impl.nvPropertiesFile;
-import com.att.nsa.drumlin.till.nv.impl.nvReadableStack;
-import com.att.nsa.drumlin.till.nv.impl.nvReadableTable;
-import com.att.nsa.drumlin.till.nv.rrNvReadable;
-import com.att.nsa.drumlin.till.nv.rrNvReadable.invalidSettingValue;
-import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;
-import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.fge.jsonschema.exceptions.ProcessingException;
-import com.github.fge.jsonschema.main.JsonSchema;
-import com.github.fge.jsonschema.main.JsonSchemaFactory;
-import com.github.fge.jsonschema.report.ProcessingMessage;
-import com.github.fge.jsonschema.report.ProcessingReport;
-import com.github.fge.jsonschema.util.JsonLoader;
-import org.apache.catalina.LifecycleException;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.onap.dcae.restapi.RestfulCollectorServlet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import javax.servlet.ServletException;
-
-public class CommonStartup extends NsaBaseEndpoint implements Runnable {
-
-       public static final String KCONFIG = "c";
-
-       public static final String KSETTING_PORT = "collector.service.port";
-       public static final int KDEFAULT_PORT = 8080;
-
-       public static final String KSETTING_SECUREPORT = "collector.service.secure.port";
-       public static final int KDEFAULT_SECUREPORT = -1;
-
-       public static final String KSETTING_KEYSTOREPASSFILE = "collector.keystore.passwordfile";
-       public static final String KDEFAULT_KEYSTOREPASSFILE = "../etc/passwordfile";
-       public static final String KSETTING_KEYSTOREFILE = "collector.keystore.file.location";
-       public static final String KDEFAULT_KEYSTOREFILE = "../etc/keystore";
-       public static final String KSETTING_KEYALIAS = "collector.keystore.alias";
-       public static final String KDEFAULT_KEYALIAS = "tomcat";
-
-       public static final String KSETTING_DMAAPCONFIGS = "collector.dmaapfile";
-       private static final String[] KDEFAULT_DMAAPCONFIGS = new String[] { "/etc/DmaapConfig.json" };
-
-       public static final String KSETTING_MAXQUEUEDEVENTS = "collector.inputQueue.maxPending";
-       public static final int KDEFAULT_MAXQUEUEDEVENTS = 1024 * 4;
-
-       public static final String KSETTING_SCHEMAVALIDATOR = "collector.schema.checkflag";
-       public static final int KDEFAULT_SCHEMAVALIDATOR = -1;
-
-       public static final String KSETTING_SCHEMAFILE = "collector.schema.file";
-       public static final String KDEFAULT_SCHEMAFILE = "{\"v5\":\"./etc/CommonEventFormat_28.3.json\"}";
-       public static final String KSETTING_EXCEPTIONCONFIG = "exceptionConfig";
-
-       public static final String KSETTING_DMAAPSTREAMID = "collector.dmaap.streamid";
-
-       public static final String KSETTING_AUTHFLAG = "header.authflag";
-       public static final int KDEFAULT_AUTHFLAG = 0;
-
-       public static final String KSETTING_AUTHLIST = "header.authlist";
-
-       public static final String KSETTING_EVENTTRANSFORMFLAG = "event.transform.flag";
-       public static final int KDEFAULT_EVENTTRANSFORMFLAG = 1;
-
-       public static final Logger inlog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.input");
-       public static final Logger oplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.output");
-       public static final Logger eplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.error");
-       public static final Logger metriclog = LoggerFactory.getLogger("com.att.ecomp.metrics");
-
-       public static int schemaValidatorflag = -1;
-       public static int authflag = 1;
-       public static int eventTransformFlag = 1;
-       public static String schemaFile;
-       public static JSONObject schemaFileJson;
-       public static String exceptionConfig;
-       public static String cambriaConfigFile;
-       private boolean listnerstatus;
-       public static String streamid;
-
-       public static LinkedBlockingQueue<JSONObject> fProcessingInputQueue;
-       private static ApiServer fTomcatServer = null;
-       private static final Logger log = LoggerFactory.getLogger(CommonStartup.class);
-
-       private CommonStartup(rrNvReadable settings) throws loadException, IOException, rrNvReadable.missingReqdSetting,
-                       rrNvReadable.invalidSettingValue, ServletException, InterruptedException {
-               final List<ApiServerConnector> connectors = new LinkedList<ApiServerConnector>();
-
-               if (settings.getInt(KSETTING_PORT, KDEFAULT_PORT) > 0) {
-                       // http service
-                       connectors.add(new ApiServerConnector.Builder(settings.getInt(KSETTING_PORT, KDEFAULT_PORT)).secure(false)
-                                       .build());
-               }
-
-               // optional https service
-               final int securePort = settings.getInt(KSETTING_SECUREPORT, KDEFAULT_SECUREPORT);
-               final String keystoreFile = settings.getString(KSETTING_KEYSTOREFILE, KDEFAULT_KEYSTOREFILE);
-               final String keystorePasswordFile = settings.getString(KSETTING_KEYSTOREPASSFILE, KDEFAULT_KEYSTOREPASSFILE);
-               final String keyAlias = settings.getString(KSETTING_KEYALIAS, KDEFAULT_KEYALIAS);
-
-               if (securePort > 0) {
-                       final String KSETTING_KEYSTOREPASS = readFile(keystorePasswordFile, Charset.defaultCharset());
-                       connectors.add(new ApiServerConnector.Builder(securePort).secure(true)
-                                       .keystorePassword(KSETTING_KEYSTOREPASS).keystoreFile(keystoreFile).keyAlias(keyAlias).build());
-
-               }
-
-               // Reading other config properties
-
-               schemaValidatorflag = settings.getInt(KSETTING_SCHEMAVALIDATOR, KDEFAULT_SCHEMAVALIDATOR);
-               if (schemaValidatorflag > 0) {
-                       schemaFile = settings.getString(KSETTING_SCHEMAFILE, KDEFAULT_SCHEMAFILE);
-                       // System.out.println("SchemaFile:" + schemaFile);
-                       schemaFileJson = new JSONObject(schemaFile);
-
-               }
-               exceptionConfig = settings.getString(KSETTING_EXCEPTIONCONFIG, null);
-               authflag = settings.getInt(CommonStartup.KSETTING_AUTHFLAG, CommonStartup.KDEFAULT_AUTHFLAG);
-               String[] currentconffile = settings.getStrings(CommonStartup.KSETTING_DMAAPCONFIGS,
-                               CommonStartup.KDEFAULT_DMAAPCONFIGS);
-               cambriaConfigFile = currentconffile[0];
-               streamid = settings.getString(KSETTING_DMAAPSTREAMID, null);
-               eventTransformFlag = settings.getInt(KSETTING_EVENTTRANSFORMFLAG, KDEFAULT_EVENTTRANSFORMFLAG);
-
-               fTomcatServer = new ApiServer.Builder(connectors, new RestfulCollectorServlet(settings)).encodeSlashes(true)
-                               .name("collector").build();
-
-               // Load override exception map
-               CustomExceptionLoader.LoadMap();
-               setListnerstatus(true);
-       }
-
-       public static void main(String[] args) {
-               ExecutorService executor = null;
-               try {
-                       // process command line arguments
-                       final Map<String, String> argMap = NsaCommandLineUtil.processCmdLine(args, true);
-                       final String config = NsaCommandLineUtil.getSetting(argMap, KCONFIG, "collector.properties");
-                       final URL settingStream = DrumlinServlet.findStream(config, CommonStartup.class);
-
-                       final nvReadableStack settings = new nvReadableStack();
-                       settings.push(new nvPropertiesFile(settingStream));
-                       settings.push(new nvReadableTable(argMap));
-
-                       fProcessingInputQueue = new LinkedBlockingQueue<JSONObject>(CommonStartup.KDEFAULT_MAXQUEUEDEVENTS);
-
-                       VESLogger.setUpEcompLogging();
-
-                       CommonStartup cs = new CommonStartup(settings);
-
-                       Thread csmain = new Thread(cs);
-                       csmain.start();
-
-                       EventProcessor ep = new EventProcessor();
-                       // Thread epThread=new Thread(ep);
-                       // epThread.start();
-                       executor = Executors.newFixedThreadPool(20);
-                       //executor.execute(ep);
-                       for (int i = 0; i < 20; ++i) {
-                               executor.execute(ep);
-                               }
-
-               } catch (loadException | missingReqdSetting | IOException | invalidSettingValue | ServletException
-                               | InterruptedException e) {
-                       CommonStartup.eplog.error("FATAL_STARTUP_ERROR" + e.getMessage());
-                       throw new RuntimeException(e);
-               } catch (Throwable e) {
-                       System.err.println("Uncaught exception - " + e.getMessage());
-                       CommonStartup.eplog.error("FATAL_ERROR" + e.getMessage());
-                       e.printStackTrace(System.err);
-               } finally {
-                       // This will make the executor accept no new threads
-                       // and finish all existing threads in the queue
-                       if (executor != null) {
-                               executor.shutdown();
-                       }
-
-               }
-       }
-
-       public void run() {
-               try {
-                       fTomcatServer.start();
-               } catch (LifecycleException | IOException e) {
-
-                       log.error("lifecycle or IO: ", e);
-               }
-               fTomcatServer.await();
-       }
-
-       public boolean isListnerstatus() {
-               return listnerstatus;
-       }
-
-       public void setListnerstatus(boolean listnerstatus) {
-               this.listnerstatus = listnerstatus;
-       }
-
-       public static Queue<JSONObject> getProcessingInputQueue() {
-               return fProcessingInputQueue;
-       }
-
-       public static class QueueFullException extends Exception {
-
-               private static final long serialVersionUID = 1L;
-       }
-
-       public static void handleEvents(JSONArray a) throws QueueFullException, JSONException, IOException {
-               final Queue<JSONObject> queue = getProcessingInputQueue();
-               try {
-
-                       CommonStartup.metriclog.info("EVENT_PUBLISH_START");
-                       for (int i = 0; i < a.length(); i++) {
-                               if (!queue.offer(a.getJSONObject(i))) {
-                                       throw new QueueFullException();
-                               }
-
-                       }
-                       log.debug("CommonStartup.handleEvents:EVENTS has been published successfully!");
-                       CommonStartup.metriclog.info("EVENT_PUBLISH_END");
-                       // ecomplogger.debug(secloggerMessageEnum.SEC_COLLECT_AND_PULIBISH_SUCCESS);
-
-               } catch (JSONException e) {
-                       throw e;
-
-               }
-       }
-
-       static String readFile(String path, Charset encoding) throws IOException {
-               byte[] encoded = Files.readAllBytes(Paths.get(path));
-               String pwd = new String(encoded);
-               return pwd.substring(0, pwd.length() - 1);
-       }
-
-       public static String schemavalidate(String jsonData, String jsonSchema) {
-               ProcessingReport report;
-               String result = "false";
-
-               try {
-                       // System.out.println("Applying schema: @<@<"+jsonSchema+">@>@ to
-                       // data: #<#<"+jsonData+">#>#");
-                       log.trace("Schema validation for event:" + jsonData);
-                       JsonNode schemaNode = JsonLoader.fromString(jsonSchema);
-                       JsonNode data = JsonLoader.fromString(jsonData);
-                       JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
-                       JsonSchema schema = factory.getJsonSchema(schemaNode);
-                       report = schema.validate(data);
-               } catch (JsonParseException e) {
-                       log.error("schemavalidate:JsonParseException for event:" + jsonData);
-                       return e.getMessage();
-               } catch (ProcessingException e) {
-                       log.error("schemavalidate:Processing exception for event:" + jsonData);
-                       return e.getMessage();
-               } catch (IOException e) {
-                       log.error(
-                                       "schemavalidate:IO exception; something went wrong trying to read json data for event:" + jsonData);
-                       return e.getMessage();
-               }
-               if (report != null) {
-                       Iterator<ProcessingMessage> iter = report.iterator();
-                       while (iter.hasNext()) {
-                               ProcessingMessage pm = iter.next();
-                               log.trace("Processing Message: " + pm.getMessage());
-                       }
-                       result = String.valueOf(report.isSuccess());
-               }
-               try {
-                       log.debug("Validation Result:" + result + " Validation report:" + report);
-               } catch (NullPointerException e) {
-                       log.error("schemavalidate:NullpointerException on report");
-               }
-               return result;
-       }
-
-
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * PROJECT\r
+ * ================================================================================\r
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.dcae.commonFunction;\r
+\r
+import com.att.nsa.apiServer.ApiServer;\r
+import com.att.nsa.apiServer.ApiServerConnector;\r
+import com.att.nsa.apiServer.endpoints.NsaBaseEndpoint;\r
+import com.att.nsa.cmdLine.NsaCommandLineUtil;\r
+import com.att.nsa.drumlin.service.framework.DrumlinServlet;\r
+import com.att.nsa.drumlin.till.nv.impl.nvPropertiesFile;\r
+import com.att.nsa.drumlin.till.nv.impl.nvReadableStack;\r
+import com.att.nsa.drumlin.till.nv.impl.nvReadableTable;\r
+import com.att.nsa.drumlin.till.nv.rrNvReadable;\r
+import com.att.nsa.drumlin.till.nv.rrNvReadable.invalidSettingValue;\r
+import com.att.nsa.drumlin.till.nv.rrNvReadable.loadException;\r
+import com.att.nsa.drumlin.till.nv.rrNvReadable.missingReqdSetting;\r
+import com.fasterxml.jackson.core.JsonParseException;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.github.fge.jsonschema.exceptions.ProcessingException;\r
+import com.github.fge.jsonschema.main.JsonSchema;\r
+import com.github.fge.jsonschema.main.JsonSchemaFactory;\r
+import com.github.fge.jsonschema.report.ProcessingMessage;\r
+import com.github.fge.jsonschema.report.ProcessingReport;\r
+import com.github.fge.jsonschema.util.JsonLoader;\r
+import org.apache.catalina.LifecycleException;\r
+import org.json.JSONArray;\r
+import org.json.JSONException;\r
+import org.json.JSONObject;\r
+import org.onap.dcae.restapi.RestfulCollectorServlet;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import java.io.IOException;\r
+import java.net.URL;\r
+import java.nio.charset.Charset;\r
+import java.nio.file.Files;\r
+import java.nio.file.Paths;\r
+import java.util.Iterator;\r
+import java.util.LinkedList;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Queue;\r
+import java.util.concurrent.ExecutorService;\r
+import java.util.concurrent.Executors;\r
+import java.util.concurrent.LinkedBlockingQueue;\r
+import javax.servlet.ServletException;\r
+\r
+public class CommonStartup extends NsaBaseEndpoint implements Runnable {\r
+\r
+       public static final String KCONFIG = "c";\r
+\r
+       public static final String KSETTING_PORT = "collector.service.port";\r
+       public static final int KDEFAULT_PORT = 8080;\r
+\r
+       public static final String KSETTING_SECUREPORT = "collector.service.secure.port";\r
+       public static final int KDEFAULT_SECUREPORT = -1;\r
+\r
+       public static final String KSETTING_KEYSTOREPASSFILE = "collector.keystore.passwordfile";\r
+       public static final String KDEFAULT_KEYSTOREPASSFILE = "../etc/passwordfile";\r
+       public static final String KSETTING_KEYSTOREFILE = "collector.keystore.file.location";\r
+       public static final String KDEFAULT_KEYSTOREFILE = "../etc/keystore";\r
+       public static final String KSETTING_KEYALIAS = "collector.keystore.alias";\r
+       public static final String KDEFAULT_KEYALIAS = "tomcat";\r
+\r
+       public static final String KSETTING_DMAAPCONFIGS = "collector.dmaapfile";\r
+       protected static final String[] KDEFAULT_DMAAPCONFIGS = new String[] { "/etc/DmaapConfig.json" };\r
+\r
+       public static final String KSETTING_MAXQUEUEDEVENTS = "collector.inputQueue.maxPending";\r
+       public static final int KDEFAULT_MAXQUEUEDEVENTS = 1024 * 4;\r
+\r
+       public static final String KSETTING_SCHEMAVALIDATOR = "collector.schema.checkflag";\r
+       public static final int KDEFAULT_SCHEMAVALIDATOR = -1;\r
+\r
+       public static final String KSETTING_SCHEMAFILE = "collector.schema.file";\r
+       public static final String KDEFAULT_SCHEMAFILE = "{\"v5\":\"./etc/CommonEventFormat_28.3.json\"}";\r
+       public static final String KSETTING_EXCEPTIONCONFIG = "exceptionConfig";\r
+\r
+       public static final String KSETTING_DMAAPSTREAMID = "collector.dmaap.streamid";\r
+\r
+       public static final String KSETTING_AUTHFLAG = "header.authflag";\r
+       public static final int KDEFAULT_AUTHFLAG = 0;\r
+\r
+       public static final String KSETTING_AUTHLIST = "header.authlist";\r
+\r
+       public static final String KSETTING_EVENTTRANSFORMFLAG = "event.transform.flag";\r
+       public static final int KDEFAULT_EVENTTRANSFORMFLAG = 1;\r
+\r
+       public static final Logger inlog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.input");\r
+       public static final Logger oplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.output");\r
+       public static final Logger eplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.error");\r
+       public static final Logger metriclog = LoggerFactory.getLogger("com.att.ecomp.metrics");\r
+\r
+       public static int schemaValidatorflag = -1;\r
+       public static int authflag = 1;\r
+       public static int eventTransformFlag = 1;\r
+       public static String schemaFile;\r
+       public static JSONObject schemaFileJson;\r
+       public static String exceptionConfig;\r
+       public static String cambriaConfigFile;\r
+       private boolean listnerstatus;\r
+       public static String streamid;\r
+\r
+       public static LinkedBlockingQueue<JSONObject> fProcessingInputQueue;\r
+       private static ApiServer fTomcatServer = null;\r
+       private static final Logger log = LoggerFactory.getLogger(CommonStartup.class);\r
+\r
+       private CommonStartup(rrNvReadable settings) throws loadException, IOException, rrNvReadable.missingReqdSetting,\r
+                       rrNvReadable.invalidSettingValue, ServletException, InterruptedException {\r
+               final List<ApiServerConnector> connectors = new LinkedList<ApiServerConnector>();\r
+\r
+               if (settings.getInt(KSETTING_PORT, KDEFAULT_PORT) > 0) {\r
+                       // http service\r
+                       connectors.add(new ApiServerConnector.Builder(settings.getInt(KSETTING_PORT, KDEFAULT_PORT)).secure(false)\r
+                                       .build());\r
+               }\r
+\r
+               // optional https service\r
+               final int securePort = settings.getInt(KSETTING_SECUREPORT, KDEFAULT_SECUREPORT);\r
+               final String keystoreFile = settings.getString(KSETTING_KEYSTOREFILE, KDEFAULT_KEYSTOREFILE);\r
+               final String keystorePasswordFile = settings.getString(KSETTING_KEYSTOREPASSFILE, KDEFAULT_KEYSTOREPASSFILE);\r
+               final String keyAlias = settings.getString(KSETTING_KEYALIAS, KDEFAULT_KEYALIAS);\r
+\r
+               if (securePort > 0) {\r
+                       final String KSETTING_KEYSTOREPASS = readFile(keystorePasswordFile, Charset.defaultCharset());\r
+                       connectors.add(new ApiServerConnector.Builder(securePort).secure(true)\r
+                                       .keystorePassword(KSETTING_KEYSTOREPASS).keystoreFile(keystoreFile).keyAlias(keyAlias).build());\r
+\r
+               }\r
+\r
+               // Reading other config properties\r
+\r
+               schemaValidatorflag = settings.getInt(KSETTING_SCHEMAVALIDATOR, KDEFAULT_SCHEMAVALIDATOR);\r
+               if (schemaValidatorflag > 0) {\r
+                       schemaFile = settings.getString(KSETTING_SCHEMAFILE, KDEFAULT_SCHEMAFILE);\r
+                       // System.out.println("SchemaFile:" + schemaFile);\r
+                       schemaFileJson = new JSONObject(schemaFile);\r
+\r
+               }\r
+               exceptionConfig = settings.getString(KSETTING_EXCEPTIONCONFIG, null);\r
+               authflag = settings.getInt(CommonStartup.KSETTING_AUTHFLAG, CommonStartup.KDEFAULT_AUTHFLAG);\r
+               String[] currentconffile = settings.getStrings(CommonStartup.KSETTING_DMAAPCONFIGS,\r
+                               CommonStartup.KDEFAULT_DMAAPCONFIGS);\r
+               cambriaConfigFile = currentconffile[0];\r
+               streamid = settings.getString(KSETTING_DMAAPSTREAMID, null);\r
+               eventTransformFlag = settings.getInt(KSETTING_EVENTTRANSFORMFLAG, KDEFAULT_EVENTTRANSFORMFLAG);\r
+\r
+               fTomcatServer = new ApiServer.Builder(connectors, new RestfulCollectorServlet(settings)).encodeSlashes(true)\r
+                               .name("collector").build();\r
+\r
+               // Load override exception map\r
+               CustomExceptionLoader.LoadMap();\r
+               setListnerstatus(true);\r
+       }\r
+\r
+       public static void main(String[] args) {\r
+               ExecutorService executor = null;\r
+               try {\r
+                       // process command line arguments\r
+                       final Map<String, String> argMap = NsaCommandLineUtil.processCmdLine(args, true);\r
+                       final String config = NsaCommandLineUtil.getSetting(argMap, KCONFIG, "collector.properties");\r
+                       final URL settingStream = DrumlinServlet.findStream(config, CommonStartup.class);\r
+\r
+                       final nvReadableStack settings = new nvReadableStack();\r
+                       settings.push(new nvPropertiesFile(settingStream));\r
+                       settings.push(new nvReadableTable(argMap));\r
+\r
+                       fProcessingInputQueue = new LinkedBlockingQueue<JSONObject>(CommonStartup.KDEFAULT_MAXQUEUEDEVENTS);\r
+\r
+                       VESLogger.setUpEcompLogging();\r
+\r
+                       CommonStartup cs = new CommonStartup(settings);\r
+\r
+                       Thread csmain = new Thread(cs);\r
+                       csmain.start();\r
+\r
+                       EventProcessor ep = new EventProcessor();\r
+                       executor = Executors.newFixedThreadPool(20);\r
+                       //executor.execute(ep);\r
+                       for (int i = 0; i < 20; ++i) {\r
+                               executor.execute(ep);\r
+                               }\r
+\r
+               } catch (loadException | missingReqdSetting | IOException | invalidSettingValue | ServletException\r
+                               | InterruptedException e) {\r
+                       CommonStartup.eplog.error("FATAL_STARTUP_ERROR" + e.getMessage());\r
+                       throw new RuntimeException(e);\r
+               } catch (Throwable e) {\r
+                       System.err.println("Uncaught exception - " + e.getMessage());\r
+                       CommonStartup.eplog.error("FATAL_ERROR" + e.getMessage());\r
+                       e.printStackTrace(System.err);\r
+               } finally {\r
+                       // This will make the executor accept no new threads\r
+                       // and finish all existing threads in the queue\r
+                       /*if (executor != null) {\r
+                               executor.shutdown();\r
+                       }*/\r
+\r
+               }\r
+       }\r
+\r
+       public void run() {\r
+               try {\r
+                       fTomcatServer.start();\r
+               } catch (LifecycleException | IOException e) {\r
+\r
+                       log.error("lifecycle or IO: ", e);\r
+               }\r
+               fTomcatServer.await();\r
+       }\r
+\r
+       public boolean isListnerstatus() {\r
+               return listnerstatus;\r
+       }\r
+\r
+       public void setListnerstatus(boolean listnerstatus) {\r
+               this.listnerstatus = listnerstatus;\r
+       }\r
+\r
+       public static Queue<JSONObject> getProcessingInputQueue() {\r
+               return fProcessingInputQueue;\r
+       }\r
+\r
+       public static class QueueFullException extends Exception {\r
+\r
+               private static final long serialVersionUID = 1L;\r
+       }\r
+\r
+       public static void handleEvents(JSONArray a) throws QueueFullException, JSONException, IOException {\r
+               final Queue<JSONObject> queue = getProcessingInputQueue();\r
+               try {\r
+\r
+                       CommonStartup.metriclog.info("EVENT_PUBLISH_START");\r
+                       for (int i = 0; i < a.length(); i++) {\r
+                               if (!queue.offer(a.getJSONObject(i))) {\r
+                                       throw new QueueFullException();\r
+                               }\r
+\r
+                       }\r
+                       log.debug("CommonStartup.handleEvents:EVENTS has been published successfully!");\r
+                       CommonStartup.metriclog.info("EVENT_PUBLISH_END");\r
+                       // ecomplogger.debug(secloggerMessageEnum.SEC_COLLECT_AND_PULIBISH_SUCCESS);\r
+\r
+               } catch (JSONException e) {\r
+                       throw e;\r
+\r
+               }\r
+       }\r
+\r
+       static String readFile(String path, Charset encoding) throws IOException {\r
+               byte[] encoded = Files.readAllBytes(Paths.get(path));\r
+               String pwd = new String(encoded);\r
+               return pwd.substring(0, pwd.length() - 1);\r
+       }\r
+\r
+       public static String schemavalidate(String jsonData, String jsonSchema) {\r
+               ProcessingReport report;\r
+               String result = "false";\r
+\r
+               try {\r
+                       // System.out.println("Applying schema: @<@<"+jsonSchema+">@>@ to\r
+                       // data: #<#<"+jsonData+">#>#");\r
+                       log.trace("Schema validation for event:" + jsonData);\r
+                       JsonNode schemaNode = JsonLoader.fromString(jsonSchema);\r
+                       JsonNode data = JsonLoader.fromString(jsonData);\r
+                       JsonSchemaFactory factory = JsonSchemaFactory.byDefault();\r
+                       JsonSchema schema = factory.getJsonSchema(schemaNode);\r
+                       report = schema.validate(data);\r
+               } catch (JsonParseException e) {\r
+                       log.error("schemavalidate:JsonParseException for event:" + jsonData);\r
+                       return e.getMessage();\r
+               } catch (ProcessingException e) {\r
+                       log.error("schemavalidate:Processing exception for event:" + jsonData);\r
+                       return e.getMessage();\r
+               } catch (IOException e) {\r
+                       log.error(\r
+                                       "schemavalidate:IO exception; something went wrong trying to read json data for event:" + jsonData);\r
+                       return e.getMessage();\r
+               }\r
+               if (report != null) {\r
+                       Iterator<ProcessingMessage> iter = report.iterator();\r
+                       while (iter.hasNext()) {\r
+                               ProcessingMessage pm = iter.next();\r
+                               log.trace("Processing Message: " + pm.getMessage());\r
+                       }\r
+                       result = String.valueOf(report.isSuccess());\r
+               }\r
+               try {\r
+                       log.debug("Validation Result:" + result + " Validation report:" + report);\r
+               } catch (NullPointerException e) {\r
+                       log.error("schemavalidate:NullpointerException on report");\r
+               }\r
+               return result;\r
+       }\r
+\r
+\r
+}\r
index 82d4bba..95e9574 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@ public class FetchDynamicConfig {
 
        private static final Logger log = LoggerFactory.getLogger(FetchDynamicConfig.class);
 
-       static String configFile = "/opt/app/KV-Configuration.json";
+       public static String configFile = "/opt/app/KV-Configuration.json";
        static String url;
        static String retString;
 
@@ -49,8 +49,8 @@ public class FetchDynamicConfig {
                        log.info("%s=%s%n", entry.getKey(), entry.getValue());
                }
 
-               if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE")
-                               && env.containsKey("HOSTNAME")) {
+               if (env.containsKey("CONSUL_HOST") && env.containsKey("CONFIG_BINDING_SERVICE")) {
+//                             && env.containsKey("HOSTNAME")) {
                        log.info(">>>Dynamic configuration to be fetched from ConfigBindingService");
                        url = env.get("CONSUL_HOST") + ":8500/v1/catalog/service/" + env.get("CONFIG_BINDING_SERVICE");
 
@@ -65,23 +65,47 @@ public class FetchDynamicConfig {
                        }
 
                        log.info("CONFIG_BINDING_SERVICE DNS RESOLVED:" + urlPart1);
-                       url = urlPart1 + "/service_component/" + env.get("HOSTNAME");
-                       retString = executecurl(url);
-
-                       JSONObject jsonObject = new JSONObject(new JSONTokener(retString));
-                       try (FileWriter file = new FileWriter(configFile)) {
-                               file.write(jsonObject.toString());
-
-                               log.info("Successfully Copied JSON Object to file /opt/app/KV-Configuration.json");
-                       } catch (IOException e) {
-                               log.error("Error in writing configuration into file /opt/app/KV-Configuration.json " + jsonObject, e);
-                               e.printStackTrace();
+                       FetchDynamicConfig fc= new FetchDynamicConfig();
+                       if (env.containsKey("HOSTNAME"))
+                       {
+                               url = urlPart1 + "/service_component/" + env.get("HOSTNAME");
+                               retString = executecurl(url);
+                       }
+                       else if (env.containsKey("SERVICE_NAME"))
+                       {
+                               url = urlPart1 + "/service_component/" + env.get("SERVICE_NAME");
+                               retString = executecurl(url);
+                       }
+                       else
+                       {
+                               log.error("Service name environment variable - HOSTNAME/SERVICE_NAME not found within container ");
                        }
+                       fc.writefile(retString);
+                       
+                       
                } else {
                        log.info(">>>Static configuration to be used");
                }
 
        }
+       
+       public void writefile (String retString)
+       {
+               log.info("URL to fetch configuration:" + url  + " Return String:" + retString);
+
+               
+               String indentedretstring=(new JSONObject(retString)).toString(4);
+               
+               try (FileWriter file = new FileWriter(FetchDynamicConfig.configFile)) {
+                       file.write(indentedretstring);
+
+                       log.info("Successfully Copied JSON Object to file /opt/app/KV-Configuration.json");
+               } catch (IOException e) {
+                       log.error("Error in writing configuration into file /opt/app/KV-Configuration.json " + retString, e);
+                       e.printStackTrace();
+               }
+               
+       }
 
        public static String executecurl(String url) {
 
index 2db4ff4..9184c3e 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ public class LoadDynamicConfig {
        public String configFile = "/opt/app/KV-Configuration.json";
        static String url;
        static String retString;
+       public String dmaapoutputfile = "./etc/DmaapConfig.json";
 
        public LoadDynamicConfig() {
 
@@ -59,35 +60,10 @@ public class LoadDynamicConfig {
                                LoadDynamicConfig lc = new LoadDynamicConfig();
                                String jsonData = readFile(lc.configFile);
                                JSONObject jsonObject = new JSONObject(jsonData);
+                               lc.writeconfig(jsonObject);
+               
 
-                               PropertiesConfiguration conf;
-                               conf = new PropertiesConfiguration(lc.propFile);
-                               conf.setEncoding(null);
-
-                               // update properties based on consul dynamic configuration
-                               Iterator<?> keys = jsonObject.keys();
-
-                               while (keys.hasNext()) {
-                                       String key = (String) keys.next();
-                                       // check if any configuration is related to dmaap
-                                       // and write into dmaapconfig.json
-                                       if (key.startsWith("streams_publishes")) {
-                                               // VESCollector only have publish streams
-                                               try (FileWriter file = new FileWriter("./etc/DmaapConfig.json")) {
-                                                       file.write(jsonObject.get(key).toString());
-                                                       log.info("Successfully written JSON Object to DmaapConfig.json");
-                                                       file.close();
-                                               } catch (IOException e) {
-                                                       log.info("Error in writing dmaap configuration into DmaapConfig.json", e);
-                                               }
-                                       } else {
-                                               conf.setProperty(key, jsonObject.get(key).toString());
-                                       }
-
-                               }
-                               conf.save();
-
-                       } catch (ConfigurationException e) {
+                       } catch (Exception e) {
                                log.error(e.getLocalizedMessage(), e);
                                e.printStackTrace();
 
@@ -98,6 +74,45 @@ public class LoadDynamicConfig {
                }
 
        }
+       
+       public void writeconfig (JSONObject jsonObject)
+       {
+               
+               PropertiesConfiguration conf;
+               try {
+                       conf = new PropertiesConfiguration(propFile);
+       
+               conf.setEncoding(null);
+
+               // update properties based on consul dynamic configuration
+               Iterator<?> keys = jsonObject.keys();
+
+               while (keys.hasNext()) {
+                       String key = (String) keys.next();
+                       // check if any configuration is related to dmaap
+                       // and write into dmaapconfig.json
+                       if (key.startsWith("streams_publishes")) {
+                               // VESCollector only have publish streams
+                               try (FileWriter file = new FileWriter(dmaapoutputfile)) {
+                                       
+                                       String indentedretstring=(new JSONObject(jsonObject.get(key).toString())).toString(4);
+                                       file.write(indentedretstring);
+                                       log.info("Successfully written JSON Object to DmaapConfig.json");
+                                       file.close();
+                               } catch (IOException e) {
+                                       log.info("Error in writing dmaap configuration into DmaapConfig.json", e);
+                               }
+                       } else {
+                               conf.setProperty(key, jsonObject.get(key).toString());
+                       }
+
+               }
+               conf.save();
+               } catch (ConfigurationException e) {
+                       log.error(e.getLocalizedMessage(), e);
+                       e.printStackTrace();
+               }
+       }
 
        public static String readFile(String filename) {
                String result = "";
index 45bdc6e..14e90cc 100644 (file)
@@ -4,7 +4,7 @@
 # ============LICENSE_START=======================================================
 # PROJECT
 # ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@ usage() {
 }
 
 
-#BASEDIR=/opt/app/d1gfp1m7/extra/VES/VESCollector-1.1.4-SNAPSHOT/
 BASEDIR=/opt/app/VESCollector/
 
 collector_start() {
@@ -108,6 +107,26 @@ collector_configupdate() {
                     else
                         echo "INFO: Dynamic config updated successfully into VESCollector configuration!"
                     fi
+                    
+                                       # Identify alias names from keystore and password provided
+         
+                       paramName="collector.keystore.alias"
+                                       localpropertyfile="/opt/app/VESCollector/etc/collector.properties"
+                                       tmpfile="/opt/app/VESCollector/etc/collector.properties.tmp"
+                                       
+                                       keystore=`grep collector.keystore.file.location $localpropertyfile | tr -d '[:space:]' | cut -d"=" -f2`
+                                       keypwdfile=`grep collector.keystore.passwordfile $localpropertyfile | tr -d '[:space:]' | cut -d"=" -f2`
+                                               
+                                       echo "/usr/bin/keytool -list -keystore $keystore < $keypwdfile | grep "PrivateKeyEntry" | cut -d"," -f1"
+                    tmpalias=`/usr/bin/keytool -list -keystore $keystore < $keypwdfile | grep "PrivateKeyEntry" | cut -d"," -f1`
+                    echo "tmpalias:" $tmpalias
+                    alias=`echo $tmpalias | cut -d":" -f2`
+                    echo "alias:" $alias
+                    sed "s~$paramName=.*~$paramName=$alias~g" $localpropertyfile > $tmpfile
+                    echo `cat $tmpfile > $localpropertyfile`
+                    rm $tmpfile
+                       echo "INFO: Keystore alias updated into configuration"
+                  
             else
                 echo "ERROR: Configuration file /opt/app/KV-Configuration.json missing"
             fi
index e54b4cb..2a7a205 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ import org.onap.dcae.commonFunction.DmaapPropertyReader;
 public class TestDmaapPropertyReader {
 
        DmaapPropertyReader dr;
-       String testinput = "src/test/resources/testDmaapConfig.json";
+       String testinput = "src/test/resources/testDmaapConfig_ip.json";
        Boolean flag = false;
 
        @Before
index f11cc90..4767295 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@ import static org.junit.Assert.*;
 
 
 import java.io.File;
-import java.io.FileReader;
 import java.net.URL;
 import java.util.Map;
 
@@ -47,13 +46,13 @@ public class TestEventProcessor {
 
        EventProcessor ec;
        String ev= "{\"event\": {\"commonEventHeader\": {       \"reportingEntityName\": \"VM name will be provided by ECOMP\", \"startEpochMicrosec\": 1477012779802988,\"lastEpochMicrosec\": 1477012789802988,\"eventId\": \"83\",\"sourceName\": \"Dummy VM name - No Metadata available\",\"sequence\": 83,\"priority\": \"Normal\",\"functionalRole\": \"vFirewall\",\"domain\": \"measurementsForVfScaling\",\"reportingEntityId\": \"VM UUID will be provided by ECOMP\",\"sourceId\": \"Dummy VM UUID - No Metadata available\",\"version\": 1.1},\"measurementsForVfScalingFields\": {\"measurementInterval\": 10,\"measurementsForVfScalingVersion\": 1.1,\"vNicUsageArray\": [{\"multicastPacketsIn\": 0,\"bytesIn\": 3896,\"unicastPacketsIn\": 0, \"multicastPacketsOut\": 0,\"broadcastPacketsOut\": 0,          \"packetsOut\": 28,\"bytesOut\": 12178,\"broadcastPacketsIn\": 0,\"packetsIn\": 58,\"unicastPacketsOut\": 0,\"vNicIdentifier\": \"eth0\"}]}}}";
-                       
+       String testinput;
        
        @Before
        public void setUp() throws Exception {
                CommonStartup.streamid="fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling";
                CommonStartup.eventTransformFlag = 1;
-               
+               testinput = "src/test/resources/testDmaapConfig_ip.json";
        
        }
 
@@ -81,7 +80,7 @@ public class TestEventProcessor {
 
            DmaapPropertyReader dr;
                EventPublisher ep = null;
-           String testinput = "src/test/resources/testDmaapConfig.json";
+       
            Boolean flag = false;
            dr = new DmaapPropertyReader(testinput);
 
@@ -106,9 +105,11 @@ public class TestEventProcessor {
 
            DmaapPropertyReader dr;
            EventPublisherHash eph = null;
+           
            Boolean flag = false;
+           dr = new DmaapPropertyReader(testinput);
                eph = EventPublisherHash.getInstance();
-               
+       
                
                if (eph.equals(null))
                {
@@ -128,13 +129,14 @@ public class TestEventProcessor {
 
            DmaapPropertyReader dr;
            EventPublisherHash eph = null;
-           String testinput = "src/test/resources/testDmaapConfig.json";
+           
            Boolean flag = false;
            dr = new DmaapPropertyReader(testinput);
                eph = EventPublisherHash.getInstance();
                EventProcessor ec = new EventProcessor();
                ec.event=new org.json.JSONObject(ev);   
-               CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig.json";
+               CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig_ip.json";
+                  
                CambriaBatchingPublisher pub = eph.Dmaaphash("sec_fault_ueb");
                
                if (pub == null || pub.equals(null))
@@ -154,7 +156,7 @@ public class TestEventProcessor {
 
            DmaapPropertyReader dr;
            EventPublisherHash eph = null;
-           String testinput = "src/test/resources/testDmaapConfig.json";
+           
            Boolean flag = true;
            dr = new DmaapPropertyReader(testinput);
                eph = EventPublisherHash.getInstance();
@@ -162,7 +164,7 @@ public class TestEventProcessor {
                
                EventProcessor ec = new EventProcessor();
                ec.event=new org.json.JSONObject(ev);
-               CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig.json";
+               CommonStartup.cambriaConfigFile="src/test/resources/testDmaapConfig_ip.json";
                eph.sendEvent(ec.event, "sec_fault_ueb");
                
                assertEquals(true, flag);
@@ -170,4 +172,3 @@ public class TestEventProcessor {
        }
 }
 
-
diff --git a/src/test/java/org/onap/dcae/vestest/TestFetchConfig.java b/src/test/java/org/onap/dcae/vestest/TestFetchConfig.java
new file mode 100644 (file)
index 0000000..ed3e108
--- /dev/null
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.vestest;
+
+import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileReader;
+import java.io.IOException;
+import org.json.JSONObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonObject;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.commonFunction.CommonStartup;
+import org.onap.dcae.commonFunction.DmaapPropertyReader;
+import org.onap.dcae.commonFunction.EventProcessor;
+import org.onap.dcae.commonFunction.EventPublisherHash;
+import org.onap.dcae.controller.FetchDynamicConfig;
+
+
+public class TestFetchConfig {
+
+       JSONObject jsonObject;
+       
+       @Before
+       public void setUp() throws Exception {
+
+
+       }
+
+       @After
+       public void tearDown() throws Exception {
+       }
+       
+
+       
+       @Test
+       public void testwritefile() {
+               Boolean flag = false;
+               
+               FetchDynamicConfig fc = new FetchDynamicConfig();
+               FetchDynamicConfig.configFile = "src/test/resources/controller-config_formatted_op.json";
+
+               
+               
+               try{
+                        JsonParser parser = new JsonParser();
+                       FileReader fr = new FileReader ("src/test/resources/controller-config_singleline_ip.json"  );
+                       final JsonObject jo =  (JsonObject) parser.parse (fr);
+                       final String jsonText = jo.toString ();
+                       jsonObject = new JSONObject ( jsonText );
+                       fc.writefile(jsonObject.toString());
+               }
+               catch(Exception e){
+                       System.out.println("Exception while opening the file");
+                       e.printStackTrace();
+               }
+               if(jsonObject.has("streams_publishes"))
+               {
+                       flag = true;
+               }
+               
+               assertEquals(true, flag);
+               
+       }
+
+
+}
+
index 902add7..765d9c6 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,30 +21,29 @@ package org.onap.dcae.vestest;
 
 import static org.junit.Assert.*;
 
-import java.io.File;
 import java.io.FileReader;
-import java.net.URL;
-import java.util.Map;
-
-import org.json.simple.JSONObject;
 
+import org.json.JSONObject;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.onap.dcae.controller.FetchDynamicConfig;
 import org.onap.dcae.controller.LoadDynamicConfig;
 
+import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 
 public class TestLoadDynamicConfig {
 
        LoadDynamicConfig lc;
-       String propop = "src/test/resources/testcollector.properties";
+       String propop =  "src/test/resources/test_collector_ip_op.properties";
+       
        
        @Before
        public void setUp() throws Exception {
        
-               
+               lc = new LoadDynamicConfig();
 
        }
 
@@ -55,18 +54,50 @@ public class TestLoadDynamicConfig {
        @Test
        public void testLoad() {
 
-       //      File file = new File(".");
-       //      for(String fileNames : file.list()) System.out.println(fileNames);
                
                Boolean flag=false;
-               lc = new LoadDynamicConfig();
-               lc.propFile = "src/test/resources/testcollector.properties";
-               lc.configFile = "src/test/resources/controller-config.json";
+               
+
+               lc.propFile = "src/test/resources/test_collector_ip_op.properties";
+               lc.configFile = "src/test/resources/controller-config_dmaap_ip.json";
                
                String data = LoadDynamicConfig.readFile(propop);
                assertEquals(data.isEmpty(), flag);
        }
 
 
+       @Test
+       public void testwrite() {
+
+               
+               Boolean flag=false;
+               
+               lc.propFile = "src/test/resources/test_collector_ip_op.properties";
+               lc.configFile = "src/test/resources/controller-config_dmaap_ip.json";
+               lc.dmaapoutputfile = "src/test/resources/DmaapConfig-op.json";
+               
+               String data = LoadDynamicConfig.readFile(lc.configFile);
+               JSONObject jsonObject = new JSONObject(data);
+               lc.writeconfig(jsonObject);
+
+               try{
+                        JsonParser parser = new JsonParser();
+                       FileReader fr = new FileReader ( lc.dmaapoutputfile );
+                       final JsonObject jo =  (JsonObject) parser.parse (fr);
+                       final String jsonText = jo.toString ();
+                       jsonObject = new JSONObject ( jsonText );
+               }
+               catch(Exception e){
+                       System.out.println("Exception while opening the file");
+                       e.printStackTrace();
+               }
+               if(jsonObject.has("ves-fault-secondary"))
+               {
+                       flag = true;
+               }
+               
+               assertEquals(true, flag);
+
+       }
 }
 
index a34b333..af8a62f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * PROJECT
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -83,30 +83,22 @@ public class TestSchemaValidation {
 
         }
 
-
+/*
         @Test
         public void testeventReceipt() {
 
-                //com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext.DrumlinRequestContext(DrumlinServlet webServlet,
-                //HttpServletRequest req, HttpServletResponse resp, DrumlinConnection s, Map<String, Object> objects, DrumlinRequestRouter router)
-                //HttpServletRequest req = new HttpServletRequest();
-                //HttpServletResponse res = new HttpServletResponse();
                 DrumlinServlet webServlet = new DrumlinServlet();
-                //webServlet.addToBaseContext(key, o);
-                //Map<String,Object> mp = new Map<String, Object>();
                 DrumlinRequestContext ctx = new DrumlinRequestContext(webServlet, null, null, null, null, null);
                 EventReceipt er= new EventReceipt();
                 try {
                        EventReceipt.receiveVESEvent(null);
                 } catch ( NullPointerException   e) {
-                        // TODO Auto-generated catch block
-
+                     
+                       e.printStackTrace();
                 }
-
-
                 Assert.assertEquals("true", "true");
 
-        }
+        }*/
 
         @Test
         public void testsafeclosefr() {
diff --git a/src/test/java/org/onap/dcae/vestest/TestVESLogger.java b/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
new file mode 100644 (file)
index 0000000..3d41eed
--- /dev/null
@@ -0,0 +1,115 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcae.vestest;
+
+import static org.junit.Assert.*;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.UUID;
+
+import org.json.JSONObject;
+import com.google.gson.JsonParser;
+import com.att.nsa.logging.LoggingContext;
+import com.google.gson.JsonObject;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dcae.commonFunction.CommonStartup;
+import org.onap.dcae.commonFunction.DmaapPropertyReader;
+import org.onap.dcae.commonFunction.EventProcessor;
+import org.onap.dcae.commonFunction.EventPublisherHash;
+import org.onap.dcae.commonFunction.VESLogger;
+import org.onap.dcae.controller.FetchDynamicConfig;
+
+
+public class TestVESLogger {
+
+       LoggingContext threadLC;
+       
+       @Before
+       public void setUp() throws Exception {
+
+                threadLC = null;
+       }
+
+       @After
+       public void tearDown() throws Exception {
+       }
+       
+
+       
+       @Test
+       public void testgetCommonLoggingContext() {
+               Boolean flag = false;
+               threadLC = VESLogger.getCommonLoggingContext();
+               if(!threadLC.equals(""))
+               {
+                       flag = true;
+               }
+               
+               assertEquals(true, flag);
+               
+       }
+       @Test
+       public void testUuidgetLoggingContextForThread() {
+               Boolean flag = false;
+               final UUID uuid = UUID.randomUUID();
+               threadLC = VESLogger.getLoggingContextForThread(uuid);
+               //if(threadLC.get("REQUEST_ID", null) != null)
+               if(!threadLC.equals(""))
+               {
+                       flag = true;
+               }
+               
+               assertEquals(true, flag);
+               
+               
+       }
+       @Test
+       public void testStringgetLoggingContextForThread() {
+               Boolean flag = false;
+               final UUID uuid = UUID.randomUUID();
+               threadLC = VESLogger.getLoggingContextForThread(uuid.toString());
+               //if(threadLC.get("REQUEST_ID", null) != null)
+               if(!threadLC.equals(""))
+               {
+                       flag = true;
+               }
+               
+               assertEquals(true, flag);
+               
+       }
+
+       @Test
+       public void testsetUpEcompLogging() {
+               Boolean flag = false;
+               VESLogger.setUpEcompLogging();
+               
+               
+               assertEquals(true, true);
+               
+       }
+       
+}
+
diff --git a/src/test/resources/controller-config.json b/src/test/resources/controller-config.json
deleted file mode 100644 (file)
index c71f434..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-       "services_calls": {},
-       "collector.schema.checkflag": 1,
-       "collector.inputQueue.maxPending": 8096,
-       "collector.keystore.alias": "dynamically generated",
-       "collector.schema.file": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.json\"}",
-       "header.authlist": "userid1,base64encodepwd1|userid2,base64encodepwd2",
-       "streams_subscribes": {},
-       "tomcat.maxthreads": "200",
-       "collector.service.secure.port": 8443,
-       "collector.dmaap.streamid": "fault=ves_fault|syslog=ves_syslog|heartbeat=ves_heartbeat|measurementsForVfScaling=ves_measurement|mobileFlow=ves_mobileflow|other=ves_other|stateChange=ves_statechange|thresholdCrossingAlert=ves_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling",
-       "event.transform.flag": 0,
-       "collector.keystore.file.location": "/opt/app/dcae-certificate/keystore.jks",
-       "collector.keystore.passwordfile": "/opt/app/dcae-certificate/.password",
-       "header.authflag": 0,
-       "collector.service.port": 8080
-}
diff --git a/src/test/resources/controller-config_dmaap_ip.json b/src/test/resources/controller-config_dmaap_ip.json
new file mode 100644 (file)
index 0000000..8979a61
--- /dev/null
@@ -0,0 +1,239 @@
+{
+       "header.authflag": 1,
+       "collector.inputQueue.maxPending": 8096,
+       "collector.keystore.alias": "dynamically generated",
+       "collector.schema.checkflag": 1,
+       "collector.keystore.file.location": "/opt/app/dcae-certificate/keystore.jks",
+       "tomcat.maxthreads": "200",
+       "collector.keystore.passwordfile": "/opt/app/dcae-certificate/.password",
+       "collector.service.secure.port": 8443,
+       "collector.schema.file": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.json\"}",
+       "collector.dmaap.streamid": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary",
+       "streams_subscribes": {},
+       "collector.service.port": -1,
+       "services_calls": {},
+       "streams_publishes": {
+               "ves-other": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-fault": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-syslog": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-other-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-syslog-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-thresholdCrossingAlert-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-voicequality": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-sipsignaling-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-heartbeat": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-mobileflow-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-heartbeat-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-measurement-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-measurement": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-sipsignaling": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-statechange-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-voicequality-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-fault-secondary": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-statechange": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-mobileflow": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               },
+               "ves-thresholdCrossingAlert": {
+                       "aaf_username": null,
+                       "type": "message_router",
+                       "aaf_password": null,
+                       "dmaap_info": {
+                               "client_id": null,
+                               "location": "mtl5",
+                               "client_role": null,
+                               "topic_url": "http://UEBHOST:3904/events/DCAE-SE-COLLECTOR-EVENTS-DEV"
+                       }
+               }
+       },
+       "event.transform.flag": 1,
+       "header.authlist": "sample1,c2FtcGxlMQ==|userid1,base64encodepwd1|userid2,base64encodepwd2"
+}
diff --git a/src/test/resources/controller-config_singleline_ip.json b/src/test/resources/controller-config_singleline_ip.json
new file mode 100644 (file)
index 0000000..220e3f1
--- /dev/null
@@ -0,0 +1 @@
+{"header.authflag": "1", "collector.schema.file": "{\"v1\": \"./etc/CommonEventFormat_27.2.json\", \"v2\": \"./etc/CommonEventFormat_27.2.json\", \"v3\": \"./etc/CommonEventFormat_27.2.json\", \"v4\": \"./etc/CommonEventFormat_27.2.json\", \"v5\": \"./etc/CommonEventFormat_28.4.json\"}", "collector.keystore.passwordfile": "/opt/app/dcae-certificate/.password", "tomcat.maxthreads": "200", "collector.dmaap.streamid": "fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling", "streams_subscribes": {}, "collector.inputQueue.maxPending": "8096", "collector.keystore.alias": "dynamically generated", "streams_publishes": {"ves-mobileflow": {"type": "message_router", "dmaap_info": {"client_id": "1517590629043", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-MOBILEFLOW-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-measurement": {"type": "message_router", "dmaap_info": {"client_id": "1517590433916", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-ENC-MEASUREMENT-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-voicequality": {"type": "message_router", "dmaap_info": {"client_id": "1517590778397", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-VES-VOICEQUALITY-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-thresholdCrossingAlert": {"type": "message_router", "dmaap_info": {"client_id": "1517590728150", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-TCA-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-fault": {"type": "message_router", "dmaap_info": {"client_id": "1517590384670", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-FAULT-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-heartbeat": {"type": "message_router", "dmaap_info": {"client_id": "1517590530041", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-HEARTBEAT-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-sipsignaling": {"type": "message_router", "dmaap_info": {"client_id": "1517590828736", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-VES-SIPSIGNALING-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-syslog": {"type": "message_router", "dmaap_info": {"client_id": "1517590482019", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-SYSLOG-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-other": {"type": "message_router", "dmaap_info": {"client_id": "1517590581045", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-OTHER-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}, "ves-statechange": {"type": "message_router", "dmaap_info": {"client_id": "1517590677649", "client_role": "com.att.secCollector.member", "location": "rdm5bdcc2", "topic_url": "https://DMAAPHOST:3905/events/com.att.dcae.dmaap.FTL.24256-SEC-STATECHANGE-OUTPUT-v1"}, "aaf_username": "userid@namespace", "aaf_password": "authpwd"}}, "collector.schema.checkflag": "1", "services_calls": {}, "event.transform.flag": "1", "collector.keystore.file.location": "/opt/app/dcae-certificate/keystore.jks", "header.authlist": "sample1,c2FtcGxlMQ==|userid1,base64encodepwd1|userid2,base64encodepwd2", "collector.service.secure.port": "8443", "collector.service.port": "-1"}
\ No newline at end of file
diff --git a/src/test/resources/test_collector_ip_op.properties b/src/test/resources/test_collector_ip_op.properties
new file mode 100644 (file)
index 0000000..ad3ee2f
--- /dev/null
@@ -0,0 +1,78 @@
+###############################################################################\r
+##\r
+## Collector Server config\r
+##\r
+##     - Default values are shown as commented settings.\r
+##\r
+###############################################################################\r
+##\r
+## HTTP(S) service\r
+##\r
+##     Normally:\r
+##\r
+##             - 8080 is http service\r
+##             - https is disabled by default (-1)\r
+##\r
+##             - At this time, the server always binds to 0.0.0.0\r
+##\r
+## The default port when header.authflag is disabled (0)\r
+collector.service.port=-1\r
+\r
+## The secure port is required if header.authflag is set to 1 (true)\r
+## Authentication is only supported via secure port\r
+## When enabled - require valid keystore defined\r
+collector.service.secure.port=8443\r
+\r
+## The keystore must be setup per installation when secure port is configured\r
+collector.keystore.file.location=/opt/app/dcae-certificate/keystore.jks\r
+collector.keystore.passwordfile=/opt/app/dcae-certificate/.password\r
+collector.keystore.alias=dynamically generated\r
+\r
+\r
+###############################################################################\r
+## Processing\r
+##\r
+## If there's a problem that prevents the collector from processing alarms,\r
+## it's normally better to apply back pressure to the caller than to try to\r
+## buffer beyond a reasonable size limit. With a limit, the server won't crash\r
+## due to being out of memory, and the caller will get a 5xx reply saying the\r
+## server is in trouble.\r
+collector.inputQueue.maxPending=8096\r
+\r
+## Schema Validation checkflag\r
+## default no validation checkflag (-1)\r
+## If enabled (1) - schemafile location must be specified\r
+collector.schema.checkflag=1\r
+collector.schema.file={\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.json\"}\r
+\r
+## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile  \r
+collector.dmaap.streamid=fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary\r
+collector.dmaapfile=./etc/DmaapConfig.json\r
+\r
+## Custom ExceptionConfiguration\r
+exceptionConfig=./etc/ExceptionConfig.json\r
+\r
+## authflag control authentication by the collector\r
+## If enabled (1) - then authlist has to be defined\r
+## When authflag is enabled, only secure port will be supported\r
+## To disable enter 0\r
+header.authflag=1\r
+## Combination of userid,base64 encoded pwd list to be supported\r
+## userid and pwd comma separated; pipe delimitation between each pair\r
+header.authlist=sample1,c2FtcGxlMQ==|userid1,base64encodepwd1|userid2,base64encodepwd2\r
+\r
+## Event transformation Flag - when set expects configurable transformation\r
+## defined under ./etc/eventTransform.json\r
+## Enabled by default; to disable set to 0\r
+event.transform.flag=1\r
+streams_subscribes = {}\r
+services_calls = {}\r
+tomcat.maxthreads = 200\r
+\r
+###############################################################################\r
+##\r
+## Tomcat control\r
+##\r
+#tomcat.maxthreads=(tomcat default, which is usually 200)\r
+\r
+\r
index 6b166b0..7c00a20 100644 (file)
@@ -1,75 +1,75 @@
-###############################################################################
-##
-## Collector Server config
-##
-##     - Default values are shown as commented settings.
-##
-###############################################################################
-##
-## HTTP(S) service
-##
-##     Normally:
-##
-##             - 8080 is http service
-##             - https is disabled by default (-1)
-##
-##             - At this time, the server always binds to 0.0.0.0
-##
-## The default port when header.authflag is disabled (0)
-collector.service.port=9999
-
-## The secure port is required if header.authflag is set to 1 (true)
-## Authentication is only supported via secure port
-## When enabled - require valid keystore defined
-collector.service.secure.port=8443
-
-## The keystore must be setup per installation when secure port is configured
-collector.keystore.file.location=../etc/keystore
-collector.keystore.passwordfile=./etc/passwordfile
-collector.keystore.alias=tomcat
-
-
-###############################################################################
-## Processing
-##
-## If there's a problem that prevents the collector from processing alarms,
-## it's normally better to apply back pressure to the caller than to try to
-## buffer beyond a reasonable size limit. With a limit, the server won't crash
-## due to being out of memory, and the caller will get a 5xx reply saying the
-## server is in trouble.
-collector.inputQueue.maxPending=8096
-
-## Schema Validation checkflag
-## default no validation checkflag (-1)
-## If enabled (1) - schemafile location must be specified
-collector.schema.checkflag=1
-collector.schema.file={\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.json\"}
-
-## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile  
-collector.dmaap.streamid=fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling
-collector.dmaapfile=./etc/DmaapConfig.json
-
-## Custom ExceptionConfiguration
-exceptionConfig=./etc/ExceptionConfig.json
-
-## authflag control authentication by the collector
-## If enabled (1) - then authlist has to be defined
-## When authflag is enabled, only secure port will be supported
-## To disable enter 0
-header.authflag=1
-## Combination of userid,base64 encoded pwd list to be supported
-## userid and pwd comma separated; pipe delimitation between each pair
-header.authlist=secureid,IWRjYWVSb2FkbTEyMyEt|sample1,c2FtcGxlMQ==|vdnsagg,dmRuc2FnZw==
-
-## Event transformation Flag - when set expects configurable transformation
-## defined under ./etc/eventTransform.json
-## Enabled by default; to disable set to 0
-event.transform.flag=1
-
-###############################################################################
-##
-## Tomcat control
-##
-#tomcat.maxthreads=(tomcat default, which is usually 200)
-
-
+###############################################################################\r
+##\r
+## Collector Server config\r
+##\r
+##     - Default values are shown as commented settings.\r
+##\r
+###############################################################################\r
+##\r
+## HTTP(S) service\r
+##\r
+##     Normally:\r
+##\r
+##             - 8080 is http service\r
+##             - https is disabled by default (-1)\r
+##\r
+##             - At this time, the server always binds to 0.0.0.0\r
+##\r
+## The default port when header.authflag is disabled (0)\r
+collector.service.port=9999\r
+\r
+## The secure port is required if header.authflag is set to 1 (true)\r
+## Authentication is only supported via secure port\r
+## When enabled - require valid keystore defined\r
+collector.service.secure.port=8443\r
+\r
+## The keystore must be setup per installation when secure port is configured\r
+collector.keystore.file.location=../etc/keystore\r
+collector.keystore.passwordfile=./etc/passwordfile\r
+collector.keystore.alias=tomcat\r
+\r
+\r
+###############################################################################\r
+## Processing\r
+##\r
+## If there's a problem that prevents the collector from processing alarms,\r
+## it's normally better to apply back pressure to the caller than to try to\r
+## buffer beyond a reasonable size limit. With a limit, the server won't crash\r
+## due to being out of memory, and the caller will get a 5xx reply saying the\r
+## server is in trouble.\r
+collector.inputQueue.maxPending=8096\r
+\r
+## Schema Validation checkflag\r
+## default no validation checkflag (-1)\r
+## If enabled (1) - schemafile location must be specified\r
+collector.schema.checkflag=1\r
+collector.schema.file={\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.json\"}\r
+\r
+## List all streamid per domain to be supported. The streamid should match to channel name on dmaapfile  \r
+collector.dmaap.streamid=fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling\r
+collector.dmaapfile=./etc/DmaapConfig.json\r
+\r
+## Custom ExceptionConfiguration\r
+exceptionConfig=./etc/ExceptionConfig.json\r
+\r
+## authflag control authentication by the collector\r
+## If enabled (1) - then authlist has to be defined\r
+## When authflag is enabled, only secure port will be supported\r
+## To disable enter 0\r
+header.authflag=1\r
+## Combination of userid,base64 encoded pwd list to be supported\r
+## userid and pwd comma separated; pipe delimitation between each pair\r
+header.authlist=secureid,IWRjYWVSb2FkbTEyMyEt|sample1,c2FtcGxlMQ==\r
+\r
+## Event transformation Flag - when set expects configurable transformation\r
+## defined under ./etc/eventTransform.json\r
+## Enabled by default; to disable set to 0\r
+event.transform.flag=1\r
+\r
+###############################################################################\r
+##\r
+## Tomcat control\r
+##\r
+#tomcat.maxthreads=(tomcat default, which is usually 200)\r
+\r
+\r