From 1211fefc36f76cc7111a6204888d21360194134e Mon Sep 17 00:00:00 2001 From: CesarCoelho Date: Thu, 24 Oct 2024 10:45:36 +0200 Subject: [PATCH] Removes unused project --- tooling/encoding-performance-test/pom.xml | 180 ----------- tooling/encoding-performance-test/runTest.bat | 3 - .../mo/performance/encoder/TestEncoder.java | 292 ------------------ .../encoder/TestGZipStreamFactory.java | 63 ---- .../encoder/TestXMLStreamFactory.java | 147 --------- .../java/esa/mo/performance/mal/TestMAL.java | 149 --------- .../util/TestStructureBuilder.java | 208 ------------- .../src/main/resources/xml/PerfTest.xml | 170 ---------- .../src/main/resources/xsd/PerfTestSchema.xsd | 103 ------ tooling/pom.xml | 1 - 10 files changed, 1316 deletions(-) delete mode 100644 tooling/encoding-performance-test/pom.xml delete mode 100644 tooling/encoding-performance-test/runTest.bat delete mode 100644 tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestEncoder.java delete mode 100644 tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestGZipStreamFactory.java delete mode 100644 tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestXMLStreamFactory.java delete mode 100644 tooling/encoding-performance-test/src/main/java/esa/mo/performance/mal/TestMAL.java delete mode 100644 tooling/encoding-performance-test/src/main/java/esa/mo/performance/util/TestStructureBuilder.java delete mode 100644 tooling/encoding-performance-test/src/main/resources/xml/PerfTest.xml delete mode 100644 tooling/encoding-performance-test/src/main/resources/xsd/PerfTestSchema.xsd diff --git a/tooling/encoding-performance-test/pom.xml b/tooling/encoding-performance-test/pom.xml deleted file mode 100644 index fa2c204da..000000000 --- a/tooling/encoding-performance-test/pom.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - 4.0.0 - - - int.esa.ccsds.mo - parent - 11.1-SNAPSHOT - ../../parent/pom.xml - - - encoding-performance-test - jar - 11.1-SNAPSHOT - - ESA MO Performance Tests - A small set of test applications for the evaluation of CCSDS MAL performance - http://www.esa.int - - - ESA - http://www.esa.int - - - - - The European Space Agency Public License, Version 2.0 - https://raw.githubusercontent.com/esa/mo-services-java/master/LICENCE.md - repo - - - - - scm:git:git@github.com:esa/mo-services-java.git - scm:git:git@github.com:esa/mo-services-java.git - https://github.com/esa/mo-services-java - - - - GitHub - https://github.com/esa/mo-services-java/issues - - - - - SamCooper - Sam Cooper - sam@brightascension.com - https://github.com/SamCooper - - - - - false - src/main/resources/xml - esa.mo.encoderperf.TestEncoder - - - - - javax.xml.bind - jaxb-api - - - com.sun.xml.bind - jaxb-impl - - - com.sun.xml.bind - jaxb-core - - - int.esa.ccsds.mo - api-area001-v003-mal - - - int.esa.ccsds.mo - encoding-string - - - int.esa.ccsds.mo - encoding-binary - - - - - - - - ${basedir}/.. - - LICENCE.md - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - org.codehaus.mojo - jaxb2-maven-plugin - - - process-resources - - xjc - - - - - org.ccsds.moims.mo.xml.test - - src/main/resources/xsd - - - - - int.esa.ccsds.mo - api-generator-maven-plugin - - - process-sources - - generate - - - ${esa.stubgen.xmlDirectory} - ${esa.stubgen.xmlRefDirectory} - src/main/resources/xsd - - org.ccsds.moims.mo.xml.test|http://www.ccsds.org/schema/PerfTestServiceSchema - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - org.codehaus.mojo - build-helper-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.apache.maven.plugins - maven-assembly-plugin - - - - diff --git a/tooling/encoding-performance-test/runTest.bat b/tooling/encoding-performance-test/runTest.bat deleted file mode 100644 index ff516662d..000000000 --- a/tooling/encoding-performance-test/runTest.bat +++ /dev/null @@ -1,3 +0,0 @@ -java -jar target\MAL_PERFORMANCE_TESTS-jar-with-dependencies.jar -pause - diff --git a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestEncoder.java b/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestEncoder.java deleted file mode 100644 index 80588e059..000000000 --- a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestEncoder.java +++ /dev/null @@ -1,292 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (C) 2013 European Space Agency - * European Space Operations Centre - * Darmstadt - * Germany - * ---------------------------------------------------------------------------- - * System : CCSDS MO MAL Encoder performance test - * ---------------------------------------------------------------------------- - * Licensed under the European Space Agency Public License, Version 2.0 - * You may not use this file except in compliance with the License. - * - * Except as expressly set forth in this License, the Software is provided to - * You on an "as is" basis and without warranties of any kind, including without - * limitation merchantability, fitness for a particular purpose, absence of - * defects or errors, accuracy or non-infringement of intellectual property rights. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * ---------------------------------------------------------------------------- - */ -package esa.mo.performance.encoder; - -import esa.mo.performance.util.TestStructureBuilder; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileOutputStream; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import org.ccsds.moims.mo.mal.encoding.MALElementInputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementOutputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementStreamFactory; -import org.ccsds.moims.mo.mal.encoding.MALEncodingContext; -import org.ccsds.moims.mo.mal.structures.*; -import org.ccsds.moims.mo.mal.transport.MALMessageHeader; -import org.ccsds.moims.mo.perftest.perftest.PerfTestHelper; -import org.ccsds.moims.mo.perftest.structures.*; - -public class TestEncoder { - - public static void main(String[] args) throws Exception { - List results = new LinkedList<>(); - - int runCount = 100; - int pktsPerReport = 1; - int paramsPerPkt = 1000; - boolean testDecode = true; - boolean dumpBinary = false; - - Date now = new Date(); - Time timestamp = new Time(now.getTime()); - - Object testXMLComposite = TestStructureBuilder.createTestXMLComposite(now, pktsPerReport, paramsPerPkt); - - results.add(new Results("esa.mo.performance.encoder.TestXMLStreamFactory", false, false, (Element) testXMLComposite, (Element) testXMLComposite)); - //results.add(new Results("esa.mo.mal.encoder.line.LineStreamFactory", false, true, size)); - results.add(new Results("esa.mo.mal.encoder.string.StringStreamFactory", false, false, pktsPerReport, paramsPerPkt, timestamp)); - //results.add(new Results("fr.cnes.maljoram.malencoding.JORAMElementStreamFactory", false, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.variable.VariableBinaryStreamFactory", false, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.split.SplitBinaryStreamFactory", false, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.fixed.FixedBinaryStreamFactory", false, false, pktsPerReport, paramsPerPkt, timestamp)); - - results.add(new Results("esa.mo.performance.encoder.TestXMLStreamFactory", true, false, (Element) testXMLComposite, (Element) testXMLComposite)); - //results.add(new Results("esa.mo.mal.encoder.line.LineStreamFactory", true, false, size)); - results.add(new Results("esa.mo.mal.encoder.string.StringStreamFactory", true, false, pktsPerReport, paramsPerPkt, timestamp)); - //results.add(new Results("fr.cnes.maljoram.malencoding.JORAMElementStreamFactory", true, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.variable.VariableBinaryStreamFactory", true, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.split.SplitBinaryStreamFactory", true, false, pktsPerReport, paramsPerPkt, timestamp)); - results.add(new Results("esa.mo.mal.encoder.binary.fixed.FixedBinaryStreamFactory", true, false, pktsPerReport, paramsPerPkt, timestamp)); - - runtests(results, runCount, testDecode, dumpBinary); - - System.out.println("Times are in microseconds per encode/decode, packet size is in bytes, differences are in %."); - System.out.println(" Encode(us) Decode(us) Encode(PPS) Decode(PPS) Size(bytes) Valid"); - for (Results res : results) { - long eTime = (long) (((double) res.encodeTime) / ((double) (runCount * 1000))); - long dTime = (long) (((double) res.decodeTime) / ((double) (runCount * 1000))); - System.out.println(" " + String.format("%35s", res.encoderName) - + " " + String.format("%6d", eTime) - + " " + String.format("%6d", dTime) - + " " + String.format("%8d", (long) ((1000000.0 / ((float) eTime)) * pktsPerReport * paramsPerPkt)) - + " " + String.format("%8d", (long) ((1000000.0 / ((float) dTime)) * pktsPerReport * paramsPerPkt)) - + " " + String.format("%8d", res.packetSize) - + " " + res.decodedCorrectly); - } - } - - protected static void runtests(List results, int count, boolean testDecode, boolean dumpBuf) throws Exception { - System.out.println("Creating stream factories"); - for (Results result : results) { - System.setProperty(MALElementStreamFactory.FACTORY_PROP_NAME_PREFIX + ".testProtocol", result.factoryClassName); - result.factory = MALElementStreamFactory.newFactory("testProtocol", new java.util.Properties()); - result.encoderName = result.factory.getClass().getSimpleName(); - if (result.compress) { - result.encoderName += " with GZip"; - } - } - - System.out.println("Creating objects"); - - MALMessageHeader header = new MALMessageHeader( - new Identifier("from"), - new Blob("".getBytes()), - new Identifier("to"), - new Time(12345678), - InteractionType.SEND, - new UOctet((short) 0), - Long.MIN_VALUE, - PerfTestHelper.PERFTEST_SERVICE.getAreaNumber(), - PerfTestHelper.PERFTEST_SERVICE.getServiceNumber(), - PerfTestHelper.PERFTEST_SERVICE.SEND_OP_NUMBER, - PerfTestHelper.PERFTEST_SERVICE.getServiceVersion(), - Boolean.FALSE, new NamedValueList()); - - MALEncodingContext ctx = new MALEncodingContext(header); - - System.out.println("Running tests"); - for (Results result : results) { - if (result.compress) { - check(result, new TestGZipStreamFactory(result.factory), count, - testDecode, dumpBuf, result.objectToEncode, result.blankToEncode, ctx); - } else { - check(result, result.factory, count, testDecode, dumpBuf, - result.objectToEncode, result.blankToEncode, ctx); - } - } - - System.out.println("Checking tests"); - Results presult = null; - for (Results result : results) { - if (result.compareable) { - if (null != presult) { - System.out.println("Equal: " - + compareObjects(presult.objectToEncode, result.objectToEncode)); - } - - presult = result; - } - } - } - - protected static void check(Results result, MALElementStreamFactory streamFactory, - int count, boolean testDecode, boolean dumpBuf, Element testComposite, - Element blankComposite, MALEncodingContext ctx) throws Exception { - System.out.println("Testing : " + result.encoderName); - - ByteArrayOutputStream baos = testEncoder(result, streamFactory, count, dumpBuf, testComposite, ctx); - - if (result.dump) { - java.io.File outputFile = new java.io.File(result.encoderName + ".txt"); - java.io.FileOutputStream fos = new FileOutputStream(outputFile); - fos.write(baos.toByteArray()); - fos.close(); - } - - if (testDecode) { - try { - result.decodedCorrectly = testDecoder(result, streamFactory, - count, baos, testComposite, blankComposite, ctx); - } catch (Throwable ex) { - result.decodedCorrectly = false; - ex.printStackTrace(); - System.out.println("FAILED decoding"); - } - } - System.out.println("Finished : " + result.encoderName); - } - - protected static ByteArrayOutputStream testEncoder(Results result, - MALElementStreamFactory streamFactory, int count, boolean dumpBuf, - Element testComposite, MALEncodingContext ctx) throws Exception { - ByteArrayOutputStream baos = null; - - System.out.println("Starting encoding..."); - long startTime = System.nanoTime(); - for (int i = 0; i < count; i++) { - baos = new ByteArrayOutputStream(); - MALElementOutputStream encoder = streamFactory.createOutputStream(baos); - - encoder.writeElement(testComposite, ctx.getOperationFields()[0]); - encoder.flush(); - encoder.close(); - } - long stopTime = System.nanoTime(); - - result.encodeTime = stopTime - startTime; - - System.out.println("Finished encoding"); - if (null != baos) { - result.packetSize = baos.size(); - - byte[] data = baos.toByteArray(); - System.out.println(" DUMP : Size " + data.length); - if (dumpBuf) { - System.out.println(" DUMP : " + byteArrayToHexString(data)); - } - } - - return baos; - } - - protected static boolean testDecoder(Results result, MALElementStreamFactory streamFactory, - int count, ByteArrayOutputStream encodedValue, Object testComposite, - Object blankComposite, MALEncodingContext ctx) throws Exception { - Object rv = null; - - System.out.println("Starting decoding..."); - long startTime = System.nanoTime(); - for (int i = 0; i < count; i++) { - byte[] bbuf = encodedValue.toByteArray(); - ByteArrayInputStream bais = new ByteArrayInputStream(bbuf); - MALElementInputStream decoder = streamFactory.createInputStream(bais); -// MALElementInputStream decoder = streamFactory.createInputStream(bbuf, 0); - rv = decoder.readElement((Element) blankComposite, ctx.getOperationFields()[0]); - decoder.close(); - } - long stopTime = System.nanoTime(); - result.decodeTime = stopTime - startTime; - System.out.println("Finished decoding"); - - return compareObjects(testComposite, rv); - } - - protected static boolean compareObjects(Object original, Object newVersion) { - if (original instanceof Element) { - return original.equals(newVersion); - } else if (original instanceof org.ccsds.moims.mo.xml.test.Report) { - org.ccsds.moims.mo.xml.test.Report car_o = (org.ccsds.moims.mo.xml.test.Report) original; - org.ccsds.moims.mo.xml.test.Report car_n = (org.ccsds.moims.mo.xml.test.Report) newVersion; - - boolean theSame = true; - - theSame &= TestStructureBuilder.compareUpdateHeader(car_o.getUpdateHeader(), car_n.getUpdateHeader()); - theSame &= TestStructureBuilder.compareObjectId(car_o.getObjectId(), car_n.getObjectId()); - theSame &= TestStructureBuilder.compareAggregationValue(car_o.getValue(), car_n.getValue()); - - return theSame; - } - - return false; - } - - public static String byteArrayToHexString(byte[] data) { - StringBuilder hexString = new StringBuilder(); - for (int i = 0; i < data.length; i++) { - String hex = Integer.toHexString(0xFF & data[i]); - if (hex.length() == 1) { - // could use a for loop, but we're only dealing with a single byte - hexString.append('0'); - } - hexString.append(hex); - } - - return hexString.toString(); - } - - protected static class Results { - - final String factoryClassName; - final boolean compress; - final boolean dump; - final Element objectToEncode; - final Element blankToEncode; - final boolean compareable; - MALElementStreamFactory factory; - String encoderName; - long encodeTime; - long decodeTime; - long packetSize; - boolean decodedCorrectly = false; - - public Results(String factoryClassName, boolean compress, boolean dump, - Element objectToEncode, Element blankToEncode) { - this.factoryClassName = factoryClassName; - this.compress = compress; - this.dump = dump; - this.objectToEncode = objectToEncode; - this.blankToEncode = blankToEncode; - this.compareable = false; - } - - public Results(String factoryClassName, boolean compress, boolean dump, - int pktsPerReport, int paramsPerPkt, Time timestamp) { - this.factoryClassName = factoryClassName; - this.compress = compress; - this.dump = dump; - this.objectToEncode = TestStructureBuilder.createTestMALComposite(timestamp, pktsPerReport, paramsPerPkt); - this.blankToEncode = new Report(); - this.compareable = true; - } - } -} diff --git a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestGZipStreamFactory.java b/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestGZipStreamFactory.java deleted file mode 100644 index fd2785a41..000000000 --- a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestGZipStreamFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (C) 2013 European Space Agency - * European Space Operations Centre - * Darmstadt - * Germany - * ---------------------------------------------------------------------------- - * System : CCSDS MO MAL Encoder performance test - * ---------------------------------------------------------------------------- - * Licensed under the European Space Agency Public License, Version 2.0 - * You may not use this file except in compliance with the License. - * - * Except as expressly set forth in this License, the Software is provided to - * You on an "as is" basis and without warranties of any kind, including without - * limitation merchantability, fitness for a particular purpose, absence of - * defects or errors, accuracy or non-infringement of intellectual property rights. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * ---------------------------------------------------------------------------- - */ -package esa.mo.performance.encoder; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Map; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import org.ccsds.moims.mo.mal.MALException; -import org.ccsds.moims.mo.mal.encoding.MALElementInputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementOutputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementStreamFactory; - -public class TestGZipStreamFactory extends MALElementStreamFactory { - - private final MALElementStreamFactory delegate; - - public TestGZipStreamFactory(MALElementStreamFactory delegate) { - this.delegate = delegate; - } - - @Override - protected void init(Map properties) throws IllegalArgumentException, MALException { - } - - @Override - public MALElementInputStream createInputStream(InputStream is) throws IllegalArgumentException, MALException { - try { - return delegate.createInputStream(new GZIPInputStream(is)); - } catch (IOException ex) { - throw new MALException("XML Encoding error", ex); - } - } - - @Override - public MALElementOutputStream createOutputStream(OutputStream os) throws IllegalArgumentException, MALException { - try { - return delegate.createOutputStream(new GZIPOutputStream(os)); - } catch (IOException ex) { - throw new MALException("XML Encoding error", ex); - } - } -} diff --git a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestXMLStreamFactory.java b/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestXMLStreamFactory.java deleted file mode 100644 index 56feaaada..000000000 --- a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/encoder/TestXMLStreamFactory.java +++ /dev/null @@ -1,147 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (C) 2013 European Space Agency - * European Space Operations Centre - * Darmstadt - * Germany - * ---------------------------------------------------------------------------- - * System : CCSDS MO MAL Encoder performance test - * ---------------------------------------------------------------------------- - * Licensed under the European Space Agency Public License, Version 2.0 - * You may not use this file except in compliance with the License. - * - * Except as expressly set forth in this License, the Software is provided to - * You on an "as is" basis and without warranties of any kind, including without - * limitation merchantability, fitness for a particular purpose, absence of - * defects or errors, accuracy or non-infringement of intellectual property rights. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * ---------------------------------------------------------------------------- - */ -package esa.mo.performance.encoder; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Map; -import javax.xml.bind.*; -import javax.xml.namespace.QName; -import org.ccsds.moims.mo.mal.MALException; -import org.ccsds.moims.mo.mal.OperationField; -import org.ccsds.moims.mo.mal.encoding.MALElementInputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementOutputStream; -import org.ccsds.moims.mo.mal.encoding.MALElementStreamFactory; -import org.ccsds.moims.mo.mal.structures.Element; -import org.ccsds.moims.mo.mal.transport.MALMessageHeader; - -public class TestXMLStreamFactory extends MALElementStreamFactory { - - @Override - protected void init(Map properties) throws IllegalArgumentException, MALException { - } - - @Override - public MALElementInputStream createInputStream(InputStream is) throws IllegalArgumentException, MALException { - return new TestXMLInputStream(is); - } - - @Override - public MALElementOutputStream createOutputStream(OutputStream os) throws IllegalArgumentException, MALException { - return new TestXMLOutputStream(os); - } - - protected static class TestXMLOutputStream implements MALElementOutputStream { - - private final OutputStream os; - - public TestXMLOutputStream(OutputStream os) { - this.os = os; - } - - @Override - public void writeHeader(MALMessageHeader header) throws IllegalArgumentException, MALException { - try { - String schemaURN = "http://www.ccsds.org/schema/PerfTestServiceSchema"; - String schemaEle = "report"; - JAXBContext jc = JAXBContext.newInstance(header.getClass().getPackage().getName()); - Marshaller marshaller = jc.createMarshaller(); - marshaller.marshal(new JAXBElement(new QName(schemaURN, schemaEle), header.getClass(), null, header), os); - } catch (JAXBException ex) { - throw new MALException("XML Encoding error", ex); - } - } - - @Override - public void writeElement(Element o, OperationField field) throws IllegalArgumentException, MALException { - try { - String schemaURN = "http://www.ccsds.org/schema/PerfTestServiceSchema"; - String schemaEle = "report"; - JAXBContext jc = JAXBContext.newInstance(o.getClass().getPackage().getName()); - Marshaller marshaller = jc.createMarshaller(); - marshaller.marshal(new JAXBElement(new QName(schemaURN, schemaEle), o.getClass(), null, o), os); - } catch (JAXBException ex) { - throw new MALException("XML Encoding error", ex); - } - } - - @Override - public void flush() throws MALException { - try { - os.flush(); - } catch (IOException ex) { - throw new MALException("XML Encoding error", ex); - } - } - - @Override - public void close() throws MALException { - try { - os.close(); - } catch (IOException ex) { - throw new MALException("XML Encoding error", ex); - } - } - } - - protected static class TestXMLInputStream implements MALElementInputStream { - - private final InputStream is; - - public TestXMLInputStream(InputStream is) { - this.is = is; - } - - @Override - public MALMessageHeader readHeader(MALMessageHeader header) throws IllegalArgumentException, MALException { - try { - JAXBContext jc = JAXBContext.newInstance(header.getClass().getPackage().getName()); - Unmarshaller unmarshaller = jc.createUnmarshaller(); - JAXBElement rootElement = (JAXBElement) unmarshaller.unmarshal(is); - return (MALMessageHeader) rootElement.getValue(); - } catch (JAXBException ex) { - throw new MALException("XML Decoding error", ex); - } - } - - @Override - public Element readElement(Element element, OperationField field) throws IllegalArgumentException, MALException { - try { - JAXBContext jc = JAXBContext.newInstance(element.getClass().getPackage().getName()); - Unmarshaller unmarshaller = jc.createUnmarshaller(); - JAXBElement rootElement = (JAXBElement) unmarshaller.unmarshal(is); - return (Element) rootElement.getValue(); - } catch (JAXBException ex) { - throw new MALException("XML Decoding error", ex); - } - } - - @Override - public void close() throws MALException { - try { - is.close(); - } catch (IOException ex) { - throw new MALException("XML Encoding error", ex); - } - } - } -} diff --git a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/mal/TestMAL.java b/tooling/encoding-performance-test/src/main/java/esa/mo/performance/mal/TestMAL.java deleted file mode 100644 index 22f2396d5..000000000 --- a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/mal/TestMAL.java +++ /dev/null @@ -1,149 +0,0 @@ -/* ---------------------------------------------------------------------------- - * Copyright (C) 2013 European Space Agency - * European Space Operations Centre - * Darmstadt - * Germany - * ---------------------------------------------------------------------------- - * System : CCSDS MO MAL Encoder performance test - * ---------------------------------------------------------------------------- - * Licensed under the European Space Agency Public License, Version 2.0 - * You may not use this file except in compliance with the License. - * - * Except as expressly set forth in this License, the Software is provided to - * You on an "as is" basis and without warranties of any kind, including without - * limitation merchantability, fitness for a particular purpose, absence of - * defects or errors, accuracy or non-infringement of intellectual property rights. - * - * See the License for the specific language governing permissions and - * limitations under the License. - * ---------------------------------------------------------------------------- - */ -package esa.mo.performance.mal; - -import esa.mo.performance.util.TestStructureBuilder; -import java.util.Date; -import org.ccsds.moims.mo.mal.MALContext; -import org.ccsds.moims.mo.mal.MALContextFactory; -import org.ccsds.moims.mo.mal.MALException; -import org.ccsds.moims.mo.mal.MALInteractionException; -import org.ccsds.moims.mo.mal.consumer.MALConsumer; -import org.ccsds.moims.mo.mal.consumer.MALConsumerManager; -import org.ccsds.moims.mo.mal.provider.MALInteraction; -import org.ccsds.moims.mo.mal.provider.MALProvider; -import org.ccsds.moims.mo.mal.provider.MALProviderManager; -import org.ccsds.moims.mo.mal.structures.*; -import org.ccsds.moims.mo.perftest.perftest.PerfTestHelper; -import org.ccsds.moims.mo.perftest.perftest.consumer.PerfTestStub; -import org.ccsds.moims.mo.perftest.perftest.provider.PerfTestInheritanceSkeleton; -import org.ccsds.moims.mo.perftest.structures.Report; - -public class TestMAL { - - public static void main(String[] args) throws Exception { - int runCount = 100000; - int pktsPerReport = 1; - int paramsPerPkt = 1000; - -// Handler fh = new ConsoleHandler(); -// fh.setLevel (Level.WARNING); -// Logger logger = Logger.getLogger("org.ccsds.moims.mo.mal.transport.gen"); -// logger.addHandler (fh); -// logger.setLevel (Level.WARNING); -// logger = Logger.getLogger("org.ccsds.moims.mo.mal.impl"); -// logger.addHandler (fh); -// logger.setLevel (Level.WARNING); - System.setProperty("org.ccsds.moims.mo.mal.factory.class", "esa.mo.mal.impl.MALContextFactoryImpl"); - System.setProperty("org.ccsds.moims.mo.mal.transport.protocol.rmi", "esa.mo.mal.transport.rmi.RMITransportFactoryImpl"); - System.setProperty("org.ccsds.moims.mo.mal.encoding.protocol.rmi", "esa.mo.mal.encoder.binary.variable.VariableBinaryStreamFactory"); - System.setProperty("org.ccsds.moims.mo.mal.transport.gen.debug", "false"); - System.setProperty("org.ccsds.moims.mo.mal.transport.gen.wrap", "false"); - System.setProperty("org.ccsds.moims.mo.mal.transport.gen.fastInProcessMessages", "true"); - - long result = runtest(runCount, pktsPerReport, paramsPerPkt); - - System.out.println("Times are in microseconds"); - System.out.println(" Call time(us) Packets(PPS)"); - - long eTime = (long) (((double) result) / ((double) (runCount * 1000))); - System.out.println(" " + String.format("%6d", eTime) - + " " + String.format("%8d", (long) ((1000000.0 / ((float) eTime)) * pktsPerReport * paramsPerPkt))); - } - - protected static long runtest(int count, int pktsPerReport, int paramsPerPkt) throws Exception { - System.out.println("Creating objects"); - MALContextFactory malFactory = MALContextFactory.newFactory(); - MALContext mal = malFactory.createMALContext(System.getProperties()); - MALProviderManager providerMgr = mal.createProviderManager(); - MALConsumerManager consumerMgr = mal.createConsumerManager(); - - Date now = new Date(); - Time timestamp = new Time(now.getTime()); - - Composite testObject = TestStructureBuilder.createTestMALComposite(timestamp, pktsPerReport, paramsPerPkt); - - MALProvider serviceProvider = providerMgr.createProvider("Demo", - null, - PerfTestHelper.PERFTEST_SERVICE, - new Blob("".getBytes()), - new DummyProvider(), - new QoSLevel[]{ - QoSLevel.ASSURED - }, - new UInteger(1), - System.getProperties(), - false, - null, - new NamedValueList()); - - IdentifierList domain = new IdentifierList(); - domain.add(new Identifier("ccsds")); - domain.add(new Identifier("mission")); - Identifier network = new Identifier("network"); - - MALConsumer serviceConsumer = consumerMgr.createConsumer((String) null, - serviceProvider.getURI(), - serviceProvider.getBrokerURI(), - PerfTestHelper.PERFTEST_SERVICE, - new Blob("".getBytes()), - domain, - network, - SessionType.LIVE, - new Identifier("LIVE"), - QoSLevel.ASSURED, - System.getProperties(), - new UInteger(0), - null); - - PerfTestStub testService = new PerfTestStub(serviceConsumer); - - System.out.println("Testing"); - - long startTime = System.nanoTime(); - for (int i = 0; i < count; i++) { - testService.request((Report) testObject); - } - long stopTime = System.nanoTime(); - - System.out.println("Finished"); - - mal.close(); - - return stopTime - startTime; - } - - private static final class DummyProvider extends PerfTestInheritanceSkeleton { - - public void send(Report _Report0, MALInteraction interaction) - throws MALInteractionException, MALException { - } - - public void send2(org.ccsds.moims.mo.xml.test.Report body0, - MALInteraction interaction) throws MALInteractionException, MALException { - } - - public Report request(Report body0, MALInteraction interaction) - throws MALInteractionException, MALException { - return body0; - } - } -} diff --git a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/util/TestStructureBuilder.java b/tooling/encoding-performance-test/src/main/java/esa/mo/performance/util/TestStructureBuilder.java deleted file mode 100644 index 1fbee5723..000000000 --- a/tooling/encoding-performance-test/src/main/java/esa/mo/performance/util/TestStructureBuilder.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package esa.mo.performance.util; - -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; -import javax.xml.datatype.DatatypeFactory; -import org.ccsds.moims.mo.mal.structures.*; -import org.ccsds.moims.mo.perftest.structures.AggregationValueList; -import org.ccsds.moims.mo.perftest.structures.GenerationMode; -import org.ccsds.moims.mo.perftest.structures.ObjectId; -import org.ccsds.moims.mo.perftest.structures.ObjectIdList; -import org.ccsds.moims.mo.perftest.structures.ParameterValue; -import org.ccsds.moims.mo.perftest.structures.ParameterValueList; -import org.ccsds.moims.mo.perftest.structures.Report; -import org.ccsds.moims.mo.perftest.structures.Validity; - -/** - * - * @author cooper_sf - */ -public abstract class TestStructureBuilder { - - public static Composite createTestMALComposite(Time timestamp, int pktsPerReport, int paramsPerPkt) { - org.ccsds.moims.mo.mal.structures.UpdateHeaderList updateHeader = new UpdateHeaderList(); - org.ccsds.moims.mo.perftest.structures.ObjectIdList objectId = new ObjectIdList(); - org.ccsds.moims.mo.perftest.structures.AggregationValueList value = new AggregationValueList(); - - for (int i = 0; i < pktsPerReport; i++) { - NullableAttributeList lst = new NullableAttributeList(); - lst.add(new NullableAttribute(new Identifier("1"))); - lst.add(new NullableAttribute(new Union(1L))); - lst.add(new NullableAttribute(new Union((long) (i + 1)))); - lst.add(new NullableAttribute(null)); - - updateHeader.add(new UpdateHeader(new Identifier(""), null, lst)); - objectId.add(new ObjectId()); - value.add(createTestMALValueUpdate(paramsPerPkt)); - } - - return new Report(updateHeader, objectId, value); - } - - public static org.ccsds.moims.mo.perftest.structures.AggregationValue createTestMALValueUpdate(int paramsPerPkt) { - //ParameterValue val = new ParameterValue(Validity.VALID, new Blob("1234".getBytes()), null); - ParameterValueList valueList = new ParameterValueList(); - for (int i = 0; i < paramsPerPkt; i++) { - //ParameterValue val = new ParameterValue(Validity.VALID, new UInteger(4294967295L), null); - ParameterValue val = new ParameterValue(Validity.VALID, new UInteger(i), null); - //ParameterValue val = new ParameterValue(Validity.VALID, new Union(Boolean.FALSE), null); - valueList.add(val); - } - return new org.ccsds.moims.mo.perftest.structures.AggregationValue(GenerationMode.PERIODIC, Boolean.FALSE, null, null, null, valueList); - } - - public static org.ccsds.moims.mo.xml.test.Report createTestXMLComposite(Date timestamp, int pktsPerReport, int paramsPerPkt) throws Exception { - DatatypeFactory xmlDatatypeFactory = DatatypeFactory.newInstance(); - GregorianCalendar gcal = new GregorianCalendar(); - gcal.setTime(timestamp); - - List domain = new ArrayList<>(); -// domain.add("ccsds"); -// domain.add("mission"); - - org.ccsds.moims.mo.xml.test.Report report = new org.ccsds.moims.mo.xml.test.Report(); - List updateHeader = report.getUpdateHeader(); - List objectId = report.getObjectId(); - List value = report.getValue(); - - for (int i = 0; i < pktsPerReport; i++) { - org.ccsds.moims.mo.xml.test.EntityKey ek = new org.ccsds.moims.mo.xml.test.EntityKey(); - ek.setFirstSubKey("1"); - ek.setSecondSubKey(1L); - ek.setThirdSubKey((long) (i + 1)); - ek.setFourthSubKey(null); - org.ccsds.moims.mo.xml.test.UpdateHeader uh = new org.ccsds.moims.mo.xml.test.UpdateHeader(); - uh.setTimestamp(xmlDatatypeFactory.newXMLGregorianCalendar(gcal)); - uh.setSourceURI(""); - uh.setUpdateType(org.ccsds.moims.mo.xml.test.UpdateType.UPDATE); - uh.setKey(ek); - updateHeader.add(uh); - //objectId.add(new ObjectId(new ObjectType(new UShort(4), new UShort(6), new UOctet((short)1), new UShort(2)), new ObjectKey(domain, (long)i))); - objectId.add(null); - value.add(createTestXMLValueUpdate(paramsPerPkt)); - } - - return report; - } - - public static org.ccsds.moims.mo.xml.test.AggregationValue createTestXMLValueUpdate(int paramsPerPkt) { - //ParameterValue val = new ParameterValue(Validity.VALID, new Blob("1234".getBytes()), null); - org.ccsds.moims.mo.xml.test.AggregationValue rv = new org.ccsds.moims.mo.xml.test.AggregationValue(); - rv.setGenerationMode(org.ccsds.moims.mo.xml.test.GenerationMode.PERIODIC); - rv.setFiltered(false); - rv.setIntervalTime(null); - rv.setDeltaTime(null); - rv.setSetIntervalTime(null); - List valueList = rv.getValues(); - - for (int i = 0; i < paramsPerPkt; i++) { - org.ccsds.moims.mo.xml.test.ParameterValue val = new org.ccsds.moims.mo.xml.test.ParameterValue(); - val.setValidityState(org.ccsds.moims.mo.xml.test.Validity.VALID); - //val.setRawValue(4294967295L); - val.setRawValue(i); - val.setConvertedValue(null); - - valueList.add(val); - } - return rv; - } - - public static boolean compareUpdateHeader(List left, List right) { - boolean theSame = left.size() == right.size(); - for (int i = 0; theSame && (i < right.size()); i++) { - org.ccsds.moims.mo.xml.test.UpdateHeader u_left = left.get(i); - org.ccsds.moims.mo.xml.test.UpdateHeader u_right = right.get(i); - theSame = compareUpdateHeader(u_left, u_right); - } - return theSame; - } - - public static boolean compareUpdateHeader(org.ccsds.moims.mo.xml.test.UpdateHeader left, org.ccsds.moims.mo.xml.test.UpdateHeader right) { - boolean theSame = true; - theSame &= 0 == left.getTimestamp().compare(right.getTimestamp()); - theSame &= left.getSourceURI().equals(right.getSourceURI()); - theSame &= 0 == left.getUpdateType().compareTo(right.getUpdateType()); - theSame &= left.getKey().getFirstSubKey().equals(right.getKey().getFirstSubKey()); - theSame &= left.getKey().getSecondSubKey().equals(right.getKey().getSecondSubKey()); - theSame &= left.getKey().getThirdSubKey().equals(right.getKey().getThirdSubKey()); - //theSame &= left.getKey().getFourthSubKey().equals(right.getKey().getFourthSubKey()); - return theSame; - } - - public static boolean compareObjectId(List left, List right) { - boolean theSame = left.size() == right.size(); - for (int i = 0; theSame && (i < right.size()); i++) { - org.ccsds.moims.mo.xml.test.ObjectId u_left = left.get(i); - org.ccsds.moims.mo.xml.test.ObjectId u_right = right.get(i); - - if ((null != u_left) || (null != u_right)) { - if ((null != u_left) && (null != u_right)) { - theSame = compareObjectId(u_left, u_right); - } else { - theSame = false; - } - } else { - theSame = true; - } - } - return theSame; - } - - public static boolean compareObjectId(org.ccsds.moims.mo.xml.test.ObjectId left, org.ccsds.moims.mo.xml.test.ObjectId right) { - boolean theSame = true; - theSame &= left.getType().getArea() == right.getType().getArea(); - theSame &= left.getType().getService() == right.getType().getService(); - theSame &= left.getType().getVersion() == right.getType().getVersion(); - theSame &= left.getType().getNumber() == right.getType().getNumber(); - - theSame &= java.util.Arrays.equals(left.getKey().getDomain().toArray(new String[0]), right.getKey().getDomain().toArray(new String[0])); - theSame &= left.getKey().getInstId() == right.getKey().getInstId(); - return theSame; - } - - public static boolean compareAggregationValue(List left, List right) { - boolean theSame = left.size() == right.size(); - for (int i = 0; theSame && (i < right.size()); i++) { - org.ccsds.moims.mo.xml.test.AggregationValue u_left = left.get(i); - org.ccsds.moims.mo.xml.test.AggregationValue u_right = right.get(i); - - if ((null != u_left) || (null != u_right)) { - if ((null != u_left) && (null != u_right)) { - theSame = compareAggregationValue(u_left, u_right); - } else { - theSame = false; - } - } else { - theSame = true; - } - } - return theSame; - } - - public static boolean compareAggregationValue(org.ccsds.moims.mo.xml.test.AggregationValue left, org.ccsds.moims.mo.xml.test.AggregationValue right) { - boolean theSame = true; - theSame &= 0 == left.getGenerationMode().compareTo(right.getGenerationMode()); - theSame &= left.isFiltered() == right.isFiltered(); -// theSame &= 0 == left.getDeltaTime().compare(right.getDeltaTime()); -// theSame &= 0 == left.getIntervalTime().compare(right.getIntervalTime()); -// theSame &= 0 == left.getSetIntervalTime().compare(right.getSetIntervalTime()); - - theSame &= left.getValues().size() == right.getValues().size(); - for (int i = 0; theSame && (i < right.getValues().size()); i++) { - org.ccsds.moims.mo.xml.test.ParameterValue u_left = left.getValues().get(i); - org.ccsds.moims.mo.xml.test.ParameterValue u_right = right.getValues().get(i); - - theSame &= 0 == u_left.getValidityState().compareTo(u_right.getValidityState()); - theSame &= u_left.getRawValue().equals(u_right.getRawValue()); -// theSame &= u_left.getConvertedValue().equals(u_right.getConvertedValue()); - } - - return theSame; - } -} diff --git a/tooling/encoding-performance-test/src/main/resources/xml/PerfTest.xml b/tooling/encoding-performance-test/src/main/resources/xml/PerfTest.xml deleted file mode 100644 index fef0ab381..000000000 --- a/tooling/encoding-performance-test/src/main/resources/xml/PerfTest.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tooling/encoding-performance-test/src/main/resources/xsd/PerfTestSchema.xsd b/tooling/encoding-performance-test/src/main/resources/xsd/PerfTestSchema.xsd deleted file mode 100644 index 09a9ac8a4..000000000 --- a/tooling/encoding-performance-test/src/main/resources/xsd/PerfTestSchema.xsd +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tooling/pom.xml b/tooling/pom.xml index fd1080edc..dfc951acf 100644 --- a/tooling/pom.xml +++ b/tooling/pom.xml @@ -69,7 +69,6 @@ simple-mo-provider simple-mo-consumer basic-demo - encoding-performance-test transport-bridge mo-navigator