diff options
26 files changed, 474 insertions, 775 deletions
diff --git a/src/main/java/org/onap/dcae/commonFunction/AnyNode.java b/src/main/java/org/onap/dcae/commonFunction/AnyNode.java index b09a17a0..267c87a9 100644 --- a/src/main/java/org/onap/dcae/commonFunction/AnyNode.java +++ b/src/main/java/org/onap/dcae/commonFunction/AnyNode.java @@ -45,27 +45,21 @@ import java.util.stream.StreamSupport; * @author koblosz */ public class AnyNode { - private static final Logger LOGGER = LoggerFactory.getLogger(AnyNode.class); - private Object obj; + private final Object obj; + private static final Logger log = LoggerFactory.getLogger(AnyNode.class); - /** - * @param filePath - * @return - * @throws IOException - */ public static AnyNode parse(String filePath) throws IOException { try (FileReader fr = new FileReader(filePath)) { - JSONTokener tokener = new JSONTokener(fr); - return new AnyNode(new JSONObject(tokener)); + return new AnyNode(new JSONObject(new JSONTokener(fr))); } catch (FileNotFoundException | JSONException e1) { - LOGGER.error("Could not find or parse file under path %s due to: %s", filePath, e1.toString()); + log.error("Could not find or parse file under path %s due to: %s", filePath, e1.toString()); e1.printStackTrace(); throw e1; } } /** - * Returns keyset of underlying object. It is assumed that underlying object is of type org.json.JSONObject. + * Returns key set of underlying object. It is assumed that underlying object is of type org.json.JSONObject. * * @return Set of string keys present in underlying JSONObject */ @@ -131,12 +125,12 @@ public class AnyNode { AnyNode result = null; try { result = get(key); - } catch (JSONException ex) { + } catch (JSONException ignored) { } return Optional.ofNullable(result); } - public JSONObject asJsonObject() { + private JSONObject asJsonObject() { return (JSONObject) this.obj; } @@ -159,14 +153,14 @@ public class AnyNode { /** * Converts this object to stream of underlying objects wrapped with AnyNode class. It is assumed that this is of type JSONArray. */ - public Stream<AnyNode> asStream() { + private Stream<AnyNode> asStream() { return StreamSupport.stream(((JSONArray) this.obj).spliterator(), false).map(AnyNode::new); } /** * Checks if specified key is present in this. It is assumed that this is of type JSONObject. */ - public boolean hasKey(String key) { + boolean hasKey(String key) { return getAsOptional(key).isPresent(); } diff --git a/src/main/java/org/onap/dcae/commonFunction/CambriaPublisherFactory.java b/src/main/java/org/onap/dcae/commonFunction/CambriaPublisherFactory.java index 41230a14..79109c04 100644 --- a/src/main/java/org/onap/dcae/commonFunction/CambriaPublisherFactory.java +++ b/src/main/java/org/onap/dcae/commonFunction/CambriaPublisherFactory.java @@ -30,38 +30,34 @@ import org.slf4j.LoggerFactory; class CambriaPublisherFactory { - private static Logger log = LoggerFactory.getLogger(CambriaPublisherFactory.class); + private final static Logger log = LoggerFactory.getLogger(CambriaPublisherFactory.class); - public CambriaBatchingPublisher createCambriaPublisher(String streamId) + CambriaBatchingPublisher createCambriaPublisher(String streamId) throws MalformedURLException, GeneralSecurityException { String authpwd = null; DmaapPropertyReader reader = DmaapPropertyReader.getInstance(CommonStartup.cambriaConfigFile); - Map<String, String> dmaapProperties = reader.getDmaapProperties(); - String ueburl = dmaapProperties.get(streamId + ".cambria.url"); + Map<String, String> dMaaPProperties = reader.getDmaapProperties(); + String ueburl = dMaaPProperties.get(streamId + ".cambria.url"); if (ueburl == null) { - ueburl = dmaapProperties.get(streamId + ".cambria.hosts"); + ueburl = dMaaPProperties.get(streamId + ".cambria.hosts"); } String topic = reader.getKeyValue(streamId + ".cambria.topic"); String authuser = reader.getKeyValue(streamId + ".basicAuthUsername"); if (authuser != null) { - authpwd = dmaapProperties.get(streamId + ".basicAuthPassword"); + authpwd = dMaaPProperties.get(streamId + ".basicAuthPassword"); } if ((authuser != null) && (authpwd != null)) { log.debug(String.format("URL:%sTOPIC:%sAuthUser:%sAuthpwd:%s", ueburl, topic, authuser, authpwd)); return new CambriaClientBuilders.PublisherBuilder().usingHosts(ueburl).onTopic(topic).usingHttps() .authenticatedByHttp(authuser, authpwd).logSendFailuresAfter(5) - // .logTo(log) - // .limitBatch(100, 10) .build(); } else { log.debug(String.format("URL:%sTOPIC:%s", ueburl, topic)); return new CambriaClientBuilders.PublisherBuilder().usingHosts(ueburl).onTopic(topic) - // .logTo(log) .logSendFailuresAfter(5) - // .limitBatch(100, 10) .build(); } } diff --git a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java index 0ca25e2b..b60104ea 100644 --- a/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java +++ b/src/main/java/org/onap/dcae/commonFunction/CommonStartup.java @@ -29,7 +29,6 @@ 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;
@@ -51,125 +50,95 @@ 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";
- protected 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_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;
-
+ private static final String KCONFIG = "c";
+ private static final String KSETTING_PORT = "collector.service.port";
+ private static final int KDEFAULT_PORT = 8080;
+ private static final String KSETTING_SECUREPORT = "collector.service.secure.port";
+ private static final int KDEFAULT_SECUREPORT = -1;
+ private static final String KSETTING_KEYSTOREPASSFILE = "collector.keystore.passwordfile";
+ private static final String KDEFAULT_KEYSTOREPASSFILE = "../etc/passwordfile";
+ private static final String KSETTING_KEYSTOREFILE = "collector.keystore.file.location";
+ private static final String KDEFAULT_KEYSTOREFILE = "../etc/keystore";
+ private static final String KSETTING_KEYALIAS = "collector.keystore.alias";
+ private static final String KDEFAULT_KEYALIAS = "tomcat";
+ private static final String KSETTING_DMAAPCONFIGS = "collector.dmaapfile";
+ private static final String[] KDEFAULT_DMAAPCONFIGS = new String[] { "/etc/DmaapConfig.json" };
+ private static final String KSETTING_SCHEMAVALIDATOR = "collector.schema.checkflag";
+ private static final int KDEFAULT_SCHEMAVALIDATOR = -1;
+ private static final String KSETTING_SCHEMAFILE = "collector.schema.file";
+ private static final String KDEFAULT_SCHEMAFILE = "{\"v5\":\"./etc/CommonEventFormat_28.3.json\"}";
+ private static final String KSETTING_DMAAPSTREAMID = "collector.dmaap.streamid";
+ private static final String KSETTING_AUTHFLAG = "header.authflag";
+ private static final int KDEFAULT_AUTHFLAG = 0;
+ private static final String KSETTING_EVENTTRANSFORMFLAG = "event.transform.flag";
+ private static final int KDEFAULT_EVENTTRANSFORMFLAG = 1;
+ private static final Logger metriclog = LoggerFactory.getLogger("com.att.ecomp.metrics");
public static final Logger inlog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.input");
- public static final Logger oplog = LoggerFactory.getLogger("org.onap.dcae.commonFunction.output");
+ 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 final String KSETTING_AUTHLIST = "header.authlist";
+ static final int KDEFAULT_MAXQUEUEDEVENTS = 1024 * 4;
public static int schemaValidatorflag = -1;
public static int authflag = 1;
- public static int eventTransformFlag = 1;
- public static String schemaFile;
+ static int eventTransformFlag = 1;
public static JSONObject schemaFileJson;
- public static String cambriaConfigFile;
- private boolean listnerstatus;
- public static String streamid;
+ static String cambriaConfigFile;
+ public static String streamID;
- public static LinkedBlockingQueue<JSONObject> fProcessingInputQueue;
+ 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>();
+ private CommonStartup(rrNvReadable settings) throws loadException, IOException, rrNvReadable.missingReqdSetting {
+ final List<ApiServerConnector> connectors = new LinkedList<>();
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);
+ String keystorePassword = readFile(keystorePasswordFile);
connectors.add(new ApiServerConnector.Builder(securePort).secure(true)
- .keystorePassword(KSETTING_KEYSTOREPASS).keystoreFile(keystoreFile).keyAlias(keyAlias).build());
+ .keystorePassword(keystorePassword).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);
+ String schemaFile = settings.getString(KSETTING_SCHEMAFILE, KDEFAULT_SCHEMAFILE);
schemaFileJson = new JSONObject(schemaFile);
}
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);
+ String[] currentConfigFile = settings.getStrings(KSETTING_DMAAPCONFIGS, KDEFAULT_DMAAPCONFIGS);
+ cambriaConfigFile = currentConfigFile[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();
-
- 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);
@@ -178,101 +147,66 @@ public class CommonStartup extends NsaBaseEndpoint implements Runnable { settings.push(new nvPropertiesFile(settingStream));
settings.push(new nvReadableTable(argMap));
- fProcessingInputQueue = new LinkedBlockingQueue<JSONObject>(CommonStartup.KDEFAULT_MAXQUEUEDEVENTS);
+ fProcessingInputQueue = new LinkedBlockingQueue<>(CommonStartup.KDEFAULT_MAXQUEUEDEVENTS);
VESLogger.setUpEcompLogging();
CommonStartup cs = new CommonStartup(settings);
- Thread csmain = new Thread(cs);
- csmain.start();
+ Thread commonStartupThread = new Thread(cs);
+ commonStartupThread.start();
EventProcessor ep = new EventProcessor();
- executor = Executors.newFixedThreadPool(20);
- //executor.execute(ep);
+ ExecutorService executor = Executors.newFixedThreadPool(20);
for (int i = 0; i < 20; ++i) {
executor.execute(ep);
- }
+ }
- } catch (loadException | missingReqdSetting | IOException | invalidSettingValue | ServletException
- | InterruptedException e) {
+ } catch (loadException | missingReqdSetting | IOException e) {
CommonStartup.eplog.error("FATAL_STARTUP_ERROR" + e.getMessage());
throw new RuntimeException(e);
} catch (Exception 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();
+ fTomcatServer.await();
} catch (LifecycleException | IOException e) {
-
- log.error("lifecycle or IO: ", e);
+ throw new RuntimeException(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();
- }
-
+ public static void handleEvents(JSONArray a) throws QueueFullException, JSONException {
+ CommonStartup.metriclog.info("EVENT_PUBLISH_START");
+ for (int i = 0; i < a.length(); i++) {
+ if (!fProcessingInputQueue.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;
-
}
+ log.debug("CommonStartup.handleEvents:EVENTS has been published successfully!");
+ CommonStartup.metriclog.info("EVENT_PUBLISH_END");
}
- static String readFile(String path) throws IOException {
+ private static String readFile(String path) 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) {
+ public static String validateAgainstSchema(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);
@@ -280,20 +214,18 @@ public class CommonStartup extends NsaBaseEndpoint implements Runnable { JsonSchema schema = factory.getJsonSchema(schemaNode);
report = schema.validate(data);
} catch (JsonParseException e) {
- log.error("schemavalidate:JsonParseException for event:" + jsonData);
+ log.error("validateAgainstSchema:JsonParseException for event:" + jsonData);
return e.getMessage();
} catch (ProcessingException e) {
- log.error("schemavalidate:Processing exception for event:" + jsonData);
+ log.error("validateAgainstSchema: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);
+ "validateAgainstSchema: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();
+ for (ProcessingMessage pm : report) {
log.trace("Processing Message: " + pm.getMessage());
}
result = String.valueOf(report.isSuccess());
@@ -301,7 +233,7 @@ public class CommonStartup extends NsaBaseEndpoint implements Runnable { try {
log.debug("Validation Result:" + result + " Validation report:" + report);
} catch (NullPointerException e) {
- log.error("schemavalidate:NullpointerException on report");
+ log.error("validateAgainstSchema:NullpointerException on report");
}
return result;
}
diff --git a/src/main/java/org/onap/dcae/commonFunction/ConfigProcessors.java b/src/main/java/org/onap/dcae/commonFunction/ConfigProcessors.java index 80a65f08..a6de0fc8 100644 --- a/src/main/java/org/onap/dcae/commonFunction/ConfigProcessors.java +++ b/src/main/java/org/onap/dcae/commonFunction/ConfigProcessors.java @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; public class ConfigProcessors { - private static Logger log = LoggerFactory.getLogger(ConfigProcessors.class); + private static final Logger log = LoggerFactory.getLogger(ConfigProcessors.class); private static final String FIELD = "field"; private static final String OLD_FIELD = "oldField"; private static final String FILTER = "filter"; @@ -39,7 +39,7 @@ public class ConfigProcessors { private static final String FILTER_NOT_MET = "Filter not met"; private static final String COMP_FALSE = "==false"; - private JSONObject event; + private final JSONObject event; public ConfigProcessors(JSONObject eventJson) { event = eventJson; @@ -170,7 +170,7 @@ public class ConfigProcessors { private String performOperation(String operation, String value) { log.info("performOperation"); - if (operation != null && "convertMBtoKB".equals(operation)) { + if ("convertMBtoKB".equals(operation)) { float kbValue = Float.parseFloat(value) * 1024; value = String.valueOf(kbValue); } @@ -184,7 +184,7 @@ public class ConfigProcessors { final String oldField = jsonObject.getString(OLD_FIELD); final JSONObject filter = jsonObject.optJSONObject(FILTER); final String operation = jsonObject.optString("operation"); - String value = ""; + String value; if (filter == null || isFilterMet(filter)) { value = getEventObjectVal(oldField).toString(); @@ -267,19 +267,19 @@ public class ConfigProcessors { final JSONArray values = jsonObject.getJSONArray("concatenate"); final JSONObject filter = jsonObject.optJSONObject(FILTER); if (filter == null || isFilterMet(filter)) { - String value = ""; + StringBuilder value = new StringBuilder(); for (int i = 0; i < values.length(); i++) { String tempVal = evaluate(values.getString(i)); if (!tempVal.equals(OBJECT_NOT_FOUND)) { if (i == 0) - value = value + tempVal; + value.append(tempVal); else - value = value + delimiter + tempVal; + value.append(delimiter).append(tempVal); } } - setEventObjectVal(field, value); + setEventObjectVal(field, value.toString()); } else log.info(FILTER_NOT_MET); } @@ -323,8 +323,6 @@ public class ConfigProcessors { private boolean checkFilter(JSONObject jo, String key, String logicKey) { String filterValue = jo.getString(key); - boolean retVal = true; - if (filterValue.contains(":")) { String[] splitVal = filterValue.split(":"); if ("matches".equals(splitVal[0])) { @@ -368,26 +366,21 @@ public class ConfigProcessors { } } } - return retVal; + return true; } public boolean isFilterMet(JSONObject jo) { - boolean retval = true; - for (String key : jo.keySet()) { if ("not".equals(key)) { JSONObject njo = jo.getJSONObject(key); for (String njoKey : njo.keySet()) { - - retval = checkFilter(njo, njoKey, key); - if (!retval) - return retval; + if (!checkFilter(njo, njoKey, key)) + return false; } } else { - retval = checkFilter(jo, key, key); - if (!retval) - return retval; + if (!checkFilter(jo, key, key)) + return false; } } return true; @@ -407,17 +400,16 @@ public class ConfigProcessors { keySeriesStr = keySeriesStr.substring(0, keySeriesStr.length() - 1); String[] keySet = keySeriesStr.split("\\.", keySeriesStr.length()); Object keySeriesObj = event; - for (int i = 0; i < (keySet.length); i++) { - + for (String aKeySet : keySet) { if (keySeriesObj != null) { if (keySeriesObj instanceof String) { log.info("STRING==" + keySeriesObj); } else if (keySeriesObj instanceof JSONArray) { - keySeriesObj = ((JSONArray) keySeriesObj).optJSONObject(Integer.parseInt(keySet[i])); + keySeriesObj = ((JSONArray) keySeriesObj).optJSONObject(Integer.parseInt(aKeySet)); } else if (keySeriesObj instanceof JSONObject) { - keySeriesObj = ((JSONObject) keySeriesObj).opt(keySet[i]); + keySeriesObj = ((JSONObject) keySeriesObj).opt(aKeySet); } else { log.info("unknown object==" + keySeriesObj); diff --git a/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java b/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java index c0659aa6..0ee1e434 100644 --- a/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java +++ b/src/main/java/org/onap/dcae/commonFunction/DmaapPropertyReader.java @@ -68,9 +68,9 @@ public class DmaapPropertyReader { Map<String, String> transformedDmaapProperties = new HashMap<>(); try { AnyNode root = AnyNode.parse(configFilePath); - if (root.hasKey("channels")) { // Check if dmaap config is handled by legacy controller/service/manager + if (isInLegacyFormat(root)) { transformedDmaapProperties = getLegacyDmaapPropertiesWithChannels(root.get("channels")); - } else {//Handing new format from controllergen2/config_binding_service + } else { transformedDmaapProperties = getDmaapPropertiesWithInfoData(root); } } catch (IOException e) { @@ -79,6 +79,10 @@ public class DmaapPropertyReader { return transformedDmaapProperties; } + private static boolean isInLegacyFormat(AnyNode root) { + return root.hasKey("channels"); + } + private static Map<String, String> getLegacyDmaapPropertiesWithChannels(AnyNode channelsNode) { return channelsNode.asList().stream() .map(DmaapPropertyReader::getTransformedMandatoryChannelProperties) diff --git a/src/main/java/org/onap/dcae/commonFunction/DmaapPublishers.java b/src/main/java/org/onap/dcae/commonFunction/DmaapPublishers.java index c86a3742..a4c62719 100644 --- a/src/main/java/org/onap/dcae/commonFunction/DmaapPublishers.java +++ b/src/main/java/org/onap/dcae/commonFunction/DmaapPublishers.java @@ -25,7 +25,6 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; import java.io.IOException; import java.net.MalformedURLException; import java.security.GeneralSecurityException; @@ -36,7 +35,7 @@ import org.slf4j.LoggerFactory; class DmaapPublishers { - private static Logger log = LoggerFactory.getLogger(DmaapPublishers.class); + private static final Logger log = LoggerFactory.getLogger(DmaapPublishers.class); private final LoadingCache<String, CambriaBatchingPublisher> publishers; private DmaapPublishers( @@ -50,13 +49,9 @@ class DmaapPublishers { static DmaapPublishers create(final CambriaPublisherFactory publisherFactory) { final LoadingCache<String, CambriaBatchingPublisher> cache = CacheBuilder.<String, CambriaBatchingPublisher>newBuilder() -// .expireAfterAccess(10, TimeUnit.MINUTES) - .removalListener(new RemovalListener<String, CambriaBatchingPublisher>() { - @Override - public void onRemoval(RemovalNotification<String, CambriaBatchingPublisher> notification) { - if (notification.getValue() != null) { - onCacheItemInvalidated(notification.getValue()); - } + .removalListener((RemovalListener<String, CambriaBatchingPublisher>) notification -> { + if (notification.getValue() != null) { + onCacheItemInvalidated(notification.getValue()); } }) .build(new CacheLoader<String, CambriaBatchingPublisher>() { @@ -75,11 +70,11 @@ class DmaapPublishers { return new DmaapPublishers(cache); } - public CambriaBatchingPublisher getByStreamId(String streamId) { + CambriaBatchingPublisher getByStreamId(String streamId) { return publishers.getUnchecked(streamId); } - public void closeByStreamId(String streamId) { + void closeByStreamId(String streamId) { publishers.invalidate(streamId); } diff --git a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java index 6dd2f5c8..06a27328 100644 --- a/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java +++ b/src/main/java/org/onap/dcae/commonFunction/EventProcessor.java @@ -41,7 +41,7 @@ import java.util.HashMap; import java.util.List;
-public class EventProcessor implements Runnable {
+class EventProcessor implements Runnable {
private static final Logger log = LoggerFactory.getLogger(EventProcessor.class);
private static final String EVENT_LITERAL = "event";
@@ -53,8 +53,8 @@ public class EventProcessor implements Runnable { static Map<String, String[]> streamidHash = new HashMap<>();
public JSONObject event;
- public EventProcessor() {
- streamidHash = parseStreamIdToStreamHashMapping(CommonStartup.streamid);
+ EventProcessor() {
+ streamidHash = parseStreamIdToStreamHashMapping(CommonStartup.streamID);
}
private Map<String, String[]> parseStreamIdToStreamHashMapping(String streamId) {
@@ -63,7 +63,6 @@ public class EventProcessor implements Runnable { for (String aList : list) {
String domain = aList.split("=")[0];
String[] streamIdList = aList.substring(aList.indexOf('=') + 1).split(",");
-
streamidHash.put(domain, streamIdList);
}
return streamidHash;
@@ -72,12 +71,9 @@ public class EventProcessor implements Runnable { @Override
public void run() {
-
try {
-
- event = CommonStartup.fProcessingInputQueue.take();
-
- while (event != null) {
+ while (true) {
+ event = CommonStartup.fProcessingInputQueue.take();
// As long as the producer is running we remove elements from
// the queue.
log.info("QueueSize:" + CommonStartup.fProcessingInputQueue.size() + "\tEventProcessor\tRemoving element: " + event);
@@ -97,8 +93,6 @@ public class EventProcessor implements Runnable { sendEventsToStreams(streamIdList);
}
log.debug("Message published" + event);
- event = CommonStartup.fProcessingInputQueue.take();
-
}
} catch (InterruptedException e) {
log.error("EventProcessor InterruptedException" + e.getMessage());
diff --git a/src/main/java/org/onap/dcae/commonFunction/EventPublisherHash.java b/src/main/java/org/onap/dcae/commonFunction/EventPublisherHash.java index 474424a7..f3907126 100644 --- a/src/main/java/org/onap/dcae/commonFunction/EventPublisherHash.java +++ b/src/main/java/org/onap/dcae/commonFunction/EventPublisherHash.java @@ -38,11 +38,6 @@ public class EventPublisherHash { private static volatile EventPublisherHash instance = new EventPublisherHash(DmaapPublishers.create()); private final DmaapPublishers dmaapPublishers; - /** - * Returns event publisher - * - * @return event publisher - */ public static EventPublisherHash getInstance() { return instance; } @@ -52,14 +47,14 @@ public class EventPublisherHash { this.dmaapPublishers = dmaapPublishers; } - public void sendEvent(JSONObject event, String streamid) { + void sendEvent(JSONObject event, String streamid) { log.debug("EventPublisher.sendEvent: instance for publish is ready"); clearVesUniqueId(event); try { sendEventUsingCachedPublisher(streamid, event); } catch (IOException | IllegalArgumentException e) { - log.error("Unable to publish event: {} streamid: {}. Exception: {}", event, streamid, e); + log.error("Unable to publish event: {} streamID: {}. Exception: {}", event, streamid, e); dmaapPublishers.closeByStreamId(streamid); } } @@ -76,19 +71,15 @@ public class EventPublisherHash { private void sendEventUsingCachedPublisher(String streamid, JSONObject event) throws IOException { int pendingMsgs = dmaapPublishers.getByStreamId(streamid).send("MyPartitionKey", event.toString()); - // this.wait(2000); - if (pendingMsgs > 100) { log.info("Pending Message Count=" + pendingMsgs); } - log.info("pub.send invoked - no error"); - //CommonStartup.oplog.info(String.format("URL:%sTOPIC:%sEvent Published:%s", ueburl, topic, event)); CommonStartup.oplog.info(String.format("StreamID:%s Event Published:%s ", streamid, event)); } @VisibleForTesting - public CambriaBatchingPublisher getDmaapPublisher(String streamId) { + CambriaBatchingPublisher getDmaapPublisher(String streamId) { return dmaapPublishers.getByStreamId(streamId); } } diff --git a/src/main/java/org/onap/dcae/controller/FetchDynamicConfig.java b/src/main/java/org/onap/dcae/controller/FetchDynamicConfig.java index db4a5ad7..99e269c1 100644 --- a/src/main/java/org/onap/dcae/controller/FetchDynamicConfig.java +++ b/src/main/java/org/onap/dcae/controller/FetchDynamicConfig.java @@ -23,20 +23,13 @@ package org.onap.dcae.controller; import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
-import org.onap.dcae.commonFunction.CommonStartup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -47,16 +40,16 @@ public class FetchDynamicConfig { private static final Logger log = LoggerFactory.getLogger(FetchDynamicConfig.class);
public static String configFile = "/opt/app/KV-Configuration.json";
- static String url;
+ private static String url;
public static String retString;
public static String retCBSString;
- public static Map<String, String> env;
+ private static Map<String, String> env;
public FetchDynamicConfig() {
}
public static void main(String[] args) {
- Boolean areEqual = false;
+ Boolean areEqual;
// Call consul api and identify the CBS Service address and port
getconsul();
// Construct and invoke CBS API to get application Configuration
@@ -73,7 +66,7 @@ public class FetchDynamicConfig { }
}
- public static void getconsul() {
+ private static void getconsul() {
env = System.getenv();
for (Map.Entry<String, String> entry : env.entrySet()) {
@@ -107,13 +100,11 @@ public class FetchDynamicConfig { ObjectMapper mapper = new ObjectMapper();
JsonNode tree1 = mapper.readTree(jsonObject.toString());
- JsonNode tree2 = mapper.readTree(retCBSString.toString());
+ JsonNode tree2 = mapper.readTree(retCBSString);
areEqual = tree1.equals(tree2);
log.info("Comparison value:" + areEqual);
} else {
log.info("First time config file read: " + configFile);
- // To allow first time file creation
- areEqual = false;
}
} catch (IOException e) {
@@ -167,7 +158,7 @@ public class FetchDynamicConfig { }
- public static String executecurl(String url) {
+ private static String executecurl(String url) {
String[] command = { "curl", "-v", url };
ProcessBuilder process = new ProcessBuilder(command);
diff --git a/src/main/java/org/onap/dcae/controller/LoadDynamicConfig.java b/src/main/java/org/onap/dcae/controller/LoadDynamicConfig.java index 9184c3e7..a8ecaba0 100644 --- a/src/main/java/org/onap/dcae/controller/LoadDynamicConfig.java +++ b/src/main/java/org/onap/dcae/controller/LoadDynamicConfig.java @@ -30,7 +30,6 @@ import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; -import java.io.InputStreamReader; import java.util.Iterator; import java.util.Map; @@ -40,9 +39,7 @@ public class LoadDynamicConfig { public String propFile = "collector.properties"; public String configFile = "/opt/app/KV-Configuration.json"; - static String url; - static String retString; - public String dmaapoutputfile = "./etc/DmaapConfig.json"; + public String dMaaPOutputFile = "./etc/DmaapConfig.json"; public LoadDynamicConfig() { @@ -93,12 +90,10 @@ public class LoadDynamicConfig { // and write into dmaapconfig.json if (key.startsWith("streams_publishes")) { // VESCollector only have publish streams - try (FileWriter file = new FileWriter(dmaapoutputfile)) { - + 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); } @@ -124,7 +119,6 @@ public class LoadDynamicConfig { line = br.readLine(); } result = sb.toString(); - br.close(); } catch (Exception e) { log.error(e.getLocalizedMessage(), e); e.printStackTrace(); diff --git a/src/main/java/org/onap/dcae/restapi/ApiException.java b/src/main/java/org/onap/dcae/restapi/ApiException.java index 3feeacfc..0f922678 100644 --- a/src/main/java/org/onap/dcae/restapi/ApiException.java +++ b/src/main/java/org/onap/dcae/restapi/ApiException.java @@ -33,9 +33,9 @@ public enum ApiException { UNAUTHORIZED_USER(ExceptionType.POLICY_EXCEPTION, "POL2000", "Unauthorized user", 401), NO_SERVER_RESOURCES(ExceptionType.SERVICE_EXCEPTION, "SVC1000", "No server resources (internal processing queue full)", 503); - public final ExceptionType type; - public final String code; - public final String details; + private final ExceptionType type; + private final String code; + private final String details; public final int httpStatusCode; ApiException(ExceptionType type, String code, String details, int httpStatusCode) { diff --git a/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java b/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java index d664b137..0d9df155 100644 --- a/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java +++ b/src/main/java/org/onap/dcae/restapi/RestfulCollectorServlet.java @@ -34,8 +34,6 @@ import org.slf4j.LoggerFactory; import com.att.nsa.apiServer.CommonServlet;
import com.att.nsa.configs.ConfigDbException;
-import com.att.nsa.drumlin.service.framework.DrumlinErrorHandler;
-import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext;
import com.att.nsa.drumlin.service.framework.routing.DrumlinRequestRouter;
import com.att.nsa.drumlin.service.framework.routing.playish.DrumlinPlayishRoutingFileSource;
import com.att.nsa.drumlin.service.standards.HttpStatusCodes;
@@ -50,12 +48,15 @@ import com.att.nsa.security.db.simple.NsaSimpleApiKey; public class RestfulCollectorServlet extends CommonServlet
{
- public static String authlist;
+ private static final long serialVersionUID = 1L;
+ private static final Logger log = LoggerFactory.getLogger ( RestfulCollectorServlet.class );
+
+ private static String authCredentialsList;
public RestfulCollectorServlet ( rrNvReadable settings ) throws loadException, missingReqdSetting
{
super ( settings, "collector", false );
- authlist = settings.getString(CommonStartup.KSETTING_AUTHLIST,null);
+ authCredentialsList = settings.getString(CommonStartup.KSETTING_AUTHLIST, null);
}
@@ -69,8 +70,7 @@ public class RestfulCollectorServlet extends CommonServlet {
super.servletSetup ();
- try
- {
+ try {
// the base class provides a bunch of things like API authentication and ECOMP compliant
// logging. The Restful Collector likely doesn't need API authentication, so for now,
// we init the base class services with an in-memory (and empty!) config DB.
@@ -82,14 +82,8 @@ public class RestfulCollectorServlet extends CommonServlet final DrumlinRequestRouter drr = getRequestRouter ();
// you can tell the request router what to do when a particular kind of exception is thrown.
- drr.setHandlerForException( IllegalArgumentException.class, new DrumlinErrorHandler()
- {
- @Override
- public void handle ( DrumlinRequestContext ctx, Throwable cause )
- {
- sendJsonReply ( ctx, HttpStatusCodes.k400_badRequest, cause.getMessage() );
- }
- });
+ drr.setHandlerForException(IllegalArgumentException.class,
+ (ctx, cause) -> sendJsonReply (ctx, HttpStatusCodes.k400_badRequest, cause.getMessage() ));
// load the routes from the config file
final URL routes = findStream ( "routes.conf" );
@@ -99,52 +93,34 @@ public class RestfulCollectorServlet extends CommonServlet if (CommonStartup.authflag > 0) {
NsaAuthenticator<NsaSimpleApiKey> NsaAuth;
- NsaAuth = AuthlistHandler(authlist);
+ NsaAuth = createAuthenticator(authCredentialsList);
this.getSecurityManager().addAuthenticator(NsaAuth);
}
log.info ( "Restful Collector Servlet is up." );
}
- catch ( SecurityException e )
- {
- throw new ServletException ( e );
- }
- catch ( IOException e )
- {
- throw new ServletException ( e );
- }
- catch ( ConfigDbException e )
- {
+ catch ( SecurityException | IOException | ConfigDbException e ) {
throw new ServletException ( e );
}
}
- public NsaAuthenticator<NsaSimpleApiKey> AuthlistHandler (String authlist)
- {
- NsaAuthenticator<NsaSimpleApiKey> NsaAuth = new SimpleAuthenticator ();
- if (authlist != null)
- {
- String authpair[] = authlist.split("\\|");
- for (String pair: authpair) {
+ public NsaAuthenticator<NsaSimpleApiKey> createAuthenticator(String authCredentials) {
+ NsaAuthenticator<NsaSimpleApiKey> authenticator = new SimpleAuthenticator();
+ if (authCredentials != null) {
+ String authpair[] = authCredentials.split("\\|");
+ for (String pair : authpair) {
String lineid[] = pair.split(",");
- String listauthid = lineid[0];
- String listauthpwd = new String(Base64.decodeBase64(lineid[1]));
- ((SimpleAuthenticator) NsaAuth).add(listauthid,listauthpwd);
+ String listauthid = lineid[0];
+ String listauthpwd = new String(Base64.decodeBase64(lineid[1]));
+ ((SimpleAuthenticator) authenticator).add(listauthid, listauthpwd);
}
+ } else {
+ ((SimpleAuthenticator) authenticator).add("admin", "collectorpasscode");
}
- else
- {
- //add a default test account
- ((SimpleAuthenticator) NsaAuth).add("admin","collectorpasscode");
- }
- return NsaAuth;
-
+ return authenticator;
}
-
- private static final long serialVersionUID = 1L;
- private static final Logger log = LoggerFactory.getLogger ( RestfulCollectorServlet.class );
}
diff --git a/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java b/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java index 24bd96ea..d028a957 100644 --- a/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java +++ b/src/main/java/org/onap/dcae/restapi/endpoints/EventReceipt.java @@ -52,8 +52,6 @@ public class EventReceipt extends NsaBaseEndpoint { private static final Logger log = LoggerFactory.getLogger(EventReceipt.class);
private static final String MESSAGE = " Message:";
- static String valresult;
- static JSONObject customerror;
public static void receiveVESEvent(DrumlinRequestContext ctx) {
// the request body carries events. assume for now it's an array
@@ -64,7 +62,6 @@ public class EventReceipt extends NsaBaseEndpoint { JSONObject jsonObject;
- FileReader fr = null;
InputStream istr = null;
int arrayFlag = 0;
String vesVersion = null;
@@ -83,9 +80,6 @@ public class EventReceipt extends NsaBaseEndpoint { if (m.find()) {
log.info("VES version:" + m.group());
vesVersion = m.group();
- m = null;
- p = null;
-
}
final UUID uuid = UUID.randomUUID();
@@ -118,10 +112,7 @@ public class EventReceipt extends NsaBaseEndpoint { return;
}
- Boolean ErrorStatus = false;
- ErrorStatus = schemaCheck( retkey, arrayFlag, jsonObject, vesVersion, ctx, uuid);
- if (ErrorStatus)
- {
+ if (schemaCheck(retkey, arrayFlag, jsonObject, vesVersion, ctx, uuid)) {
return;
}
@@ -137,10 +128,6 @@ public class EventReceipt extends NsaBaseEndpoint { respondWithCustomMsginJson(ctx, ApiException.NO_SERVER_RESOURCES);
return;
} finally {
- if (fr != null) {
- safeClose(fr);
- }
-
if (istr != null) {
safeClose(istr);
}
@@ -150,28 +137,28 @@ public class EventReceipt extends NsaBaseEndpoint { }
- public static String getUser( DrumlinRequestContext ctx){
- String authorization = null;
- authorization = ctx.request().getFirstHeader("Authorization");
- if (authorization != null && authorization.startsWith("Basic")) {
- // Authorization: Basic base64credentials
+ private static String getUser(DrumlinRequestContext ctx){
+ String authorization = ctx.request().getFirstHeader("Authorization");
+ if (authorization != null && authorization.startsWith("Basic")) {
String base64Credentials = authorization.substring("Basic".length()).trim();
String credentials = new String(Base64.getDecoder().decode(base64Credentials),
Charset.forName("UTF-8"));
- // credentials = username:password
final String[] values = credentials.split(":",2);
- log.debug("User:" + values[0].toString() + " Pwd:" + values[1].toString());
- return values[0].toString();
+ log.debug("User:" + values[0] + " Pwd:" + values[1]);
+ return values[0];
}
return null;
}
- public static Boolean schemaCheck(NsaSimpleApiKey retkey, int arrayFlag,JSONObject jsonObject, String vesVersion, DrumlinRequestContext ctx, UUID uuid) throws JSONException, QueueFullException, IOException
- {
+
+ private static Boolean schemaCheck(NsaSimpleApiKey retkey, int arrayFlag,
+ JSONObject jsonObject, String vesVersion,
+ DrumlinRequestContext ctx, UUID uuid)
+ throws JSONException, QueueFullException, IOException {
+
JSONArray jsonArray;
JSONArray jsonArrayMod = new JSONArray();
JSONObject event;
- Boolean ErrorStatus=false;
FileReader fr;
if (retkey != null || CommonStartup.authflag == 0) {
if (CommonStartup.schemaValidatorflag > 0) {
@@ -180,25 +167,24 @@ public class EventReceipt extends NsaBaseEndpoint { fr = new FileReader(schemaFileVersion(vesVersion));
String schema = new JsonParser().parse(fr).toString();
- valresult = CommonStartup.schemavalidate(jsonObject.toString(), schema);
- if (valresult.equals("true")) {
- log.info("Validation successful");
- } else if (valresult.equals("false")) {
- log.info("Validation failed");
- respondWithCustomMsginJson(ctx, ApiException.SCHEMA_VALIDATION_FAILED);
- ErrorStatus=true;
- return ErrorStatus;
- } else {
- log.error("Validation errored" + valresult);
- respondWithCustomMsginJson(ctx, ApiException.INVALID_JSON_INPUT);
- ErrorStatus=true;
- return ErrorStatus;
+ String valresult = CommonStartup.validateAgainstSchema(jsonObject.toString(), schema);
+ switch (valresult) {
+ case "true":
+ log.info("Validation successful");
+ break;
+ case "false":
+ log.info("Validation failed");
+ respondWithCustomMsginJson(ctx, ApiException.SCHEMA_VALIDATION_FAILED);
+ return true;
+ default:
+ log.error("Validation errored" + valresult);
+ respondWithCustomMsginJson(ctx, ApiException.INVALID_JSON_INPUT);
+ return true;
}
} else {
log.info("Validation failed");
respondWithCustomMsginJson(ctx, ApiException.SCHEMA_VALIDATION_FAILED);
- ErrorStatus=true;
- return ErrorStatus;
+ return true;
}
if (arrayFlag == 1) {
jsonArray = jsonObject.getJSONArray("eventList");
@@ -222,8 +208,7 @@ public class EventReceipt extends NsaBaseEndpoint { log.info(String.format("Rejecting request with content type %s Message:%s",
ctx.request().getContentType(), jsonObject));
respondWithCustomMsginJson(ctx, ApiException.INVALID_CONTENT_TYPE);
- ErrorStatus=true;
- return ErrorStatus;
+ return true;
}
CommonStartup.handleEvents(jsonArrayMod);
@@ -231,30 +216,18 @@ public class EventReceipt extends NsaBaseEndpoint { log.info(String.format("Unauthorized request %s FROM %s %s %s %s", getUser(ctx), ctx.request().getRemoteAddress(), ctx.request().getContentType(), MESSAGE,
jsonObject));
respondWithCustomMsginJson(ctx, ApiException.UNAUTHORIZED_USER);
- ErrorStatus=true;
- return ErrorStatus;
+ return true;
}
- return ErrorStatus;
+ return false;
}
- public static void respondWithCustomMsginJson(DrumlinRequestContext ctx, ApiException apiException) {
+ private static void respondWithCustomMsginJson(DrumlinRequestContext ctx, ApiException apiException) {
ctx.response()
.sendErrorAndBody(apiException.httpStatusCode,
apiException.toJSON().toString(), MimeTypes.kAppJson);
}
- public static void safeClose(FileReader fr) {
- if (fr != null) {
- try {
- fr.close();
- } catch (IOException e) {
- log.error("Error closing file reader stream : " + e);
- }
- }
-
- }
-
- public static void safeClose(InputStream is) {
+ private static void safeClose(InputStream is) {
if (is != null) {
try {
is.close();
@@ -266,17 +239,8 @@ public class EventReceipt extends NsaBaseEndpoint { }
public static String schemaFileVersion(String version) {
- String filename = null;
-
- if (CommonStartup.schemaFileJson.has(version)) {
- filename = CommonStartup.schemaFileJson.getString(version);
- } else {
- filename = CommonStartup.schemaFileJson.getString("v5");
-
- }
- log.info(String.format("VESversion: %s Schema File:%s", version, filename));
- return filename;
-
+ return CommonStartup.schemaFileJson.has(version) ?
+ CommonStartup.schemaFileJson.getString(version) : CommonStartup.schemaFileJson.getString("v5");
}
}
diff --git a/src/test/java/org/onap/dcae/commonFunction/ApiExceptionTest.java b/src/test/java/org/onap/dcae/commonFunction/ApiExceptionTest.java index 0e494030..ef5b477c 100644 --- a/src/test/java/org/onap/dcae/commonFunction/ApiExceptionTest.java +++ b/src/test/java/org/onap/dcae/commonFunction/ApiExceptionTest.java @@ -44,7 +44,7 @@ public class ApiExceptionTest { @Test public void shouldConvertExceptionToBackwardCompatibleFormat() { JSONObject responseBody = ApiException.UNAUTHORIZED_USER.toJSON(); - assertJSONEqual(responseBody, asJSON("" + assertEquals(responseBody.toString(), new JSONObject("" + "{ " + " 'requestError': { " + " 'PolicyException': { " @@ -53,14 +53,7 @@ public class ApiExceptionTest { + " } " + " } " + "} " - )); - } - - private JSONObject asJSON(String jsonString) { - return new JSONObject(jsonString.replace("'", "\"")); - } - - private void assertJSONEqual(JSONObject o1, JSONObject o2) { - assertEquals(o1.toString(), o2.toString()); + .replace("'", "\"") + ).toString()); } } diff --git a/src/test/java/org/onap/dcae/commonFunction/ConfigProcessorAdapterTest.java b/src/test/java/org/onap/dcae/commonFunction/ConfigProcessorAdapterTest.java index 634424b0..180dfcf1 100644 --- a/src/test/java/org/onap/dcae/commonFunction/ConfigProcessorAdapterTest.java +++ b/src/test/java/org/onap/dcae/commonFunction/ConfigProcessorAdapterTest.java @@ -42,7 +42,7 @@ public class ConfigProcessorAdapterTest { @Test - public void shouldCallIsFilterMetOnAdapter() throws Exception { + public void shouldCallIsFilterMetOnAdapter() { //given JSONObject parameter = new JSONObject(); when(configProcessors.isFilterMet(parameter)).thenReturn(true); diff --git a/src/test/java/org/onap/dcae/commonFunction/DmaapPublishersTest.java b/src/test/java/org/onap/dcae/commonFunction/DmaapPublishersTest.java index 782b7c25..f4955ac8 100644 --- a/src/test/java/org/onap/dcae/commonFunction/DmaapPublishersTest.java +++ b/src/test/java/org/onap/dcae/commonFunction/DmaapPublishersTest.java @@ -57,8 +57,9 @@ public class DmaapPublishersTest { @Mock private CambriaBatchingPublisher cambriaPublisher; private DmaapPublishers cut; + @Rule - public ExpectedException expectedException = ExpectedException.none(); + public final ExpectedException expectedException = ExpectedException.none(); @Before public void setUp() throws MalformedURLException, GeneralSecurityException { diff --git a/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java b/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java index a3a47720..973ee014 100644 --- a/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java +++ b/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java @@ -27,7 +27,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import java.io.FileNotFoundException; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -43,11 +42,10 @@ import static org.onap.dcae.commonFunction.EventProcessor.EVENT_LIST_TYPE; public class EventProcessorTest { private final 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\"}]}}}"; - private String testinput = "src/test/resources/testDmaapConfig_ip.json"; @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"; + public void setUp() { + 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; } @@ -65,7 +63,7 @@ public class EventProcessorTest { } @Test - public void shouldParseJsonEvents() throws FileNotFoundException, ReflectiveOperationException { + public void shouldParseJsonEvents() throws ReflectiveOperationException { //given EventProcessor eventProcessor = new EventProcessor(); String event_json = "[{ \"filter\": {\"event.commonEventHeader.domain\":\"heartbeat\",\"VESversion\":\"v4\"},\"processors\":[" + diff --git a/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java b/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java index 18194864..e0fd5a42 100644 --- a/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java +++ b/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java @@ -19,6 +19,8 @@ */ package org.onap.dcae.commonFunction; +import static java.util.Base64.getDecoder; +import static java.util.Base64.getEncoder; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; @@ -34,7 +36,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import java.io.FileReader; import java.io.IOException; -import java.util.Base64; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import org.json.JSONArray; @@ -77,7 +78,7 @@ public class TestCommonStartup { @Test public void testParseStreamIdToStreamHashMapping() { // given - 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.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"; EventProcessor eventProcessor = new EventProcessor(); // when @@ -95,7 +96,7 @@ public class TestCommonStartup { String user1 = "secureid"; String password1Hashed = "IWRjYWVSb2FkbTEyMyEt"; - String password1UnHashed = decode("IWRjYWVSb2FkbTEyMyEt"); + String password1UnHashed = new String(getDecoder().decode("IWRjYWVSb2FkbTEyMyEt")); String user2 = "sample1"; String password2Hashed = "c2FtcGxlMQ"; @@ -105,24 +106,17 @@ public class TestCommonStartup { DrumlinRequest drumlinRequestMock = Mockito.mock(DrumlinRequest.class); - String basicHeaderForUser1 = "Basic " + encode(user1, password1UnHashed); + String basicHeaderForUser1 = "Basic " + getEncoder().encodeToString((user1 + ":" + password1UnHashed).getBytes()); when(drumlinRequestMock.getFirstHeader("Authorization")).thenReturn(basicHeaderForUser1); // when - SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) rsv.AuthlistHandler(authlist); + SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) rsv.createAuthenticator(authlist); NsaSimpleApiKey authentic = simpleAuthenticator.isAuthentic(drumlinRequestMock); // then assertEquals(authentic.getSecret(), password1UnHashed); } - private String decode(String hashedPassword) { - return new String(Base64.getDecoder().decode(hashedPassword.getBytes())); - } - - private String encode(String user1, String password1UnHashed) { - return Base64.getEncoder().encodeToString((user1 + ":" + password1UnHashed).getBytes()); - } } diff --git a/src/test/java/org/onap/dcae/vestest/AnyNodeTest.java b/src/test/java/org/onap/dcae/vestest/AnyNodeTest.java index 1613465f..695f53c9 100644 --- a/src/test/java/org/onap/dcae/vestest/AnyNodeTest.java +++ b/src/test/java/org/onap/dcae/vestest/AnyNodeTest.java @@ -51,7 +51,7 @@ public class AnyNodeTest { @Test(expected = IOException.class) public void testShouldRethrowExceptionWhenFileNotFound() throws IOException { - AnyNode.parse("not/existng/path"); + AnyNode.parse("not/existing/path"); } @Test diff --git a/src/test/java/org/onap/dcae/vestest/DmaapPropertyReaderTest.java b/src/test/java/org/onap/dcae/vestest/DmaapPropertyReaderTest.java index eadf62f2..46f5da4b 100644 --- a/src/test/java/org/onap/dcae/vestest/DmaapPropertyReaderTest.java +++ b/src/test/java/org/onap/dcae/vestest/DmaapPropertyReaderTest.java @@ -24,7 +24,6 @@ import com.google.common.collect.ImmutableMap; import org.junit.Test;
import org.onap.dcae.commonFunction.DmaapPropertyReader;
-import java.net.MalformedURLException;
import java.util.Map;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
@@ -53,7 +52,7 @@ public class DmaapPropertyReaderTest { private static final String FAULT_UEB_CAMBRIA_TOPIC_KEY = FAULT_UEB_KEY_PREFIX + ".cambria.topic";
private static final String VES_ALERT_SND_AUTH_USERNAME_KEY = VES_ALERT_SND_KEY_PREFIX + ".basicAuthUsername";
- public static final String NULL_TOSTRING = "null";
+ private static final String NULL_TOSTRING = "null";
private static final Map<String, String> expectedCompleteGen2DmaapConfig = ImmutableMap.<String, String>builder()
.put(ALERT_BASIC_AUTH_PWD_KEY, "SamplePassWD2")
@@ -106,7 +105,7 @@ public class DmaapPropertyReaderTest { }
@Test
- public void shouldCreateReaderWithCompleteGen2DmaapConfig() throws MalformedURLException {
+ public void shouldCreateReaderWithCompleteGen2DmaapConfig() {
assertReaderPreservedAllEntriesAfterTransformation(fullGen2DmaapConfig, expectedCompleteGen2DmaapConfig);
}
diff --git a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java index 2d6087e5..49b53d24 100644 --- a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java +++ b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java @@ -7,9 +7,9 @@ * 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.
@@ -31,260 +31,279 @@ import org.junit.Test; import org.onap.dcae.commonFunction.ConfigProcessors;
-
public class TestConfigProcessor {
- public JSONObject getFileAsJsonObject()
- {
- JSONObject jsonObject = null;
- FileReader fr = null;
- final JsonParser parser = new JsonParser();
- String jsonfilepath="src/test/resources/event4xjson.txt";
- try{
- fr = new FileReader ( jsonfilepath );
- 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();
- }
- finally {
- //close the file
- if (fr != null) {
- try {
- fr.close();
- } catch (IOException e) {
- System.out.println("Error closing file reader stream : " +e.toString());
- }
- }
- }
- return jsonObject;
- }
- @Test
- public void testAttrMap(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("functionRole==" + functionRole);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.commonEventHeader.nfNamingCode\",\"oldField\": \"event.commonEventHeader.functionalRole\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.map(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.nfNamingCode").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals (functionRole, responseData);
- }
-
- @Test
- public void testArrayMap(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- final String alarmAdditionalInformation = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("alarmAdditionalInformation").toString();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.map(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventAdditionalInformation").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals (alarmAdditionalInformation, responseData);
- }
- @Test
- public void testJobjMaptoArray(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
- System.out.println("event==" + jsonObject.toString());
- //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors.receiveDiscards").toString();
- System.out.println("receiveDiscards==" + receiveDiscards);
- cpEvent.map(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.vNicPerformanceArray[0].receivedDiscardedPacketsAccumulated").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals (receiveDiscards, responseData);
- }
- @Test
- public void testAttrAdd(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
- System.out.println("event==" + jsonObject.toString());
- //System.out.println("functionRole==" + functionRole);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.addAttribute(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("2.0", responseData);
- }
-
- @Test
- public void testAttrUpdate(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
- System.out.println("event==" + jsonObject.toString());
- //System.out.println("functionRole==" + functionRole);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.updateAttribute(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("2.0", responseData);
- }
-
- @Test
- public void testAttrConcatenate(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- final String eventType = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("eventType").toString();
- final String domain = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("domain").toString();
- final String alarmCondition = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("alarmCondition").toString();
- System.out.println("event==" + jsonObject.toString());
- final String eventName = domain + "_" + eventType + "_" + alarmCondition;
- System.out.println("eventName==" + eventName);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\":\"event.commonEventHeader.eventName\",\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\",\"$event.faultFields.alarmCondition\"],\"delimiter\":\"_\"}");
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.concatenateValue(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.eventName").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals (eventName, responseData);
- }
-
- @Test
- public void testAttrSubtract(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- final String memoryConfigured = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("memoryConfigured").toString();
- final String memoryUsed = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("memoryUsed").toString();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("memoryConfigured==" + memoryConfigured);
- System.out.println("memoryUsed==" + memoryUsed);
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.memoryFree\",\"subtract\": [\"$event.faultFields.memoryConfigured\",\"$event.faultFields.memoryUsed\"]}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.subtractValue(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.memoryFree").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("1980.0", responseData);
- }
-
- @Test
- public void testSetValue(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing SetValue");
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.setValue(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("2.0", responseData);
- }
-
- @Test
- public void testSetEventObjectVal(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing SetEventObjectVal");
- //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.setEventObjectVal("event.faultFields.version", "2.0", "number");
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("2.0", responseData);
- }
-
- @Test
- public void testGetValue(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing GetValue");
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventSeverity\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.getValue(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("CRITICAL", responseData);
- }
-
- @Test
- public void testGetEventObjectVal(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing GetEventObjectVal");
- //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventSeverity\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.getEventObjectVal("event.faultFields.eventSeverity");
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("CRITICAL", responseData);
- }
-
- @Test
- public void testRemoveAttribute(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing removeAttribute");
- final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.memoryUsed\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
- cpEvent.removeAttribute(jsonArgs);
- final String responseData = cpEvent.getEventObjectVal("event.faultFields.memoryUsed").toString();
- System.out.println("modified event==" + jsonObject.toString());
- System.out.println("responseData==" + responseData);
- assertEquals ("ObjectNotFound", responseData);
- }
-
- @Test
- public void testIsFilterMet(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing isFilterMet");
- final JSONObject jsonArgs = new JSONObject ( "{\"event.faultFields.eventSeverity\":\"CRITICAL\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
-
- final boolean response = cpEvent.isFilterMet(jsonArgs);
- String responseData = "CRITICAL";
- if (response == false)
- responseData = "notCRITICAL";
-
- System.out.println("responseData==" + responseData);
- assertEquals ("CRITICAL", responseData);
- }
-
- @Test
- public void testSuppressEvent(){
-
- final JSONObject jsonObject = getFileAsJsonObject();
- System.out.println("event==" + jsonObject.toString());
- System.out.println("Testing SuppressEvent");
- final JSONObject jsonArgs = new JSONObject ( "{\"event.faultFields.eventSeverity\":\"CRITICAL\"}" );
- ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
-
- cpEvent.suppressEvent(jsonArgs);
- String responseData = cpEvent.getEventObjectVal("suppressEvent").toString();
-
- System.out.println("responseData==" + responseData);
- assertEquals ("true", responseData);
- }
+
+ private JSONObject getFileAsJsonObject() {
+ JSONObject jsonObject = null;
+ FileReader fr = null;
+ final JsonParser parser = new JsonParser();
+ String jsonFilePath = "src/test/resources/event4xjson.txt";
+ try {
+ fr = new FileReader(jsonFilePath);
+ 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();
+ } finally {
+ //close the file
+ if (fr != null) {
+ try {
+ fr.close();
+ } catch (IOException e) {
+ System.out.println("Error closing file reader stream : " + e.toString());
+ }
+ }
+ }
+ return jsonObject;
+ }
+
+ @Test
+ public void testAttrMap() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader")
+ .get("functionalRole").toString();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("functionRole==" + functionRole);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.commonEventHeader.nfNamingCode\",\"oldField\": \"event.commonEventHeader.functionalRole\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.nfNamingCode").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals(functionRole, responseData);
+ }
+
+ @Test
+ public void testArrayMap() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ final String alarmAdditionalInformation = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
+ .get("alarmAdditionalInformation").toString();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventAdditionalInformation")
+ .toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals(alarmAdditionalInformation, responseData);
+ }
+
+ @Test
+ public void testJSONObjectMapToArray() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors.receiveDiscards").toString();
+ System.out.println("receiveDiscards==" + receiveDiscards);
+ cpEvent.map(jsonArgs);
+ final String responseData = cpEvent
+ .getEventObjectVal("event.faultFields.vNicPerformanceArray[0].receivedDiscardedPacketsAccumulated")
+ .toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals(receiveDiscards, responseData);
+ }
+
+ @Test
+ public void testAttrAdd() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("functionRole==" + functionRole);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.addAttribute(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("2.0", responseData);
+ }
+
+ @Test
+ public void testAttrUpdate() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
+ System.out.println("event==" + jsonObject.toString());
+ //System.out.println("functionRole==" + functionRole);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.updateAttribute(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("2.0", responseData);
+ }
+
+ @Test
+ public void testAttrConcatenate() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ final String eventType = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("eventType")
+ .toString();
+ final String domain = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("domain")
+ .toString();
+ final String alarmCondition = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
+ .get("alarmCondition").toString();
+ System.out.println("event==" + jsonObject.toString());
+ final String eventName = domain + "_" + eventType + "_" + alarmCondition;
+ System.out.println("eventName==" + eventName);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\":\"event.commonEventHeader.eventName\",\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\",\"$event.faultFields.alarmCondition\"],\"delimiter\":\"_\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.concatenateValue(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.commonEventHeader.eventName").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals(eventName, responseData);
+ }
+
+ @Test
+ public void testAttrSubtract() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ final String memoryConfigured = (jsonObject.getJSONObject("event")).getJSONObject("faultFields")
+ .get("memoryConfigured").toString();
+ final String memoryUsed = (jsonObject.getJSONObject("event")).getJSONObject("faultFields").get("memoryUsed")
+ .toString();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("memoryConfigured==" + memoryConfigured);
+ System.out.println("memoryUsed==" + memoryUsed);
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.memoryFree\",\"subtract\": [\"$event.faultFields.memoryConfigured\",\"$event.faultFields.memoryUsed\"]}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.subtractValue(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.memoryFree").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("1980.0", responseData);
+ }
+
+ @Test
+ public void testSetValue() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing SetValue");
+ final JSONObject jsonArgs = new JSONObject(
+ "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.setValue(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("2.0", responseData);
+ }
+
+ @Test
+ public void testSetEventObjectVal() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing SetEventObjectVal");
+ //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.setEventObjectVal("event.faultFields.version", "2.0", "number");
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("2.0", responseData);
+ }
+
+ @Test
+ public void testGetValue() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing GetValue");
+ final JSONObject jsonArgs = new JSONObject("{\"field\": \"event.faultFields.eventSeverity\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.getValue(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("CRITICAL", responseData);
+ }
+
+ @Test
+ public void testGetEventObjectVal() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing GetEventObjectVal");
+ //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventSeverity\"}" );
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.getEventObjectVal("event.faultFields.eventSeverity");
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("CRITICAL", responseData);
+ }
+
+ @Test
+ public void testRemoveAttribute() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing removeAttribute");
+ final JSONObject jsonArgs = new JSONObject("{\"field\": \"event.faultFields.memoryUsed\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+ cpEvent.removeAttribute(jsonArgs);
+ final String responseData = cpEvent.getEventObjectVal("event.faultFields.memoryUsed").toString();
+ System.out.println("modified event==" + jsonObject.toString());
+ System.out.println("responseData==" + responseData);
+ assertEquals("ObjectNotFound", responseData);
+ }
+
+ @Test
+ public void testIsFilterMet() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing isFilterMet");
+ final JSONObject jsonArgs = new JSONObject("{\"event.faultFields.eventSeverity\":\"CRITICAL\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+
+ final boolean response = cpEvent.isFilterMet(jsonArgs);
+ String responseData = "CRITICAL";
+ if (!response) {
+ responseData = "notCRITICAL";
+ }
+
+ System.out.println("responseData==" + responseData);
+ assertEquals("CRITICAL", responseData);
+ }
+
+ @Test
+ public void testSuppressEvent() {
+
+ final JSONObject jsonObject = getFileAsJsonObject();
+ System.out.println("event==" + jsonObject.toString());
+ System.out.println("Testing SuppressEvent");
+ final JSONObject jsonArgs = new JSONObject("{\"event.faultFields.eventSeverity\":\"CRITICAL\"}");
+ ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
+
+ cpEvent.suppressEvent(jsonArgs);
+ String responseData = cpEvent.getEventObjectVal("suppressEvent").toString();
+
+ System.out.println("responseData==" + responseData);
+ assertEquals("true", responseData);
+ }
}
diff --git a/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java b/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java index 2b392067..0489811d 100644 --- a/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java +++ b/src/test/java/org/onap/dcae/vestest/TestJsonSchemaValidation.java @@ -34,7 +34,7 @@ public class TestJsonSchemaValidation { @Test public void shouldValidEventPassSchema_27_2() throws IOException { - String result = CommonStartup.schemavalidate( + String result = CommonStartup.validateAgainstSchema( readJSONFromFile("src/test/resources/VES_valid.txt").toString(), readJSONFromFile("etc/CommonEventFormat_27.2.json").toString()); assertEquals(result, "true"); @@ -43,7 +43,7 @@ public class TestJsonSchemaValidation { @Test public void shouldInvalidEventDoesNotPassSchema_27_2() throws IOException { - String result = CommonStartup.schemavalidate( + String result = CommonStartup.validateAgainstSchema( readJSONFromFile("src/test/resources/VES_invalid.txt").toString(), readJSONFromFile("etc/CommonEventFormat_27.2.json").toString()); assertEquals(result, "false"); diff --git a/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java b/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java index ee0a3cba..03a074d7 100644 --- a/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java +++ b/src/test/java/org/onap/dcae/vestest/TestLoadDynamicConfig.java @@ -21,7 +21,6 @@ package org.onap.dcae.vestest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.onap.dcae.vestest.TestingUtilities.correctQuotes; import static org.onap.dcae.vestest.TestingUtilities.createTemporaryFile; import com.github.fge.jackson.JsonLoader; @@ -46,7 +45,7 @@ public class TestLoadDynamicConfig { @Test public void shouldReadFileContent() throws IOException { // given - String expectedJSON = correctQuotes("{ 'field' : 1 }"); + String expectedJSON = "{ \"field\" : 1 }"; Files.write(temporaryFile, expectedJSON.getBytes()); // when @@ -62,7 +61,7 @@ public class TestLoadDynamicConfig { LoadDynamicConfig loadDynamicConfig = new LoadDynamicConfig(); loadDynamicConfig.propFile = "src/test/resources/test_collector_ip_op.properties"; loadDynamicConfig.configFile = "src/test/resources/controller-config_dmaap_ip.json"; - loadDynamicConfig.dmaapoutputfile = temporaryFile.toString(); + loadDynamicConfig.dMaaPOutputFile = temporaryFile.toString(); String sampleConfiguration = LoadDynamicConfig.readFile(loadDynamicConfig.configFile); // when diff --git a/src/test/java/org/onap/dcae/vestest/TestingUtilities.java b/src/test/java/org/onap/dcae/vestest/TestingUtilities.java index 43e7a84e..7c7c09dc 100644 --- a/src/test/java/org/onap/dcae/vestest/TestingUtilities.java +++ b/src/test/java/org/onap/dcae/vestest/TestingUtilities.java @@ -36,10 +36,6 @@ final class TestingUtilities { // utility class, no objects allowed } - static String correctQuotes(String s) { - return s.replace("'", "\""); - } - static JsonObject readJSONFromFile(Path path) { return rethrow(() -> (JsonObject) new JsonParser().parse(new String(readAllBytes(path)))); } diff --git a/src/test/resources/test_collector_ip_op.properties b/src/test/resources/test_collector_ip_op.properties index a78258ec..f29a2ba6 100644 --- a/src/test/resources/test_collector_ip_op.properties +++ b/src/test/resources/test_collector_ip_op.properties @@ -1,78 +1,16 @@ -############################################################################### -## -## 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=-1 - -## 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=/opt/app/dcae-certificate/keystore.jks collector.keystore.passwordfile=/opt/app/dcae-certificate/.password collector.keystore.alias=dynamically generated - - -############################################################################### -## 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=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 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=sample1,c2FtcGxlMQ==|userid1,base64encodepwd1|userid2,base64encodepwd2 - -## 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 +collector.inputQueue.maxPending = 8096 streams_subscribes = {} services_calls = {} tomcat.maxthreads = 200 - -############################################################################### -## -## Tomcat control -## -#tomcat.maxthreads=(tomcat default, which is usually 200) - - diff --git a/src/test/resources/testcollector.properties b/src/test/resources/testcollector.properties index 7c00a208..7de53d61 100644 --- a/src/test/resources/testcollector.properties +++ b/src/test/resources/testcollector.properties @@ -1,75 +1,14 @@ -###############################################################################
-##
-## 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==
-
-## 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)
-
|