From 8b805372218d73a26057cbe59e07ff53f26226db Mon Sep 17 00:00:00 2001 From: Gokul Singaraju Date: Tue, 13 Mar 2018 15:53:18 -0400 Subject: Fix coverage and build issues Issue-ID: VNFSDK-217 Change-Id: I2a2def9aea76f4bf8c6d3e743163436f91bf6d22 Signed-Off-by: Gokul Singaraju --- .../evel_javalib2/dependency-reduced-pom.xml | 244 ++ veslibrary/ves_javalibrary/evel_javalib2/pom.xml | 389 ++- .../java/evel_javalibrary/att/com/AgentMain.java | 410 +++ .../java/evel_javalibrary/att/com/EvelBatch.java | 83 + .../java/evel_javalibrary/att/com/EvelFault.java | 529 +++ .../java/evel_javalibrary/att/com/EvelHeader.java | 723 ++++ .../att/com/EvelHeartbeatField.java | 214 ++ .../evel_javalibrary/att/com/EvelMobileFlow.java | 2064 +++++++++++ .../java/evel_javalibrary/att/com/EvelObject.java | 41 + .../java/evel_javalibrary/att/com/EvelOption.java | 44 + .../evel_javalibrary/att/com/EvelOptionDouble.java | 87 + .../evel_javalibrary/att/com/EvelOptionInt.java | 88 + .../att/com/EvelOptionIntHeader.java | 51 + .../evel_javalibrary/att/com/EvelOptionLong.java | 75 + .../evel_javalibrary/att/com/EvelOptionString.java | 88 + .../evel_javalibrary/att/com/EvelOptionTime.java | 91 + .../java/evel_javalibrary/att/com/EvelOther.java | 357 ++ .../att/com/EvelScalingMeasurement.java | 3680 ++++++++++++++++++++ .../evel_javalibrary/att/com/EvelSipSignaling.java | 558 +++ .../evel_javalibrary/att/com/EvelStateChange.java | 258 ++ .../java/evel_javalibrary/att/com/EvelSyslog.java | 486 +++ .../att/com/EvelThresholdCross.java | 502 +++ .../evel_javalibrary/att/com/EvelVoiceQuality.java | 671 ++++ .../java/evel_javalibrary/att/com/RingBuffer.java | 276 ++ .../evel_javalib2/src/test/java/TestJunit.java | 360 ++ .../evel_javalib2/src/test/java/TestRunner.java | 34 + 26 files changed, 12267 insertions(+), 136 deletions(-) create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/dependency-reduced-pom.xml create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelFault.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelHeader.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelHeartbeatField.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelMobileFlow.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelObject.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOption.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionDouble.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionInt.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionIntHeader.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionLong.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionString.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOptionTime.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelOther.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelSipSignaling.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelStateChange.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelSyslog.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelThresholdCross.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelVoiceQuality.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/RingBuffer.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java create mode 100644 veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestRunner.java diff --git a/veslibrary/ves_javalibrary/evel_javalib2/dependency-reduced-pom.xml b/veslibrary/ves_javalibrary/evel_javalib2/dependency-reduced-pom.xml new file mode 100644 index 0000000..2c9b207 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/dependency-reduced-pom.xml @@ -0,0 +1,244 @@ + + + + oparent + org.onap.oparent + 1.0.0-SNAPSHOT + ../pom.xml/pom.xml + + 4.0.0 + org.onap.vnfsdk.ves-agent + evel_javalib2 + vnfsdk-ves-agent-vesjavalibrary + + + + maven-compiler-plugin + 3.5 + + 1.8 + 1.8 + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + regex-property + + regex-property + + + docker.version + ${project.version} + (^[0-9]+.[0-9]+.[0-9]+$) + $1-STAGING + false + + + + + + maven-shade-plugin + 2.4.3 + + + package + + shade + + + + + + org.onap.dcae.inventory.InventoryApplication + + + + + + + + com.spotify + docker-maven-plugin + 1.0.0 + + ${onap.nexus.dockerregistry.daily}/onap/${project.groupId}.${project.artifactId} + openjdk:8-jre + ["java", "-jar", "/opt/${project.build.finalName}.jar", "server"] + + + /opt + ${project.build.directory} + ${project.build.finalName}.jar + + + + 8080 + + + ${project.version}-${maven.build.timestamp} + latest + + ${onap.nexus.dockerregistry.daily} + + + + maven-site-plugin + 3.6 + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 2.10 + + + + + org.codehaus.mojo + sonar-maven-plugin + 3.2 + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ecomp-staging + ${nexusproxy} + 176c31dfe190a + + + + maven-surefire-plugin + 2.20.1 + + + org.apache.maven.surefire + surefire-junit47 + 2.20.1 + + + + + + + + ecomp-snapshots + Snapshot Repository + ${nexusproxy}/${snapshotNexusPath} + + + ecomp-staging + Staging Repository + ${nexusproxy}/${stagingNexusPath} + + + + + junit + junit + 4.12 + test + + + hamcrest-core + org.hamcrest + + + + + org.mockito + mockito-all + 2.0.2-beta + test + + + org.powermock + powermock-module-junit4 + 1.6.5 + test + + + powermock-module-junit4-common + org.powermock + + + + + org.powermock + powermock-api-mockito + 1.6.5 + test + + + mockito-core + org.mockito + + + powermock-api-mockito-common + org.powermock + + + hamcrest-core + org.hamcrest + + + + + + + + maven-javadoc-plugin + 2.10.4 + + false + org.umlgraph.doclet.UmlGraphDoc + + org.umlgraph + umlgraph + 5.6 + + -views + true + + + + + + 1.1.1 + ${env.GIT_NO_PROJECT} + content/sites/site/org/onap/vnfsdk-ves-agent/${project.version} + content/repositories/staging/ + UTF-8 + content/repositories/releases/ + yyyyMMdd'T'HHmmss + 1.5.8 + content/repositories/snapshots/ + 1.2.3 + content/sites/site/org/onap/vnfsdk-ves-agent/${project.version}/ + UTF-8 + https://nexus.onap.org + ${project.version} + content/repositories/releases/ + 2017 + AT&T Intellectual Property. All rights reserved. + content/repositories/snapshots/ + + + diff --git a/veslibrary/ves_javalibrary/evel_javalib2/pom.xml b/veslibrary/ves_javalibrary/evel_javalib2/pom.xml index 6a00a19..07bfbec 100644 --- a/veslibrary/ves_javalibrary/evel_javalib2/pom.xml +++ b/veslibrary/ves_javalibrary/evel_javalib2/pom.xml @@ -1,26 +1,60 @@ + - 4.0.0 + 4.0.0 + + + org.onap.oparent + oparent + 1.0.0-SNAPSHOT + + org.onap.vnfsdk.ves-agent evel_javalib2 - 0.0.1-SNAPSHOT vnfsdk-ves-agent-vesjavalibrary - + + - UTF-8 - 1.7 - 1.7 - - ${env.GIT_NO_PROJECT} - ${project.version} - UTF-8 - https://nexus.onap.org - content/repositories/snapshots/ - content/repositories/releases/ - content/repositories/staging/ - content/sites/site/org/onap/vnfsdk-ves-agent/${project.version} + UTF-8 + ${env.GIT_NO_PROJECT} + ${project.version} + UTF-8 + 1.1.1 + 1.2.3 + 1.5.8 + + 2017 + AT&T Intellectual Property. All rights reserved. + + yyyyMMdd'T'HHmmss + https://nexus.onap.org + content/repositories/snapshots/ + content/repositories/releases/ + content/sites/site/org/onap/vnfsdk-ves-agent/${project.version}/ + content/repositories/snapshots/ + content/repositories/releases/ + content/repositories/staging/ + content/sites/site/org/onap/vnfsdk-ves-agent/${project.version} + ecomp-snapshots @@ -34,135 +68,218 @@ - - - ecomp-releases - Release Repository - ${nexusproxy}/${releaseNexusPath} - - - ecomp-snapshots - Snapshot Repository - ${nexusproxy}/${snapshotNexusPath} - - - - ecomp-site - dav:${nexusproxy}/${sitePath} - - - - src - + + + + junit + junit + 4.12 + test + + + log4j + log4j + 1.2.17 + + + javax.json + javax.json-api + 1.1 + + + org.slf4j + slf4j-log4j12 + 1.7.5 + + + org.glassfish + javax.json + 1.0.4 + + + org.mockito + mockito-all + 2.0.2-beta + test + + + org.powermock + powermock-module-junit4 + 1.6.5 + test + + + org.powermock + powermock-api-mockito + 1.6.5 + test + + + + + - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ${nexusproxy} - 176c31dfe190a - ecomp-staging - + org.apache.maven.plugins + maven-compiler-plugin + 3.5 + + 1.8 + 1.8 + - org.apache.maven.plugins - maven-site-plugin - 3.6 - - - org.apache.maven.wagon - wagon-webdav-jackrabbit - 2.10 - - + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + regex-property + + regex-property + + + docker.version + ${project.version} + (^[0-9]+.[0-9]+.[0-9]+$) + $1-STAGING + false + + + + - org.codehaus.groovy.maven - gmaven-plugin + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 - - validate - - execute - - - - println project.properties['ves.project.version']; - def versionArray; - if ( project.properties['ves.project.version'] != null ) { - versionArray = project.properties['ves.project.version'].split('\\.'); - } - - if ( project.properties['ves.project.version'].endsWith("-SNAPSHOT") ) { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-latest"; - } else { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; - } - - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; - - - - + + + package + + shade + + + + + + + + org.onap.dcae.inventory.InventoryApplication + + + + + - - - org.eclipse.m2e - lifecycle-mapping + + + com.spotify + docker-maven-plugin 1.0.0 - - - - - org.codehaus.mojo - aspectj-maven-plugin - [1.0,) - - test-compile - compile - - - - - - - - + ${onap.nexus.dockerregistry.daily}/onap/${project.groupId}.${project.artifactId} + openjdk:8-jre + ["java", "-jar", "/opt/${project.build.finalName}.jar", "server"] + + + /opt + ${project.build.directory} + ${project.build.finalName}.jar + + + + 8080 + + + ${project.version}-${maven.build.timestamp} + latest + + ${onap.nexus.dockerregistry.daily} + + + + + org.apache.maven.plugins + maven-site-plugin + 3.6 + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 2.10 + + + + + + org.codehaus.mojo + sonar-maven-plugin + 3.2 + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ecomp-staging + ${nexusproxy} + 176c31dfe190a + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20.1 + + + org.apache.maven.surefire + surefire-junit47 + 2.20.1 + + + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + false + org.umlgraph.doclet.UmlGraphDoc + + org.umlgraph + umlgraph + 5.6 + + -views + true - - - - - - - - junit - junit - 4.11 - test - - - log4j - log4j - 1.2.17 - - - javax.json - javax.json-api - 1.1 - - - org.slf4j - slf4j-log4j12 - 1.7.5 - - - org.glassfish - javax.json - 1.0.4 - - + + diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java new file mode 100644 index 0000000..7380d90 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/AgentMain.java @@ -0,0 +1,410 @@ + +package evel_javalibrary.att.com; + +/**************************************************************************//** + * @file + * Header for EVEL library + * + * This file implements the EVEL library which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it without worrying about details of the API transport. + * + * License + * ------- + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import org.apache.log4j.Logger; +import org.apache.log4j.Level; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyStore; + +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import javax.net.ssl.TrustManagerFactory; + +import org.apache.log4j.BasicConfigurator; + +/** + * @author Gokul Singaraju + */ + + +public class AgentMain { + +/**************************************************************************//** + * Error codes + * + * Error codes for EVEL low level interface + *****************************************************************************/ +public enum EVEL_ERR_CODES { + EVEL_SUCCESS, /** The operation was successful. */ + EVEL_ERR_GEN_FAIL, /** Non-specific failure. */ + EVEL_CURL_LIBRARY_FAIL, /** A cURL library operation failed. */ + EVEL_PTHREAD_LIBRARY_FAIL, /** A Posix threads operation failed. */ + EVEL_OUT_OF_MEMORY, /** A memory allocation failure occurred. */ + EVEL_EVENT_BUFFER_FULL, /** Too many events in the ring-buffer. */ + EVEL_EVENT_HANDLER_INACTIVE, /** Attempt to raise event when inactive. */ + EVEL_NO_METADATA, /** Failed to retrieve OpenStack metadata. */ + EVEL_BAD_METADATA, /** OpenStack metadata invalid format. */ + EVEL_BAD_JSON_FORMAT, /** JSON failed to parse correctly. */ + EVEL_JSON_KEY_NOT_FOUND, /** Failed to find the specified JSON key. */ + EVEL_MAX_ERROR_CODES /** Maximum number of valid error codes. */ +} + + private static final Logger logger = Logger.getLogger(AgentMain.class); + + private static String url = null; + private static URL vesurl = null; + private static URL vesbatchurl = null; + private static HttpURLConnection con = null; + private static String userpass = null; + private static String keystore_pth = null; + private static String jks_passw = null; + private static String key_passw = null; + private static String version = "5"; + + /* RingBuffer to forward messages on sending AgentDispatcher thread */ + private static RingBuffer ringb = new RingBuffer(100); + + Thread thr; + + /* AgentDispatcher loops on messages in RingBuffer and POSTs them + * to external Collector + */ + private static class AgentDispatcher implements Runnable { + + private String readStream(InputStream stream) throws Exception { + StringBuilder builder = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(stream))) { + String line; + while ((line = in.readLine()) != null) { + builder.append(line); // + "\r\n"(no need, json has no line breaks!) + } + in.close(); + } + logger.error("Resp: " + builder.toString()); + //System.out.println("Resp: " + builder.toString()); + return builder.toString(); + } + + // Create a trust manager that does not validate certificate chains + TrustManager[] trustAllCerts = new TrustManager[] { + new X509TrustManager() { + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[0]; + } + public void checkClientTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + public void checkServerTrusted( + java.security.cert.X509Certificate[] certs, String authType) { + } + } + }; + + public void run() { + + String datatosend=null; + for(;;){ + EvelObject tosend = ringb.take(); + if( tosend != null && ((datatosend = (String) tosend.datastr) != null)) + { + //process data + logger.trace(url + "Got an event size "+datatosend.length()); + logger.trace(datatosend); + + try { + + if( tosend.type == false) + con = (HttpURLConnection) vesurl.openConnection(); + else + con = (HttpURLConnection) vesbatchurl.openConnection(); + + if (con instanceof HttpsURLConnection) { + HttpsURLConnection httpsConnection = (HttpsURLConnection) con; + + try { + + SSLContext sc = SSLContext.getInstance("TLSv1.2"); + /* Get the JKS contents */ + if( !keystore_pth.isEmpty() && !jks_passw.isEmpty() && !key_passw.isEmpty() ) + { + final KeyStore keyStore = KeyStore.getInstance("JKS"); + try (final InputStream is = new FileInputStream(keystore_pth)) { + keyStore.load(is, jks_passw.toCharArray()); + } + final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory + .getDefaultAlgorithm()); + kmf.init(keyStore, key_passw.toCharArray()); + final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory + .getDefaultAlgorithm()); + tmf.init(keyStore); + sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new java.security.SecureRandom()); + } + else + { + // Init the SSLContext with a TrustManager[] and SecureRandom() + sc.init(null, trustAllCerts, new java.security.SecureRandom()); + } + httpsConnection.setDefaultHostnameVerifier(new HostnameVerifier() + { + public boolean verify(String hostname, SSLSession session) + { + return true; + } + }); + httpsConnection.setSSLSocketFactory(sc.getSocketFactory()); + con = httpsConnection; + + } + catch (final Exception exc) { + exc.printStackTrace(); + logger.error("SSL/TLS connection error"); + } + } + + //add reuqest header + con.setRequestMethod("POST"); + // No caching, we want the real thing. + con.setUseCaches (false); + // Specify the content type. + con.setRequestProperty("Content-Type", "application/json"); + con.setInstanceFollowRedirects( false ); + //Basic username password authentication + String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes("UTF-8")); + con.setRequestProperty ("Authorization", basicAuth); + + con.setReadTimeout(15000 /* milliseconds */); + con.setConnectTimeout(15000 /* milliseconds */); + // Send post request + con.setDoOutput(true); + con.setDoInput(true); + + con.setFixedLengthStreamingMode(datatosend.length()); + OutputStream os = con.getOutputStream(); + BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter(os, "UTF-8")); + //Call writer POST + writer.write(datatosend); + writer.flush(); + writer.close(); + os.close(); + //Handle the response code for POST request + int respCode = con.getResponseCode(); + logger.trace(url + "Connection HTTP Response code :"+respCode); + if(respCode < HttpURLConnection.HTTP_OK ) { + logger.trace(url + " **INFO**"); + } + else if(respCode >= HttpURLConnection.HTTP_OK && respCode < HttpURLConnection.HTTP_MULT_CHOICE ) + { + logger.trace(url + " **OK**"); + } + else if(respCode >= HttpURLConnection.HTTP_MULT_CHOICE && respCode < HttpURLConnection.HTTP_BAD_REQUEST ) + { + logger.warn(url + " **REDIRECTION**"); + } + else if(respCode >= HttpURLConnection.HTTP_BAD_REQUEST ) + { + logger.warn(url + " **SERVER ERROR**"); + + InputStream es = con.getErrorStream(); + readStream(es); + } + + + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + } + else + { + logger.trace(url + "Waiting for events"); + try { + Thread.sleep(5); + } catch (InterruptedException e) { + logger.trace("Interrupted on "+url); + e.printStackTrace(); + } + } + }//end for + }//end run + }//end AgentDispatcher + // Validate URL + public static boolean isValidURL(String urlStr) { + try { + URL url = new URL(urlStr); + return true; + } + catch (MalformedURLException e) { + return false; + } + } + + /**************************************************************************//** + * Library initialization. + * + * Initialize the EVEL library. + * + * @note This function initializes the Java EVEL library interfaces. + * Validates input parameters and starts the AgentDispatcher thread + * + * @param event_api_url The API's URL. + * @param port The API's port. + * @param path The optional path (may be NULL). + * @param topic The optional topic part of the URL (may be NULL). + * @param username Username for Basic Authentication of requests. + * @param password Password for Basic Authentication of requests. + * @param Level Java Log levels. + * + * @returns Status code + * @retval EVEL_SUCCESS On success + * @retval ::EVEL_ERR_CODES On failure. + *****************************************************************************/ + public static EVEL_ERR_CODES evel_initialize( + String event_api_url, + int port, + String path, + String topic, + String username, + String password, + String keystore_path, + String jks_password, + String key_password, + Level level) throws IOException + { + EVEL_ERR_CODES rc = EVEL_ERR_CODES.EVEL_SUCCESS; + + EVEL_ENTER(); + + BasicConfigurator.configure(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_api_url != null); + assert(port > 1024); + assert(username != null); + + logger.setLevel(level); + + if( !isValidURL(event_api_url) ){ + System.out.println("Invalid Event API URL"); + logger.error("Invalid Event API URL"); + rc = EVEL_ERR_CODES.EVEL_ERR_GEN_FAIL; + System.exit(1); + } + + if(path == null){ + path = ""; + } else { + version += "/example_vnf"; + } + + keystore_pth = keystore_path; + jks_passw = jks_password; + key_passw = key_password; + + url = event_api_url+":"+Integer.toString(port)+path+"/eventListener/v"+version; + vesurl = null; + try { + vesurl = new URL(url); + vesbatchurl = new URL(url+"/eventBatch"); + } catch (MalformedURLException e) { + logger.info("Error in url input"); + e.printStackTrace(); + System.exit(1); + } + userpass = username + ":" + password; + + logger.info("Starting Agent Dispatcher thread"); + Thread t = new Thread(new AgentDispatcher()); + t.start(); + + EVEL_EXIT(); + return rc; + + } + + private static void EVEL_EXIT() { + logger.trace("Exit VES Agent Main"); + } + + private static void EVEL_ENTER() { + logger.trace("Enter VES Agent Main"); + } + + /**************************************************************************//** + * Handle user formatted post message + * + * @note This function handles VES 5.x formatted messages from all valid + * Domains and stores them in RingBuffer. + * + * @param obj VES 5.x formatted user messages with common header + * and optional specialized body + * + * @retval boolean True On successful acceptance False on failure + *****************************************************************************/ + + public static boolean evel_post_event(EvelHeader obj) + { + String data = obj.evel_json_encode_event().toString(); + EvelObject myobj = new EvelObject(data,false); + boolean ret = ringb.put(myobj); + logger.info("Evel Post event ret:"+ret); + return ret; + } + + + /**************************************************************************//** + * Handle user formatted post message + * + * @note This function handles VES 5.x formatted messages from all valid + * Domains and stores them in RingBuffer. + * + * @param obj VES 5.x formatted user messages with common header + * and optional specialized body + * + * @retval boolean True On successful acceptance False on failure + *****************************************************************************/ + + public static boolean evel_post_event(EvelBatch obj) + { + String data = obj.evel_json_encode_event().toString(); + EvelObject myobj = new EvelObject(data,true); + boolean ret = ringb.put(myobj); + logger.info("Evel Post batch event ret:"+ret); + return ret; + } + + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java new file mode 100644 index 0000000..6db25b5 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelBatch.java @@ -0,0 +1,83 @@ +package evel_javalibrary.att.com; + +/**************************************************************************//** + * @file + * Evel Batch container class + * + * This file implements the Evel Mobile Flow Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send Mobile flow events. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + + +import java.util.ArrayList; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +import org.apache.log4j.Logger; + + +public class EvelBatch { + + ArrayList batch_events; + + private static final Logger LOGGER = Logger.getLogger( EvelScalingMeasurement.class.getName() ); + + + public EvelBatch(){ + batch_events = new ArrayList(); + if( batch_events == null ) LOGGER.error("Unable to allocate new batch"); + } + + public boolean addEvent(EvelHeader element){ + boolean ret = false; + ret = batch_events.add(element); + if( ret == false){ + LOGGER.error("Unable to add batch event"); + } + return ret; + + } + + /**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * retval : String of JSON event header only message + *****************************************************************************/ + JsonObject evel_json_encode_event() + { + JsonObjectBuilder batchobj = Json.createObjectBuilder(); + + if( batch_events != null && batch_events.size() > 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i additional_info; + + private static final Logger LOGGER = Logger.getLogger( EvelFault.class.getName() ); + + /**************************************************************************//** + * Create a new fault event. + * + * @note The mandatory fields on the Fault must be supplied to this factory + * function and are immutable once set. Optional fields have explicit + * setter functions, but again values may only be set once so that the + * Fault has immutable properties. + * @param condition The condition indicated by the Fault. + * @param specproblem The specific problem triggering the fault. + * @param priority The priority of the event. + * @param severity The severity of the Fault. + * @param ev_source_type Source of Alarm event + * @param status status of Virtual Function + *****************************************************************************/ + public EvelFault(String evname, String ev_id, + String condition, String specproblem, + EvelHeader.PRIORITIES tpriority, + EVEL_SEVERITIES severity, + EVEL_SOURCE_TYPES ev_source_type, + EVEL_VF_STATUSES status) + { + //Initializes Evel Header and Domain + super(evname,ev_id); + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT; + //Validate inputs + assert( condition != null); + assert( specific_problem != null); + assert(EvelHeader.PRIORITIES.EVEL_MAX_PRIORITIES.compareTo(tpriority) < 0 ); + assert(EVEL_SEVERITIES.EVEL_MAX_SEVERITIES.compareTo(severity) < 0 ); + assert(EVEL_VF_STATUSES.EVEL_MAX_VF_STATUSES.compareTo(status) < 0 ); + //Init mandatory fields + event_severity = severity; + event_source_type = ev_source_type; + alarm_condition = condition; + specific_problem = specproblem; + vf_status = status; + priority = tpriority; + //Init optional fields + category = new EvelOptionString(false, null); + alarm_interface_a = new EvelOptionString(false, null); + additional_info = null; + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Fault. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param fault Pointer to the fault. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_fault_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Fault Category property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param category Category : license, link, routing, security, signaling. + * ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_fault_category_set( String categ) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT); + assert(categ != null); + + category.SetValuePr(categ,"Fault Category set"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Alarm Interface A property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param interface The Alarm Interface A to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_fault_interface_set(String intf) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT); + assert(intf != null); + + alarm_interface_a.SetValuePr(intf,"Alarm Interface A"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Event Type property of the Fault. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param fault Pointer to the fault. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_fault_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(type != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT); + + evel_header_type_set(type); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Map an ::EVEL_SOURCE_TYPES enum value to the equivalent string. + * + * @param source_type The source type to convert. + * @returns The equivalent string. + *****************************************************************************/ + String evel_source_type(EVEL_SOURCE_TYPES source_type) + { + String result; + + EVEL_ENTER(); + + switch (source_type) + { + case EVEL_SOURCE_OTHER: + result = "other"; + break; + + case EVEL_SOURCE_ROUTER: + result = "router"; + break; + + case EVEL_SOURCE_SWITCH: + result = "switch"; + break; + + case EVEL_SOURCE_HOST: + result = "host"; + break; + + case EVEL_SOURCE_CARD: + result = "card"; + break; + + case EVEL_SOURCE_PORT: + result = "port"; + break; + + case EVEL_SOURCE_SLOT_THRESHOLD: + result = "slotThreshold"; + break; + + case EVEL_SOURCE_PORT_THRESHOLD: + result = "portThreshold"; + break; + + case EVEL_SOURCE_VIRTUAL_MACHINE: + result = "virtualMachine"; + break; + + case EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION: + result = "virtualNetworkFunction"; + break; + + default: + result = null; + LOGGER.error(MessageFormatter.format("Unexpected Event Source Type {0}", source_type)); + System.exit(1); + } + + EVEL_EXIT(); + + return result; + } + + /**************************************************************************//** + * Map an ::EVEL_SEVERITIES enum value to the equivalent string. + * + * @param severity The severity to convert. + * @returns The equivalent string. + *****************************************************************************/ + String evel_severity(EVEL_SEVERITIES severity) + { + String result = null; + + EVEL_ENTER(); + + switch (severity) + { + case EVEL_SEVERITY_CRITICAL: + result = "CRITICAL"; + break; + + case EVEL_SEVERITY_MAJOR: + result = "MAJOR"; + break; + + case EVEL_SEVERITY_MINOR: + result = "MINOR"; + break; + + case EVEL_SEVERITY_WARNING: + result = "WARNING"; + break; + + case EVEL_SEVERITY_NORMAL: + result = "NORMAL"; + break; + + default: + LOGGER.error("Unexpected event severity "+severity); + System.exit(1); + } + + EVEL_EXIT(); + + return result; + } + + + /**************************************************************************//** + * Map an ::EVEL_VF_STATUSES enum value to the equivalent string. + * + * @param vf_status The vf_status to convert. + * @returns The equivalent string. + *****************************************************************************/ + String evel_vf_status(EVEL_VF_STATUSES vf_status) + { + String result; + + EVEL_ENTER(); + + switch (vf_status) + { + case EVEL_VF_STATUS_ACTIVE: + result = "Active"; + break; + + case EVEL_VF_STATUS_IDLE: + result = "Idle"; + break; + + case EVEL_VF_STATUS_PREP_TERMINATE: + result = "Preparing to terminate"; + break; + + case EVEL_VF_STATUS_READY_TERMINATE: + result = "Ready to terminate"; + break; + + case EVEL_VF_STATUS_REQ_TERMINATE: + result = "Requesting termination"; + break; + + default: + result = null; + LOGGER.error("Unexpected VF Status "+vf_status); + System.exit(1); + } + + EVEL_EXIT(); + + return result; + } + + /**************************************************************************//** + * Encode the fault in JSON according to AT&T's schema for the fault type. + * + * @retval JsonObjectBuilder of fault body portion of message + *****************************************************************************/ + JsonObjectBuilder evelFaultObject() + { + String fault_severity; + String fault_source_type; + String fault_vf_status; + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_FAULT); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + + fault_severity = evel_severity(event_severity); + fault_source_type = evel_source_type(event_source_type); + fault_vf_status = evel_vf_status(vf_status); + + JsonObjectBuilder evelfault = Json.createObjectBuilder() + .add("alarmCondition", alarm_condition); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + + if( category.is_set ) + evelfault.add("eventCategory", category.GetValue()); + if( alarm_interface_a.is_set ) + evelfault.add("eventCategory", alarm_interface_a.GetValue()); + + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + evelfault.add( "eventSeverity", fault_severity); + evelfault.add( "eventSourceType", fault_source_type); + evelfault.add( "specificProblem", specific_problem); + evelfault.add( "vfStatus", fault_vf_status); + evelfault.add( "faultFieldsVersion", version); + + /***************************************************************************/ + /* Encode additional Name value pairs if any. */ + /***************************************************************************/ + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i>> 4]; + hexChars[j * 2 + 1] = hexArray[v & 0x0F]; + } + return new String(hexChars); + } + + /**************************************************************************//** + * Initialize a newly created event header. + * + * @param header Pointer to the header being initialized. + *****************************************************************************/ + public EvelHeader(String eventname,String ev_id) + { + EVEL_ENTER(); + + assert(eventname != null); + + /***************************************************************************/ + /* Initialize the header. Get a new event sequence number. Note that if */ + /* any memory allocation fails in here we will fail gracefully because */ + /* everything downstream can cope with nulls. */ + /***************************************************************************/ + this.event_domain = DOMAINS.EVEL_DOMAIN_HEARTBEAT; + if(ev_id == null){ + event_id = MessageFormat.format("{0}", event_sequence); + LOGGER.warning("WARNING:not confirming to Common Event Format 28.3 standard"); + } else + event_id = ev_id; + event_name = eventname; + start_epoch_microsec = last_epoch_microsec; + last_epoch_microsec = System.nanoTime()/1000; + priority = PRIORITIES.EVEL_PRIORITY_NORMAL; + + String hostname = "Unknown"; + String uuid = "Unknown"; + + try + { + InetAddress addr; + addr = InetAddress.getLocalHost(); + hostname = addr.getHostName(); + } + catch (UnknownHostException ex) + { + System.out.println("Hostname can not be resolved"); + } + + try{ + + Enumeration networks = + NetworkInterface.getNetworkInterfaces(); + while(networks.hasMoreElements()) { + NetworkInterface network = networks.nextElement(); + byte[] mac = network.getHardwareAddress(); + + if(hostname.equalsIgnoreCase("unknown")) + { + Enumeration inetAddrs = network.getInetAddresses(); + while(inetAddrs.hasMoreElements()){ + InetAddress inetAddr = (InetAddress) inetAddrs.nextElement(); + if (!inetAddr.isLoopbackAddress()) { + hostname = inetAddr.getHostAddress(); + break; + } + } + } + + if (mac != null) { + /* System.out.print("Current MAC address : "); + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < mac.length; i++) { + sb.append(String.format("%02X%s", mac[i], + (i < mac.length - 1) ? "-" : "")); + } */ + + uuid = bytesToHex(mac); + } + } + + } catch (SocketException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + reporting_entity_name = hostname; + source_name = hostname; + sequence = event_sequence; + + major_version = EVEL_HEADER_MAJOR_VERSION; + minor_version = EVEL_HEADER_MINOR_VERSION; + event_sequence++; + + /***************************************************************************/ + /* Optional parameters. */ + /***************************************************************************/ + event_type = new EvelOptionString(false, null); + nfcnaming_code = new EvelOptionString(false, null); + nfnaming_code = new EvelOptionString(false, null); + reporting_entity_id = new EvelOptionString(true, uuid); + source_id = new EvelOptionString(true, uuid); + internal_field = new EvelOptionIntHeader(false, null); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Create a new heartbeat event. + * + * @note that the heartbeat is just a "naked" commonEventHeader! + * + * @returns pointer to the newly manufactured ::EVENT_HEADER. + * @retval null Failed to create the event. + ****************************************************************************/ + + + public static EvelHeader evel_new_heartbeat() + { + EvelHeader header = null; + EVEL_ENTER(); + /***************************************************************************/ + /* Initialize the header. Get a new event sequence number. Note that if */ + /* any memory allocation fails in here we will fail gracefully because */ + /* everything downstream can cope with nulls. */ + /***************************************************************************/ + header = new EvelHeader("Heartbeat",null); + header.event_type.set_option(true); + header.event_type.SetValue("HEARTBEAT"); + LOGGER.info(header.event_type.value); + + EVEL_EXIT(); + return header; + } + + /**************************************************************************//** + * Create a new heartbeat event. + * + * @note that the heartbeat is just a "naked" commonEventHeader! + * + * @returns pointer to the newly manufactured ::EVENT_HEADER. + * @retval null Failed to create the event. + ****************************************************************************/ + + + public static EvelHeader evel_new_heartbeat(String evname,String evid) + { + EvelHeader header = null; + EVEL_ENTER(); + /***************************************************************************/ + /* Initialize the header. Get a new event sequence number. Note that if */ + /* any memory allocation fails in here we will fail gracefully because */ + /* everything downstream can cope with nulls. */ + /***************************************************************************/ + header = new EvelHeader(evname,evid); + header.event_type.set_option(true); + header.event_type.SetValue("HEARTBEAT");; + LOGGER.info(header.event_type.value); + + EVEL_EXIT(); + return header; + } + + + /**************************************************************************//** + * Set the Event Type property of the event header. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_header_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(type != null); + + event_type.set_option(true); + event_type.SetValue(type); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Start Epoch property of the event header. + * + * @note The Start Epoch defaults to the time of event creation. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param start_epoch_microsec + * The start epoch to set, in microseconds. + *****************************************************************************/ + public void evel_start_epoch_set(Long epoch_microsec) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + start_epoch_microsec = epoch_microsec; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Last Epoch property of the event header. + * + * @note The Last Epoch defaults to the time of event creation. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param last_epoch_microsec + * The last epoch to set, in microseconds. + *****************************************************************************/ + public void evel_last_epoch_set(Long epoch_microsec) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + last_epoch_microsec = epoch_microsec; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the NFC Naming code property of the event header. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param nfcnamingcode String + *****************************************************************************/ + public void evel_nfcnamingcode_set(String nfcnam) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(nfcnam != null); + nfcnaming_code.set_option(true); + nfcnaming_code.SetValue(nfcnam); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the NF Naming code property of the event header. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param nfnamingcode String + *****************************************************************************/ + public void evel_nfnamingcode_set(String nfnam) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(nfnam != null); + nfnaming_code.set_option(true); + nfnaming_code.SetValue(nfnam); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Reporting Entity Name property of the event header. + * + * @note The Reporting Entity Name defaults to the OpenStack VM Name. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param entity_name The entity name to set. + *****************************************************************************/ + public void evel_reporting_entity_name_set(String entity_name) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(entity_name != null); + + /***************************************************************************/ + /* Free the previously allocated memory and replace it with a copy of the */ + /* provided one. */ + /***************************************************************************/ + reporting_entity_name = entity_name; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Reporting Entity Id property of the event header. + * + * @note The Reporting Entity Id defaults to the OpenStack VM UUID. + * + * @param header Pointer to the ::EVENT_HEADER. + * @param entity_id The entity id to set. + *****************************************************************************/ + public void evel_reporting_entity_id_set(String entity_id) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and assign the new value. */ + /***************************************************************************/ + assert(entity_id != null); + + /***************************************************************************/ + /* Free the previously allocated memory and replace it with a copy of the */ + /* provided one. Note that evel_force_option_string strdups entity_id. */ + /***************************************************************************/ + reporting_entity_id.set_option(true); + reporting_entity_id.SetValue(entity_id); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Priority property of the event header. + * + * @note The Priority of event being reported. + * + * @param priorityval Value of priority. + * + *****************************************************************************/ + public void evel_header_set_priority(PRIORITIES priority_val) + { + EVEL_ENTER(); + + assert(EvelHeader.PRIORITIES.EVEL_MAX_PRIORITIES.compareTo(priority_val) < 0 ); + + priority = priority_val; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Priority property of the event header. + * + * @note The Reporting Entity Id defaults to the OpenStack VM UUID. + * + * @param val Optional true or false. + * @param srcid The source id to set. + *****************************************************************************/ + public void evel_header_set_sourceid(boolean val, String srcid) + { + EVEL_ENTER(); + + assert(srcid != null); + + source_id.set_option(val); + + source_id.SetValue(srcid); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Source name property of the event header. + * + * @note Source name should identify the IP address or Source Event originator + * for inventory + * + * @param srcname String for sourcename. + *****************************************************************************/ + public void evel_header_set_source_name(String srcname) + { + EVEL_ENTER(); + + assert(srcname != null); + + source_name = srcname; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string. + * + * @param domain The domain to convert. + * @returns The equivalent string. + *****************************************************************************/ + String evel_event_domain(DOMAINS domain) + { + String result; + + EVEL_ENTER(); + + switch (domain) + { + case EVEL_DOMAIN_HEARTBEAT: + result = "heartbeat"; + break; + + case EVEL_DOMAIN_FAULT: + result = "fault"; + break; + + case EVEL_DOMAIN_MEASUREMENT: + result = "measurementsForVfScaling"; + break; + + case EVEL_DOMAIN_REPORT: + result = "measurementsForVfReporting"; + break; + + case EVEL_DOMAIN_MOBILE_FLOW: + result = "mobileFlow"; + break; + + case EVEL_DOMAIN_HEARTBEAT_FIELD: + result = "heartbeat"; + break; + + case EVEL_DOMAIN_SIPSIGNALING: + result = "sipSignaling"; + break; + + case EVEL_DOMAIN_STATE_CHANGE: + result = "stateChange"; + break; + + case EVEL_DOMAIN_SYSLOG: + result = "syslog"; + break; + + case EVEL_DOMAIN_OTHER: + result = "other"; + break; + + case EVEL_DOMAIN_VOICE_QUALITY: + result = "voiceQuality"; + break; + + case EVEL_DOMAIN_THRESHOLD_CROSSING: + result = "thresholdCrossingAlert"; + break; + + default: + result = null; + LOGGER.severe(MessageFormat.format("Unexpected domain {0}", domain)); + } + + EVEL_EXIT(); + + return result; + } + + /**************************************************************************//** + * Map an ::EVEL_EVENT_PRIORITIES enum value to the equivalent string. + * + * @param priority The priority to convert. + * @returns The equivalent string. + *****************************************************************************/ + String evel_event_priority(PRIORITIES priority) + { + String result; + + EVEL_ENTER(); + + switch (priority) + { + case EVEL_PRIORITY_HIGH: + result = "High"; + break; + + case EVEL_PRIORITY_MEDIUM: + result = "Medium"; + break; + + case EVEL_PRIORITY_NORMAL: + result = "Normal"; + break; + + case EVEL_PRIORITY_LOW: + result = "Low"; + break; + + default: + result = null; + LOGGER.severe(MessageFormat.format("Unexpected priority {0}", priority)); + } + + EVEL_EXIT(); + + return result; + } + + /**************************************************************************//** + * Encode the CommonEventHeaeder as a JSON event object builder + * according to AT&T's schema. + * + * @retval JsonObjectBuilder of fault body portion of message + *****************************************************************************/ + JsonObjectBuilder eventHeaderObject() + { + String domain = evel_event_domain(event_domain); + String prity = evel_event_priority(priority); + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Required fields. */ + /***************************************************************************/ + + JsonObjectBuilder commheader = Json.createObjectBuilder() + .add("domain", domain) + .add("eventId", event_id) + .add("eventName", event_name) + .add("lastEpochMicrosec", last_epoch_microsec) + .add("priority", prity) + .add("reportingEntityName", reporting_entity_name) + .add("sequence", sequence) + .add("sourceName", source_name) + .add("startEpochMicrosec", start_epoch_microsec) + .add("version", version) + .add("reportingEntityId", reporting_entity_id.GetValue()) + .add("sourceId", source_id.GetValue()); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + + if( event_type.is_set ) + commheader.add("eventType", event_type.GetValue()); + if( source_id.is_set ) + commheader.add("sourceId", source_id.GetValue()); + if( reporting_entity_id.is_set ) + commheader.add("reportingEntityId", reporting_entity_id.GetValue()); + + if( internal_field.is_set ) + commheader.add("internalField",internal_field.toString()); + + if( nfcnaming_code.is_set ) + commheader.add("nfcNamingCode", nfcnaming_code.GetValue()); + if( nfnaming_code.is_set ) + commheader.add("nfNamingCode", nfnaming_code.GetValue()); + + EVEL_EXIT(); + + return commheader; + + } + + + /**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * retval : String of JSON event header only message + *****************************************************************************/ + JsonObject evel_json_encode_event() + { + + JsonObject obj = Json.createObjectBuilder() + .add("event", Json.createObjectBuilder() + .add( "commonEventHeader",eventHeaderObject() ) + ).build(); + + EVEL_EXIT(); + + return obj; + + } + + + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelHeartbeatField.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelHeartbeatField.java new file mode 100644 index 0000000..f07557d --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelHeartbeatField.java @@ -0,0 +1,214 @@ +package evel_javalibrary.att.com; +/**************************************************************************//** + * @file + * Evel Heartbeat field class + * + * This file implements the Evel Heartbeat Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send Agent status. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import java.text.MessageFormat; +import java.util.ArrayList; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +import org.apache.log4j.Logger; + + +public class EvelHeartbeatField extends EvelHeader { + + //version of Heartbeat field format revisions + int major_version = 1; + int minor_version = 0; + + /**************************************************************************//** + * Alert types. + * JSON equivalent fields: newState, oldState + *****************************************************************************/ + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + int heartbeat_interval; + + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + ArrayList additional_info; + + private static final Logger LOGGER = Logger.getLogger( EvelHeartbeatField.class.getName() ); + + /**************************************************************************//** + * Construct Heartbeat field event. + * + * @param interval The Heartbeat interval at which messages are sent. + * + *****************************************************************************/ + public EvelHeartbeatField(int interval,String evname,String evid) + { + super(evname,evid); + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_HEARTBEAT_FIELD; + assert( interval > 0 ); + + heartbeat_interval = interval; + + additional_info = null; + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Fault. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_hrtbt_field_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_STATE_CHANGE); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Interval property of the Heartbeat fields event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param interval Heartbeat interval. + *****************************************************************************/ + public void evel_hrtbt_interval_set( int interval) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_set_option_string. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_HEARTBEAT_FIELD); + assert(interval > 0); + + heartbeat_interval = interval; + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode the Heartbeat field in JSON according to AT&T's schema. + * + * @retval JsonObjectBuilder of Heartbeat field body portion of message + *****************************************************************************/ + JsonObjectBuilder evelHeartbeatFieldObject() + { + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_HEARTBEAT_FIELD); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + + JsonObjectBuilder evelstate = Json.createObjectBuilder() + .add("heartbeatInterval", heartbeat_interval); + + evelstate.add( "heartbeatFieldsVersion", version); + + /***************************************************************************/ + /* Checkpoint, so that we can wind back if all fields are suppressed. */ + /***************************************************************************/ + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i= 0.0); + assert(tavg_packet_delay_variation >= 0.0); + assert(tavg_packet_latency >= 0); + assert(tavg_receive_throughput >= 0); + assert(tavg_transmit_throughput >= 0); + assert(tflow_activation_epoch > 0); + assert(tflow_activation_microsec >= 0); + assert(tflow_deactivation_epoch > 0); + assert(tflow_deactivation_microsec >= 0); + assert(tflow_status != null); + assert(tmax_packet_delay_variation >= 0); + assert(tnum_activation_failures >= 0); + assert(tnum_bit_errors >= 0); + assert(tnum_bytes_received >= 0); + assert(tnum_bytes_transmitted >= 0); + assert(tnum_dropped_packets >= 0); + assert(tnum_l7_bytes_received >= 0); + assert(tnum_l7_bytes_transmitted >= 0); + assert(tnum_lost_packets >= 0); + assert(tnum_out_of_order_packets >= 0); + assert(tnum_packet_errors >= 0); + assert(tnum_packets_received_excl_retrans >= 0); + assert(tnum_packets_received_incl_retrans >= 0); + assert(tnum_packets_transmitted_incl_retrans >= 0); + assert(tnum_retries >= 0); + assert(tnum_timeouts >= 0); + assert(tnum_tunneled_l7_bytes_received >= 0); + assert(tround_trip_time >= 0); + assert(ttime_to_first_byte >= 0); + + /***************************************************************************/ + /* Allocate the Mobile Flow GTP Per Flow Metrics. */ + /***************************************************************************/ + LOGGER.debug("New Mobile Flow GTP Per Flow Metrics"); + + /***************************************************************************/ + /* Initialize the Mobile Flow GTP Per Flow Metrics fields. Optional */ + /* string values are uninitialized (null). */ + /***************************************************************************/ + avg_bit_error_rate = tavg_bit_error_rate; + avg_packet_delay_variation = tavg_packet_delay_variation; + avg_packet_latency = tavg_packet_latency; + avg_receive_throughput = tavg_receive_throughput; + avg_transmit_throughput = tavg_transmit_throughput; + flow_activation_epoch = tflow_activation_epoch; + flow_activation_microsec = tflow_activation_microsec; + flow_deactivation_epoch = tflow_deactivation_epoch; + flow_deactivation_microsec = tflow_deactivation_microsec; + flow_deactivation_time = tflow_deactivation_time; + flow_status = tflow_status; + max_packet_delay_variation = tmax_packet_delay_variation; + num_activation_failures = tnum_activation_failures; + num_bit_errors = tnum_bit_errors; + num_bytes_received = tnum_bytes_received; + num_bytes_transmitted = tnum_bytes_transmitted; + num_dropped_packets = tnum_dropped_packets; + num_l7_bytes_received = tnum_l7_bytes_received; + num_l7_bytes_transmitted = tnum_l7_bytes_transmitted; + num_lost_packets = tnum_lost_packets; + num_out_of_order_packets = tnum_out_of_order_packets; + num_packet_errors = tnum_packet_errors; + num_packets_received_excl_retrans = + tnum_packets_received_excl_retrans; + num_packets_received_incl_retrans = + tnum_packets_received_incl_retrans; + num_packets_transmitted_incl_retrans = + tnum_packets_transmitted_incl_retrans; + num_retries = tnum_retries; + num_timeouts = tnum_timeouts; + num_tunneled_l7_bytes_received = tnum_tunneled_l7_bytes_received; + round_trip_time = tround_trip_time; + time_to_first_byte = ttime_to_first_byte; + ip_tos_counts = new EvelOptionInt[EVEL_TOS_SUPPORTED]; + for (ii = 0; ii < EVEL_TOS_SUPPORTED; ii++) + { + ip_tos_counts[ii] = new EvelOptionInt(); + } + tcp_flag_counts = new EvelOptionInt[EVEL_MAX_TCP_FLAGS]; + for (ii = 0; ii < EVEL_MAX_TCP_FLAGS; ii++) + { + tcp_flag_counts[ii] = new EvelOptionInt(); + } + qci_cos_counts = new EvelOptionInt[EVEL_MAX_QCI_COS_TYPES]; + for (ii = 0; ii < EVEL_MAX_QCI_COS_TYPES; ii++) + { + qci_cos_counts[ii] = new EvelOptionInt(); + } + dur_connection_failed_status = new EvelOptionInt(); + dur_tunnel_failed_status = new EvelOptionInt(); + flow_activated_by = new EvelOptionString(); + flow_activation_time = new EvelOptionTime(); + flow_deactivated_by = new EvelOptionString(); + gtp_connection_status = new EvelOptionString(); + gtp_tunnel_status = new EvelOptionString(); + large_packet_rtt = new EvelOptionInt(); + large_packet_threshold = new EvelOptionDouble(); + max_receive_bit_rate = new EvelOptionInt(); + max_transmit_bit_rate = new EvelOptionInt(); + num_gtp_echo_failures = new EvelOptionInt(); + num_gtp_tunnel_errors = new EvelOptionInt(); + num_http_errors = new EvelOptionInt(); + + EVEL_EXIT(); + } + } + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + String flow_direction; + public MOBILE_GTP_PER_FLOW_METRICS gtp_per_flow_metrics; + String ip_protocol_type; + String ip_version; + String other_endpoint_ip_address; + int other_endpoint_port; + String reporting_endpoint_ip_addr; + int reporting_endpoint_port; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + ArrayList additional_info; + EvelOptionString application_type; + EvelOptionString app_protocol_type; + EvelOptionString app_protocol_version; + EvelOptionString cid; + EvelOptionString connection_type; + EvelOptionString ecgi; + EvelOptionString gtp_protocol_type; + EvelOptionString gtp_version; + EvelOptionString http_header; + EvelOptionString imei; + EvelOptionString imsi; + EvelOptionString lac; + EvelOptionString mcc; + EvelOptionString mnc; + EvelOptionString msisdn; + EvelOptionString other_functional_role; + EvelOptionString rac; + EvelOptionString radio_access_technology; + EvelOptionString sac; + EvelOptionInt sampling_algorithm; + EvelOptionString tac; + EvelOptionString tunnel_id; + EvelOptionString vlan_id; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + + + /*****************************************************************************/ + /* Local prototypes */ + /*****************************************************************************/ + + + /**************************************************************************//** + * Create a new Mobile Flow event. + * + * @note The mandatory fields on the Mobile Flow must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once so + * that the Mobile Flow has immutable properties. + * @param flow_direction Flow direction. + * @param gtp_per_flow_metrics GTP per-flow metrics. + * @param ip_protocol_type IP protocol type. + * @param ip_version IP protocol version. + * @param other_endpoint_ip_address IP address of the other endpoint. + * @param other_endpoint_port IP port of the other endpoint. + * @param reporting_endpoint_ip_addr IP address of the reporting endpoint. + + * @param reporting_endpoint_port IP port of the reporting endpoint. + *****************************************************************************/ + public EvelMobileFlow( String evname, String evid, + String flow_dir, + MOBILE_GTP_PER_FLOW_METRICS gtp_per_flow_metr, + String ip_protocol_typ, + String ip_vers, + String other_endpoint_ip_addr, + int other_endpoint_pt, + String reporting_endpoint_ipaddr, + int reporting_endpoint_pt) + { + super(evname,evid); + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(flow_dir != null); + assert(gtp_per_flow_metr != null); + assert(ip_protocol_typ != null); + assert(ip_vers != null); + assert(other_endpoint_ip_addr != null); + assert(other_endpoint_pt > 0); + assert(reporting_endpoint_ipaddr != null); + assert(reporting_endpoint_pt > 0); + + /***************************************************************************/ + /* Allocate the Mobile Flow. */ + /***************************************************************************/ + LOGGER.debug("New Mobile Flow created"); + + /***************************************************************************/ + /* Initialize the header & the Mobile Flow fields. Optional string values */ + /* are uninitialized (null). */ + /***************************************************************************/ + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW; + flow_direction = flow_dir; + gtp_per_flow_metrics = gtp_per_flow_metr; + ip_protocol_type = ip_protocol_typ; + ip_version = ip_vers; + other_endpoint_ip_address = other_endpoint_ip_addr; + other_endpoint_port = other_endpoint_pt; + reporting_endpoint_ip_addr = reporting_endpoint_ipaddr; + reporting_endpoint_port = reporting_endpoint_pt; + + application_type = new EvelOptionString(); + app_protocol_type = new EvelOptionString(); + app_protocol_version = new EvelOptionString(); + cid = new EvelOptionString(); + connection_type = new EvelOptionString(); + ecgi = new EvelOptionString(); + gtp_protocol_type = new EvelOptionString(); + gtp_version = new EvelOptionString(); + http_header = new EvelOptionString(); + imei = new EvelOptionString(); + imsi = new EvelOptionString(); + lac = new EvelOptionString(); + mcc = new EvelOptionString(); + mnc = new EvelOptionString(); + msisdn = new EvelOptionString(); + other_functional_role = new EvelOptionString(); + rac = new EvelOptionString(); + radio_access_technology = new EvelOptionString(); + sac = new EvelOptionString(); + sampling_algorithm = new EvelOptionInt(); + tac = new EvelOptionString(); + tunnel_id = new EvelOptionString(); + vlan_id = new EvelOptionString(); + additional_info = null; + + EVEL_EXIT(); + + } + + + + /**************************************************************************//** + * Add an additional value name/value pair to the Mobile flow. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_flow_addl_field_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Event Type property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_flow_type_set(String typ) + { + EVEL_ENTER(); + assert(typ != null); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + evel_header_type_set(typ); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Application Type property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Application Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_flow_app_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(type != null); + + application_type.SetValuePr( + type, + "Application Type"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Application Protocol Type property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Application Protocol Type to be set. ASCIIZ string. + * The caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_flow_app_prot_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(type != null); + + app_protocol_type.SetValuePr( + type, + "Application Protocol Type"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Application Protocol Version property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param version The Application Protocol Version to be set. ASCIIZ + * string. The caller does not need to preserve the value + * once the function returns. + *****************************************************************************/ + void evel_mobile_flow_app_prot_ver_set(String version) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(version != null); + + app_protocol_version.SetValuePr( + version, + "Application Protocol Version"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the CID property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cid The CID to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_cid_set(String cd) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(cid != null); + + cid.SetValuePr( + cd, + "CID"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Connection Type property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Connection Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_flow_con_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(type != null); + + connection_type.SetValuePr( + type, + "Connection Type"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the ECGI property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param ecgi The ECGI to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_ecgi_set(String ecgit) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(ecgit != null); + + ecgi.SetValuePr( + ecgit, + "ECGI"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the GTP Protocol Type property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param type The GTP Protocol Type to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_flow_gtp_prot_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(type != null); + + gtp_protocol_type.SetValuePr( + type, + "GTP Protocol Type"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the GTP Protocol Version property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param version The GTP Protocol Version to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_flow_gtp_prot_ver_set(String version) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(version != null); + + gtp_version.SetValuePr( + version, + "GTP Protocol Version"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the HTTP Header property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param header The HTTP header to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_http_header_set(String header) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(header != null); + + http_header.SetValuePr( + header, + "HTTP Header"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the IMEI property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param imei The IMEI to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_imei_set(String imeit) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(imeit != null); + + imei.SetValuePr( + imeit, + "IMEI"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the IMSI property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param imsi The IMSI to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_imsi_set(String imsit) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(imsit != null); + + imsi.SetValuePr( + imsit, + "IMSI"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the LAC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param lac The LAC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_lac_set(String lact) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + assert(lact != null); + + lac.SetValuePr( + lact, + "LAC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the MCC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param mcc The MCC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_mcc_set(String mcct) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(mcct != null); + + mcc.SetValuePr( + mcct, + "MCC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the MNC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param mnc The MNC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_mnc_set(String mnct) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(mnct != null); + + mnc.SetValuePr( + mnct, + "MNC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the MSISDN property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param msisdn The MSISDN to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_msisdn_set(String msisdnt) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(msisdnt != null); + + msisdn.SetValuePr( + msisdnt, + "MSISDN"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Other Functional Role property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param role The Other Functional Role to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_flow_other_func_role_set(String role) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(role != null); + + other_functional_role.SetValuePr( + role, + "Other Functional Role"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the RAC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param rac The RAC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_rac_set(String ract) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(ract != null); + + rac.SetValuePr( + ract, + "RAC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Radio Access Technology property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param tech The Radio Access Technology to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_flow_radio_acc_tech_set(String tech) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(tech != null); + + radio_access_technology.SetValuePr( + tech, + "Radio Access Technology"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the SAC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param sac The SAC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_sac_set(String sact) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(sact != null); + + sac.SetValuePr( + sact, + "SAC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Sampling Algorithm property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param algorithm The Sampling Algorithm to be set. + *****************************************************************************/ + public void evel_mobile_flow_samp_alg_set( + int algorithm) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(algorithm >= 0); + + sampling_algorithm.SetValuePr( + algorithm, + "Sampling Algorithm"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the TAC property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param tac The TAC to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_tac_set(String tact) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(tact != null); + + tac.SetValuePr( + tact, + "TAC"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Tunnel ID property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param tunnel_id The Tunnel ID to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_tunnel_id_set(String tunnel_idt) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(tunnel_idt != null); + + tunnel_id.SetValuePr( + tunnel_idt, + "Tunnel ID"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the VLAN ID property of the Mobile Flow. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param vlan_id The VLAN ID to be set. ASCIIZ string. The caller does + * not need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_mobile_flow_vlan_id_set(String vlan_idt) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + assert(vlan_idt != null); + + vlan_id.SetValuePr( + vlan_idt, + "VLAN ID"); + EVEL_EXIT(); + } + + + + /**************************************************************************//** + * Set the Duration of Connection Failed Status property of the Mobile GTP Per + * Flow Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param duration The Duration of Connection Failed Status to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_dur_con_fail_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int duration) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(duration >= 0); + + metrics.dur_connection_failed_status.SetValuePr( + duration, + "Duration of Connection Failed Status"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Duration of Tunnel Failed Status property of the Mobile GTP Per Flow + * Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param duration The Duration of Tunnel Failed Status to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_dur_tun_fail_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int duration) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(duration >= 0); + + metrics.dur_tunnel_failed_status.SetValuePr( + duration, + "Duration of Tunnel Failed Status"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Activated By property of the Mobile GTP Per Flow metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param act_by The Activated By to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_act_by_set(MOBILE_GTP_PER_FLOW_METRICS metrics, + String act_by) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(act_by != null); + + metrics.flow_activated_by.SetValuePr( + act_by, + "Activated By"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Activation Time property of the Mobile GTP Per Flow metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param act_time The Activation Time to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_act_time_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + Date act_time) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + + metrics.flow_activation_time.SetValuePr( + act_time, + "Activation Time"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Deactivated By property of the Mobile GTP Per Flow metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param deact_by The Deactivated By to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_deact_by_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + String deact_by) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(deact_by != null); + + metrics.flow_deactivated_by.SetValuePr( + deact_by, + "Deactivated By"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the GTP Connection Status property of the Mobile GTP Per Flow metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param status The GTP Connection Status to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_con_status_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + String status) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(status != null); + + metrics.gtp_connection_status.SetValuePr( + status, + "GTP Connection Status"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the GTP Tunnel Status property of the Mobile GTP Per Flow metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param status The GTP Tunnel Status to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_tun_status_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + String status) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(status != null); + + metrics.gtp_tunnel_status.SetValuePr( + status, + "GTP Tunnel Status"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set an IP Type-of-Service count property of the Mobile GTP Per Flow metrics. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param index The index of the IP Type-of-Service. + * @param count The count. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_iptos_set(MOBILE_GTP_PER_FLOW_METRICS metrics, + int index, + int count) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(index >= 0); + assert(index < EVEL_TOS_SUPPORTED); + assert(count >= 0); + assert(count <= 255); + + LOGGER.debug("IP Type-of-Service "+index); + metrics.ip_tos_counts[index].SetValuePr( + count, + "IP Type-of-Service"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Large Packet Round-Trip Time property of the Mobile GTP Per Flow + * Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param rtt The Large Packet Round-Trip Time to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_large_pkt_rtt_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int rtt) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(rtt >= 0); + + metrics.large_packet_rtt.SetValuePr( + rtt, + "Large Packet Round-Trip Time"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Large Packet Threshold property of the Mobile GTP Per Flow Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param threshold The Large Packet Threshold to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_large_pkt_thresh_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + double threshold) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(threshold >= 0.0); + + metrics.large_packet_threshold.SetValuePr( + threshold, + "Large Packet Threshold"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Max Receive Bit Rate property of the Mobile GTP Per Flow Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param rate The Max Receive Bit Rate to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_max_rcv_bit_rate_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int rate) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(rate >= 0); + + metrics.max_receive_bit_rate.SetValuePr( + rate, + "Max Receive Bit Rate"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Max Transmit Bit Rate property of the Mobile GTP Per Flow Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param rate The Max Transmit Bit Rate to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_max_trx_bit_rate_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int rate) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(rate >= 0); + + metrics.max_transmit_bit_rate.SetValuePr( + rate, + "Max Transmit Bit Rate"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Number of GTP Echo Failures property of the Mobile GTP Per Flow + * Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param num The Number of GTP Echo Failures to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_num_echo_fail_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int num) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(num >= 0); + + metrics.num_gtp_echo_failures.SetValuePr( + num, + "Number of GTP Echo Failures"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Number of GTP Tunnel Errors property of the Mobile GTP Per Flow + * Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param num The Number of GTP Tunnel Errors to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_num_tun_fail_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int num) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(num >= 0); + + metrics.num_gtp_tunnel_errors.SetValuePr( + num, + "Number of GTP Tunnel Errors"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Number of HTTP Errors property of the Mobile GTP Per Flow Metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param num The Number of HTTP Errors to be set. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_num_http_errors_set( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int num) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(num >= 0); + + metrics.num_http_errors.SetValuePr( + num, + "Number of HTTP Errors"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a TCP flag count to the metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param tcp_flag The TCP flag to be updated. + * @param count The associated flag count, which must be nonzero. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_tcp_flag_count_add( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int tcp_flag, + int count) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(tcp_flag >= 0 && tcp_flag < EVEL_MAX_TCP_FLAGS); + assert(count >= 0); + + LOGGER.debug("TCP Flag: "+tcp_flag); + metrics.tcp_flag_counts[tcp_flag].SetValuePr( + count, + "TCP flag"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a QCI COS count to the metrics. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param metrics Pointer to the Mobile GTP Per Flow Metrics. + * @param qci_cos The QCI COS count to be updated. + * @param count The associated QCI COS count. + *****************************************************************************/ + public void evel_mobile_gtp_metrics_qci_cos_count_add( + MOBILE_GTP_PER_FLOW_METRICS metrics, + int qci_cos, + int count) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(metrics != null); + assert(qci_cos >= 0); + assert(qci_cos < EVEL_MAX_QCI_COS_TYPES); + assert(count >= 0); + + LOGGER.debug("QCI COS: "+ qci_cos); + metrics.qci_cos_counts[qci_cos].SetValuePr( + count, + "QCI COS"); + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode the GTP Per Flow Object in JSON according to AT&T's schema. + * + * @retval JsonObjectBuilder of GTP Flow body portion of message + *****************************************************************************/ + JsonObjectBuilder evelGtpPerFlowObject() + { + int index; + boolean found_ip_tos; + boolean found_tcp_flag; + boolean found_qci_cos; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Mandatory parameters. */ + /***************************************************************************/ + MOBILE_GTP_PER_FLOW_METRICS metrics = gtp_per_flow_metrics; + + JsonObjectBuilder obj = Json.createObjectBuilder() + .add("avgBitErrorRate", metrics.avg_bit_error_rate) + .add("avgPacketDelayVariation", metrics.avg_packet_delay_variation) + .add("avgPacketLatency", metrics.avg_packet_latency) + .add("avgReceiveThroughput", metrics.avg_receive_throughput) + .add("avgTransmitThroughput", metrics.avg_transmit_throughput) + .add("flowActivationEpoch", metrics.flow_activation_epoch) + .add("flowActivationMicrosec", metrics.flow_activation_microsec) + .add("flowDeactivationEpoch", metrics.flow_deactivation_epoch) + .add("flowDeactivationMicrosec", metrics.flow_deactivation_microsec) + .add("flowDeactivationTime", metrics.flow_deactivation_time.toString()) + .add("flowStatus", metrics.flow_status) + .add("maxPacketDelayVariation", metrics.max_packet_delay_variation) + .add("numActivationFailures", metrics.num_activation_failures) + .add( "numBitErrors", metrics.num_bit_errors) + .add( "numBytesReceived", metrics.num_bytes_received) + .add( "numBytesTransmitted", metrics.num_bytes_transmitted) + .add( "numDroppedPackets", metrics.num_dropped_packets) + .add( "numL7BytesReceived", metrics.num_l7_bytes_received) + .add( "numL7BytesTransmitted", metrics.num_l7_bytes_transmitted) + .add( "numLostPackets", metrics.num_lost_packets) + .add( "numOutOfOrderPackets", metrics.num_out_of_order_packets) + .add( "numPacketErrors", metrics.num_packet_errors) + .add( "numPacketsReceivedExclRetrans", + metrics.num_packets_received_excl_retrans) + .add( + "numPacketsReceivedInclRetrans", + metrics.num_packets_received_incl_retrans) + .add( + "numPacketsTransmittedInclRetrans", + metrics.num_packets_transmitted_incl_retrans) + .add( "numRetries", metrics.num_retries) + .add( "numTimeouts", metrics.num_timeouts) + .add( + "numTunneledL7BytesReceived", + metrics.num_tunneled_l7_bytes_received) + .add( "roundTripTime", metrics.round_trip_time) + .add( "timeToFirstByte", metrics.time_to_first_byte); + + /***************************************************************************/ + /* Optional parameters. */ + /***************************************************************************/ + found_ip_tos = false; + for (index = 0; index < EVEL_TOS_SUPPORTED; index++) + { + if (metrics.ip_tos_counts[index].is_set) + { + found_ip_tos = true; + break; + } + } + + if (found_ip_tos) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for (index = 0; index < EVEL_TOS_SUPPORTED; index++) + { + if (metrics.ip_tos_counts[index].is_set) + { + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add(Integer.toString(index), metrics.ip_tos_counts[index].value); + builder.add(obj2); + } + } + obj.add("ipTosCountList", builder); + } + + + /***************************************************************************/ + /* Make some compile-time assertions about EVEL_TCP_FLAGS. If you update */ + /* these, make sure you update evel_tcp_flag_strings to match the enum. */ + /***************************************************************************/ + + found_tcp_flag = false; + for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++) + { + if (metrics.tcp_flag_counts[index].is_set) + { + found_tcp_flag = true; + break; + } + } + + if (found_tcp_flag) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++) + { + if (metrics.tcp_flag_counts[index].is_set) + { + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add(Integer.toString(index), evel_tcp_flag_strings[index]); + builder.add(obj2); + } + } + obj.add("tcpFlagList", builder); + } + + if (found_tcp_flag) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++) + { + if (metrics.tcp_flag_counts[index].is_set) + { + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add(evel_tcp_flag_strings[index], metrics.tcp_flag_counts[index].value); + builder.add(obj2); + } + } + obj.add("tcpFlagCountList", builder); + } + + /***************************************************************************/ + /* Make some compile-time assertions about EVEL_QCI_COS_TYPES. If you */ + /* update these, make sure you update evel_qci_cos_strings to match the */ + /* enum. */ + /***************************************************************************/ + + found_qci_cos = false; + for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++) + { + if (metrics.qci_cos_counts[index].is_set) + { + found_qci_cos = true; + break; + } + } + + if (found_qci_cos) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++) + { + if (metrics.qci_cos_counts[index].is_set) + { + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add(Integer.toString(index), evel_qci_cos_strings[index]); + builder.add(obj2); + } + } + obj.add("mobileQciCosList", builder); + } + + if (found_qci_cos) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++) + { + if (metrics.qci_cos_counts[index].is_set) + { + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add(evel_qci_cos_strings[index], metrics.qci_cos_counts[index].value); + builder.add(obj2); + } + } + obj.add("mobileQciCosCountList", builder); + } + + metrics.dur_connection_failed_status.encJsonValue(obj, "durConnectionFailedStatus"); + metrics.dur_tunnel_failed_status.encJsonValue(obj, "durTunnelFailedStatus"); + metrics.flow_activated_by.encJsonValue(obj, "flowActivatedBy"); + metrics.flow_activation_time.encJsonValue(obj,"flowActivationTime"); + metrics.flow_deactivated_by.encJsonValue(obj, "flowDeactivatedBy"); + metrics.gtp_connection_status.encJsonValue(obj, "gtpConnectionStatus"); + metrics.gtp_tunnel_status.encJsonValue(obj, "gtpTunnelStatus"); + metrics.large_packet_rtt.encJsonValue(obj, "largePacketRtt"); + metrics.large_packet_threshold.encJsonValue(obj, "largePacketThreshold"); + metrics.max_receive_bit_rate.encJsonValue(obj, "maxReceiveBitRate"); + metrics.max_transmit_bit_rate.encJsonValue(obj, "maxTransmitBitRate"); + metrics.num_gtp_echo_failures.encJsonValue(obj, "numGtpEchoFailures"); + metrics.num_gtp_tunnel_errors.encJsonValue(obj, "numGtpTunnelErrors"); + metrics.num_http_errors.encJsonValue(obj, "numHttpErrors"); + + return obj; + + } + + + /**************************************************************************//** + * Encode Mobile Flow Object according to VES schema + * + * @retval JSON Object of Mobile Flow event + *****************************************************************************/ + JsonObjectBuilder evelMobileFlowObject() + { + + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MOBILE_FLOW); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + JsonObjectBuilder evelmf = Json.createObjectBuilder() + .add("flowDirection", flow_direction) + .add("ipProtocolType", ip_protocol_type) + .add("ipVersion", ip_version) + .add("otherEndpointIpAddress", other_endpoint_ip_address) + .add("otherEndpointPort", other_endpoint_port) + .add("reportingEndpointIpAddr", reporting_endpoint_ip_addr) + .add("reportingEndpointPort", reporting_endpoint_port); + + //call gtp per flow object encoding function + if(gtp_per_flow_metrics != null) + evelmf.add("gtpPerFlowMetrics", evelGtpPerFlowObject()); + + + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + // additional fields + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i additional_objects; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + Map additional_info; + Map> evelmap; + + + private static final Logger LOGGER = Logger.getLogger( EvelOther.class.getName() ); + + /**************************************************************************//** + * Create a new Other event. + * + *****************************************************************************/ + public EvelOther(String evname,String evid) + { + //Init header and domain + super(evname,evid); + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + + /***************************************************************************/ + /* Allocate the measurement. */ + /***************************************************************************/ + LOGGER.debug("New Evel Other Object"); + + /***************************************************************************/ + /* Initialize the header & the measurement fields. */ + /***************************************************************************/ + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER; + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + additional_info = null; + additional_objects = null; + evelmap = null; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Event Type property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_other_type_set(String typ) + { + EVEL_ENTER(); + assert(typ != null); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + evel_header_type_set(typ); + + EVEL_EXIT(); + } + + + + + /**************************************************************************//** + * Adds name value pair under hash key + * + * + * @param hashname String Hash name. + * @param name String Name. + * @param value String Value. + *****************************************************************************/ + public void evel_other_field_add_namedarray(String hashname,String name, String value) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + assert(hashname != null); + assert(name != null); + assert(value != null); + + Map mymap = null; + + try{ + + if( evelmap == null) + evelmap = new HashMap>(); + + if( evelmap.containsKey(hashname) ) + { + mymap = evelmap.get(hashname); + } + else + { + mymap = new HashMap(); + evelmap.put(hashname, mymap); + LOGGER.debug("Inserted map hash : "+hashname+" name="+name); + } + + if( mymap.containsKey(name) ) + { + String val = mymap.get(name); + LOGGER.error("Error already contains key " + name + "val "+val ); + } + else + { + mymap.put(name, value); + LOGGER.debug("Adding hash : "+hashname+" name="+name+"value= "+value); + } + + } catch( Exception e) + { + e.printStackTrace(); + } + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Add a json object to optional jsonObject list. + * + * @param jsonobj Pointer to json object + *****************************************************************************/ + public void evel_other_field_add_jsonobj(javax.json.JsonObject jsonobj) + { + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + assert(jsonobj != null); + + LOGGER.debug("Adding jsonObject"); + + if( additional_objects == null ) + additional_objects = new ArrayList(); + + additional_objects.add(jsonobj); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a field name/value pair to the Other. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * @param name ASCIIZ string with the field's name. The caller does not + * need to preserve the value once the function returns. + * @param value ASCIIZ string with the field's value. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_other_field_add(String name, String value) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + assert(name != null); + assert(value != null); + + LOGGER.debug("Adding name="+name+" value="+value); + + if(additional_info == null) + additional_info = new HashMap(); + + if(additional_info.containsKey(name)) + LOGGER.error("Already exists Unable to add map : name="+name+"value= "+value); + else + additional_info.put(name, value); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode Other Object according to VES schema + * + * @retval JSON Object of Other event + *****************************************************************************/ + JsonObjectBuilder evelOtherObject() + { + + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + + /***************************************************************************/ + /* Additional Objects. */ + /***************************************************************************/ + + JsonObjectBuilder eveloth = Json.createObjectBuilder(); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + // additional fields + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(Map.Entry entry : additional_info.entrySet()){ + LOGGER.debug(MessageFormat.format("Key : {0} and Value: {1}", entry.getKey(), entry.getValue())); + JsonObject obj = Json.createObjectBuilder() + .add("name", entry.getKey()) + .add("value",entry.getValue()).build(); + builder.add(obj); + } + eveloth.add("nameValuePairs", builder); + } + + if( additional_objects != null && additional_objects.size() > 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(Map.Entry> entry : evelmap.entrySet()){ + LOGGER.debug(MessageFormat.format("Key : {0} and Value: {1}", entry.getKey(), entry.getValue())); + Map item = entry.getValue(); + + JsonObjectBuilder obj = Json.createObjectBuilder() + .add( "name", entry.getKey()); + JsonArrayBuilder builder2 = Json.createArrayBuilder(); + for(Map.Entry entry2 : item.entrySet()){ + LOGGER.debug(MessageFormat.format("Key : {0} and Value: {1}", entry2.getKey(), entry2.getValue())); + JsonObjectBuilder obj2 = Json.createObjectBuilder() + .add("name", entry2.getKey()) + .add("value",entry2.getValue()); + builder2.add(obj2.build()); + } + + obj.add("arrayOfFields", builder2); + builder.add(obj.build()); + } + eveloth.add("hashOfNameValuePairArrays", builder); + } + + + + + /***************************************************************************/ + /* Although optional, we always generate the version. Note that this */ + /* closes the object, too. */ + /***************************************************************************/ + eveloth.add("otherFieldsVersion", version); + + EVEL_EXIT(); + + return eveloth; + } + + /**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * retval : String of JSON event message + *****************************************************************************/ + JsonObject evel_json_encode_event() + { + EVEL_ENTER(); + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_OTHER); + //encode common event header and body for other + JsonObject obj = Json.createObjectBuilder() + .add("event", Json.createObjectBuilder() + .add( "commonEventHeader",eventHeaderObject() ) + .add( "otherFields",evelOtherObject() ) + ).build(); + + EVEL_EXIT(); + + return obj; + + } + + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java new file mode 100644 index 0000000..bcbcd20 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelScalingMeasurement.java @@ -0,0 +1,3680 @@ +package evel_javalibrary.att.com; +/**************************************************************************//** + * @file + * Evel Scaling Measurement class + * + * This file implements the Evel Scaling Measurement Event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send CPU, Memory, Disk Measurements to Collector. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import java.text.MessageFormat; +import java.util.ArrayList; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +import org.apache.log4j.Logger; +import org.slf4j.helpers.MessageFormatter; + + +public class EvelScalingMeasurement extends EvelHeader { + + int major_version = 2; + int minor_version = 1; + + /**************************************************************************//** + * CPU Usage. + * JSON equivalent field: cpuUsage + *****************************************************************************/ + public class MEASUREMENT_CPU_USE { + String id; + double usage; + public EvelOptionDouble idle; + public EvelOptionDouble intrpt; + public EvelOptionDouble nice; + public EvelOptionDouble softirq; + public EvelOptionDouble steal; + public EvelOptionDouble sys; + public EvelOptionDouble user; + public EvelOptionDouble wait; + } + + + /**************************************************************************//** + * Disk Usage. + * JSON equivalent field: diskUsage + *****************************************************************************/ + public class MEASUREMENT_DISK_USE { + String id; + public EvelOptionDouble iotimeavg; + public EvelOptionDouble iotimelast; + public EvelOptionDouble iotimemax; + public EvelOptionDouble iotimemin; + public EvelOptionDouble mergereadavg; + public EvelOptionDouble mergereadlast; + public EvelOptionDouble mergereadmax; + public EvelOptionDouble mergereadmin; + public EvelOptionDouble mergewriteavg; + public EvelOptionDouble mergewritelast; + public EvelOptionDouble mergewritemax; + public EvelOptionDouble mergewritemin; + public EvelOptionDouble octetsreadavg; + public EvelOptionDouble octetsreadlast; + public EvelOptionDouble octetsreadmax; + public EvelOptionDouble octetsreadmin; + public EvelOptionDouble octetswriteavg; + public EvelOptionDouble octetswritelast; + public EvelOptionDouble octetswritemax; + public EvelOptionDouble octetswritemin; + public EvelOptionDouble opsreadavg; + public EvelOptionDouble opsreadlast; + public EvelOptionDouble opsreadmax; + public EvelOptionDouble opsreadmin; + public EvelOptionDouble opswriteavg; + public EvelOptionDouble opswritelast; + public EvelOptionDouble opswritemax; + public EvelOptionDouble opswritemin; + public EvelOptionDouble pendingopsavg; + public EvelOptionDouble pendingopslast; + public EvelOptionDouble pendingopsmax; + public EvelOptionDouble pendingopsmin; + public EvelOptionDouble timereadavg; + public EvelOptionDouble timereadlast; + public EvelOptionDouble timereadmax; + public EvelOptionDouble timereadmin; + public EvelOptionDouble timewriteavg; + public EvelOptionDouble timewritelast; + public EvelOptionDouble timewritemax; + public EvelOptionDouble timewritemin; + + } + + /**************************************************************************//** + * Filesystem Usage. + * JSON equivalent field: filesystemUsage + *****************************************************************************/ + public class MEASUREMENT_FSYS_USE { + String filesystem_name; + double block_configured; + double block_iops; + double block_used; + double ephemeral_configured; + double ephemeral_iops; + double ephemeral_used; + } + + /**************************************************************************//** + * Memory Usage. + * JSON equivalent field: memoryUsage + *****************************************************************************/ + public class MEASUREMENT_MEM_USE { + String id; + String vmid; + double membuffsz; + public EvelOptionDouble memcache; + public EvelOptionDouble memconfig; + public EvelOptionDouble memfree; + public EvelOptionDouble slabrecl; + public EvelOptionDouble slabunrecl; + public EvelOptionDouble memused; + } + + /**************************************************************************//** + * myerrors. + * JSON equivalent field: myerrors + *****************************************************************************/ + public class MEASUREMENT_ERRORS { + int receive_discards; + int receive_myerrors; + int transmit_discards; + int transmit_myerrors; + } + + /**************************************************************************//** + * Latency Bucket. + * JSON equivalent field: latencyBucketMeasure + *****************************************************************************/ + public class MEASUREMENT_LATENCY_BUCKET { + int count; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + public EvelOptionDouble high_end; + public EvelOptionDouble low_end; + + } + + /**************************************************************************//** + * Virtual NIC usage. + * JSON equivalent field: vNicUsage + *****************************************************************************/ + public class MEASUREMENT_VNIC_PERFORMANCE { + String vnic_id; + String valuesaresuspect; + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + /*Cumulative count of broadcast packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_bcast_packets_acc; + /*Count of broadcast packets received within the measurement interval*/ + public EvelOptionDouble recvd_bcast_packets_delta; + /*Cumulative count of discarded packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_discarded_packets_acc; + /*Count of discarded packets received within the measurement interval*/ + public EvelOptionDouble recvd_discarded_packets_delta; + /*Cumulative count of error packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_error_packets_acc; + /*Count of error packets received within the measurement interval*/ + public EvelOptionDouble recvd_error_packets_delta; + /*Cumulative count of multicast packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_mcast_packets_acc; + /*Count of mcast packets received within the measurement interval*/ + public EvelOptionDouble recvd_mcast_packets_delta; + /*Cumulative count of octets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_octets_acc; + /*Count of octets received within the measurement interval*/ + public EvelOptionDouble recvd_octets_delta; + /*Cumulative count of all packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_total_packets_acc; + /*Count of all packets received within the measurement interval*/ + public EvelOptionDouble recvd_total_packets_delta; + /*Cumulative count of unicast packets received as read at the end of + the measurement interval*/ + public EvelOptionDouble recvd_ucast_packets_acc; + /*Count of unicast packets received within the measurement interval*/ + public EvelOptionDouble recvd_ucast_packets_delta; + /*Cumulative count of transmitted broadcast packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_bcast_packets_acc; + /*Count of transmitted broadcast packets within the measurement interval*/ + public EvelOptionDouble tx_bcast_packets_delta; + /*Cumulative count of transmit discarded packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_discarded_packets_acc; + /*Count of transmit discarded packets within the measurement interval*/ + public EvelOptionDouble tx_discarded_packets_delta; + /*Cumulative count of transmit error packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_error_packets_acc; + /*Count of transmit error packets within the measurement interval*/ + public EvelOptionDouble tx_error_packets_delta; + /*Cumulative count of transmit multicast packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_mcast_packets_acc; + /*Count of transmit multicast packets within the measurement interval*/ + public EvelOptionDouble tx_mcast_packets_delta; + /*Cumulative count of transmit octets at the end of + the measurement interval*/ + public EvelOptionDouble tx_octets_acc; + /*Count of transmit octets received within the measurement interval*/ + public EvelOptionDouble tx_octets_delta; + /*Cumulative count of all transmit packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_total_packets_acc; + /*Count of transmit packets within the measurement interval*/ + public EvelOptionDouble tx_total_packets_delta; + /*Cumulative count of all transmit unicast packets at the end of + the measurement interval*/ + public EvelOptionDouble tx_ucast_packets_acc; + /*Count of transmit unicast packets within the measurement interval*/ + public EvelOptionDouble tx_ucast_packets_delta; + } + + /**************************************************************************//** + * Codec Usage. + * JSON equivalent field: codecsInUse + *****************************************************************************/ + public class MEASUREMENT_CODEC_USE { + String codec_id; + int number_in_use; + } + + /**************************************************************************//** + * Feature Usage. + * JSON equivalent field: featuresInUse + *****************************************************************************/ + public class MEASUREMENT_FEATURE_USE { + String feature_id; + int feature_utilization; + } + + + /**************************************************************************//** + * Custom Defined Measurement. + * JSON equivalent field: measurements + *****************************************************************************/ + public class CUSTOM_MEASUREMENT { + String name; + String value; + } + + /**************************************************************************//** + * Measurement Group. + * JSON equivalent field: additionalMeasurements + *****************************************************************************/ + public class MEASUREMENT_GROUP { + String name; + ArrayList measurements; + } + + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + double measurement_interval; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + ArrayList additional_info; + ArrayList additional_measurements; + ArrayList additional_objects; + ArrayList codec_usage; + EvelOptionInt concurrent_sessions; + EvelOptionInt configured_entities; + ArrayList cpu_usage; + ArrayList disk_usage; + boolean errstat; + MEASUREMENT_ERRORS myerrors; + ArrayList feature_usage; + ArrayList filesystem_usage; + ArrayList latency_distribution; + EvelOptionDouble mean_request_latency; + ArrayList mem_usage; + EvelOptionInt media_ports_in_use; + EvelOptionInt request_rate; + EvelOptionInt vnfc_scaling_metric; + ArrayList vnic_usage; + + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + + private static final Logger LOGGER = Logger.getLogger( EvelScalingMeasurement.class.getName() ); + + + /**************************************************************************//** + * Constructs a new Measurement event. + * + * @note The mandatory fields on the Measurement must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once so + * that the Measurement has immutable properties. + * + * @param measurement_interval + * + *****************************************************************************/ + public EvelScalingMeasurement(double meas_interval,String evname,String evid) + { //Init header + super(evname,evid); + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(meas_interval >= 0.0); + + LOGGER.debug("New measurement is at "+meas_interval); + + /***************************************************************************/ + /* Initialize the header & the measurement fields. */ + /***************************************************************************/ + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT; + //initialize optional fields + measurement_interval = meas_interval; + additional_info = null; + additional_measurements = null; + additional_objects = null; + cpu_usage = null; + disk_usage = null; + mem_usage = null; + filesystem_usage = null; + latency_distribution = null; + vnic_usage = null; + codec_usage = null; + feature_usage = null; + errstat = false; + + mean_request_latency = new EvelOptionDouble(false, 0.0); + vnfc_scaling_metric = new EvelOptionInt(false, 0); + concurrent_sessions = new EvelOptionInt(false, 0); + configured_entities = new EvelOptionInt(false, 0); + media_ports_in_use = new EvelOptionInt(false, 0); + request_rate = new EvelOptionInt(false, 0); + errstat = false; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Event Type property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_measurement_type_set(String typ) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + evel_header_type_set(typ); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_measurement_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Concurrent Sessions property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param concurrent_sessions The Concurrent Sessions to be set. + *****************************************************************************/ + public void evel_measurement_conc_sess_set(int conc_sessions) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(conc_sessions >= 0); + + concurrent_sessions.SetValuePr(conc_sessions,"Concurrent Sessions"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Configured Entities property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param configured_entities The Configured Entities to be set. + *****************************************************************************/ + public void evel_measurement_cfg_ents_set(EvelScalingMeasurement measurement, + int config_entities) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(config_entities >= 0); + + configured_entities.SetValuePr(config_entities,"Configured Entities"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional set of myerrors to the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param measurement Pointer to the measurement. + * @param receive_discard The number of receive discards. + * @param receive_error The number of receive myerrors. + * @param transmit_discard The number of transmit discards. + * @param transmit_error The number of transmit myerrors. + *****************************************************************************/ + public void evel_measurement_myerrors_set( + int receive_discard, + int receive_error, + int transmit_discard, + int transmit_error) + { + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(receive_discard >= 0); + assert(receive_error >= 0); + assert(transmit_discard >= 0); + assert(transmit_error >= 0); + + if (errstat == false) + { + errstat = true; + LOGGER.debug(MessageFormat.format("Adding myerrors: {0}, {1}, {2}, {3}", + receive_discard, + receive_error, + transmit_discard, + transmit_error)); + if( myerrors == null )myerrors = new MEASUREMENT_ERRORS(); + myerrors.receive_discards = receive_discard; + myerrors.receive_myerrors = receive_error; + myerrors.transmit_discards = transmit_discard; + myerrors.transmit_myerrors = transmit_error; + } + else + { + LOGGER.debug(MessageFormat.format("Adding myerrors: {0}, {1}; {2}, {3} myerrors already set: {4}, {5}; {6}, {7}", + receive_discard, + receive_error, + transmit_discard, + transmit_error, + myerrors.receive_discards, + myerrors.receive_myerrors, + myerrors.transmit_discards, + myerrors.transmit_myerrors)); + } + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Mean Request Latency property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param mean_request_latency The Mean Request Latency to be set. + *****************************************************************************/ + public void evel_measurement_mean_req_lat_set( + double mean_req_latency) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(mean_req_latency >= 0.0); + + mean_request_latency.SetValuePr(mean_req_latency,"Mean Request Latency"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Request Rate property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param request_rate The Request Rate to be set. + *****************************************************************************/ + public void evel_measurement_request_rate_set(int req_rate) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(req_rate >= 0); + + request_rate.SetValuePr(req_rate,"Request Rate"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional CPU usage value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param id ASCIIZ string with the CPU's identifier. + * @param usage CPU utilization. + *****************************************************************************/ + public MEASUREMENT_CPU_USE evel_measurement_new_cpu_use_add(String id, double usage) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(id != null); + assert(usage >= 0.0); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormatter.format("Adding id={0} usage={1}", id, usage)); + MEASUREMENT_CPU_USE cpu_use = new MEASUREMENT_CPU_USE(); + assert(cpu_use != null); + cpu_use.id = id; + cpu_use.usage = usage; + cpu_use.idle = new EvelOptionDouble(); + cpu_use.intrpt = new EvelOptionDouble(); + cpu_use.nice = new EvelOptionDouble(); + cpu_use.softirq = new EvelOptionDouble(); + cpu_use.steal = new EvelOptionDouble(); + cpu_use.sys = new EvelOptionDouble(); + cpu_use.user = new EvelOptionDouble(); + cpu_use.wait = new EvelOptionDouble(); + + if( cpu_usage == null ){ + cpu_usage = new ArrayList(); + if( cpu_usage == null)LOGGER.error("Unable to allocate new cpu usage"); + } + + cpu_usage.add(cpu_use); + + EVEL_EXIT(); + return cpu_use; + } + + /**************************************************************************//** + * Set the CPU Idle value in measurement interval + * percentage of CPU time spent in the idle task + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_idle_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.idle.SetValuePr(val,"CPU idle time"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the percentage of time spent servicing interrupts + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_interrupt_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.intrpt.SetValuePr(val,"CPU interrupt value"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the percentage of time spent running user space processes that have been niced + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_nice_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.nice.SetValuePr(val, "CPU nice value"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the percentage of time spent handling soft irq interrupts + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_softirq_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.softirq.SetValuePr(val, "CPU Soft IRQ value"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the percentage of time spent in involuntary wait + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_steal_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.steal.SetValuePr(val,"CPU involuntary wait"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the percentage of time spent on system tasks running the kernel + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_system_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.sys.SetValuePr(val,"CPU System load"); + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the percentage of time spent running un-niced user space processes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_usageuser_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.user.SetValuePr(val,"CPU User load value"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the percentage of CPU time spent waiting for I/O operations to complete + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param cpu_use Pointer to the CPU Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_cpu_use_wait_set(MEASUREMENT_CPU_USE cpu_use, + double val) + { + EVEL_ENTER(); + cpu_use.wait.SetValuePr(val, "CPU Wait IO value"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Add an additional Memory usage value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param id ASCIIZ string with the Memory identifier. + * @param vmidentifier ASCIIZ string with the VM's identifier. + * @param membuffsz Memory Size. + * + * @return Returns pointer to memory use structure in measurements + *****************************************************************************/ + public MEASUREMENT_MEM_USE evel_measurement_new_mem_use_add( + String id, String vmidentifier, double membuffsz) + { + MEASUREMENT_MEM_USE mem_use = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(id != null); + assert(membuffsz >= 0.0); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormatter.format("Adding id={0} buffer size={1}", id, membuffsz)); + mem_use = new MEASUREMENT_MEM_USE(); + assert(mem_use != null); + mem_use.id = id; + mem_use.vmid = vmidentifier; + mem_use.membuffsz = membuffsz; + mem_use.memcache = new EvelOptionDouble(); + mem_use.memconfig= new EvelOptionDouble(); + mem_use.memfree= new EvelOptionDouble(); + mem_use.slabrecl= new EvelOptionDouble(); + mem_use.slabunrecl= new EvelOptionDouble(); + mem_use.memused= new EvelOptionDouble(); + + assert(mem_use.id != null); + + if( mem_usage == null ){ + mem_usage = new ArrayList(); + if( mem_usage == null )LOGGER.error("Unable to allocate new memory usage"); + } + + + mem_usage.add(mem_use); + + EVEL_EXIT(); + return mem_use; + } + + /**************************************************************************//** + * Set kilobytes of memory used for cache + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_memcache_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.memcache.SetValuePr(val,"Memory cache value"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set kilobytes of memory configured in the virtual machine on which the VNFC reporting + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_memconfig_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.memconfig.SetValuePr(val, "Memory configured value"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set kilobytes of physical RAM left unused by the system + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_memfree_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.memfree.SetValuePr(val, "Memory freely available value"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the part of the slab that can be reclaimed such as caches measured in kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_slab_reclaimed_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.slabrecl.SetValuePr(val, "Memory reclaimable slab set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the part of the slab that cannot be reclaimed such as caches measured in kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_slab_unreclaimable_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.slabunrecl.SetValuePr(val, "Memory unreclaimable slab set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the total memory minus the sum of free, buffered, cached and slab memory in kilobytes + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param mem_use Pointer to the Memory Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_mem_use_usedup_set(MEASUREMENT_MEM_USE mem_use, + double val) + { + EVEL_ENTER(); + mem_use.memused.SetValuePr(val, "Memory usedup total set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional Disk usage value name/value pair to the Measurement. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param id ASCIIZ string with the CPU's identifier. + * @param usage Disk utilization. + *****************************************************************************/ + public MEASUREMENT_DISK_USE evel_measurement_new_disk_use_add(String id) + { + MEASUREMENT_DISK_USE disk_use = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(id != null); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormatter.format("Adding id={0} disk usage", id)); + disk_use = new MEASUREMENT_DISK_USE(); + assert(disk_use != null); + disk_use.id = id; + assert(disk_use.id != null); + + disk_use.iotimeavg= new EvelOptionDouble(); + disk_use.iotimelast= new EvelOptionDouble(); + disk_use.iotimemax= new EvelOptionDouble(); + disk_use.iotimemin= new EvelOptionDouble(); + disk_use.mergereadavg= new EvelOptionDouble(); + disk_use.mergereadlast= new EvelOptionDouble(); + disk_use.mergereadmax= new EvelOptionDouble(); + disk_use.mergereadmin= new EvelOptionDouble(); + disk_use.mergewriteavg= new EvelOptionDouble(); + disk_use.mergewritelast= new EvelOptionDouble(); + disk_use.mergewritemax= new EvelOptionDouble(); + disk_use.mergewritemin= new EvelOptionDouble(); + disk_use.octetsreadavg= new EvelOptionDouble(); + disk_use.octetsreadlast= new EvelOptionDouble(); + disk_use.octetsreadmax= new EvelOptionDouble(); + disk_use.octetsreadmin= new EvelOptionDouble(); + disk_use.octetswriteavg= new EvelOptionDouble(); + disk_use.octetswritelast= new EvelOptionDouble(); + disk_use.octetswritemax= new EvelOptionDouble(); + disk_use.octetswritemin= new EvelOptionDouble(); + disk_use.opsreadavg= new EvelOptionDouble(); + disk_use.opsreadlast= new EvelOptionDouble(); + disk_use.opsreadmax= new EvelOptionDouble(); + disk_use.opsreadmin= new EvelOptionDouble(); + disk_use.opswriteavg= new EvelOptionDouble(); + disk_use.opswritelast= new EvelOptionDouble(); + disk_use.opswritemax= new EvelOptionDouble(); + disk_use.opswritemin= new EvelOptionDouble(); + disk_use.pendingopsavg= new EvelOptionDouble(); + disk_use.pendingopslast= new EvelOptionDouble(); + disk_use.pendingopsmax= new EvelOptionDouble(); + disk_use.pendingopsmin= new EvelOptionDouble(); + disk_use.timereadavg= new EvelOptionDouble(); + disk_use.timereadlast= new EvelOptionDouble(); + disk_use.timereadmax= new EvelOptionDouble(); + disk_use.timereadmin= new EvelOptionDouble(); + disk_use.timewriteavg= new EvelOptionDouble(); + disk_use.timewritelast= new EvelOptionDouble(); + disk_use.timewritemax= new EvelOptionDouble(); + disk_use.timewritemin= new EvelOptionDouble(); + + if( disk_usage == null ){ + disk_usage = new ArrayList(); + if( disk_usage == null ) LOGGER.error("Unable to allocate new disk usage"); + } + + + disk_usage.add(disk_use); + + + EVEL_EXIT(); + return disk_use; + } + + /**************************************************************************//** + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the average over the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_iotimeavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.iotimeavg.SetValuePr(val,"Disk ioload set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the last value within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_iotimelast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.iotimelast.SetValuePr(val, "Disk ioloadlast set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the maximum value within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_iotimemax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.iotimemax.SetValuePr(val, "Disk ioloadmax set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set milliseconds spent doing input/output operations over 1 sec; treat + * this metric as a device load percentage where 1000ms matches 100% load; + * provide the minimum value within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_iotimemin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.iotimemin.SetValuePr(val, "Disk ioloadmin set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergereadavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergereadavg.SetValuePr(val, "Disk Merged read average set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergereadlast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergereadlast.SetValuePr(val, "Disk mergedload last set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergereadmax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergereadmax.SetValuePr(val, "Disk merged loadmax set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of logical read operations that were merged into physical read + * operations, e.g., two logical reads were served by one physical disk access; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergereadmin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergereadmin.SetValuePr(val, "Disk merged loadmin set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergewritelast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergewritelast.SetValuePr(val, "Disk merged writelast set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergewritemax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergewritemax.SetValuePr(val, "Disk writemax set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of logical write operations that were merged into physical read + * operations, e.g., two logical writes were served by one physical disk access; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_mergewritemin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.mergewritemin.SetValuePr(val, "Disk writemin set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of octets per second read from a disk or partition; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetsreadavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetsreadavg.SetValuePr(val, "Octets readavg set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of octets per second read from a disk or partition; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetsreadlast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetsreadlast.SetValuePr(val, "Octets readlast set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of octets per second read from a disk or partition; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetsreadmax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetsreadmax.SetValuePr(val, "Octets readmax set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of octets per second read from a disk or partition; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetsreadmin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetsreadmin.SetValuePr(val, "Octets readmin set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetswriteavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetswriteavg.SetValuePr(val, "Octets writeavg set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetswritelast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetswritelast.SetValuePr(val, "Octets writelast set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetswritemax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetswritemax.SetValuePr(val, "Octets writemax set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of octets per second written to a disk or partition; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_octetswritemin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.octetswritemin.SetValuePr(val, "Octets writemin set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opsreadavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opsreadavg.SetValuePr(val, "Disk read operation average set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opsreadlast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opsreadlast.SetValuePr(val, "Disk read operation last set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opsreadmax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opsreadmax.SetValuePr(val, "Disk read operation maximum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of read operations per second issued to the disk; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opsreadmin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opsreadmin.SetValuePr(val, "Disk read operation minimum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opswriteavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opswriteavg.SetValuePr(val, "Disk write operation average set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opswritelast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opswritelast.SetValuePr(val, "Disk write operation last set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opswritemax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opswritemax.SetValuePr(val, "Disk write operation maximum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set number of write operations per second issued to the disk; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_opswritemin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.opswritemin.SetValuePr(val, "Disk write operation minimum set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_pendingopsavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.pendingopsavg.SetValuePr(val, "Disk pending operation average set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_pendingopslast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.pendingopslast.SetValuePr(val, "Disk pending operation last set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_pendingopsmax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.pendingopsmax.SetValuePr(val, "Disk pending operation maximum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set queue size of pending I/O operations per second; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_pendingopsmin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.pendingopsmin.SetValuePr(val, "Disk pending operation min set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timereadavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timereadavg.SetValuePr(val, "Disk read time average set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timereadlast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timereadlast.SetValuePr(val, "Disk read time last set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timereadmax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timereadmax.SetValuePr(val, "Disk read time maximum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a read operation took to complete; + * provide the minimum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timereadmin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timereadmin.SetValuePr(val, "Disk read time minimum set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timewriteavg_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timewriteavg.SetValuePr(val, "Disk write time average set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the last measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timewritelast_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timewritelast.SetValuePr(val, "Disk write time last set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the maximum measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timewritemax_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timewritemax.SetValuePr(val, "Disk write time max set"); + EVEL_EXIT(); + } + /**************************************************************************//** + * Set milliseconds a write operation took to complete; + * provide the average measurement within the measurement interval + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param disk_use Pointer to the Disk Use. + * @param val double + *****************************************************************************/ + public void evel_measurement_disk_use_timewritemin_set(MEASUREMENT_DISK_USE disk_use, + double val) + { + EVEL_ENTER(); + disk_use.timewritemin.SetValuePr(val, "Disk write time min set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional File System usage value name/value pair to the + * Measurement. + * + * The filesystem_name is null delimited ASCII string. The library takes a + * copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param filesystem_name ASCIIZ string with the file-system's UUID. + * @param block_configured Block storage configured. + * @param block_used Block storage in use. + * @param block_iops Block storage IOPS. + * @param ephemeral_configured Ephemeral storage configured. + * @param ephemeral_used Ephemeral storage in use. + * @param ephemeral_iops Ephemeral storage IOPS. + *****************************************************************************/ + public void evel_measurement_fsys_use_add( + String filesystem_name, + double block_configured, + double block_used, + double block_iops, + double ephemeral_configured, + double ephemeral_used, + double ephemeral_iops) + { + MEASUREMENT_FSYS_USE fsys_use = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(filesystem_name != null); + assert(block_configured >= 0.0); + assert(block_used >= 0.0); + assert(block_iops >= 0.0); + assert(ephemeral_configured >= 0.0); + assert(ephemeral_used >= 0.0); + assert(ephemeral_iops >= 0.0); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug("Adding filesystem_name="+filesystem_name); + fsys_use = new MEASUREMENT_FSYS_USE(); + assert(fsys_use != null); + fsys_use.filesystem_name = filesystem_name; + fsys_use.block_configured = block_configured; + fsys_use.block_used = block_used; + fsys_use.block_iops = block_iops; + fsys_use.ephemeral_configured = ephemeral_configured; + fsys_use.ephemeral_used = ephemeral_used; + fsys_use.ephemeral_iops = ephemeral_iops; + + if( filesystem_usage == null ){ + filesystem_usage = new ArrayList(); + if( filesystem_usage == null )LOGGER.error("Unable to allocate new file system usage"); + } + + filesystem_usage.add(fsys_use); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a Feature usage value name/value pair to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param feature ASCIIZ string with the feature's name. + * @param utilization Utilization of the feature. + *****************************************************************************/ + public void evel_measurement_feature_use_add( + String feature, + int utilization) + { + MEASUREMENT_FEATURE_USE feature_use = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(feature != null); + assert(utilization >= 0); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormatter.format("Adding Feature={0} Use={1}", feature, utilization)); + feature_use = new MEASUREMENT_FEATURE_USE(); + assert(feature_use != null); + feature_use.feature_id = feature; + assert(feature_use.feature_id != null); + feature_use.feature_utilization = utilization; + + if( feature_usage == null ){ + feature_usage = new ArrayList(); + if( feature_usage == null )LOGGER.error("Unable to allocate new feature usage"); + } + + feature_usage.add(feature_use); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a Additional Measurement value name/value pair to the Report. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param measurement Pointer to the Measaurement. + * @param group ASCIIZ string with the measurement group's name. + * @param name ASCIIZ string containing the measurement's name. + * @param value ASCIIZ string containing the measurement's value. + *****************************************************************************/ + public void evel_measurement_custom_measurement_add( + String group, + String name, + String value) + { + MEASUREMENT_GROUP measurement_group = null; + CUSTOM_MEASUREMENT custom_measurement = null; + MEASUREMENT_GROUP item = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(group != null); + assert(name != null); + assert(value != null); + + /***************************************************************************/ + /* Allocate a container for the name/value pair. */ + /***************************************************************************/ + LOGGER.debug(MessageFormat.format("Adding Measurement Group={0} Name={1} Value={2}", + group, name, value)); + custom_measurement = new CUSTOM_MEASUREMENT(); + assert(custom_measurement != null); + custom_measurement.name = name; + assert(custom_measurement.name != null); + custom_measurement.value = value; + assert(custom_measurement.value != null); + + /***************************************************************************/ + /* See if we have that group already. */ + /***************************************************************************/ + if (additional_measurements != null && additional_measurements.size()>0) + { + for(int i=0;i(); + if( additional_measurements == null){ + LOGGER.debug("Creating new Measurement Group list"+group); + additional_measurements = new ArrayList(); + if( additional_measurements == null ){ + LOGGER.error("Unable to allocate additional measurements "); + } + } + additional_measurements.add(measurement_group); + } + + /***************************************************************************/ + /* If we didn't have the group already, create it. */ + /***************************************************************************/ + LOGGER.debug("Adding custom measurement"); + measurement_group.measurements.add(custom_measurement); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add a Codec usage value name/value pair to the Measurement. + * + * The name is null delimited ASCII string. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * + * @param codec ASCIIZ string with the codec's name. + * @param utilization Number of codecs in use. + *****************************************************************************/ + public void evel_measurement_codec_use_add( String codec, + int utilization ) + { + MEASUREMENT_CODEC_USE codec_use = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(codec != null); + assert(utilization >= 0.0); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormatter.format("Adding Codec={0} Use={1}", codec, utilization)); + codec_use = new MEASUREMENT_CODEC_USE(); + assert(codec_use != null); + codec_use.codec_id = codec; + codec_use.number_in_use = utilization; + + if( codec_usage == null ){ + codec_usage = new ArrayList(); + if( codec_usage == null )LOGGER.error("Unable to allocate new codec usage"); + } + + codec_usage.add(codec_use); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Media Ports in Use property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + + * @param media_ports_in_use The media port usage to set. + *****************************************************************************/ + public void evel_measurement_media_port_use_set( + int media_portsuse) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(media_portsuse >= 0); + + media_ports_in_use.SetValuePr( + media_portsuse, + "Media Ports In Use"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the VNFC Scaling Metric property of the Measurement. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param scaling_metric The scaling metric to set. + *****************************************************************************/ + public void evel_measurement_vnfc_scaling_metric_set(EvelScalingMeasurement measurement, + int scaling_metric) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(measurement != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(scaling_metric >= 0.0); + + vnfc_scaling_metric.SetValuePr( + scaling_metric, + "VNFC Scaling Metric"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Create a new Latency Bucket to be added to a Measurement event. + * + * @note The mandatory fields on the ::MEASUREMENT_LATENCY_BUCKET must be + * supplied to this factory function and are immutable once set. + * Optional fields have explicit setter functions, but again values + * may only be set once so that the ::MEASUREMENT_LATENCY_BUCKET has + * immutable properties. + * + * @param count Count of events in this bucket. + * + * @returns pointer to the newly manufactured ::MEASUREMENT_LATENCY_BUCKET. + * If the structure is not used it must be released using free. + * @retval null Failed to create the Latency Bucket. + *****************************************************************************/ + public MEASUREMENT_LATENCY_BUCKET evel_new_meas_latency_bucket(int count) + { + MEASUREMENT_LATENCY_BUCKET bucket=null; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(count >= 0); + + /***************************************************************************/ + /* Allocate, then set Mandatory Parameters. */ + /***************************************************************************/ + LOGGER.debug("Creating bucket, count = "+count); + bucket = new MEASUREMENT_LATENCY_BUCKET(); + assert(bucket != null); + + /***************************************************************************/ + /* Set Mandatory Parameters. */ + /***************************************************************************/ + bucket.count = count; + + /***************************************************************************/ + /* Initialize Optional Parameters. */ + /***************************************************************************/ + bucket.low_end = new EvelOptionDouble(); + bucket.high_end = new EvelOptionDouble(); + + EVEL_EXIT(); + + return bucket; + } + + /**************************************************************************//** + * Set the High End property of the Measurement Latency Bucket. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param bucket Pointer to the Measurement Latency Bucket. + * @param high_end High end of the bucket's range. + *****************************************************************************/ + public void evel_meas_latency_bucket_high_end_set( + MEASUREMENT_LATENCY_BUCKET bucket, + double high_end) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(high_end >= 0.0); + bucket.high_end.SetValuePr(high_end, "High End"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Low End property of the Measurement Latency Bucket. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param bucket Pointer to the Measurement Latency Bucket. + * @param low_end Low end of the bucket's range. + *****************************************************************************/ + public void evel_meas_latency_bucket_low_end_set( + MEASUREMENT_LATENCY_BUCKET bucket, + double low_end) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(low_end >= 0.0); + bucket.low_end.SetValuePr(low_end, "Low End"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional Measurement Latency Bucket to the specified event. + * + * @param measurement Pointer to the Measurement event. + * @param bucket Pointer to the Measurement Latency Bucket to add. + *****************************************************************************/ + public void evel_meas_latency_bucket_add(MEASUREMENT_LATENCY_BUCKET bucket) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(bucket != null); + + if( latency_distribution == null ){ + latency_distribution = new ArrayList(); + if( latency_distribution == null )LOGGER.error("Unable to allocate new file system usage"); + } + latency_distribution.add(bucket); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional Latency Distribution bucket to the Measurement. + * + * This function implements the previous API, purely for convenience. + * + * + * @param low_end Low end of the bucket's range. + * @param high_end High end of the bucket's range. + * @param count Count of events in this bucket. + *****************************************************************************/ + public void evel_measurement_latency_add( + double low_end, + double high_end, + int count) + { + MEASUREMENT_LATENCY_BUCKET bucket = null; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Trust the assertions in the underlying methods. */ + /***************************************************************************/ + bucket = evel_new_meas_latency_bucket(count); + bucket.low_end.SetValue(low_end); + bucket.high_end.SetValue(high_end); + evel_meas_latency_bucket_add(bucket); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Create a new vNIC Use to be added to a Measurement event. + * + * @note The mandatory fields on the ::MEASUREMENT_VNIC_PERFORMANCE must be supplied + * to this factory function and are immutable once set. Optional + * fields have explicit setter functions, but again values may only be + * set once so that the ::MEASUREMENT_VNIC_PERFORMANCE has immutable + * properties. + * + * @param vnic_id ASCIIZ string with the vNIC's ID. + * @param val_suspect True or false confidence in data. + * + * @returns pointer to the newly manufactured ::MEASUREMENT_VNIC_PERFORMANCE. + * If the structure is not used it must be released using + * ::evel_measurement_free_vnic_performance. + * @retval null Failed to create the vNIC Use. + *****************************************************************************/ + public MEASUREMENT_VNIC_PERFORMANCE evel_measurement_new_vnic_performance(String vnic_id, + String val_suspect) + { + MEASUREMENT_VNIC_PERFORMANCE vnic_perf=null; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vnic_id != null); + assert(val_suspect.equals("true") || val_suspect.equals("false")); + + /***************************************************************************/ + /* Allocate, then set Mandatory Parameters. */ + /***************************************************************************/ + + vnic_perf = new MEASUREMENT_VNIC_PERFORMANCE(); + assert(vnic_perf != null); + vnic_perf.vnic_id = vnic_id; + vnic_perf.valuesaresuspect = val_suspect; + + vnic_perf.recvd_bcast_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_bcast_packets_delta= new EvelOptionDouble(); + + vnic_perf.recvd_discarded_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_discarded_packets_delta= new EvelOptionDouble(); + vnic_perf.recvd_error_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_error_packets_delta= new EvelOptionDouble(); + vnic_perf.recvd_mcast_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_mcast_packets_delta= new EvelOptionDouble(); + vnic_perf.recvd_octets_acc= new EvelOptionDouble(); + vnic_perf.recvd_octets_delta= new EvelOptionDouble(); + vnic_perf.recvd_total_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_total_packets_delta= new EvelOptionDouble(); + vnic_perf.recvd_ucast_packets_acc= new EvelOptionDouble(); + vnic_perf.recvd_ucast_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_bcast_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_bcast_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_discarded_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_discarded_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_error_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_error_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_mcast_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_mcast_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_octets_acc= new EvelOptionDouble(); + vnic_perf.tx_octets_delta= new EvelOptionDouble(); + vnic_perf.tx_total_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_total_packets_delta= new EvelOptionDouble(); + vnic_perf.tx_ucast_packets_acc= new EvelOptionDouble(); + vnic_perf.tx_ucast_packets_delta= new EvelOptionDouble(); + + LOGGER.debug("Adding "+vnic_perf+"VNIC ID="+ vnic_perf.vnic_id+"Value="+vnic_perf.valuesaresuspect); + + /***************************************************************************/ + /* Initialize Optional Parameters. */ + /***************************************************************************/ + EVEL_EXIT(); + + return vnic_perf; + } + + + + /**************************************************************************//** + * Set the Accumulated Broadcast Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_bcast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_bcast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_bcast_packets_acc >= 0.0); + + vnic_performance.recvd_bcast_packets_acc.SetValuePr( + recvd_bcast_packets_acc, + "Broadcast Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Broadcast Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_bcast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_bcast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_bcast_packets_delta >= 0.0); + + vnic_performance.recvd_bcast_packets_delta.SetValuePr( + recvd_bcast_packets_delta, + "Delta Broadcast Packets recieved"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Discarded Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_discard_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_discard_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_discard_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_discard_packets_acc >= 0.0); + + vnic_performance.recvd_discarded_packets_acc.SetValuePr( + recvd_discard_packets_acc, + "Discarded Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Discarded Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_discard_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_discard_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_discard_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_discard_packets_delta >= 0.0); + + vnic_performance.recvd_discarded_packets_delta.SetValuePr( + recvd_discard_packets_delta, + "Delta Discarded Packets recieved"); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Error Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_error_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_error_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_error_packets_acc >= 0.0); + + vnic_performance.recvd_error_packets_acc.SetValuePr( + recvd_error_packets_acc, + "Error Packets received accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Error Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_error_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_error_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_error_packets_delta >= 0.0); + + vnic_performance.recvd_error_packets_delta.SetValuePr( + recvd_error_packets_delta, + "Delta Error Packets recieved"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Accumulated Multicast Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_mcast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_mcast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_mcast_packets_acc >= 0.0); + + vnic_performance.recvd_mcast_packets_acc.SetValuePr( + recvd_mcast_packets_acc, + "Multicast Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Multicast Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_mcast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_mcast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_mcast_packets_delta >= 0.0); + + vnic_performance.recvd_mcast_packets_delta.SetValuePr( + recvd_mcast_packets_delta, + "Delta Multicast Packets recieved"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Accumulated Octets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_octets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_octets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_octets_acc >= 0.0); + + vnic_performance.recvd_octets_acc.SetValuePr( + recvd_octets_acc, + "Octets received accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Octets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_octets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_octets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_octets_delta >= 0.0); + + vnic_performance.recvd_octets_delta.SetValuePr( + recvd_octets_delta, + "Delta Octets recieved"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Accumulated Total Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_total_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_total_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_total_packets_acc >= 0.0); + + vnic_performance.recvd_total_packets_acc.SetValuePr( + recvd_total_packets_acc, + "Total Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Total Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_total_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_total_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_total_packets_delta >= 0.0); + + vnic_performance.recvd_total_packets_delta.SetValuePr( + recvd_total_packets_delta, + "Delta Total Packets recieved"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Accumulated Unicast Packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_ucast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_rx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_ucast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_ucast_packets_acc >= 0.0); + + vnic_performance.recvd_ucast_packets_acc.SetValuePr( + recvd_ucast_packets_acc, + "Unicast Packets received accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Unicast packets Received in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param recvd_ucast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_rx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double recvd_ucast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(recvd_ucast_packets_delta >= 0.0); + + vnic_performance.recvd_ucast_packets_delta.SetValuePr( + recvd_ucast_packets_delta, + "Delta Unicast packets recieved"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Transmitted Broadcast Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_bcast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_bcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_bcast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_bcast_packets_acc >= 0.0); + + vnic_performance.tx_bcast_packets_acc.SetValuePr( + tx_bcast_packets_acc, + "Transmitted Broadcast Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Broadcast packets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_bcast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_bcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_bcast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_bcast_packets_delta >= 0.0); + + vnic_performance.tx_bcast_packets_delta.SetValuePr( + tx_bcast_packets_delta, + "Delta Transmitted Broadcast packets "); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Transmitted Discarded Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_discarded_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_discarded_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_discarded_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_discarded_packets_acc >= 0.0); + + vnic_performance.tx_discarded_packets_acc.SetValuePr( + tx_discarded_packets_acc, + "Transmitted Discarded Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Discarded packets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_discarded_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_discarded_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_discarded_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_discarded_packets_delta >= 0.0); + + vnic_performance.tx_discarded_packets_delta.SetValuePr( + tx_discarded_packets_delta, + "Delta Transmitted Discarded packets "); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Transmitted Errored Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_error_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_error_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_error_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_error_packets_acc >= 0.0); + + vnic_performance.tx_error_packets_acc.SetValuePr( + tx_error_packets_acc, + "Transmitted Error Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Errored packets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_error_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_error_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_error_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_error_packets_delta >= 0.0); + + vnic_performance.tx_error_packets_delta.SetValuePr( + tx_error_packets_delta, + "Delta Transmitted Error packets "); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Transmitted Multicast Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_mcast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_mcast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_mcast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_mcast_packets_acc >= 0.0); + + vnic_performance.tx_mcast_packets_acc.SetValuePr( + tx_mcast_packets_acc, + "Transmitted Multicast Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Multicast packets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_mcast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_mcast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_mcast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_mcast_packets_delta >= 0.0); + + vnic_performance.tx_mcast_packets_delta.SetValuePr( + tx_mcast_packets_delta, + "Delta Transmitted Multicast packets "); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Transmitted Octets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_octets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_octets_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_octets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_octets_acc >= 0.0); + + vnic_performance.tx_octets_acc.SetValuePr( + tx_octets_acc, + "Transmitted Octets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Octets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_octets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_octets_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_octets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_octets_delta >= 0.0); + + vnic_performance.tx_octets_delta.SetValuePr( + tx_octets_delta, + "Delta Transmitted Octets "); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Transmitted Total Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_total_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_total_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_total_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_total_packets_acc >= 0.0); + + vnic_performance.tx_total_packets_acc.SetValuePr( + tx_total_packets_acc, + "Transmitted Total Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Total Packets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_total_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_total_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_total_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_total_packets_delta >= 0.0); + + vnic_performance.tx_total_packets_delta.SetValuePr( + tx_total_packets_delta, + "Delta Transmitted Total Packets "); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Transmitted Unicast Packets in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_ucast_packets_acc + *****************************************************************************/ + public void evel_vnic_performance_tx_ucast_pkt_acc_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_ucast_packets_acc) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_ucast_packets_acc >= 0.0); + + vnic_performance.tx_ucast_packets_acc.SetValuePr( + tx_ucast_packets_acc, + "Transmitted Unicast Packets accumulated"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Delta Octets Transmitted in measurement interval + * property of the vNIC performance. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param vnic_performance Pointer to the vNIC Use. + * @param tx_ucast_packets_delta + *****************************************************************************/ + public void evel_vnic_performance_tx_ucast_pkt_delta_set(MEASUREMENT_VNIC_PERFORMANCE vnic_performance, + double tx_ucast_packets_delta) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(tx_ucast_packets_delta >= 0.0); + + vnic_performance.tx_ucast_packets_delta.SetValuePr( + tx_ucast_packets_delta, + "Delta Transmitted Unicast Packets "); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Add an additional vNIC Use to the specified Measurement event. + * + * + * @param vnic_performance Pointer to the vNIC Use to add. + *****************************************************************************/ + public void evel_meas_vnic_performance_add( + MEASUREMENT_VNIC_PERFORMANCE vnic_performance) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(vnic_performance != null); + + if( vnic_usage == null ){ + vnic_usage = new ArrayList(); + if( vnic_usage == null )LOGGER.error("Unable to allocate new file system usage"); + } + + vnic_usage.add(vnic_performance); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional vNIC usage record Measurement. + * + * This function implements the previous API, purely for convenience. + * + * The ID is null delimited ASCII string. The library takes a copy so the + * caller does not have to preserve values after the function returns. + * + * @param measurement Pointer to the measurement. + * @param vnic_id ASCIIZ string with the vNIC's ID. + * @param valset true or false confidence level + * @param recvd_bcast_packets_acc Recieved broadcast packets + * @param recvd_bcast_packets_delta Received delta broadcast packets + * @param recvd_discarded_packets_acc Recieved discarded packets + * @param recvd_discarded_packets_delta Received discarded delta packets + * @param recvd_error_packets_acc Received error packets + * @param recvd_error_packets_delta, Received delta error packets + * @param recvd_mcast_packets_acc Received multicast packets + * @param recvd_mcast_packets_delta Received delta multicast packets + * @param recvd_octets_acc Received octets + * @param recvd_octets_delta Received delta octets + * @param recvd_total_packets_acc Received total packets + * @param recvd_total_packets_delta Received delta total packets + * @param recvd_ucast_packets_acc Received Unicast packets + * @param recvd_ucast_packets_delta Received delta unicast packets + * @param tx_bcast_packets_acc Transmitted broadcast packets + * @param tx_bcast_packets_delta Transmitted delta broadcast packets + * @param tx_discarded_packets_acc Transmitted packets discarded + * @param tx_discarded_packets_delta Transmitted delta discarded packets + * @param tx_error_packets_acc Transmitted error packets + * @param tx_error_packets_delta Transmitted delta error packets + * @param tx_mcast_packets_acc Transmitted multicast packets accumulated + * @param tx_mcast_packets_delta Transmitted delta multicast packets + * @param tx_octets_acc Transmitted octets + * @param tx_octets_delta Transmitted delta octets + * @param tx_total_packets_acc Transmitted total packets + * @param tx_total_packets_delta Transmitted delta total packets + * @param tx_ucast_packets_acc Transmitted Unicast packets + * @param tx_ucast_packets_delta Transmitted delta Unicast packets + *****************************************************************************/ + public void evel_measurement_vnic_performance_add( + String vnic_id, + String valset, + double recvd_bcast_packets_acc, + double recvd_bcast_packets_delta, + double recvd_discarded_packets_acc, + double recvd_discarded_packets_delta, + double recvd_error_packets_acc, + double recvd_error_packets_delta, + double recvd_mcast_packets_acc, + double recvd_mcast_packets_delta, + double recvd_octets_acc, + double recvd_octets_delta, + double recvd_total_packets_acc, + double recvd_total_packets_delta, + double recvd_ucast_packets_acc, + double recvd_ucast_packets_delta, + double tx_bcast_packets_acc, + double tx_bcast_packets_delta, + double tx_discarded_packets_acc, + double tx_discarded_packets_delta, + double tx_error_packets_acc, + double tx_error_packets_delta, + double tx_mcast_packets_acc, + double tx_mcast_packets_delta, + double tx_octets_acc, + double tx_octets_delta, + double tx_total_packets_acc, + double tx_total_packets_delta, + double tx_ucast_packets_acc, + double tx_ucast_packets_delta) + { + MEASUREMENT_VNIC_PERFORMANCE vnic_performance = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Trust the assertions in the underlying methods. */ + /***************************************************************************/ + vnic_performance = evel_measurement_new_vnic_performance(vnic_id, valset); + + evel_vnic_performance_rx_bcast_pkt_acc_set(vnic_performance, recvd_bcast_packets_acc); + evel_vnic_performance_rx_bcast_pkt_delta_set(vnic_performance, recvd_bcast_packets_delta); + evel_vnic_performance_rx_discard_pkt_acc_set(vnic_performance, recvd_discarded_packets_acc); + evel_vnic_performance_rx_discard_pkt_delta_set(vnic_performance, recvd_discarded_packets_delta); + evel_vnic_performance_rx_error_pkt_acc_set(vnic_performance, recvd_error_packets_acc); + evel_vnic_performance_rx_error_pkt_delta_set(vnic_performance, recvd_error_packets_delta); + evel_vnic_performance_rx_mcast_pkt_acc_set(vnic_performance, recvd_mcast_packets_acc); + evel_vnic_performance_rx_mcast_pkt_delta_set(vnic_performance, recvd_mcast_packets_delta); + evel_vnic_performance_rx_octets_acc_set(vnic_performance, recvd_octets_acc); + evel_vnic_performance_rx_octets_delta_set(vnic_performance, recvd_octets_delta); + evel_vnic_performance_rx_total_pkt_acc_set(vnic_performance, recvd_total_packets_acc); + evel_vnic_performance_rx_total_pkt_delta_set(vnic_performance, recvd_total_packets_delta); + evel_vnic_performance_rx_ucast_pkt_acc_set(vnic_performance, recvd_ucast_packets_acc); + evel_vnic_performance_rx_ucast_pkt_delta_set(vnic_performance, recvd_ucast_packets_delta); + evel_vnic_performance_tx_bcast_pkt_acc_set(vnic_performance, tx_bcast_packets_acc); + evel_vnic_performance_tx_bcast_pkt_delta_set(vnic_performance, tx_bcast_packets_delta); + evel_vnic_performance_tx_discarded_pkt_acc_set(vnic_performance, tx_discarded_packets_acc); + evel_vnic_performance_tx_discarded_pkt_delta_set(vnic_performance, tx_discarded_packets_delta); + evel_vnic_performance_tx_error_pkt_acc_set(vnic_performance, tx_error_packets_acc); + evel_vnic_performance_tx_error_pkt_delta_set(vnic_performance, tx_error_packets_delta); + evel_vnic_performance_tx_mcast_pkt_acc_set(vnic_performance, tx_mcast_packets_acc); + evel_vnic_performance_tx_mcast_pkt_delta_set(vnic_performance, tx_mcast_packets_delta); + evel_vnic_performance_tx_octets_acc_set(vnic_performance, tx_octets_acc); + evel_vnic_performance_tx_octets_delta_set(vnic_performance, tx_octets_delta); + evel_vnic_performance_tx_total_pkt_acc_set(vnic_performance, tx_total_packets_acc); + evel_vnic_performance_tx_total_pkt_delta_set(vnic_performance, tx_total_packets_delta); + evel_vnic_performance_tx_ucast_pkt_acc_set(vnic_performance, tx_ucast_packets_acc); + evel_vnic_performance_tx_ucast_pkt_delta_set(vnic_performance, tx_ucast_packets_delta); + + if( vnic_usage == null ){ + vnic_usage = new ArrayList(); + if( vnic_usage == null )LOGGER.error("Unable to allocate new file system usage"); + } + + vnic_usage.add(vnic_performance); + } + + /**************************************************************************//** + * Add a json object to jsonObject list. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param jsonobj Pointer to json object + *****************************************************************************/ + public void evel_measurement_add_jsonobj(javax.json.JsonObject jsonobj) + { + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + assert(jsonobj != null); + + LOGGER.debug("Adding jsonObject"); + + if( additional_objects == null ) + additional_objects = new ArrayList(); + + additional_objects.add(jsonobj); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Encode Scaling Measurement Object according to VES schema + * + * @retval JSON Object of Scaling Measurement event + *****************************************************************************/ + JsonObjectBuilder evelScalingMeasurementObject() + { + MEASUREMENT_CPU_USE cpu_use = null; + MEASUREMENT_MEM_USE mem_use = null; + MEASUREMENT_DISK_USE disk_use = null; + MEASUREMENT_FSYS_USE fsys_use = null; + MEASUREMENT_LATENCY_BUCKET bucket = null; + MEASUREMENT_VNIC_PERFORMANCE vnic_use = null; + MEASUREMENT_FEATURE_USE feature_use = null; + MEASUREMENT_CODEC_USE codec_use = null; + MEASUREMENT_GROUP meas_group = null; + CUSTOM_MEASUREMENT custom_meas = null; + //DLIST_ITEM item = null; + //DLIST_ITEM nested_item = null; + //DLIST_ITEM addl_info_item = null; + //OTHER_FIELD addl_info = null; + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_MEASUREMENT); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + JsonObjectBuilder evelmeasmt = Json.createObjectBuilder() + .add("measurementInterval", measurement_interval); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + // additional fields + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0 ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i additional_info; + EvelOptionString compressed_sip; /* JSON: compressedSip */ + EvelOptionString summary_sip; /* JSON: summarySip */ + + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + + private static final Logger LOGGER = Logger.getLogger( EvelSipSignaling.class.getName() ); + + + /**************************************************************************//** + * Create a new SIP Signaling event. + * @param corlator Correlator value + * @param locip_address Local IP address + * @param loc_port Local Port + * @param remip_address Remote IP address + * @param rem_port Remote Port + * + *****************************************************************************/ + public EvelSipSignaling(String evname,String evid, + String vendr_name, + String corlator, + String locip_address, + String loc_port, + String remip_address, + String rem_port) + {//Init header + super(evname,evid); + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vendr_name != null); + assert(corlator != null); + assert(locip_address != null); + assert(loc_port != null); + + assert(remip_address != null); + assert(rem_port != null); + + LOGGER.debug("New SipSignaling vendor "+vendr_name+" correlator"+corlator+"local_ip_address"+locip_address+"local port"+loc_port+"remote ip address"+remip_address+"remote port"+rem_port); + + /***************************************************************************/ + /* Initialize the header & the Domain */ + /***************************************************************************/ + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING; + /***************************************************************************/ + /* Initialize mandatory fields */ + /***************************************************************************/ + + correlator = corlator; + local_ip_address = locip_address; + local_port = loc_port; + remote_ip_address = remip_address; + remote_port = rem_port; + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + + vnfname_field = new VENDOR_VNFNAME_FIELD(); + vnfname_field.vendorname = vendr_name; + vnfname_field.vfmodule = new EvelOptionString(); + vnfname_field.vnfname = new EvelOptionString(); + + additional_info = null; + compressed_sip = new EvelOptionString(); + summary_sip = new EvelOptionString(); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Event Type property of the SIP signaling. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_type_set(String typ) + { + EVEL_ENTER(); + assert(typ != null); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + evel_header_type_set(typ); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Local Ip Address property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param local_ip_address + * The Local Ip Address to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_signaling_local_ip_address_set( + String loc_ip_address) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(loc_ip_address != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Local IP "+loc_ip_address); + + local_ip_address = loc_ip_address; + + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Local Port property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param local_port The Local Port to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_local_port_set(String loc_port) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(loc_port != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Local Port "+loc_port); + + local_port = loc_port; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Remote Ip Address property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param remote_ip_address + * The Remote Ip Address to be set. ASCIIZ string. The + * caller does not need to preserve the value once the + * function returns. + *****************************************************************************/ + public void evel_signaling_remote_ip_address_set(String remip_address) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(remip_address != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Remote IP Address "+remip_address); + + remote_ip_address = remip_address; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Remote Port property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param remote_port The Remote Port to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_remote_port_set(String rem_port) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(rem_port != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Remote Port "+rem_port); + + remote_port = rem_port; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Vendor module property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param modulename The module name to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_vnfmodule_name_set(String module_name) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(module_name != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Module Name "+module_name); + + vnfname_field.vfmodule.SetValue(module_name); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Vendor module property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param vnfname The Virtual Network function to be set. ASCIIZ string. + * The caller does not need to preserve the value once + * the function returns. + *****************************************************************************/ + public void evel_signaling_vnfname_set(String vnfname) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vnfname != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling VNF Name "+vnfname); + + vnfname_field.vnfname.SetValue(vnfname); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Compressed SIP property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param compressed_sip + * The Compressed SIP to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_compressed_sip_set(String compr_sip) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(compr_sip != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Compressed SIP "+compr_sip); + + compressed_sip.SetValue(compr_sip); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Summary SIP property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param summary_sip The Summary SIP to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_summary_sip_set(String summ_sip) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(summ_sip != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting SipSignaling Summary SIP "+summ_sip); + + summary_sip.SetValue(summ_sip); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Correlator property of the Signaling event. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param correlator The correlator to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_correlator_set(String corlator) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(corlator != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + LOGGER.debug("Setting Correlator "+corlator); + + correlator = corlator; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Signaling. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_signaling_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode SIP Signaling Object according to VES schema + * + * @retval JSON Object of SIP event + *****************************************************************************/ + JsonObjectBuilder evelSipSignalingObject() + { + + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SIPSIGNALING); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + + JsonObjectBuilder vnfnamedobj = Json.createObjectBuilder() + .add( "vendorName",vnfname_field.vendorname); + vnfname_field.vfmodule.encJsonValue(vnfnamedobj,"vfModuleName"); + vnfname_field.vfmodule.encJsonValue(vnfnamedobj,"vnfName"); + + JsonObjectBuilder evelsip = Json.createObjectBuilder() + .add("correlator", correlator) + .add("localIpAddress", local_ip_address) + .add("localPort", local_port) + .add("remoteIpAddress", remote_ip_address) + .add("remotePort", remote_port) + .add("vendorVnfNamedFields", vnfnamedobj); + + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + compressed_sip.encJsonValue(evelsip, "compressedSip"); + summary_sip.encJsonValue(evelsip, "summarySip"); + + + // additional fields + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i additional_info; + + private static final Logger LOGGER = Logger.getLogger( EvelStateChange.class.getName() ); + + /**************************************************************************//** + * Create a new State Change event. + * + * @note The mandatory fields on the State Change must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once + * so that the State Change has immutable properties. + * + * @param new_state The new state of the reporting entity. + * @param old_state The old state of the reporting entity. + * @param interface The card or port name of the reporting entity. + * + *****************************************************************************/ + public EvelStateChange(String evname, String evid, + EVEL_ENTITY_STATE newstate, + EVEL_ENTITY_STATE oldstate, + String interfce) + { + super(evname,evid); + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_STATE_CHANGE; + assert(EVEL_ENTITY_STATE.EVEL_MAX_ENTITY_STATES.compareTo(newstate) < 0 ); + assert(EVEL_ENTITY_STATE.EVEL_MAX_ENTITY_STATES.compareTo(oldstate) < 0 ); + assert( interfce != null); + + new_state = newstate; + old_state = oldstate; + state_interface = interfce; + + additional_info = null; + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Fault. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_statechange_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_STATE_CHANGE); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Convert a ::EVEL_ENTITY_STATE to it's string form for JSON encoding. + * + * @param state The entity state to encode. + * + * @returns the corresponding string + *****************************************************************************/ + String evel_entity_state(EVEL_ENTITY_STATE state) + { + String result=null; + + EVEL_ENTER(); + + switch (state) + { + case EVEL_ENTITY_STATE_IN_SERVICE: + result = "inService"; + break; + + case EVEL_ENTITY_STATE_MAINTENANCE: + result = "maintenance"; + break; + + case EVEL_ENTITY_STATE_OUT_OF_SERVICE: + result = "outOfService"; + break; + + default: + LOGGER.error("Unexpected entity state "+state); + System.exit(1); + } + + EVEL_EXIT(); + + return result; + } + + + /**************************************************************************//** + * Encode the State Change in JSON according to AT&T's schema. + * + *****************************************************************************/ + JsonObjectBuilder evelStateChangeObject() + { + String nstate; + String ostate; + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_STATE_CHANGE); + + + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + nstate = evel_entity_state(new_state); + ostate = evel_entity_state(old_state); + + JsonObjectBuilder evelstate = Json.createObjectBuilder() + .add("newState", nstate) + .add("oldState", ostate) + .add("stateInterface", state_interface); + + evelstate.add( "stateChangeFieldsVersion", version); + + /***************************************************************************/ + /* Optional additional information */ + /***************************************************************************/ + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i 0); + + syslog_proc_id.SetValuePr( + proc_id, + "Process ID"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Version property of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param version The Version to be set. ASCIIZ string. The caller does not + * need to preserve the value once the function returns. + *****************************************************************************/ + public void evel_syslog_version_set(int version) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + assert(version >= 0); + + syslog_ver.SetValuePr( + version, + "Version"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Structured Data property of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param s_data The Structured Data to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_syslog_s_data_set(String s_data) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + assert(s_data != null); + + syslog_s_data.SetValuePr( + s_data, + "Structured Data"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Structured SDID property of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param sdid The Structured Data to be set. ASCIIZ string. name@number + * Caller does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_syslog_sdid_set(String sdid) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + assert(sdid != null); + + syslog_sdid.SetValuePr( + sdid, + "SdId set"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Structured Severity property of the Syslog. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param sdid The Structured Data to be set. ASCIIZ string. + * Caller does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_syslog_severity_set(String severty) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + assert(severty != null); + + if( severty.equals("Alert") || severty.equals("Critical") || severty.equals("Debug") || + severty.equals("Emergency") || severty.equals("Error") || severty.equals("Info") || + severty.equals("Notice") || severty.equals("Warning") ) + { + syslog_severity.SetValuePr( + severty, + "Severity set"); + } + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode the Syslog in JSON according to AT&T's schema. + * + *****************************************************************************/ + JsonObjectBuilder evelSyslogObject() + { + String evt_source_type; + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + JsonObjectBuilder obj = Json.createObjectBuilder() + .add("eventSourceType", event_source_type.toString()) + .add("syslogMsg", syslog_msg) + .add("syslogTag", syslog_tag) + .add("syslogFieldsVersion",version); + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + event_source_host.encJsonValue(obj, "eventSourceHost"); + syslog_facility.encJsonValue(obj,"syslogFacility"); + syslog_priority.encJsonValue(obj,"syslogPri"); + syslog_proc.encJsonValue(obj, "syslogProc"); + syslog_proc_id.encJsonValue(obj, "syslogProcId"); + syslog_s_data.encJsonValue(obj, "syslogSData"); + syslog_sdid.encJsonValue(obj, "syslogSdId"); + syslog_severity.encJsonValue(obj, "syslogSev"); + syslog_ver.encJsonValue(obj, "syslogVer"); + + EVEL_EXIT(); + + return obj; + } + + /**************************************************************************//** + * Encode the event as a JSON event object according to AT&T's schema. + * retval : String of JSON syslog event message + *****************************************************************************/ + JsonObject evel_json_encode_event() + { + EVEL_ENTER(); + + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_SYSLOG); + + JsonObject obj = Json.createObjectBuilder() + .add("event", Json.createObjectBuilder() + .add( "commonEventHeader",eventHeaderObject() ) + .add( "syslogFields",evelSyslogObject() ) + ).build(); + + EVEL_EXIT(); + + return obj; + + } + + + + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelThresholdCross.java b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelThresholdCross.java new file mode 100644 index 0000000..7b7ec51 --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/main/java/evel_javalibrary/att/com/EvelThresholdCross.java @@ -0,0 +1,502 @@ +package evel_javalibrary.att.com; +/**************************************************************************//** + * @file + * Evel Threshold Crossing event class + * + * This file implements the Evel Threshold Crossing event class which is intended to provide a + * simple wrapper around the complexity of AT&T's Vendor Event Listener API so + * that VNFs can use it to send Threshold Crossing Alert events. + * + * License + * ------- + * Unless otherwise specified, all software contained herein is + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *****************************************************************************/ + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Date; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +import org.apache.log4j.Logger; + +import evel_javalibrary.att.com.EvelMobileFlow.MOBILE_GTP_PER_FLOW_METRICS; + + +public class EvelThresholdCross extends EvelHeader { + + + int major_version = 1; + int minor_version = 1; + + /**************************************************************************//** + * Alert types. + * JSON equivalent fields: newState, oldState + *****************************************************************************/ + public enum EVEL_EVENT_ACTION { + EVEL_EVENT_ACTION_CLEAR, + EVEL_EVENT_ACTION_CONTINUE, + EVEL_EVENT_ACTION_SET, + EVEL_MAX_EVENT_ACTION + } + + public enum EVEL_ALERT_TYPE { + EVEL_CARD_ANOMALY, + EVEL_ELEMENT_ANOMALY, + EVEL_INTERFACE_ANOMALY, + EVEL_SERVICE_ANOMALY, + EVEL_MAX_ANOMALY + } + + public enum EVEL_SEVERITIES{ + EVEL_SEVERITY_CRITICAL, + EVEL_SEVERITY_MAJOR, + EVEL_SEVERITY_MINOR, + EVEL_SEVERITY_WARNING, + EVEL_SEVERITY_NORMAL, + EVEL_MAX_SEVERITIES + } + + + /***************************************************************************/ + /* Mandatory fields */ + /***************************************************************************/ + + public class PERF_COUNTER { + String criticality; + String name; + String thresholdCrossed; + String value; + } + + PERF_COUNTER additionalParameters; + EVEL_EVENT_ACTION alertAction; + String alertDescription; + EVEL_ALERT_TYPE alertType; + Date collectionTimestamp; + EVEL_SEVERITIES eventSeverity; + Date eventStartTimestamp; + + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + ArrayList additional_info; + EvelOptionString alertValue; + ArrayList alertidList; + EvelOptionString dataCollector; + EvelOptionString elementType; + EvelOptionString interfaceName; + EvelOptionString networkService; + EvelOptionString possibleRootCause; + + + private static final Logger LOGGER = Logger.getLogger( EvelThresholdCross.class.getName() ); + + /**************************************************************************//** + * Create a new Threshold Crossing event. + * + * + * @param String tcriticality Counter Criticality MAJ MIN, + * @param String tname Counter Threshold name + * @param String tthresholdCrossed Counter Threshold crossed value + * @param String tvalue Counter actual value + * @param EVEL_EVENT_ACTION talertAction Alert set continue or clear + * @param String talertDescription + * @param EVEL_ALERT_TYPE talertType Kind of anamoly + * @param Date tcollectionTimestamp time at which alert was collected + * @param EVEL_SEVERITIES teventSeverity Severity of Alert + * @param Date teventStartTimestamp Time when this alert started + *****************************************************************************/ + public EvelThresholdCross( String evname,String evid, + String tcriticality, + String tname, + String tthresholdCrossed, + String tvalue, + EVEL_EVENT_ACTION talertAction, + String talertDescription, + EVEL_ALERT_TYPE talertType, + Date tcollectionTimestamp, + EVEL_SEVERITIES teventSeverity, + Date teventStartTimestamp) + { + super(evname,evid); + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING; + assert( tcriticality!= null ); + assert( tname!= null ); + assert( tthresholdCrossed!= null ); + assert( tvalue!= null ); + assert( talertAction!= null ); + + additionalParameters = new PERF_COUNTER(); + assert( additionalParameters != null); + + additionalParameters.criticality = tcriticality; + additionalParameters.name = tname; + additionalParameters.thresholdCrossed = tthresholdCrossed; + additionalParameters.value = tvalue; + alertAction = talertAction; + alertDescription = talertDescription; + alertType = talertType; + collectionTimestamp = tcollectionTimestamp; + eventSeverity = teventSeverity; + eventStartTimestamp = teventStartTimestamp; + + additional_info = null; + alertValue = new EvelOptionString(); + alertidList = null; + dataCollector = new EvelOptionString(); + elementType = new EvelOptionString(); + interfaceName = new EvelOptionString(); + networkService = new EvelOptionString(); + possibleRootCause = new EvelOptionString(); + } + + + /**************************************************************************//** + * Set the Event Type property of the TC Alert. + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * @param type The Event Type to be set. ASCIIZ string. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_thresholdcross_type_set(String type) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions and call evel_header_type_set. */ + /***************************************************************************/ + assert(type!=null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + evel_header_type_set(type); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an optional additional alertid value to Alert. + * + *****************************************************************************/ + public void evel_thresholdcross_alertid_add(String alertid) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + assert(alertid != null); + + if( alertidList == null ) + { + alertidList = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding alertid={0}", alertid)); + + alertidList.add(new String(alertid)); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an optional additional value name/value pair to the Alert. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_thresholdcross_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the TCA probable Root cause. + * + * @param sheader Possible root cause to Threshold + *****************************************************************************/ + public void evel_threshold_cross_possible_rootcause_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + possibleRootCause.SetValuePr( + sheader, + "Rootcause value"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the TCA networking cause. + * + * @param sheader Possible networking service value to Threshold + *****************************************************************************/ + public void evel_threshold_cross_networkservice_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + networkService.SetValuePr( + sheader, + "Networking service value"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the TCA Interface name. + * + * @param sheader Interface name to threshold + *****************************************************************************/ + public void evel_threshold_cross_interfacename_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + interfaceName.SetValuePr( + sheader, + "TCA Interface name"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the TCA Data element type. + * + * @param sheader element type of Threshold + *****************************************************************************/ + public void evel_threshold_cross_data_elementtype_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + elementType.SetValuePr( + sheader, + "TCA Element type value"); + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the TCA Data collector value. + * + * @param sheader Data collector value + *****************************************************************************/ + public void evel_threshold_cross_data_collector_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + dataCollector.SetValuePr( + sheader, + "Datacollector value"); + EVEL_EXIT(); + } + + + + /**************************************************************************//** + * Set the TCA alert value. + * + * @param sheader Possible alert value + *****************************************************************************/ + public void evel_threshold_cross_alertvalue_set(String sheader) + { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + assert(sheader != null); + + alertValue.SetValuePr( + sheader, + "Alert value"); + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Encode the fault in JSON according to AT&T's schema for the TC ALert type. + * + * @retvalue JSON object of TC Alert encoding + *****************************************************************************/ + JsonObjectBuilder evelThresholdCrossingObject() + { + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_THRESHOLD_CROSSING); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + //encode counter + JsonObjectBuilder counterobj = Json.createObjectBuilder() + .add( "criticality",additionalParameters.criticality) + .add( "name", additionalParameters.name) + .add( "thresholdCrossed",additionalParameters.thresholdCrossed) + .add( "value", additionalParameters.value); + + + JsonObjectBuilder evelrep = Json.createObjectBuilder() + .add("additionalParameters", counterobj) + .add("alertAction", alertAction.toString()) + .add("alertDescription", alertDescription) + .add("alertType", alertType.toString()) + .add("collectionTimestamp", collectionTimestamp.toString()) + .add("eventSeverity",eventSeverity.toString()) + .add("eventStartTimestamp",eventStartTimestamp.toString()); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + alertValue.encJsonValue(evelrep, "alertValue"); + if( alertidList != null && alertidList.size() > 0) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i additional_info; + END_OF_CALL_VOICE_QUALITY_METRICS endOfCallVqmSummaries; + EvelOptionString evphoneNumber; + + /***************************************************************************/ + /* Optional fields */ + /***************************************************************************/ + + private static final Logger LOGGER = Logger.getLogger( EvelVoiceQuality.class.getName() ); + + + /**************************************************************************//** + * Create a new Voice Quality event. + * + * @note The mandatory fields on the Voice Quality must be supplied to this + * factory function and are immutable once set. Optional fields have + * explicit setter functions, but again values may only be set once so + * that the event has immutable properties. + * + * @param calleeSideCodec callee codec for voice call + * @param callerSideCodec caller codec + * @param corlator Correlator + * @param midCallRtcp Midcall RTCP value + * @param vendr_name Vendor name + * + * @returns pointer to the newly manufactured ::EVENT_MEASUREMENT. If the + * event is not used (i.e. posted) it must be released using + * ::evel_free_event. + * @retval null Failed to create the event. + *****************************************************************************/ + public EvelVoiceQuality(String evname, String evid, + String calleeSideCodc, + String callerSideCodc, String corlator, + String midCllRtcp, String vendr_name) + { + super(evname,evid); + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vendr_name != null); + assert(calleeSideCodc != null); + assert(callerSideCodc != null); + assert(midCllRtcp != null); + assert(corlator != null); + + + /***************************************************************************/ + /* Allocate the measurement. */ + /***************************************************************************/ + LOGGER.debug("New Voice Quality vendor "+vendr_name+" correlator"+corlator+"calleeSideCodec"+calleeSideCodc+"callerSideCodec"+callerSideCodc+"midCallRtcp"+midCllRtcp); + + /***************************************************************************/ + /* Initialize the header & the measurement fields. */ + /***************************************************************************/ + event_domain = EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY; + correlator = corlator; + calleeSideCodec = calleeSideCodc; + callerSideCodec = callerSideCodc; + midCallRtcp = midCllRtcp; + + vnfname_field = new VENDOR_VNFNAME_FIELD(); + vnfname_field.vendorname = vendr_name; + vnfname_field.vfmodule = new EvelOptionString(); + vnfname_field.vnfname = new EvelOptionString(); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + additional_info = null; + endOfCallVqmSummaries = null; + evphoneNumber = new EvelOptionString(); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an additional value name/value pair to the Voice Quality. + * + * The name and value are null delimited ASCII strings. The library takes + * a copy so the caller does not have to preserve values after the function + * returns. + * + * @param name ASCIIZ string with the attribute's name. The caller + * does not need to preserve the value once the function + * returns. + * @param value ASCIIZ string with the attribute's value. The caller + * does not need to preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_addl_info_add(String name, String value) + { + String[] addl_info = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + assert(name != null); + assert(value != null); + + if( additional_info == null ) + { + additional_info = new ArrayList(); + } + + LOGGER.debug(MessageFormat.format("Adding name={0} value={1}", name, value)); + addl_info = new String[2]; + assert(addl_info != null); + addl_info[0] = name; + addl_info[1] = value; + + additional_info.add(addl_info); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Callee side codec for Call for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param calleeCodecForCall The Callee Side Codec to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_callee_codec_set(String calleeCodecForCall) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(calleeCodecForCall != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting Correlator "+calleeCodecForCall); + + calleeSideCodec = calleeCodecForCall; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Caller side codec for Call for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param callerCodecForCall The Caller Side Codec to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_caller_codec_set(String callerCodecForCall) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(callerCodecForCall != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting CallerCodecForCall "+callerCodecForCall); + + callerSideCodec = callerCodecForCall; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the correlator for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param correlator The correlator value to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_correlator_set(String vCorrelator) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vCorrelator != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting Correlator "+vCorrelator); + + correlator = vCorrelator; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the RTCP Call Data for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param rtcpCallData The RTCP Call Data to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_rtcp_data_set(String rtcpCallData) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(rtcpCallData != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting RTCP Data "+rtcpCallData); + + midCallRtcp = rtcpCallData; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Vendor VNF Name fields for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param modulename The Vendor, VNF and VfModule names to be set. + * ASCIIZ string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_vnfmodule_name_set(String module_name) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(module_name != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting VoiceQuality Module Name "+module_name); + + vnfname_field.vfmodule.SetValue(module_name); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Set the Vendor VNF Name fields for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param modulename The Vendor, VNF and VfModule names to be set. + * ASCIIZ string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_vnfname_set(String vnfname) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(vnfname != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + LOGGER.debug("Setting VoiceQuality VNF Name "+vnfname); + + vnfname_field.vnfname.SetValue(vnfname); + + EVEL_EXIT(); + } + + + /**************************************************************************//** + * Set the Phone Number associated with the Correlator for domain Voice Quality + * + * @note The property is treated as immutable: it is only valid to call + * the setter once. However, we don't assert if the caller tries to + * overwrite, just ignoring the update instead. + * + * + * @param calleeCodecForCall The Phone Number to be set. ASCIIZ + * string. The caller does not need to + * preserve the value once the function + * returns. + *****************************************************************************/ + public void evel_voice_quality_phone_number_set(String phoneNumber) { + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(phoneNumber != null); + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + + evphoneNumber.SetValuePr(phoneNumber,"Phone_Number"); + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Add an End of Call Voice Quality Metrices + + * The adjacencyName and endpointDescription is null delimited ASCII string. + * The library takes a copy so the caller does not have to preserve values + * after the function returns. + * + * @param voiceQuality Pointer to the measurement. + * @param adjacencyName Adjacency name + * @param endpointDescription Enumeration: ‘Caller’, ‘Callee’. + * @param endpointJitter Endpoint jitter + * @param endpointRtpOctetsDiscarded Endpoint RTP octets discarded. + * @param endpointRtpOctetsReceived Endpoint RTP octets received. + * @param endpointRtpOctetsSent Endpoint RTP octets sent + * @param endpointRtpPacketsDiscarded Endpoint RTP packets discarded. + * @param endpointRtpPacketsReceived Endpoint RTP packets received. + * @param endpointRtpPacketsSent Endpoint RTP packets sent. + * @param localJitter Local jitter. + * @param localRtpOctetsDiscarded Local RTP octets discarded. + * @param localRtpOctetsReceived Local RTP octets received. + * @param localRtpOctetsSent Local RTP octets sent. + * @param localRtpPacketsDiscarded Local RTP packets discarded. + * @param localRtpPacketsReceived Local RTP packets received. + * @param localRtpPacketsSent Local RTP packets sent. + * @param mosCqe Decimal range from 1 to 5 + * (1 decimal place) + * @param packetsLost No Packets lost + * @param packetLossPercent Calculated percentage packet loss + * @param rFactor rFactor from 0 to 100 + * @param roundTripDelay Round trip delay in milliseconds + *****************************************************************************/ + public void evel_voice_quality_end_metrics_set( + String adjacencyName, String endpointDescr, + double endpointJitter, + double endpointRtpOctetsDiscarded, + double endpointRtpOctetsReceived, + double endpointRtpOctetsSent, + double endpointRtpPacketsDiscarded, + double endpointRtpPacketsReceived, + double endpointRtpPacketsSent, + double localJitter, + double localRtpOctetsDiscarded, + double localRtpOctetsReceived, + double localRtpOctetsSent, + double localRtpPacketsDiscarded, + double localRtpPacketsReceived, + double localRtpPacketsSent, + double mosCqe, + double packetsLost, + double packetLossPercent, + double rFactor, + double roundTripDelay) { + + END_OF_CALL_VOICE_QUALITY_METRICS vQMetrices = null; + EVEL_ENTER(); + + /***************************************************************************/ + /* Check assumptions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + assert(adjacencyName != null); + assert(mosCqe >= 1 && mosCqe <= 5); + assert(rFactor >= 0 && rFactor <= 100); + assert(endpointDescr != null && (endpointDescr.equals("Caller")||endpointDescr.equals("Callee")) ); + + /***************************************************************************/ + /* Allocate a container for the value and push onto the list. */ + /***************************************************************************/ + LOGGER.debug(MessageFormat.format("Adding adjacencyName={0} endpointDescription={1}", adjacencyName, endpointDescr)); + vQMetrices = new END_OF_CALL_VOICE_QUALITY_METRICS(); + assert(vQMetrices != null); + + vQMetrices.adjacencyName = adjacencyName; + vQMetrices.endpointDescription = endpointDescr; + + vQMetrices.endpointJitter = new EvelOptionDouble(); + vQMetrices.endpointRtpOctetsDiscarded= new EvelOptionDouble(); + vQMetrices.endpointRtpOctetsReceived= new EvelOptionDouble(); + vQMetrices.endpointRtpOctetsSent= new EvelOptionDouble(); + vQMetrices.endpointRtpPacketsDiscarded= new EvelOptionDouble(); + vQMetrices.endpointRtpPacketsReceived= new EvelOptionDouble(); + vQMetrices.endpointRtpPacketsSent= new EvelOptionDouble(); + vQMetrices.localJitter= new EvelOptionDouble(); + vQMetrices.localRtpOctetsDiscarded= new EvelOptionDouble(); + vQMetrices.localRtpOctetsReceived= new EvelOptionDouble(); + vQMetrices.localRtpOctetsSent= new EvelOptionDouble(); + vQMetrices.localRtpPacketsDiscarded= new EvelOptionDouble(); + vQMetrices.localRtpPacketsReceived= new EvelOptionDouble(); + vQMetrices.localRtpPacketsSent= new EvelOptionDouble(); + vQMetrices.mosCqe= new EvelOptionDouble(); + vQMetrices.packetsLost= new EvelOptionDouble(); + vQMetrices.packetLossPercent= new EvelOptionDouble(); + vQMetrices.rFactor= new EvelOptionDouble(); + vQMetrices.roundTripDelay= new EvelOptionDouble(); + + vQMetrices.endpointJitter.SetValuePr(endpointJitter, "Endpoint jitter"); + vQMetrices.endpointRtpOctetsDiscarded.SetValuePr(endpointRtpOctetsDiscarded, "Endpoint RTP octets discarded"); + vQMetrices.endpointRtpOctetsReceived.SetValuePr(endpointRtpOctetsReceived, "Endpoint RTP octets received"); + vQMetrices.endpointRtpOctetsSent.SetValuePr(endpointRtpOctetsSent, "Endpoint RTP octets sent"); + vQMetrices.endpointRtpPacketsDiscarded.SetValuePr(endpointRtpPacketsDiscarded, "Endpoint RTP packets discarded"); + vQMetrices.endpointRtpPacketsReceived.SetValuePr(endpointRtpPacketsReceived, "Endpoint RTP packets received"); + vQMetrices.endpointRtpPacketsSent.SetValuePr(endpointRtpPacketsSent, "Endpoint RTP packets sent"); + vQMetrices.localJitter.SetValuePr( localJitter, "Local jitter"); + vQMetrices.localRtpOctetsDiscarded.SetValuePr(localRtpOctetsDiscarded, "Local RTP octets discarded"); + vQMetrices.localRtpOctetsReceived.SetValuePr(localRtpOctetsReceived, "Local RTP octets received"); + vQMetrices.localRtpOctetsSent.SetValuePr(localRtpOctetsSent, "Local RTP octets sent"); + vQMetrices.localRtpPacketsDiscarded.SetValuePr(localRtpPacketsDiscarded, "Local RTP packets discarded"); + vQMetrices.localRtpPacketsReceived.SetValuePr(localRtpPacketsReceived, "Local RTP packets received"); + vQMetrices.localRtpPacketsSent.SetValuePr(localRtpPacketsSent, "Local RTP packets sent"); + vQMetrices.mosCqe.SetValuePr(mosCqe, "Decimal range from 1 to 5 (1 decimal place)"); + vQMetrices.packetsLost.SetValuePr(packetsLost, "Packets lost"); + vQMetrices.packetLossPercent.SetValuePr(packetLossPercent, "Calculated percentage packet loss"); + vQMetrices.rFactor.SetValuePr(rFactor, "rFactor "); + vQMetrices.roundTripDelay.SetValuePr(roundTripDelay, "Round trip delay in milliseconds "); + + endOfCallVqmSummaries = vQMetrices; + + EVEL_EXIT(); + } + + /**************************************************************************//** + * Encode the Voice Quality in JSON according to AT&T's schema + * + * @retvalue JSON object of VoiceQuality body encoding + *****************************************************************************/ + JsonObjectBuilder evelVoiceQualityObject() + { + + double version = major_version+(double)minor_version/10; + + EVEL_ENTER(); + + /***************************************************************************/ + /* Check preconditions. */ + /***************************************************************************/ + assert(event_domain == EvelHeader.DOMAINS.EVEL_DOMAIN_VOICE_QUALITY); + + /***************************************************************************/ + /* Mandatory fields. */ + /***************************************************************************/ + + JsonObjectBuilder vnfnamedobj = Json.createObjectBuilder() + .add( "vendorName",vnfname_field.vendorname); + vnfname_field.vfmodule.encJsonValue(vnfnamedobj,"vfModuleName"); + vnfname_field.vfmodule.encJsonValue(vnfnamedobj,"vnfName"); + + JsonObjectBuilder evelvq = Json.createObjectBuilder() + .add("correlator", correlator) + .add("calleeSideCodec", calleeSideCodec) + .add("callerSideCodec", callerSideCodec) + .add("midCallRtcp", midCallRtcp) + .add("voiceQualityFieldsVersion", version) + .add("vendorVnfNameFields", vnfnamedobj); + + /***************************************************************************/ + /* Optional fields. */ + /***************************************************************************/ + evphoneNumber.encJsonValue(evelvq, "phoneNumber"); + + + // additional fields + if( additional_info != null ) + { + JsonArrayBuilder builder = Json.createArrayBuilder(); + for(int i=0;i= capacity){ + writePos = 0; + } + elements[writePos] = element; + writePos++; + available++; + ret = true; + } + + //release Locks + lock.release(); + countsem.release(); + + + return ret; + } + + public int put(EvelObject[] newElements){ + return put(newElements, newElements.length); + } + + public int put(EvelObject[] newElements, int length){ + //Acquire locks + try { + spacesem.acquire(); + lock.acquire(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + int readPos = 0; + if(this.writePos > this.available){ + //space above writePos is all empty + + if(length <= this.capacity - this.writePos){ + //space above writePos is sufficient to insert batch + + for(; readPos < length; readPos++){ + this.elements[this.writePos++] = newElements[readPos]; + } + this.available += readPos; + //release + lock.release(); + countsem.release(); + return length; + + } else { + //both space above writePos and below writePos is necessary to use + //to insert batch. + + int lastEmptyPos = writePos - available; + + for(; this.writePos < this.capacity; this.writePos++){ + this.elements[this.writePos] = newElements[readPos++]; + } + + //fill into bottom of array too. + this.writePos = 0; + + int endPos = Math.min(length - readPos, capacity - available - readPos); + for(;this.writePos < endPos; this.writePos++){ + this.elements[this.writePos] = newElements[readPos++]; + } + this.available += readPos; + //release + lock.release(); + countsem.release(); + return readPos; + } + } else { + int endPos = this.capacity - this.available + this.writePos; + + for(; this.writePos < endPos; this.writePos++){ + this.elements[this.writePos] = newElements[readPos++]; + } + this.available += readPos; + //release + lock.release(); + countsem.release(); + + return readPos; + } + + } + + /* + * Takes a stored object in Ringbuffer and releases the space + */ + + public EvelObject take() { + + EvelObject nextObj; + //acquire lock + try { + countsem.acquire(); + lock.acquire(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(available == 0){ + nextObj = null; + } + else { + int nextSlot = writePos - available; + if(nextSlot < 0){ + nextSlot += capacity; + } + nextObj = elements[nextSlot]; + available--; + } + //releases object + lock.release(); + spacesem.release(); + + return nextObj; + } + + + public int take(EvelObject[] into){ + return take(into, into.length); + } + + + public int take(EvelObject[] into, int length){ + int intoPos = 0; + + //acquire lock + try { + countsem.acquire(); + lock.acquire(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if(available <= writePos){ + int nextPos= writePos - available; + int endPos = nextPos + Math.min(available, length); + + for(;nextPos < endPos; nextPos++){ + into[intoPos++] = this.elements[nextPos]; + } + this.available -= intoPos; + + //release + lock.release(); + countsem.release(); + + return intoPos; + } else { + int nextPos = writePos - available + capacity; + + int leftInTop = capacity - nextPos; + if(length <= leftInTop){ + //copy directly + for(; intoPos < length; intoPos++){ + into[intoPos] = this.elements[nextPos++]; + } + this.available -= length; + //release + lock.release(); + countsem.release(); + return length; + + } else { + //copy top + for(; nextPos < capacity; nextPos++){ + into[intoPos++] = this.elements[nextPos]; + } + + //copy bottom - from 0 to writePos + nextPos = 0; + int leftToCopy = length - intoPos; + int endPos = Math.min(writePos, leftToCopy); + + for(;nextPos < endPos; nextPos++){ + into[intoPos++] = this.elements[nextPos]; + } + + this.available -= intoPos; + + //release + lock.release(); + countsem.release(); + + return intoPos; + } + } + } + +} diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java new file mode 100644 index 0000000..044a3ae --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestJunit.java @@ -0,0 +1,360 @@ +/* + * ============LICENSE_START======================================================= + * ves-agent + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import evel_javalibrary.att.com.*; +import evel_javalibrary.att.com.AgentMain.EVEL_ERR_CODES; +import evel_javalibrary.att.com.EvelFault.EVEL_SEVERITIES; +import evel_javalibrary.att.com.EvelFault.EVEL_SOURCE_TYPES; +import evel_javalibrary.att.com.EvelFault.EVEL_VF_STATUSES; +import evel_javalibrary.att.com.EvelHeader.PRIORITIES; +import evel_javalibrary.att.com.EvelMobileFlow.MOBILE_GTP_PER_FLOW_METRICS; +import evel_javalibrary.att.com.EvelScalingMeasurement.MEASUREMENT_CPU_USE; +import evel_javalibrary.att.com.EvelScalingMeasurement.MEASUREMENT_VNIC_PERFORMANCE; +import evel_javalibrary.att.com.EvelStateChange.EVEL_ENTITY_STATE; +import evel_javalibrary.att.com.EvelThresholdCross.EVEL_ALERT_TYPE; +import evel_javalibrary.att.com.EvelThresholdCross.EVEL_EVENT_ACTION; + + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; +import org.apache.log4j.Logger; +import org.apache.log4j.Level; +import org.apache.log4j.BasicConfigurator; + +import java.io.*; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.Date; + + +@PrepareForTest({AgentMain.class}) +@RunWith(PowerMockRunner.class) +public class TestJunit { + + private AgentMain mymainmock = null; + private EvelHeader header = null; + + //private static final Logger LOG = LoggerFactory.getLogger(TestJunit.class); + private static final Logger LOG = Logger.getLogger(TestJunit.class.getName()); + + @Before + public void setupClass() { + BasicConfigurator.configure(); + mymainmock = mock(AgentMain.class); + + // PowerMockito does bytecode magic to mock static methods and use final classes + PowerMockito.mockStatic(AgentMain.class); + + //evel init + try { + mymainmock.evel_initialize( "http://127.0.0.1", 30000, "/vendor_event_listener", "/example_vnf", null, null,null, "pill", "will", Level.DEBUG); + } catch ( Exception e ) + { + e.printStackTrace(); + } + } + + + @Test + public void testHeartbeat() { + + header = EvelHeader.evel_new_heartbeat("Hearbeat_vAFX","vmname_ip"); + header.evel_nfnamingcode_set("vVNF"); + header.evel_nfcnamingcode_set("vVNF"); + + when(mymainmock.evel_post_event(header)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(header); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + + @Test + public void testFault() { + + EvelFault flt = new EvelFault("Fault_vVNF", "vmname_ip", + "NIC error", "Hardware failed", + EvelHeader.PRIORITIES.EVEL_PRIORITY_HIGH, + EVEL_SEVERITIES.EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_TYPES.EVEL_SOURCE_CARD, + EVEL_VF_STATUSES.EVEL_VF_STATUS_ACTIVE); + flt.evel_fault_addl_info_add("nichw", "fail"); + flt.evel_fault_addl_info_add("nicsw", "fail"); + when(mymainmock.evel_post_event(flt)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(flt); + LOG.info("Returned "+ret); + assertTrue( ret ); + + } + + @Test + public void testBatch() { + EvelBatch be = new EvelBatch(); + EvelFault flt2 = new EvelFault("Fault_vVNF", "vmname_ip", + "NIC error", "Hardware failed", + EvelHeader.PRIORITIES.EVEL_PRIORITY_HIGH, + EVEL_SEVERITIES.EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_TYPES.EVEL_SOURCE_CARD, + EVEL_VF_STATUSES.EVEL_VF_STATUS_ACTIVE); + flt2.evel_fault_addl_info_add("nichw", "fail"); + flt2.evel_fault_addl_info_add("nicsw", "fail"); + be.addEvent(flt2); + + EvelFault flt3 = new EvelFault("Fault_vVNF", "vmname_ip2", + "NIC error", "Hardware failed", + EvelHeader.PRIORITIES.EVEL_PRIORITY_NORMAL, + EVEL_SEVERITIES.EVEL_SEVERITY_MAJOR, + EVEL_SOURCE_TYPES.EVEL_SOURCE_CARD, + EVEL_VF_STATUSES.EVEL_VF_STATUS_ACTIVE); + flt3.evel_fault_type_set("Interface fault"); + flt3.evel_fault_category_set("Failed category"); + flt3.evel_fault_interface_set("An Interface Card"); + flt3.evel_fault_addl_info_add("nichw", "fail"); + flt3.evel_fault_addl_info_add("nicsw", "fail"); + be.addEvent(flt3); + + + EvelStateChange stc = new EvelStateChange("StateChange_vVNF", "vmname_ip", + EvelStateChange.EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_IN_SERVICE, + EvelStateChange.EVEL_ENTITY_STATE.EVEL_ENTITY_STATE_OUT_OF_SERVICE,"bgp"); + stc.evel_statechange_addl_info_add("bgpa", "fail"); + stc.evel_statechange_addl_info_add("bgpb", "fail"); + //AgentMain.evel_post_event(stc); + + be.addEvent(stc); + when(mymainmock.evel_post_event(be)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(be); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testMeasurement() { + EvelScalingMeasurement sm = new EvelScalingMeasurement(10.0,"Measurements_vVNF", "vmname_ip"); + sm.evel_measurement_myerrors_set(10,20,30,40); + MEASUREMENT_CPU_USE my1 = sm.evel_measurement_new_cpu_use_add("cpu1", 100.0); + my1.idle.SetValue(20.0); + my1.sys.SetValue(21.0); + MEASUREMENT_CPU_USE my2 = sm.evel_measurement_new_cpu_use_add("cpu2", 10.0); + my2.steal.SetValue(34.0); + my2.user.SetValue(32.0); + sm.evel_measurement_custom_measurement_add("group1","name1","val1"); + sm.evel_measurement_custom_measurement_add("group1","name2","val2"); + sm.evel_measurement_custom_measurement_add("group2","name1","val1"); + sm.evel_measurement_custom_measurement_add("group2","name2","val2"); + + + MEASUREMENT_VNIC_PERFORMANCE vnic_p = sm.evel_measurement_new_vnic_performance("vnic1","true"); + vnic_p.recvd_bcast_packets_acc.SetValue(2400000.0); + vnic_p.recvd_mcast_packets_delta.SetValue(5677888.0); + vnic_p.recvd_mcast_packets_acc.SetValue(5677888.0); + vnic_p.tx_ucast_packets_acc.SetValue(547856576.0); + vnic_p.tx_ucast_packets_delta.SetValue(540000.0); + sm.evel_meas_vnic_performance_add(vnic_p); + + when(mymainmock.evel_post_event(sm)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(sm); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testSyslog() { + EvelSyslog sysl = new EvelSyslog("Syslog_vVNF", "vmname_ip", + EvelFault.EVEL_SOURCE_TYPES.EVEL_SOURCE_ROUTER, + "Router failed","JUNIPER"); + sysl.evel_syslog_proc_id_set(456); + sysl.evel_syslog_proc_set("routed"); + + when(mymainmock.evel_post_event(sysl)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(sysl); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testHtbtField() { + EvelHeartbeatField hfld = new EvelHeartbeatField(123,"HeartbeatField_vVNF", "vmname_ip"); + hfld.evel_hrtbt_interval_set(23); + + when(mymainmock.evel_post_event(hfld)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(hfld); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testSipSignaling() { + + EvelSipSignaling sip = new EvelSipSignaling("SipSignaling_vVNF", "vmname_ip","aricent","corlator","127.0.0.1","5647","10.1.1.124","5678"); + + when(mymainmock.evel_post_event(sip)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(sip); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testVoiceQuality() { + EvelVoiceQuality vq = new EvelVoiceQuality("VoiceQuality_vVNF", "vmname_ip", + "calleeSideCodc", + "callerSideCodc", "corlator", + "midCllRtcp", "juniper"); + vq.evel_voice_quality_end_metrics_set("adjname", "Caller", 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 15.1, 160.12, 170, 180, 190); + + when(mymainmock.evel_post_event(vq)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(vq); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testEvelOther() { + EvelOther ev = new EvelOther("MyCustomEvent_vVNF", "vmname_ip"); + ev.evel_other_field_add("a1", "b1"); + ev.evel_other_field_add("a1", "b2"); + + ev.evel_other_field_add_namedarray("a1", "b1", "c1"); + ev.evel_other_field_add_namedarray("a1", "b2", "c2"); + ev.evel_other_field_add_namedarray("a2", "b1", "c1"); + ev.evel_other_field_add_namedarray("a2", "b1", "c1"); + + when(mymainmock.evel_post_event(ev)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(ev); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + @Test + public void testThresholdCross() { + String dateStart = "01/14/2012 09:29:58"; + String dateStop = "01/15/2012 10:31:48"; + + //HH converts hour in 24 hours format (0-23), day calculation + SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + + Date d1 = null; + Date d2 = null; + + try { + d1 = format.parse(dateStart); + d2 = format.parse(dateStop); + }catch (Exception e) { + e.printStackTrace(); + } + + + EvelThresholdCross tca = new EvelThresholdCross("ThresholdCross_vVNF", "vmname_ip", + "CRIT", + "mcast Limit reached", + "mcastRxPackets", + "1250000000", + EvelThresholdCross.EVEL_EVENT_ACTION.EVEL_EVENT_ACTION_SET, + "Mcast Rx breached", + EvelThresholdCross.EVEL_ALERT_TYPE.EVEL_ELEMENT_ANOMALY, + d1, + EvelThresholdCross.EVEL_SEVERITIES.EVEL_SEVERITY_CRITICAL, + d2); + tca.evel_threshold_cross_interfacename_set("ns345"); + tca.evel_thresholdcross_addl_info_add("n1", "v1"); + tca.evel_thresholdcross_addl_info_add("n2", "v2"); + tca.evel_thresholdcross_alertid_add("alert1"); + tca.evel_thresholdcross_alertid_add("alert2"); + + when(mymainmock.evel_post_event(tca)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(tca); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + + @Test + public void testMobileFlow() { + String dateStart = "01/14/2012 09:29:58"; + Date d1 = null; + SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + try { + d1 = format.parse(dateStart); + }catch (Exception e) { + e.printStackTrace(); + } + EvelMobileFlow mf = new EvelMobileFlow("MobileFlow_vVNF", "vmname_ip", + "In", + null, + "GTP", + "v2.3", + "1.2.3.4", + 345556, + "5.6.7.8", + 334344); + MOBILE_GTP_PER_FLOW_METRICS mygtp = mf.new MOBILE_GTP_PER_FLOW_METRICS( + 1.01, + 2.02, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + d1, + "ACTIVE", + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28); + mf.gtp_per_flow_metrics = mygtp; + + when(mymainmock.evel_post_event(mf)).thenReturn(true); + boolean ret = mymainmock.evel_post_event(mf); + LOG.info("Returned "+ret); + assertTrue( ret ); + } + + +} + diff --git a/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestRunner.java b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestRunner.java new file mode 100644 index 0000000..89f42be --- /dev/null +++ b/veslibrary/ves_javalibrary/evel_javalib2/src/test/java/TestRunner.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ves-agent + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +public class TestRunner { + public static void main(String[] args) { + Result result = JUnitCore.runClasses(TestJunit.class); + + for (Failure failure : result.getFailures()) { + System.out.println(failure.toString()); + } + + System.out.println(result.wasSuccessful()); + } +} -- cgit 1.2.3-korg