You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(7) |
Dec
(18) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(20) |
Feb
(7) |
Mar
|
Apr
(8) |
May
(9) |
Jun
(7) |
Jul
(23) |
Aug
(3) |
Sep
|
Oct
(16) |
Nov
|
Dec
(3) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(6) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
(2) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
(30) |
Nov
|
Dec
|
2012 |
Jan
(4) |
Feb
(2) |
Mar
(1) |
Apr
(23) |
May
(4) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ope...@li...> - 2012-04-11 19:33:28
|
Revision: 283 http://openfast.svn.sourceforge.net/openfast/?rev=283&view=rev Author: jacob_northey Date: 2012-04-11 19:33:22 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [maven-release-plugin] prepare release openfast-1.1.0 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-11 19:23:40 UTC (rev 282) +++ trunk/pom.xml 2012-04-11 19:33:22 UTC (rev 283) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.2.0-SNAPSHOT</version> + <version>1.1.0</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.1.0</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 19:23:46
|
Revision: 282 http://openfast.svn.sourceforge.net/openfast/?rev=282&view=rev Author: jacob_northey Date: 2012-04-11 19:23:40 +0000 (Wed, 11 Apr 2012) Log Message: ----------- Changed deployment server from web.sourceforge.net to shell.sourceforge.net. Added deployment details to README Modified Paths: -------------- trunk/README trunk/pom.xml Modified: trunk/README =================================================================== --- trunk/README 2012-04-11 19:22:40 UTC (rev 281) +++ trunk/README 2012-04-11 19:23:40 UTC (rev 282) @@ -1,8 +1,29 @@ -OpenFAST uses the Maven2 build tool. Downloaded the latest version of Maven2 from http://maven.apache.org. +Building +======== + OpenFAST uses the Maven2 build tool. Downloaded the latest version of Maven2 from http://maven.apache.org. -To build OpenFAST using maven, enter from a command line: + To build OpenFAST using maven, enter from a command line: > mvn package - -To generate Eclipse .project and .classpath files so that OpenFAST can be imported into Eclipse: + +Eclipse +======= + To generate Eclipse .project and .classpath files so that OpenFAST can be imported into Eclipse: > mvn eclipse:eclipse - \ No newline at end of file + +Deploying +========= + To deploy to the OpenFAST maven repository complete the following steps: + 1. Contact project administrators to get shell access to the OpenFAST + 2. Add the following configuration to the M2 settings.xml file where [USERNAME] is an authorized user from step 1. + <server> + <id>sourceforge.net</id> + <username>[USERNAME],openfast</username> + <filePermissions>664</filePermissions> + <directoryPermissions>775</directoryPermissions> + <password>[PASSWORD]</password> + </server> + + SourceForge has new restricted shell access. To release or deploy OpenFAST, use the following steps: + For more information see http://maven.apache.org/plugins/maven-site-plugin-3.0-beta-3/examples/site-deploy-to-sourceforge.net.html + 1. ssh -t jac...@sh... create + 2. mvn deploy \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-11 19:22:40 UTC (rev 281) +++ trunk/pom.xml 2012-04-11 19:23:40 UTC (rev 282) @@ -230,21 +230,21 @@ <id>sourceforge.net</id> <name>Sourceforge.net Repository</name> <url> - scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/release + scp://shell.sourceforge.net/home/project-web/openfast/htdocs/maven/release </url> </repository> <snapshotRepository> <id>sourceforge.net</id> <name>Sourceforge.net Snapshot Repository</name> <url> - scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/snapshot + scp://shell.sourceforge.net/home/project-web/openfast/htdocs/maven/snapshot </url> </snapshotRepository> <site> <id>sourceforge.net</id> <name>Sourceforge.net OpenFAST Web Site</name> <url> - scp://web.sourceforge.net/home/project-web/openfast/htdocs + scp://shell.sourceforge.net/home/project-web/openfast/htdocs </url> </site> </distributionManagement> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 19:22:50
|
Revision: 281 http://openfast.svn.sourceforge.net/openfast/?rev=281&view=rev Author: jacob_northey Date: 2012-04-11 19:22:40 +0000 (Wed, 11 Apr 2012) Log Message: ----------- Removed Paths: ------------- tags/openfast-1.1.0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 18:01:51
|
Revision: 280 http://openfast.svn.sourceforge.net/openfast/?rev=280&view=rev Author: jacob_northey Date: 2012-04-11 18:01:40 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-11 18:01:37 UTC (rev 279) +++ trunk/pom.xml 2012-04-11 18:01:40 UTC (rev 280) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.1.0</version> + <version>1.2.0-SNAPSHOT</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.1.0</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 18:01:43
|
Revision: 279 http://openfast.svn.sourceforge.net/openfast/?rev=279&view=rev Author: jacob_northey Date: 2012-04-11 18:01:37 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [maven-release-plugin] copy for tag openfast-1.1.0 Added Paths: ----------- tags/openfast-1.1.0/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 18:01:42
|
Revision: 278 http://openfast.svn.sourceforge.net/openfast/?rev=278&view=rev Author: jacob_northey Date: 2012-04-11 18:01:33 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [maven-release-plugin] prepare release openfast-1.1.0 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-04-11 17:25:58 UTC (rev 277) +++ trunk/pom.xml 2012-04-11 18:01:33 UTC (rev 278) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.4-SNAPSHOT</version> + <version>1.1.0</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.1.0</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.1.0</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 17:26:08
|
Revision: 277 http://openfast.svn.sourceforge.net/openfast/?rev=277&view=rev Author: jacob_northey Date: 2012-04-11 17:25:58 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [FAST-40] Bound multicast socket to group and port Modified Paths: -------------- trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java 2012-04-11 17:21:00 UTC (rev 276) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java 2012-04-11 17:25:58 UTC (rev 277) @@ -22,6 +22,7 @@ import java.io.IOException; import java.net.InetAddress; +import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.net.SocketException; @@ -47,7 +48,7 @@ protected MulticastSocket createSocket() throws FastConnectionException { try { - MulticastSocket socket = new MulticastSocket(port); + MulticastSocket socket = new MulticastSocket(new InetSocketAddress(group, port)); if (ifaddr != null) { try { socket.setInterface(InetAddress.getByName(ifaddr)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 17:21:11
|
Revision: 276 http://openfast.svn.sourceforge.net/openfast/?rev=276&view=rev Author: jacob_northey Date: 2012-04-11 17:21:00 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [FAST-26] Implemented available in MulticastInputStream Modified Paths: -------------- trunk/src/main/java/org/openfast/codec/FastDecoder.java trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java Modified: trunk/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 17:02:37 UTC (rev 275) +++ trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 17:21:00 UTC (rev 276) @@ -22,12 +22,12 @@ import java.io.IOException; import java.io.InputStream; + import org.openfast.BitVector; import org.openfast.BitVectorReader; import org.openfast.BitVectorValue; import org.openfast.Context; import org.openfast.Message; -import org.openfast.error.FastConstants; import org.openfast.error.FastException; import org.openfast.template.MessageTemplate; import org.openfast.template.type.codec.TypeCodec; Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java 2012-04-11 17:02:37 UTC (rev 275) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java 2012-04-11 17:21:00 UTC (rev 276) @@ -53,4 +53,9 @@ } return (buffer.get() & 0xFF); } + + @Override + public int available() throws IOException { + return buffer.remaining(); + } } Modified: trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 17:02:37 UTC (rev 275) +++ trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 17:21:00 UTC (rev 276) @@ -23,17 +23,16 @@ */ package org.openfast.template.type.codec; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + import org.openfast.BitVector; import org.openfast.BitVectorValue; import org.openfast.Global; import org.openfast.ScalarValue; import org.openfast.error.FastConstants; -import org.openfast.error.FastException; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - public final class BitVectorType extends TypeCodec { private static final long serialVersionUID = 1L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 17:02:47
|
Revision: 275 http://openfast.svn.sourceforge.net/openfast/?rev=275&view=rev Author: joshseidel Date: 2012-04-11 17:02:37 +0000 (Wed, 11 Apr 2012) Log Message: ----------- Updated and merged to the current trunk with the updated changes and bug fixes. Modified Paths: -------------- branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java branches/generics-cleanup/src/main/java/org/openfast/error/FastConstants.java branches/generics-cleanup/src/main/java/org/openfast/template/Group.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/AsciiString.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/BitVectorType.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/ByteVectorType.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableByteVector.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/SignedInteger.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java branches/generics-cleanup/src/test/java/org/openfast/codec/FastDecoderTest.java branches/generics-cleanup/src/test/java/org/openfast/submitted/OpraFeedTest.java Added Paths: ----------- branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml branches/generics-cleanup/src/test/resources/submitted/ Property Changed: ---------------- branches/generics-cleanup/ Property changes on: branches/generics-cleanup ___________________________________________________________________ Modified: svn:mergeinfo - /trunk:267-270 + /trunk:267-274 Modified: branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 17:02:37 UTC (rev 275) @@ -27,26 +27,44 @@ import org.openfast.BitVectorValue; import org.openfast.Context; import org.openfast.Message; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; import org.openfast.template.MessageTemplate; import org.openfast.template.type.codec.TypeCodec; +/** + * A FastDecoder is the core class for reading and decoding FAST messages from any input stream. This class can be used + * instead of {@link org.openfast.MessageInputStream} when working with FAST messages embedded in other protocols. + * <br/><br/> + * <b><i>NOTE:</i></b> The context object that is used to construct a FastDecoder should not be shared with any other decoders or encoders. + */ public class FastDecoder implements Coder { private final InputStream in; private final Context context; + /** + * Construct a new FastDecoder with a context and input stream. + * + * @param context The context containg templates to be used in decoding and where FAST dictionary data will be stored + * @param in The input stream to read messages from + */ public FastDecoder(Context context, InputStream in) { this.in = in; this.context = context; } - public Message readMessage() { + /** + * Read the next FAST message from the input stream. + * + * @return an object representing the decoded FAST message + * @throws FastException if a decoding error occurs or the end of the input stream has been reached + */ + public Message readMessage() throws FastException { BitVectorValue bitVectorValue = (BitVectorValue) TypeCodec.BIT_VECTOR.decode(in); - if (bitVectorValue == null) { - return null; // Must have reached end of stream; + return null; } - BitVector pmap = bitVectorValue.value; BitVectorReader presenceMapReader = new BitVectorReader(pmap); @@ -63,7 +81,13 @@ return template.decode(in, templateId, presenceMapReader, context); } - + + /** + * Helper method that can be used to read past a non-FAST message header. + * + * @param offset number of bytes in the stream to skip + * @return the decoded FAST message encountered after skipping the offset. + */ public Message readMessage(int offset) { if (offset > 0) { try { @@ -75,6 +99,9 @@ return readMessage(); } + /** + * Reset the FAST dictionary. + */ public void reset() { context.reset(); } Modified: branches/generics-cleanup/src/main/java/org/openfast/error/FastConstants.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/error/FastConstants.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/error/FastConstants.java 2012-04-11 17:02:37 UTC (rev 275) @@ -68,6 +68,7 @@ ErrorCode IMPOSSIBLE_EXCEPTION = new ErrorCode(DYNAMIC, 101, "IMPOSSIBLE", "This should never happen.", ERROR); ErrorCode IO_ERROR = new ErrorCode(DYNAMIC, 102, "IOERROR", "An IO error occurred.", FATAL); ErrorCode PARSE_ERROR = new ErrorCode(DYNAMIC, 103, "PARSEERR", "An exception occurred while parsing.", ERROR); + ErrorCode END_OF_STREAM = new ErrorCode(DYNAMIC, 104, "ENDSTREAM", "There is not more data in the stream.", ERROR); String TEMPLATE_DEFINITION_1_1 = "http://www.fixprotocol.org/ns/fast/td/1.1"; QName LENGTH_FIELD = new QName("length", TEMPLATE_DEFINITION_1_1); QName LENGTH_NAME_ATTR = new QName("name", TEMPLATE_DEFINITION_1_1); Modified: branches/generics-cleanup/src/main/java/org/openfast/template/Group.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/Group.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/Group.java 2012-04-11 17:02:37 UTC (rev 275) @@ -171,7 +171,7 @@ if (context.isTraceEnabled()) { context.getEncodeTrace().groupStart(this); } - BitVectorBuilder presenceMapBuilder = new BitVectorBuilder(template.getMaxPresenceMapSize()); + BitVectorBuilder presenceMapBuilder = new BitVectorBuilder(groupValue.getGroup().getMaxPresenceMapSize()); try { byte[][] fieldEncodings = new byte[fields.length][]; for (int fieldIndex = 0; fieldIndex < fields.length; ++fieldIndex) { Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/AsciiString.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/AsciiString.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/AsciiString.java 2012-04-11 17:02:37 UTC (rev 275) @@ -23,14 +23,15 @@ */ package org.openfast.template.type.codec; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + import org.openfast.ByteUtil; import org.openfast.Global; import org.openfast.ScalarValue; import org.openfast.StringValue; import org.openfast.error.FastConstants; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; final class AsciiString extends TypeCodec { private static final long serialVersionUID = 1L; @@ -73,10 +74,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } buffer.write(byt); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } byte[] bytes = buffer.toByteArray(); bytes[bytes.length - 1] &= 0x7f; Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/BitVectorType.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 17:02:37 UTC (rev 275) @@ -27,6 +27,9 @@ import org.openfast.BitVectorValue; import org.openfast.Global; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -61,10 +64,12 @@ try { byt = in.read(); if (byt < 0) { - return null; + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception } } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } buffer.write(byt); } while ((byt & 0x80) == 0); Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/ByteVectorType.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/ByteVectorType.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/ByteVectorType.java 2012-04-11 17:02:37 UTC (rev 275) @@ -27,8 +27,11 @@ import java.io.InputStream; import org.openfast.ByteVectorValue; +import org.openfast.Global; import org.openfast.IntegerValue; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; final class ByteVectorType extends TypeCodec { private static final long serialVersionUID = 1L; @@ -63,9 +66,15 @@ byte[] encoding = new byte[length]; for (int i = 0; i < length; ++i) try { - encoding[i] = (byte) in.read(); + int nextByte = in.read(); + if (nextByte < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } + encoding[i] = (byte) nextByte; } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return new ByteVectorValue(encoding); } Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2012-04-11 17:02:37 UTC (rev 275) @@ -28,6 +28,8 @@ import org.openfast.ScalarValue; import org.openfast.StringValue; import org.openfast.error.FastConstants; +import org.openfast.error.FastException; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -72,10 +74,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } buffer.write(byt); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } byte[] bytes = buffer.toByteArray(); bytes[bytes.length - 1] &= 0x7f; Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableByteVector.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2012-04-11 17:02:37 UTC (rev 275) @@ -47,9 +47,15 @@ byte[] encoding = new byte[length]; for (int i = 0; i < length; ++i) try { - encoding[i] = (byte) in.read(); + int nextByte = in.read(); + if (nextByte < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } + encoding[i] = (byte) nextByte; } catch (IOException e) { Global.handleError(FastConstants.IO_ERROR, "An error occurred while decoding a nullable byte vector.", e); + return null; // short circuit if global error handler does not throw exception } return new ByteVectorValue(encoding); } Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/SignedInteger.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/SignedInteger.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/SignedInteger.java 2012-04-11 17:02:37 UTC (rev 275) @@ -25,8 +25,11 @@ import java.io.IOException; import java.io.InputStream; + +import org.openfast.Global; import org.openfast.NumericValue; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; public final class SignedInteger extends IntegerCodec { private static final long serialVersionUID = 1L; @@ -65,16 +68,25 @@ long value = 0; try { int byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } if ((byt & 0x40) > 0) { value = -1; } value = (value << 7) | (byt & 0x7f); while ((byt & 0x80) == 0) { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } value = (value << 7) | (byt & 0x7f); } } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return createValue(value); } Modified: branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java 2012-04-11 17:02:37 UTC (rev 275) @@ -25,7 +25,10 @@ import java.io.IOException; import java.io.InputStream; + +import org.openfast.Global; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; public final class UnsignedInteger extends IntegerCodec { private static final long serialVersionUID = 1L; @@ -61,10 +64,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } value = (value << 7) | (byt & 0x7f); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return createValue(value); } Modified: branches/generics-cleanup/src/test/java/org/openfast/codec/FastDecoderTest.java =================================================================== --- branches/generics-cleanup/src/test/java/org/openfast/codec/FastDecoderTest.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/test/java/org/openfast/codec/FastDecoderTest.java 2012-04-11 17:02:37 UTC (rev 275) @@ -17,9 +17,8 @@ Contributor(s): Jacob Northey <ja...@la...> Craig Otis <co...@la...> -*/ + */ - package org.openfast.codec; import java.io.IOException; @@ -34,16 +33,16 @@ import org.openfast.Message; import org.openfast.ScalarValue; import org.openfast.StringValue; +import org.openfast.error.FastException; import org.openfast.template.Field; import org.openfast.template.MessageTemplate; import org.openfast.template.Scalar; import org.openfast.template.operator.Operator; import org.openfast.template.type.Type; - public class FastDecoderTest extends TestCase { public void testDecodeEmptyMessage() { - MessageTemplate messageTemplate = new MessageTemplate("", new Field[] { }); + MessageTemplate messageTemplate = new MessageTemplate("", new Field[] {}); InputStream in = ByteUtil.createByteStream("11000000 11110001"); Context context = new Context(); context.registerTemplate(113, messageTemplate); @@ -53,7 +52,7 @@ } public void testDecodeSequentialEmptyMessages() { - MessageTemplate messageTemplate = new MessageTemplate("", new Field[] { }); + MessageTemplate messageTemplate = new MessageTemplate("", new Field[] {}); InputStream in = ByteUtil.createByteStream("11000000 11110001 10000000"); Context context = new Context(); context.registerTemplate(113, messageTemplate); @@ -66,10 +65,8 @@ } public void testDecodeSimpleMessage() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { new Scalar("1", Type.U32, Operator.COPY, + ScalarValue.UNDEFINED, false) }); InputStream in = ByteUtil.createByteStream("11100000 11110001 10000001"); Context context = new Context(); context.registerTemplate(113, template); @@ -84,19 +81,19 @@ } public void testDecodeMessageWithAllFieldTypes() { - // --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6--- + // --PMAP-- --TID--- ---#1--- -------#2-------- + // ------------#3------------ ---#4--- ------------#5------------ + // ---#6--- String msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010"; InputStream in = ByteUtil.createByteStream(msgstr); - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("4", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("5", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("6", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("4", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("6", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), }); Context context = new Context(); context.registerTemplate(113, template); @@ -111,19 +108,17 @@ } public void testDecodeMessageWithSignedIntegerFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.I32, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.I32, Operator.INCREMENT, - new IntegerValue(10), false), - new Scalar("4", Type.I32, Operator.INCREMENT, - ScalarValue.UNDEFINED, false), - new Scalar("5", Type.I32, Operator.CONSTANT, - new IntegerValue(1), false), /* NON-TRANSFERRABLE */ - new Scalar("6", Type.I32, Operator.DEFAULT, - new IntegerValue(2), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.I32, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.I32, Operator.INCREMENT, new IntegerValue(10), false), + new Scalar("4", Type.I32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.I32, Operator.CONSTANT, new IntegerValue(1), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("6", Type.I32, Operator.DEFAULT, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.setInteger(1, 109); @@ -133,17 +128,17 @@ message.setInteger(5, 1); message.setInteger(6, 2); - // --PMAP-- --TID--- --------#1------- ------------#2------------ ---#4--- + // --PMAP-- --TID--- --------#1------- ------------#2------------ + // ---#4--- String msg1 = "11101000 11110001 00000000 11101101 00000001 01100110 10011110 10000011"; - // --PMAP-- ---#2--- ---#6--- + // --PMAP-- ---#2--- ---#6--- String msg2 = "10000100 11111111 10000011"; - // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- + // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- String msg3 = "10101100 00000000 11100000 00001000 10000111 10000001 10000011"; - InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + - msg3); + InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + msg3); Context context = new Context(); context.registerTemplate(113, template); @@ -170,19 +165,17 @@ } public void testDecodeMessageWithUnsignedIntegerFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.U32, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.U32, Operator.INCREMENT, - new IntegerValue(10), false), - new Scalar("4", Type.U32, Operator.INCREMENT, - ScalarValue.UNDEFINED, false), - new Scalar("5", Type.U32, Operator.CONSTANT, - new IntegerValue(1), false), /* NON-TRANSFERRABLE */ - new Scalar("6", Type.U32, Operator.DEFAULT, - new IntegerValue(2), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.U32, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.U32, Operator.INCREMENT, new IntegerValue(10), false), + new Scalar("4", Type.U32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.U32, Operator.CONSTANT, new IntegerValue(1), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("6", Type.U32, Operator.DEFAULT, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.setInteger(1, 109); @@ -192,17 +185,16 @@ message.setInteger(5, 1); message.setInteger(6, 2); - // --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4--- + // --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4--- String msg1 = "11101000 11110001 11101101 00000001 01100110 10011110 10000011"; - // --PMAP-- ---#2--- ---#6--- + // --PMAP-- ---#2--- ---#6--- String msg2 = "10000100 11111111 10000011"; - // --PMAP-- ---#1--- --------#2------- ---#4--- ---#6--- + // --PMAP-- ---#1--- --------#2------- ---#4--- ---#6--- String msg3 = "10101100 11100000 00001000 10000111 10000001 10000011"; - InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + - msg3); + InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + msg3); Context context = new Context(); context.registerTemplate(113, template); @@ -229,15 +221,15 @@ } public void testDecodeMessageWithStringFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.ASCII, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.ASCII, Operator.CONSTANT, - new StringValue("e"), false), /* NON-TRANSFERRABLE */ - new Scalar("4", Type.ASCII, Operator.DEFAULT, - new StringValue("long"), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.ASCII, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.ASCII, Operator.CONSTANT, new StringValue("e"), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("4", Type.ASCII, Operator.DEFAULT, new StringValue("long"), false) }); Message message = new Message(template); message.setString(1, "on"); @@ -245,10 +237,12 @@ message.setString(3, "e"); message.setString(4, "long"); - // --PMAP-- --TID--- --------#1------- ---------------------#2--------------------- + // --PMAP-- --TID--- --------#1------- + // ---------------------#2--------------------- String msg1 = "11100000 11110001 01101111 11101110 10000000 01000100 01000011 01000010 00110011 10110010"; - // --PMAP-- ------------#2------------ ---------------------#4--------------------- + // --PMAP-- ------------#2------------ + // ---------------------#4--------------------- String msg2 = "10010000 10000010 00110001 10110110 01110011 01101000 01101111 01110010 11110100"; InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2); @@ -266,14 +260,17 @@ readMessage = decoder.readMessage(); assertEquals(message, readMessage); } - + public void testDecodeEndOfStream() { - FastDecoder decoder = new FastDecoder(new Context(), new InputStream() { - public int read() throws IOException { - return -1; - }}); - - Message message = decoder.readMessage(); - assertNull(message); + FastDecoder decoder = new FastDecoder(new Context(), new InputStream() { + public int read() throws IOException { + return -1; + } + }); + try { + decoder.readMessage(); + fail("The decoder should have thrown a FAST Exception."); + } catch (FastException e) { + } } } Copied: branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java (from rev 274, trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java) =================================================================== --- branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java (rev 0) +++ branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java 2012-04-11 17:02:37 UTC (rev 275) @@ -0,0 +1,72 @@ +package org.openfast.submitted; + +import java.io.ByteArrayOutputStream; +import java.util.List; + +import junit.framework.TestCase; + +import org.openfast.GroupValue; +import org.openfast.Message; +import org.openfast.MessageOutputStream; +import org.openfast.SequenceValue; +import org.openfast.template.MessageTemplate; +import org.openfast.template.Sequence; +import org.openfast.template.loader.XMLMessageTemplateLoader; + +public class BitVectorOobExceptionTest extends TestCase { + + public void testIt() { + XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); + loader.load(BitVectorOobExceptionTest.class.getResourceAsStream("/submitted/BitVectorOobExceptionTest.xml")); + MessageTemplate messageTemplate = loader.getTemplateRegistry().get("MarketDataIncrementalRefresh_25"); + Message outObj = new Message(messageTemplate); + MessageOutputStream messageOut = new MessageOutputStream(new ByteArrayOutputStream()); + messageOut.registerTemplate(25, messageTemplate); + outObj.setInteger("MsgSeqNum", 1); + outObj.setLong("SendingTime", 2); + outObj.setInteger("TradeDate", 1); + Sequence MDEntriesSequence = messageTemplate.getSequence("MDEntries"); + SequenceValue MDEntriesSequenceValue = new SequenceValue(MDEntriesSequence); + + GroupValue MDEntriesOutGroup = new GroupValue(MDEntriesSequence.getGroup()); + + MDEntriesOutGroup.setString("MDUpdateAction", "a"); + MDEntriesOutGroup.setString("MDEntryType", "a"); + MDEntriesOutGroup.setInteger("RptSeq", 1); + MDEntriesOutGroup.setInteger("PriceBandType", 1); + MDEntriesOutGroup.setLong("SecurityID", 5); + MDEntriesOutGroup.setString("SecurityIDSource", "b"); + MDEntriesOutGroup.setString("SecurityExchange", "c"); + MDEntriesOutGroup.setString("MDStreamID", "d"); + MDEntriesOutGroup.setDecimal("MDEntryPx", 1); + MDEntriesOutGroup.setDecimal("MDEntrySize", 2); + MDEntriesOutGroup.setInteger("MDEntryDate", 3); + MDEntriesOutGroup.setInteger("MDEntryTime", 4); + MDEntriesOutGroup.setString("TickDirection", "e"); + MDEntriesOutGroup.setString("QuoteCondition", "f"); + MDEntriesOutGroup.setString("TradeCondition", "g"); + MDEntriesOutGroup.setString("OpenCloseSettlFlag", "h"); + MDEntriesOutGroup.setLong("NoSharesIssued", 5); + MDEntriesOutGroup.setString("Currency", "j"); + MDEntriesOutGroup.setString("OrderID", "k"); + MDEntriesOutGroup.setString("TradeID", "l"); + MDEntriesOutGroup.setString("MDEntryBuyer", "m"); + MDEntriesOutGroup.setString("MDEntrySeller", "n"); + MDEntriesOutGroup.setInteger("NumberOfOrders", 5); + MDEntriesOutGroup.setInteger("MDEntryPositionNo", 7); + MDEntriesOutGroup.setInteger("PriceType", 8); + MDEntriesOutGroup.setDecimal("NetChgPrevDay", 9); + MDEntriesOutGroup.setInteger("SellerDays", 10); + MDEntriesOutGroup.setInteger("SettlPriceType", 11); + MDEntriesOutGroup.setDecimal("TradeVolume", 12); + MDEntriesOutGroup.setInteger("PriceLimitType", 13); + MDEntriesOutGroup.setDecimal("LowLimitPrice", 14); + MDEntriesOutGroup.setDecimal("HighLimitPrice", 15); + MDEntriesOutGroup.setDecimal("TradingReferencePrice", 16); + MDEntriesOutGroup.setLong("MDEntryID", 17); + MDEntriesOutGroup.setInteger("MDInsertDate", 18); + MDEntriesSequenceValue.add(MDEntriesOutGroup); + outObj.setFieldValue("MDEntries", MDEntriesSequenceValue); + messageOut.writeMessage(outObj); + } +} Copied: branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml (from rev 274, trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml) =================================================================== --- branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml (rev 0) +++ branches/generics-cleanup/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml 2012-04-11 17:02:37 UTC (rev 275) @@ -0,0 +1,105 @@ +<templates> + <template name="MarketDataIncrementalRefresh_25" id="25" dictionary="25"> + <string name="MsgType" id="35"> + <constant value="X" /> + </string> + <uInt32 name="MsgSeqNum" id="34" /> + <uInt64 name="SendingTime" id="52" /> + <string name="ApplVerID" id="1128" presence="optional"> + <constant value="9" /> + </string> + <uInt32 name="TradeDate" id="75" presence="optional"> + <default /> + </uInt32> + <sequence name="MDEntries"> + <length name="NoMDEntries" id="268" /> + <string name="MDUpdateAction" id="279"> + <copy /> + </string> + <string name="MDEntryType" id="269"> + <copy /> + </string> + <uInt32 name="RptSeq" id="83" presence="optional"> + <increment /> + </uInt32> + <!-- 1.5.1 --> + <uInt32 name="PriceBandType" id="6939" presence="optional"> + <default /> + </uInt32> + <!-- component InstrumentIdentification --> + <int64 name="SecurityID" id="48" presence="optional"> + <copy /> + </int64> + <string name="SecurityIDSource" id="22" presence="optional"> + <default value="8" /> + </string> + <string name="SecurityExchange" id="207" presence="optional"> + <default value="BVMF" /> + </string> + <!--1.4.1--> + <string name="MDStreamID" id="1500" presence="optional"> + <default /> + </string> + <decimal name="MDEntryPx" id="270" presence="optional"> + <delta /> + </decimal> + <decimal name="MDEntrySize" id="271" presence="optional"> + <delta /> + </decimal> + <uInt32 name="MDEntryDate" id="272"> + <copy /> + </uInt32> + <uInt32 name="MDEntryTime" id="273"> + <copy /> + </uInt32> + <string name="TickDirection" id="274" presence="optional"> + <default /> + </string> + <!--1.4.1--> + <string name="QuoteCondition" id="276" presence="optional"> + <default /> + </string> + <string name="TradeCondition" id="277" presence="optional"> + <default /> + </string> + <string name="OpenCloseSettlFlag" id="286" presence="optional"> + <default /> + </string> + <uInt64 name="NoSharesIssued" id="7595" presence="optional"> + <default /> + </uInt64> + <string name="Currency" id="15" presence="optional" ><default/></string> + <string name="OrderID" id="37" presence="optional" ><default/></string> + <string name="TradeID" id="1003" presence="optional" ><default/></string> + <string name="MDEntryBuyer" id="288" presence="optional"> + <copy /> + </string> + <string name="MDEntrySeller" id="289" presence="optional"> + <copy /> + </string> + <uInt32 name="NumberOfOrders" id="346" presence="optional"> + <default /> + </uInt32> + <uInt32 name="MDEntryPositionNo" id="290" presence="optional"> + <increment /> + </uInt32> + <!--1.4.1 AggressorSide only used in GLOBEX--> + <!--1.4.1--> + <uInt32 name="PriceType" id="423" presence="optional"><default /></uInt32> + + <decimal name="NetChgPrevDay" id="451" presence="optional"><default /></decimal> + <!--1.4.1--> + <uInt32 name="SellerDays" id="287" presence="optional"><default/></uInt32> + <uInt32 name="SettlPriceType" id="731" presence="optional"><default/></uInt32> + <decimal name="TradeVolume" id="1020" presence="optional"><default/></decimal> + <uInt32 name="PriceLimitType" id="1306" presence="optional"><default/></uInt32> + <decimal name="LowLimitPrice" id="1148" presence="optional" ><default /></decimal> + <decimal name="HighLimitPrice" id="1149" presence="optional" ><default /></decimal> + <decimal name="TradingReferencePrice" id="1150" presence="optional" ><default /></decimal> + <!-- Stock-index related fields, like PercentageVar, aren't broadcast --> + <!-- Probe --> + <uInt64 name="MDEntryID" id="278" presence="optional"><default /></uInt64> + <uInt32 name="MDInsertDate" id="37016" presence="optional"><default /></uInt32> + </sequence> + </template> +</templates> \ No newline at end of file Modified: branches/generics-cleanup/src/test/java/org/openfast/submitted/OpraFeedTest.java =================================================================== --- branches/generics-cleanup/src/test/java/org/openfast/submitted/OpraFeedTest.java 2012-04-11 16:54:40 UTC (rev 274) +++ branches/generics-cleanup/src/test/java/org/openfast/submitted/OpraFeedTest.java 2012-04-11 17:02:37 UTC (rev 275) @@ -26,6 +26,8 @@ import org.openfast.Message; import org.openfast.MessageBlockReader; import org.openfast.MessageInputStream; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; import org.openfast.template.loader.XMLMessageTemplateLoader; import org.openfast.test.OpenFastTestCase; @@ -66,9 +68,14 @@ OpraBlockReader opraBlockReader = new OpraBlockReader(); in.setBlockReader(opraBlockReader); in.setTemplateRegistry(loader.getTemplateRegistry()); - Message msg = in.readMessage(); - while (msg != null) { - msg = in.readMessage(); + in.readMessage(); + while (true) { + try { + in.readMessage(); + } catch (FastException e) { + assertEquals(FastConstants.END_OF_STREAM, e.getCode()); + return; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 16:54:50
|
Revision: 274 http://openfast.svn.sourceforge.net/openfast/?rev=274&view=rev Author: jacob_northey Date: 2012-04-11 16:54:40 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [FAST-43] Added pmap null check to readMessage method in case the Global error handler does not throw an exception Modified Paths: -------------- trunk/src/main/java/org/openfast/codec/FastDecoder.java Modified: trunk/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 16:47:59 UTC (rev 273) +++ trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 16:54:40 UTC (rev 274) @@ -62,7 +62,9 @@ */ public Message readMessage() throws FastException { BitVectorValue bitVectorValue = (BitVectorValue) TypeCodec.BIT_VECTOR.decode(in); - + if (bitVectorValue == null) { + return null; + } BitVector pmap = (bitVectorValue).value; BitVectorReader presenceMapReader = new BitVectorReader(pmap); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 16:48:09
|
Revision: 273 http://openfast.svn.sourceforge.net/openfast/?rev=273&view=rev Author: jacob_northey Date: 2012-04-11 16:47:59 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [FAST-43] Changed FastDecoder to throw exception when end of stream reached. Modified Paths: -------------- trunk/src/main/java/org/openfast/codec/FastDecoder.java trunk/src/main/java/org/openfast/error/FastConstants.java trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java trunk/src/main/java/org/openfast/template/type/codec/ByteVectorType.java trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java trunk/src/main/java/org/openfast/template/type/codec/SignedInteger.java trunk/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java trunk/src/test/java/org/openfast/codec/FastDecoderTest.java trunk/src/test/java/org/openfast/submitted/OpraFeedTest.java Modified: trunk/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/codec/FastDecoder.java 2012-04-11 16:47:59 UTC (rev 273) @@ -27,26 +27,42 @@ import org.openfast.BitVectorValue; import org.openfast.Context; import org.openfast.Message; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; import org.openfast.template.MessageTemplate; import org.openfast.template.type.codec.TypeCodec; +/** + * A FastDecoder is the core class for reading and decoding FAST messages from any input stream. This class can be used + * instead of {@link org.openfast.MessageInputStream} when working with FAST messages embedded in other protocols. + * <br/><br/> + * <b><i>NOTE:</i></b> The context object that is used to construct a FastDecoder should not be shared with any other decoders or encoders. + */ public class FastDecoder implements Coder { private final InputStream in; private final Context context; + /** + * Construct a new FastDecoder with a context and input stream. + * + * @param context The context containg templates to be used in decoding and where FAST dictionary data will be stored + * @param in The input stream to read messages from + */ public FastDecoder(Context context, InputStream in) { this.in = in; this.context = context; } - public Message readMessage() { + /** + * Read the next FAST message from the input stream. + * + * @return an object representing the decoded FAST message + * @throws FastException if a decoding error occurs or the end of the input stream has been reached + */ + public Message readMessage() throws FastException { BitVectorValue bitVectorValue = (BitVectorValue) TypeCodec.BIT_VECTOR.decode(in); - if (bitVectorValue == null) { - return null; // Must have reached end of stream; - } - BitVector pmap = (bitVectorValue).value; BitVectorReader presenceMapReader = new BitVectorReader(pmap); @@ -63,7 +79,13 @@ return template.decode(in, templateId, presenceMapReader, context); } - + + /** + * Helper method that can be used to read past a non-FAST message header. + * + * @param offset number of bytes in the stream to skip + * @return the decoded FAST message encountered after skipping the offset. + */ public Message readMessage(int offset) { if (offset > 0) { try { @@ -75,6 +97,9 @@ return readMessage(); } + /** + * Reset the FAST dictionary. + */ public void reset() { context.reset(); } Modified: trunk/src/main/java/org/openfast/error/FastConstants.java =================================================================== --- trunk/src/main/java/org/openfast/error/FastConstants.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/error/FastConstants.java 2012-04-11 16:47:59 UTC (rev 273) @@ -68,6 +68,7 @@ ErrorCode IMPOSSIBLE_EXCEPTION = new ErrorCode(DYNAMIC, 101, "IMPOSSIBLE", "This should never happen.", ERROR); ErrorCode IO_ERROR = new ErrorCode(DYNAMIC, 102, "IOERROR", "An IO error occurred.", FATAL); ErrorCode PARSE_ERROR = new ErrorCode(DYNAMIC, 103, "PARSEERR", "An exception occurred while parsing.", ERROR); + ErrorCode END_OF_STREAM = new ErrorCode(DYNAMIC, 104, "ENDSTREAM", "There is not more data in the stream.", ERROR); String TEMPLATE_DEFINITION_1_1 = "http://www.fixprotocol.org/ns/fast/td/1.1"; QName LENGTH_FIELD = new QName("length", TEMPLATE_DEFINITION_1_1); QName LENGTH_NAME_ATTR = new QName("name", TEMPLATE_DEFINITION_1_1); Modified: trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/AsciiString.java 2012-04-11 16:47:59 UTC (rev 273) @@ -23,14 +23,15 @@ */ package org.openfast.template.type.codec; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; + import org.openfast.ByteUtil; import org.openfast.Global; import org.openfast.ScalarValue; import org.openfast.StringValue; import org.openfast.error.FastConstants; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; final class AsciiString extends TypeCodec { private static final long serialVersionUID = 1L; @@ -73,10 +74,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } buffer.write(byt); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } byte[] bytes = buffer.toByteArray(); bytes[bytes.length - 1] &= 0x7f; Modified: trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/BitVectorType.java 2012-04-11 16:47:59 UTC (rev 273) @@ -27,6 +27,9 @@ import org.openfast.BitVectorValue; import org.openfast.Global; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -61,10 +64,12 @@ try { byt = in.read(); if (byt < 0) { - return null; + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception } } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } buffer.write(byt); } while ((byt & 0x80) == 0); Modified: trunk/src/main/java/org/openfast/template/type/codec/ByteVectorType.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/ByteVectorType.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/ByteVectorType.java 2012-04-11 16:47:59 UTC (rev 273) @@ -27,8 +27,11 @@ import java.io.InputStream; import org.openfast.ByteVectorValue; +import org.openfast.Global; import org.openfast.IntegerValue; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; final class ByteVectorType extends TypeCodec { private static final long serialVersionUID = 1L; @@ -63,9 +66,15 @@ byte[] encoding = new byte[length]; for (int i = 0; i < length; i++) try { - encoding[i] = (byte) in.read(); + int nextByte = in.read(); + if (nextByte < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } + encoding[i] = (byte) nextByte; } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return new ByteVectorValue(encoding); } Modified: trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/NullableAsciiString.java 2012-04-11 16:47:59 UTC (rev 273) @@ -28,6 +28,8 @@ import org.openfast.ScalarValue; import org.openfast.StringValue; import org.openfast.error.FastConstants; +import org.openfast.error.FastException; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -72,10 +74,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } buffer.write(byt); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } byte[] bytes = buffer.toByteArray(); bytes[bytes.length - 1] &= 0x7f; Modified: trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2012-04-11 16:47:59 UTC (rev 273) @@ -47,9 +47,15 @@ byte[] encoding = new byte[length]; for (int i = 0; i < length; i++) try { - encoding[i] = (byte) in.read(); + int nextByte = in.read(); + if (nextByte < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } + encoding[i] = (byte) nextByte; } catch (IOException e) { Global.handleError(FastConstants.IO_ERROR, "An error occurred while decoding a nullable byte vector.", e); + return null; // short circuit if global error handler does not throw exception } return new ByteVectorValue(encoding); } Modified: trunk/src/main/java/org/openfast/template/type/codec/SignedInteger.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/SignedInteger.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/SignedInteger.java 2012-04-11 16:47:59 UTC (rev 273) @@ -25,8 +25,11 @@ import java.io.IOException; import java.io.InputStream; + +import org.openfast.Global; import org.openfast.NumericValue; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; public final class SignedInteger extends IntegerCodec { private static final long serialVersionUID = 1L; @@ -65,16 +68,25 @@ long value = 0; try { int byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } if ((byt & 0x40) > 0) { value = -1; } value = (value << 7) | (byt & 0x7f); while ((byt & 0x80) == 0) { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } value = (value << 7) | (byt & 0x7f); } } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return createValue(value); } Modified: trunk/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java 2012-04-11 16:47:59 UTC (rev 273) @@ -25,7 +25,10 @@ import java.io.IOException; import java.io.InputStream; + +import org.openfast.Global; import org.openfast.ScalarValue; +import org.openfast.error.FastConstants; public final class UnsignedInteger extends IntegerCodec { private static final long serialVersionUID = 1L; @@ -61,10 +64,15 @@ try { do { byt = in.read(); + if (byt < 0) { + Global.handleError(FastConstants.END_OF_STREAM, "The end of the input stream has been reached."); + return null; // short circuit if global error handler does not throw exception + } value = (value << 7) | (byt & 0x7f); } while ((byt & 0x80) == 0); } catch (IOException e) { - throw new RuntimeException(e); + Global.handleError(FastConstants.IO_ERROR, "A IO error has been encountered while decoding.", e); + return null; // short circuit if global error handler does not throw exception } return createValue(value); } Modified: trunk/src/test/java/org/openfast/codec/FastDecoderTest.java =================================================================== --- trunk/src/test/java/org/openfast/codec/FastDecoderTest.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/test/java/org/openfast/codec/FastDecoderTest.java 2012-04-11 16:47:59 UTC (rev 273) @@ -17,9 +17,8 @@ Contributor(s): Jacob Northey <ja...@la...> Craig Otis <co...@la...> -*/ + */ - package org.openfast.codec; import java.io.IOException; @@ -34,16 +33,16 @@ import org.openfast.Message; import org.openfast.ScalarValue; import org.openfast.StringValue; +import org.openfast.error.FastException; import org.openfast.template.Field; import org.openfast.template.MessageTemplate; import org.openfast.template.Scalar; import org.openfast.template.operator.Operator; import org.openfast.template.type.Type; - public class FastDecoderTest extends TestCase { public void testDecodeEmptyMessage() { - MessageTemplate messageTemplate = new MessageTemplate("", new Field[] { }); + MessageTemplate messageTemplate = new MessageTemplate("", new Field[] {}); InputStream in = ByteUtil.createByteStream("11000000 11110001"); Context context = new Context(); context.registerTemplate(113, messageTemplate); @@ -53,7 +52,7 @@ } public void testDecodeSequentialEmptyMessages() { - MessageTemplate messageTemplate = new MessageTemplate("", new Field[] { }); + MessageTemplate messageTemplate = new MessageTemplate("", new Field[] {}); InputStream in = ByteUtil.createByteStream("11000000 11110001 10000000"); Context context = new Context(); context.registerTemplate(113, messageTemplate); @@ -66,10 +65,8 @@ } public void testDecodeSimpleMessage() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { new Scalar("1", Type.U32, Operator.COPY, + ScalarValue.UNDEFINED, false) }); InputStream in = ByteUtil.createByteStream("11100000 11110001 10000001"); Context context = new Context(); context.registerTemplate(113, template); @@ -84,19 +81,19 @@ } public void testDecodeMessageWithAllFieldTypes() { - // --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6--- + // --PMAP-- --TID--- ---#1--- -------#2-------- + // ------------#3------------ ---#4--- ------------#5------------ + // ---#6--- String msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010"; InputStream in = ByteUtil.createByteStream(msgstr); - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("4", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("5", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("6", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("4", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("6", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), }); Context context = new Context(); context.registerTemplate(113, template); @@ -111,19 +108,17 @@ } public void testDecodeMessageWithSignedIntegerFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.I32, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.I32, Operator.INCREMENT, - new IntegerValue(10), false), - new Scalar("4", Type.I32, Operator.INCREMENT, - ScalarValue.UNDEFINED, false), - new Scalar("5", Type.I32, Operator.CONSTANT, - new IntegerValue(1), false), /* NON-TRANSFERRABLE */ - new Scalar("6", Type.I32, Operator.DEFAULT, - new IntegerValue(2), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.I32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.I32, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.I32, Operator.INCREMENT, new IntegerValue(10), false), + new Scalar("4", Type.I32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.I32, Operator.CONSTANT, new IntegerValue(1), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("6", Type.I32, Operator.DEFAULT, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.setInteger(1, 109); @@ -133,17 +128,17 @@ message.setInteger(5, 1); message.setInteger(6, 2); - // --PMAP-- --TID--- --------#1------- ------------#2------------ ---#4--- + // --PMAP-- --TID--- --------#1------- ------------#2------------ + // ---#4--- String msg1 = "11101000 11110001 00000000 11101101 00000001 01100110 10011110 10000011"; - // --PMAP-- ---#2--- ---#6--- + // --PMAP-- ---#2--- ---#6--- String msg2 = "10000100 11111111 10000011"; - // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- + // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- String msg3 = "10101100 00000000 11100000 00001000 10000111 10000001 10000011"; - InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + - msg3); + InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + msg3); Context context = new Context(); context.registerTemplate(113, template); @@ -170,19 +165,17 @@ } public void testDecodeMessageWithUnsignedIntegerFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.U32, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.U32, Operator.INCREMENT, - new IntegerValue(10), false), - new Scalar("4", Type.U32, Operator.INCREMENT, - ScalarValue.UNDEFINED, false), - new Scalar("5", Type.U32, Operator.CONSTANT, - new IntegerValue(1), false), /* NON-TRANSFERRABLE */ - new Scalar("6", Type.U32, Operator.DEFAULT, - new IntegerValue(2), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.U32, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.U32, Operator.INCREMENT, new IntegerValue(10), false), + new Scalar("4", Type.U32, Operator.INCREMENT, ScalarValue.UNDEFINED, false), + new Scalar("5", Type.U32, Operator.CONSTANT, new IntegerValue(1), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("6", Type.U32, Operator.DEFAULT, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.setInteger(1, 109); @@ -192,17 +185,16 @@ message.setInteger(5, 1); message.setInteger(6, 2); - // --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4--- + // --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4--- String msg1 = "11101000 11110001 11101101 00000001 01100110 10011110 10000011"; - // --PMAP-- ---#2--- ---#6--- + // --PMAP-- ---#2--- ---#6--- String msg2 = "10000100 11111111 10000011"; - // --PMAP-- ---#1--- --------#2------- ---#4--- ---#6--- + // --PMAP-- ---#1--- --------#2------- ---#4--- ---#6--- String msg3 = "10101100 11100000 00001000 10000111 10000001 10000011"; - InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + - msg3); + InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2 + ' ' + msg3); Context context = new Context(); context.registerTemplate(113, template); @@ -229,15 +221,15 @@ } public void testDecodeMessageWithStringFieldTypesAndAllOperators() { - MessageTemplate template = new MessageTemplate("", - new Field[] { - new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), - new Scalar("2", Type.ASCII, Operator.DELTA, ScalarValue.UNDEFINED, false), - new Scalar("3", Type.ASCII, Operator.CONSTANT, - new StringValue("e"), false), /* NON-TRANSFERRABLE */ - new Scalar("4", Type.ASCII, Operator.DEFAULT, - new StringValue("long"), false) - }); + MessageTemplate template = new MessageTemplate("", new Field[] { + new Scalar("1", Type.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false), + new Scalar("2", Type.ASCII, Operator.DELTA, ScalarValue.UNDEFINED, false), + new Scalar("3", Type.ASCII, Operator.CONSTANT, new StringValue("e"), false), /* + * NON + * - + * TRANSFERRABLE + */ + new Scalar("4", Type.ASCII, Operator.DEFAULT, new StringValue("long"), false) }); Message message = new Message(template); message.setString(1, "on"); @@ -245,10 +237,12 @@ message.setString(3, "e"); message.setString(4, "long"); - // --PMAP-- --TID--- --------#1------- ---------------------#2--------------------- + // --PMAP-- --TID--- --------#1------- + // ---------------------#2--------------------- String msg1 = "11100000 11110001 01101111 11101110 10000000 01000100 01000011 01000010 00110011 10110010"; - // --PMAP-- ------------#2------------ ---------------------#4--------------------- + // --PMAP-- ------------#2------------ + // ---------------------#4--------------------- String msg2 = "10010000 10000010 00110001 10110110 01110011 01101000 01101111 01110010 11110100"; InputStream in = ByteUtil.createByteStream(msg1 + ' ' + msg2); @@ -266,14 +260,17 @@ readMessage = decoder.readMessage(); assertEquals(message, readMessage); } - + public void testDecodeEndOfStream() { - FastDecoder decoder = new FastDecoder(new Context(), new InputStream() { - public int read() throws IOException { - return -1; - }}); - - Message message = decoder.readMessage(); - assertNull(message); + FastDecoder decoder = new FastDecoder(new Context(), new InputStream() { + public int read() throws IOException { + return -1; + } + }); + try { + decoder.readMessage(); + fail("The decoder should have thrown a FAST Exception."); + } catch (FastException e) { + } } } Modified: trunk/src/test/java/org/openfast/submitted/OpraFeedTest.java =================================================================== --- trunk/src/test/java/org/openfast/submitted/OpraFeedTest.java 2012-04-11 13:06:46 UTC (rev 272) +++ trunk/src/test/java/org/openfast/submitted/OpraFeedTest.java 2012-04-11 16:47:59 UTC (rev 273) @@ -26,6 +26,8 @@ import org.openfast.Message; import org.openfast.MessageBlockReader; import org.openfast.MessageInputStream; +import org.openfast.error.FastConstants; +import org.openfast.error.FastException; import org.openfast.template.loader.XMLMessageTemplateLoader; import org.openfast.test.OpenFastTestCase; @@ -66,9 +68,14 @@ OpraBlockReader opraBlockReader = new OpraBlockReader(); in.setBlockReader(opraBlockReader); in.setTemplateRegistry(loader.getTemplateRegistry()); - Message msg = in.readMessage(); - while (msg != null) { - msg = in.readMessage(); + in.readMessage(); + while (true) { + try { + in.readMessage(); + } catch (FastException e) { + assertEquals(FastConstants.END_OF_STREAM, e.getCode()); + return; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-11 13:06:58
|
Revision: 272 http://openfast.svn.sourceforge.net/openfast/?rev=272&view=rev Author: jacob_northey Date: 2012-04-11 13:06:46 +0000 (Wed, 11 Apr 2012) Log Message: ----------- [FAST-44] Fixed encoding error when sequence contains more fields than the template it resides in Modified Paths: -------------- trunk/src/main/java/org/openfast/template/Group.java Added Paths: ----------- trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml trunk/src/test/resources/submitted/ trunk/src/test/resources/submitted/BitVectorOobExceptionTest.xml Modified: trunk/src/main/java/org/openfast/template/Group.java =================================================================== --- trunk/src/main/java/org/openfast/template/Group.java 2012-04-09 18:51:59 UTC (rev 271) +++ trunk/src/main/java/org/openfast/template/Group.java 2012-04-11 13:06:46 UTC (rev 272) @@ -165,7 +165,7 @@ if (context.isTraceEnabled()) { context.getEncodeTrace().groupStart(this); } - BitVectorBuilder presenceMapBuilder = new BitVectorBuilder(template.getMaxPresenceMapSize()); + BitVectorBuilder presenceMapBuilder = new BitVectorBuilder(groupValue.getGroup().getMaxPresenceMapSize()); try { byte[][] fieldEncodings = new byte[fields.length][]; for (int fieldIndex = 0; fieldIndex < fields.length; fieldIndex++) { Added: trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java =================================================================== --- trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java (rev 0) +++ trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.java 2012-04-11 13:06:46 UTC (rev 272) @@ -0,0 +1,72 @@ +package org.openfast.submitted; + +import java.io.ByteArrayOutputStream; +import java.util.List; + +import junit.framework.TestCase; + +import org.openfast.GroupValue; +import org.openfast.Message; +import org.openfast.MessageOutputStream; +import org.openfast.SequenceValue; +import org.openfast.template.MessageTemplate; +import org.openfast.template.Sequence; +import org.openfast.template.loader.XMLMessageTemplateLoader; + +public class BitVectorOobExceptionTest extends TestCase { + + public void testIt() { + XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); + loader.load(BitVectorOobExceptionTest.class.getResourceAsStream("/submitted/BitVectorOobExceptionTest.xml")); + MessageTemplate messageTemplate = loader.getTemplateRegistry().get("MarketDataIncrementalRefresh_25"); + Message outObj = new Message(messageTemplate); + MessageOutputStream messageOut = new MessageOutputStream(new ByteArrayOutputStream()); + messageOut.registerTemplate(25, messageTemplate); + outObj.setInteger("MsgSeqNum", 1); + outObj.setLong("SendingTime", 2); + outObj.setInteger("TradeDate", 1); + Sequence MDEntriesSequence = messageTemplate.getSequence("MDEntries"); + SequenceValue MDEntriesSequenceValue = new SequenceValue(MDEntriesSequence); + + GroupValue MDEntriesOutGroup = new GroupValue(MDEntriesSequence.getGroup()); + + MDEntriesOutGroup.setString("MDUpdateAction", "a"); + MDEntriesOutGroup.setString("MDEntryType", "a"); + MDEntriesOutGroup.setInteger("RptSeq", 1); + MDEntriesOutGroup.setInteger("PriceBandType", 1); + MDEntriesOutGroup.setLong("SecurityID", 5); + MDEntriesOutGroup.setString("SecurityIDSource", "b"); + MDEntriesOutGroup.setString("SecurityExchange", "c"); + MDEntriesOutGroup.setString("MDStreamID", "d"); + MDEntriesOutGroup.setDecimal("MDEntryPx", 1); + MDEntriesOutGroup.setDecimal("MDEntrySize", 2); + MDEntriesOutGroup.setInteger("MDEntryDate", 3); + MDEntriesOutGroup.setInteger("MDEntryTime", 4); + MDEntriesOutGroup.setString("TickDirection", "e"); + MDEntriesOutGroup.setString("QuoteCondition", "f"); + MDEntriesOutGroup.setString("TradeCondition", "g"); + MDEntriesOutGroup.setString("OpenCloseSettlFlag", "h"); + MDEntriesOutGroup.setLong("NoSharesIssued", 5); + MDEntriesOutGroup.setString("Currency", "j"); + MDEntriesOutGroup.setString("OrderID", "k"); + MDEntriesOutGroup.setString("TradeID", "l"); + MDEntriesOutGroup.setString("MDEntryBuyer", "m"); + MDEntriesOutGroup.setString("MDEntrySeller", "n"); + MDEntriesOutGroup.setInteger("NumberOfOrders", 5); + MDEntriesOutGroup.setInteger("MDEntryPositionNo", 7); + MDEntriesOutGroup.setInteger("PriceType", 8); + MDEntriesOutGroup.setDecimal("NetChgPrevDay", 9); + MDEntriesOutGroup.setInteger("SellerDays", 10); + MDEntriesOutGroup.setInteger("SettlPriceType", 11); + MDEntriesOutGroup.setDecimal("TradeVolume", 12); + MDEntriesOutGroup.setInteger("PriceLimitType", 13); + MDEntriesOutGroup.setDecimal("LowLimitPrice", 14); + MDEntriesOutGroup.setDecimal("HighLimitPrice", 15); + MDEntriesOutGroup.setDecimal("TradingReferencePrice", 16); + MDEntriesOutGroup.setLong("MDEntryID", 17); + MDEntriesOutGroup.setInteger("MDInsertDate", 18); + MDEntriesSequenceValue.add(MDEntriesOutGroup); + outObj.setFieldValue("MDEntries", MDEntriesSequenceValue); + messageOut.writeMessage(outObj); + } +} Added: trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml =================================================================== --- trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml (rev 0) +++ trunk/src/test/java/org/openfast/submitted/BitVectorOobExceptionTest.xml 2012-04-11 13:06:46 UTC (rev 272) @@ -0,0 +1,105 @@ +<templates> + <template name="MarketDataIncrementalRefresh_25" id="25" dictionary="25"> + <string name="MsgType" id="35"> + <constant value="X" /> + </string> + <uInt32 name="MsgSeqNum" id="34" /> + <uInt64 name="SendingTime" id="52" /> + <string name="ApplVerID" id="1128" presence="optional"> + <constant value="9" /> + </string> + <uInt32 name="TradeDate" id="75" presence="optional"> + <default /> + </uInt32> + <sequence name="MDEntries"> + <length name="NoMDEntries" id="268" /> + <string name="MDUpdateAction" id="279"> + <copy /> + </string> + <string name="MDEntryType" id="269"> + <copy /> + </string> + <uInt32 name="RptSeq" id="83" presence="optional"> + <increment /> + </uInt32> + <!-- 1.5.1 --> + <uInt32 name="PriceBandType" id="6939" presence="optional"> + <default /> + </uInt32> + <!-- component InstrumentIdentification --> + <int64 name="SecurityID" id="48" presence="optional"> + <copy /> + </int64> + <string name="SecurityIDSource" id="22" presence="optional"> + <default value="8" /> + </string> + <string name="SecurityExchange" id="207" presence="optional"> + <default value="BVMF" /> + </string> + <!--1.4.1--> + <string name="MDStreamID" id="1500" presence="optional"> + <default /> + </string> + <decimal name="MDEntryPx" id="270" presence="optional"> + <delta /> + </decimal> + <decimal name="MDEntrySize" id="271" presence="optional"> + <delta /> + </decimal> + <uInt32 name="MDEntryDate" id="272"> + <copy /> + </uInt32> + <uInt32 name="MDEntryTime" id="273"> + <copy /> + </uInt32> + <string name="TickDirection" id="274" presence="optional"> + <default /> + </string> + <!--1.4.1--> + <string name="QuoteCondition" id="276" presence="optional"> + <default /> + </string> + <string name="TradeCondition" id="277" presence="optional"> + <default /> + </string> + <string name="OpenCloseSettlFlag" id="286" presence="optional"> + <default /> + </string> + <uInt64 name="NoSharesIssued" id="7595" presence="optional"> + <default /> + </uInt64> + <string name="Currency" id="15" presence="optional" ><default/></string> + <string name="OrderID" id="37" presence="optional" ><default/></string> + <string name="TradeID" id="1003" presence="optional" ><default/></string> + <string name="MDEntryBuyer" id="288" presence="optional"> + <copy /> + </string> + <string name="MDEntrySeller" id="289" presence="optional"> + <copy /> + </string> + <uInt32 name="NumberOfOrders" id="346" presence="optional"> + <default /> + </uInt32> + <uInt32 name="MDEntryPositionNo" id="290" presence="optional"> + <increment /> + </uInt32> + <!--1.4.1 AggressorSide only used in GLOBEX--> + <!--1.4.1--> + <uInt32 name="PriceType" id="423" presence="optional"><default /></uInt32> + + <decimal name="NetChgPrevDay" id="451" presence="optional"><default /></decimal> + <!--1.4.1--> + <uInt32 name="SellerDays" id="287" presence="optional"><default/></uInt32> + <uInt32 name="SettlPriceType" id="731" presence="optional"><default/></uInt32> + <decimal name="TradeVolume" id="1020" presence="optional"><default/></decimal> + <uInt32 name="PriceLimitType" id="1306" presence="optional"><default/></uInt32> + <decimal name="LowLimitPrice" id="1148" presence="optional" ><default /></decimal> + <decimal name="HighLimitPrice" id="1149" presence="optional" ><default /></decimal> + <decimal name="TradingReferencePrice" id="1150" presence="optional" ><default /></decimal> + <!-- Stock-index related fields, like PercentageVar, aren't broadcast --> + <!-- Probe --> + <uInt64 name="MDEntryID" id="278" presence="optional"><default /></uInt64> + <uInt32 name="MDInsertDate" id="37016" presence="optional"><default /></uInt32> + </sequence> + </template> +</templates> \ No newline at end of file Added: trunk/src/test/resources/submitted/BitVectorOobExceptionTest.xml =================================================================== --- trunk/src/test/resources/submitted/BitVectorOobExceptionTest.xml (rev 0) +++ trunk/src/test/resources/submitted/BitVectorOobExceptionTest.xml 2012-04-11 13:06:46 UTC (rev 272) @@ -0,0 +1,105 @@ +<templates> + <template name="MarketDataIncrementalRefresh_25" id="25" dictionary="25"> + <string name="MsgType" id="35"> + <constant value="X" /> + </string> + <uInt32 name="MsgSeqNum" id="34" /> + <uInt64 name="SendingTime" id="52" /> + <string name="ApplVerID" id="1128" presence="optional"> + <constant value="9" /> + </string> + <uInt32 name="TradeDate" id="75" presence="optional"> + <default /> + </uInt32> + <sequence name="MDEntries"> + <length name="NoMDEntries" id="268" /> + <string name="MDUpdateAction" id="279"> + <copy /> + </string> + <string name="MDEntryType" id="269"> + <copy /> + </string> + <uInt32 name="RptSeq" id="83" presence="optional"> + <increment /> + </uInt32> + <!-- 1.5.1 --> + <uInt32 name="PriceBandType" id="6939" presence="optional"> + <default /> + </uInt32> + <!-- component InstrumentIdentification --> + <int64 name="SecurityID" id="48" presence="optional"> + <copy /> + </int64> + <string name="SecurityIDSource" id="22" presence="optional"> + <default value="8" /> + </string> + <string name="SecurityExchange" id="207" presence="optional"> + <default value="BVMF" /> + </string> + <!--1.4.1--> + <string name="MDStreamID" id="1500" presence="optional"> + <default /> + </string> + <decimal name="MDEntryPx" id="270" presence="optional"> + <delta /> + </decimal> + <decimal name="MDEntrySize" id="271" presence="optional"> + <delta /> + </decimal> + <uInt32 name="MDEntryDate" id="272"> + <copy /> + </uInt32> + <uInt32 name="MDEntryTime" id="273"> + <copy /> + </uInt32> + <string name="TickDirection" id="274" presence="optional"> + <default /> + </string> + <!--1.4.1--> + <string name="QuoteCondition" id="276" presence="optional"> + <default /> + </string> + <string name="TradeCondition" id="277" presence="optional"> + <default /> + </string> + <string name="OpenCloseSettlFlag" id="286" presence="optional"> + <default /> + </string> + <uInt64 name="NoSharesIssued" id="7595" presence="optional"> + <default /> + </uInt64> + <string name="Currency" id="15" presence="optional" ><default/></string> + <string name="OrderID" id="37" presence="optional" ><default/></string> + <string name="TradeID" id="1003" presence="optional" ><default/></string> + <string name="MDEntryBuyer" id="288" presence="optional"> + <copy /> + </string> + <string name="MDEntrySeller" id="289" presence="optional"> + <copy /> + </string> + <uInt32 name="NumberOfOrders" id="346" presence="optional"> + <default /> + </uInt32> + <uInt32 name="MDEntryPositionNo" id="290" presence="optional"> + <increment /> + </uInt32> + <!--1.4.1 AggressorSide only used in GLOBEX--> + <!--1.4.1--> + <uInt32 name="PriceType" id="423" presence="optional"><default /></uInt32> + + <decimal name="NetChgPrevDay" id="451" presence="optional"><default /></decimal> + <!--1.4.1--> + <uInt32 name="SellerDays" id="287" presence="optional"><default/></uInt32> + <uInt32 name="SettlPriceType" id="731" presence="optional"><default/></uInt32> + <decimal name="TradeVolume" id="1020" presence="optional"><default/></decimal> + <uInt32 name="PriceLimitType" id="1306" presence="optional"><default/></uInt32> + <decimal name="LowLimitPrice" id="1148" presence="optional" ><default /></decimal> + <decimal name="HighLimitPrice" id="1149" presence="optional" ><default /></decimal> + <decimal name="TradingReferencePrice" id="1150" presence="optional" ><default /></decimal> + <!-- Stock-index related fields, like PercentageVar, aren't broadcast --> + <!-- Probe --> + <uInt64 name="MDEntryID" id="278" presence="optional"><default /></uInt64> + <uInt32 name="MDInsertDate" id="37016" presence="optional"><default /></uInt32> + </sequence> + </template> +</templates> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-09 18:52:06
|
Revision: 271 http://openfast.svn.sourceforge.net/openfast/?rev=271&view=rev Author: joshseidel Date: 2012-04-09 18:51:59 +0000 (Mon, 09 Apr 2012) Log Message: ----------- Merged the branch with the most recent version of trunk. Modified Paths: -------------- branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java branches/generics-cleanup/src/main/java/org/openfast/examples/OpenFastExample.java branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/Main.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java Added Paths: ----------- branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java branches/generics-cleanup/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java Property Changed: ---------------- branches/generics-cleanup/ Property changes on: branches/generics-cleanup ___________________________________________________________________ Added: svn:mergeinfo + /trunk:267-270 Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java 2012-04-09 18:51:59 UTC (rev 271) @@ -10,27 +10,29 @@ public class MessageBlockReaderFactory { final Variant variant; final int offset; + final boolean isMulticast; public MessageBlockReaderFactory() { - this(Variant.DEFAULT, 0); + this(Variant.DEFAULT, 0, true); } - public MessageBlockReaderFactory(final Variant variant, final int offset) { + public MessageBlockReaderFactory(final Variant variant, final int offset, boolean isMulticast) { this.variant = variant; this.offset = offset; + this.isMulticast = isMulticast; } public MessageBlockReader create() { - switch(variant) { - case CME: - return new CmeMessageBlockReader(); + if(Variant.CME == variant) + { + if(this.isMulticast) + return new CmeMessageBlockReader(); + else + return new CmeTcpReplayMessageBlockReader(); + } + return createDefault(); + } - case DEFAULT: - default: - return createDefault(); - } - } - MessageBlockReader createDefault() { if(offset <= 0) return MessageBlockReader.NULL; Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java 2012-04-09 18:51:59 UTC (rev 271) @@ -10,25 +10,27 @@ public class MessageBlockWriterFactory { final Variant variant; final int offset; + final boolean isMulticast; public MessageBlockWriterFactory() { - this(Variant.DEFAULT, 0); + this(Variant.DEFAULT, 0, true); } - public MessageBlockWriterFactory(final Variant variant, final int offset) { + public MessageBlockWriterFactory(final Variant variant, final int offset, boolean isMulticast) { this.variant = variant; this.offset = offset; + this.isMulticast = isMulticast; } public MessageBlockWriter create() { - switch(variant) { - case CME: - return new CmeMessageBlockWriter(); - - case DEFAULT: - default: - return createDefault(); - } + if(Variant.CME == variant) + { + if(this.isMulticast) + return new CmeMessageBlockWriter(); + else + return new CmeTcpReplayMessageBlockWriter(); + } + return createDefault(); } MessageBlockWriter createDefault() { Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/OpenFastExample.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/OpenFastExample.java 2012-04-09 18:51:59 UTC (rev 271) @@ -26,9 +26,20 @@ protected static final String READ_OFFSET_DESCRIPTION = "The number of leading bytes that should be discarded when reading each message."; protected static final String WRITE_OFFSET_DESCRIPTION = "The number of leading bytes that should be appended as padding when sending each message."; protected static final String VARIANT_DESCRIPTION = "Enable exchange-specific behavior. Valid values: CME"; + protected static final String RESET = "reset"; + protected static final String RESET_DESCRIPTION = "Enable reset of the encoder/decoder on every message."; public enum Variant { DEFAULT, CME } + public static boolean isMulticast(CommandLine cl) { + if (cl.hasOption(PROTOCOL)) { + if ("udp".equals(cl.getOptionValue(PROTOCOL))) { + return true; + } + } + return false; + } + protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { BasicParser parser = new BasicParser(); Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-04-09 18:51:59 UTC (rev 271) @@ -21,12 +21,14 @@ private final Endpoint endpoint; private final TemplateRegistry templateRegistry; protected final MessageBlockReaderFactory messageBlockReaderFactory; + protected final boolean shouldResetOnEveryMessage; public FastMessageConsumer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, new MessageBlockReaderFactory()); + this(endpoint, templatesFile, new MessageBlockReaderFactory(), false); } - public FastMessageConsumer(Endpoint endpoint, File templatesFile, MessageBlockReaderFactory messageBlockReaderFactory) { + public FastMessageConsumer(Endpoint endpoint, File templatesFile, + MessageBlockReaderFactory messageBlockReaderFactory, boolean shouldResetOnEveryMessage) { this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); loader.setLoadTemplateIdFromAuxId(true); @@ -37,6 +39,7 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.messageBlockReaderFactory = messageBlockReaderFactory; + this.shouldResetOnEveryMessage = shouldResetOnEveryMessage; } public void start() throws FastConnectionException, IOException { @@ -55,6 +58,9 @@ try { Message message = msgInStream.readMessage(); System.out.println(msgBlockReader.toString() + ' ' + message.toString()); + if(shouldResetOnEveryMessage) { + msgInStream.reset(); + } } catch(final FastException e) { System.err.println(e.getMessage()); Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java 2012-04-09 18:51:59 UTC (rev 271) @@ -26,6 +26,7 @@ options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("j", READ_OFFSET, true, READ_OFFSET_DESCRIPTION); options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); + options.addOption("d", RESET, false, RESET_DESCRIPTION); } /** @@ -45,10 +46,8 @@ String host = cl.hasOption(HOST) ? cl.getOptionValue(HOST) : "localhost"; String ifaddr = cl.hasOption(INTERFACE) ? cl.getOptionValue(INTERFACE) : null; - if (cl.hasOption(PROTOCOL)) { - if ("udp".equals(cl.getOptionValue(PROTOCOL))) { - endpoint = new MulticastClientEndpoint(port, host, ifaddr); - } + if(isMulticast(cl)) { + endpoint = new MulticastClientEndpoint(port, host, ifaddr); } if (endpoint == null) { endpoint = new TcpEndpoint(host, port); @@ -65,8 +64,9 @@ final int readOffset = cl.hasOption(READ_OFFSET) ? getInteger(cl, READ_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; - final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset); - FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory); + final boolean shouldResetOnEveryMessage = (cl.hasOption(RESET) || (Variant.CME == variant)); + final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset, isMulticast(cl)); + FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory, shouldResetOnEveryMessage); try { consumer.start(); Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-04-09 18:51:59 UTC (rev 271) @@ -28,12 +28,14 @@ protected List<MessageOutputStream> connections = new ArrayList<MessageOutputStream>(); protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); protected final MessageBlockWriterFactory messageBlockWriterFactory; + protected final boolean shouldResetOnEveryMessage; public FastMessageProducer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, new MessageBlockWriterFactory()); + this(endpoint, templatesFile, new MessageBlockWriterFactory(), false); } - public FastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) { + public FastMessageProducer(Endpoint endpoint, File templatesFile, + MessageBlockWriterFactory messageBlockWriterFactory, boolean shouldResetOnEveryMessage) { Global.setErrorHandler(ErrorHandler.NULL); this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); @@ -45,7 +47,8 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.converter.setTemplateRegistry(this.templateRegistry); - this.messageBlockWriterFactory = messageBlockWriterFactory; + this.messageBlockWriterFactory = messageBlockWriterFactory; + this.shouldResetOnEveryMessage = shouldResetOnEveryMessage; } public void encode(File xmlDataFile) throws FastConnectionException, IOException { @@ -76,6 +79,9 @@ for (Message message : messages) { for(MessageOutputStream out : msgOutputStreams) { out.writeMessage(message); + if(shouldResetOnEveryMessage) { + out.reset(); + } } } } Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/producer/Main.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/producer/Main.java 2012-04-09 18:51:59 UTC (rev 271) @@ -26,17 +26,9 @@ options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); options.addOption("k", WRITE_OFFSET, true, WRITE_OFFSET_DESCRIPTION); options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); + options.addOption("d", RESET, false, RESET_DESCRIPTION); } - - public static boolean isMulticast(CommandLine cl) { - if (cl.hasOption(PROTOCOL)) { - if ("udp".equals(cl.getOptionValue(PROTOCOL))) { - return true; - } - } - return false; - } - + /** * @param args */ @@ -77,11 +69,12 @@ try { final int writeOffset = cl.hasOption(WRITE_OFFSET) ? getInteger(cl, WRITE_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; - final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset); + final boolean shouldResetOnEveryMessage = (cl.hasOption(RESET) || (Variant.CME == variant)); + final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset, isMulticast(cl)); FastMessageProducer producer = isMulticast(cl) - ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory) - : new FastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory); + ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory, shouldResetOnEveryMessage) + : new FastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory, shouldResetOnEveryMessage); producer.start(); producer.encode(xmlDataFile); Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-04-06 14:11:18 UTC (rev 270) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-04-09 18:51:59 UTC (rev 271) @@ -17,16 +17,17 @@ private MessageOutputStream out; public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile) throws IOException, FastConnectionException { - this(endpoint, templatesFile, new MessageBlockWriterFactory()); + this(endpoint, templatesFile, new MessageBlockWriterFactory(), false); } - public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) throws IOException, FastConnectionException { - super(endpoint, templatesFile, messageBlockWriterFactory); + public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory, + boolean shouldResetOnEveryMessage) throws IOException, FastConnectionException { + super(endpoint, templatesFile, messageBlockWriterFactory, shouldResetOnEveryMessage); Context context = new Context(); context.setErrorHandler(ErrorHandler.NULL); context.setTemplateRegistry(templateRegistry); out = new MessageOutputStream(endpoint.connect().getOutputStream(), context); - out.setBlockWriter(messageBlockWriterFactory.create()); + out.setBlockWriter(messageBlockWriterFactory.create()); } protected void publish(List<Message> messages, List<MessageOutputStream> msgOutputStreams) { @@ -36,7 +37,9 @@ for(Message message : messages) { out.writeMessage(message, true); } - out.reset(); + if(shouldResetOnEveryMessage) { + out.reset(); + } } public void start() { Copied: branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java (from rev 270, trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java) =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java (rev 0) +++ branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java 2012-04-09 18:51:59 UTC (rev 271) @@ -0,0 +1,38 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import org.openfast.Message; +import org.openfast.MessageBlockReader; +import org.openfast.template.type.codec.TypeCodec; + +public class CmeTcpReplayMessageBlockReader implements MessageBlockReader { + CmeMessageBlockReader preambleReader = new CmeMessageBlockReader(); + long lengthIndicator = 0; + + public void messageRead(InputStream in, Message message) { + } + + public boolean readBlock(InputStream in) { + lengthIndicator = TypeCodec.UINT.decode(in).toLong(); + return preambleReader.readBlock(in); + } + + public long getLastLengthIndicator() { + return lengthIndicator; + } + + public long getLastSeqNum() { + return preambleReader.getLastSeqNum(); + } + + public long getLastSubId() { + return preambleReader.getLastSubId(); + } + + @Override + public String toString() { + return "(" + getLastLengthIndicator() + "|" + getLastSeqNum() + "|" + getLastSubId() + ")"; + } +} + Copied: branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java (from rev 270, trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java) =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java (rev 0) +++ branches/generics-cleanup/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java 2012-04-09 18:51:59 UTC (rev 271) @@ -0,0 +1,30 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.DataOutputStream; +import org.openfast.IntegerValue; +import org.openfast.Message; +import org.openfast.MessageBlockWriter; +import org.openfast.template.type.codec.TypeCodec; + +/** + * Write the CME "length indicator" and "preamble" headers. + * The sub-channel identifier (the fifth byte) is always (int)0. + */ +public class CmeTcpReplayMessageBlockWriter implements MessageBlockWriter { + CmeMessageBlockWriter preambleWriter = new CmeMessageBlockWriter(); + + public void writeBlockLength(OutputStream out, Message message, byte[] encodedMessage) throws IOException { + out.write(encodeTotalLen(encodedMessage.length, CmeConstants.PREAMBLE_LEN)); + preambleWriter.writeBlockLength(out, message, encodedMessage); + } + + final static byte[] encodeTotalLen(int encodedMessageLen, int preambleLen) { + byte [] result = TypeCodec.UINT.encodeValue(new IntegerValue(preambleLen + encodedMessageLen)); + final int endIndex = result.length - 1; + result[endIndex] = (byte)(result[endIndex] | (byte)0x80); // set stop bit + return result; + } +} Copied: branches/generics-cleanup/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java (from rev 270, trunk/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java) =================================================================== --- branches/generics-cleanup/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java (rev 0) +++ branches/generics-cleanup/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java 2012-04-09 18:51:59 UTC (rev 271) @@ -0,0 +1,89 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +package org.openfast.impl; + +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; +import junit.framework.TestCase; +import org.openfast.Message; +import org.openfast.ScalarValue; +import org.openfast.template.Field; +import org.openfast.template.MessageTemplate; +import org.openfast.template.Scalar; +import org.openfast.template.operator.Operator; +import org.openfast.template.type.Type; + +public class CmeTcpReplayMessageBlockReaderWriterTest extends TestCase { + final static byte[] encodedMessageWithHeader = { + (byte)0x91, // "Length Indicator" (17) + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, // "Preamble" (seqNo=1, subId=0) + (byte)0xc0, (byte)0x83, (byte)0x81, (byte)0x23, // FAST message... + (byte)0x5c, (byte)0x5e, (byte)0x0d, (byte)0x5f, // FAST message... + (byte)0x03, (byte)0x60, (byte)0xc4, (byte)0x82 // FAST message. + }; + + final byte[] encodedMessageSansHeader = { + (byte)0xc0, (byte)0x83, (byte)0x81, (byte)0x23, + (byte)0x5c, (byte)0x5e, (byte)0x0d, (byte)0x5f, + (byte)0x03, (byte)0x60, (byte)0xc4, (byte)0x82 + }; + + final static MessageTemplate msgTemplate = new MessageTemplate("", + new Field[] { + new Scalar("MsgSeqNum", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false) + } + ); + + public void testEncodeTotalLen() { + byte[] encoded = CmeTcpReplayMessageBlockWriter.encodeTotalLen(encodedMessageSansHeader.length, CmeConstants.PREAMBLE_LEN); + assertEquals(encodedMessageWithHeader[0], encoded[0]); + } + + public void testRead() { + CmeTcpReplayMessageBlockReader reader = new CmeTcpReplayMessageBlockReader(); + assertTrue(reader.readBlock(new ByteArrayInputStream(encodedMessageWithHeader))); + assertEquals(17, reader.getLastLengthIndicator()); + assertEquals(1, reader.getLastSeqNum()); + assertEquals(0, reader.getLastSubId()); + } + + public void testWriteThenRead() throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + Message msg = new Message(msgTemplate); + msg.setLong("MsgSeqNum", 1L); + + CmeTcpReplayMessageBlockWriter writer = new CmeTcpReplayMessageBlockWriter(); + writer.writeBlockLength(out, msg, encodedMessageSansHeader); + + CmeTcpReplayMessageBlockReader reader = new CmeTcpReplayMessageBlockReader(); + assertTrue(reader.readBlock(new ByteArrayInputStream(out.toByteArray()))); + assertEquals(encodedMessageSansHeader.length + CmeConstants.PREAMBLE_LEN , reader.getLastLengthIndicator()); + assertEquals(msg.getLong("MsgSeqNum"), reader.getLastSeqNum()); + assertEquals(0, reader.getLastSubId()); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-04-06 14:11:25
|
Revision: 270 http://openfast.svn.sourceforge.net/openfast/?rev=270&view=rev Author: gatny Date: 2012-04-06 14:11:18 +0000 (Fri, 06 Apr 2012) Log Message: ----------- New commandline flag to optionally enable resetting of encoder/decoder on every message. Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/OpenFastExample.java trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java trunk/src/main/java/org/openfast/examples/consumer/Main.java trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java trunk/src/main/java/org/openfast/examples/producer/Main.java trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java Modified: trunk/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2012-04-06 14:11:18 UTC (rev 270) @@ -26,6 +26,8 @@ protected static final String READ_OFFSET_DESCRIPTION = "The number of leading bytes that should be discarded when reading each message."; protected static final String WRITE_OFFSET_DESCRIPTION = "The number of leading bytes that should be appended as padding when sending each message."; protected static final String VARIANT_DESCRIPTION = "Enable exchange-specific behavior. Valid values: CME"; + protected static final String RESET = "reset"; + protected static final String RESET_DESCRIPTION = "Enable reset of the encoder/decoder on every message."; public enum Variant { DEFAULT, CME } @@ -37,7 +39,7 @@ } return false; } - + protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { BasicParser parser = new BasicParser(); Modified: trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-04-06 14:11:18 UTC (rev 270) @@ -21,12 +21,14 @@ private final Endpoint endpoint; private final TemplateRegistry templateRegistry; protected final MessageBlockReaderFactory messageBlockReaderFactory; + protected final boolean shouldResetOnEveryMessage; public FastMessageConsumer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, new MessageBlockReaderFactory()); + this(endpoint, templatesFile, new MessageBlockReaderFactory(), false); } - public FastMessageConsumer(Endpoint endpoint, File templatesFile, MessageBlockReaderFactory messageBlockReaderFactory) { + public FastMessageConsumer(Endpoint endpoint, File templatesFile, + MessageBlockReaderFactory messageBlockReaderFactory, boolean shouldResetOnEveryMessage) { this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); loader.setLoadTemplateIdFromAuxId(true); @@ -37,6 +39,7 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.messageBlockReaderFactory = messageBlockReaderFactory; + this.shouldResetOnEveryMessage = shouldResetOnEveryMessage; } public void start() throws FastConnectionException, IOException { @@ -55,6 +58,9 @@ try { Message message = msgInStream.readMessage(); System.out.println(msgBlockReader.toString() + ' ' + message.toString()); + if(shouldResetOnEveryMessage) { + msgInStream.reset(); + } } catch(final FastException e) { System.err.println(e.getMessage()); Modified: trunk/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/Main.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/consumer/Main.java 2012-04-06 14:11:18 UTC (rev 270) @@ -26,6 +26,7 @@ options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("j", READ_OFFSET, true, READ_OFFSET_DESCRIPTION); options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); + options.addOption("d", RESET, false, RESET_DESCRIPTION); } /** @@ -63,8 +64,9 @@ final int readOffset = cl.hasOption(READ_OFFSET) ? getInteger(cl, READ_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; + final boolean shouldResetOnEveryMessage = (cl.hasOption(RESET) || (Variant.CME == variant)); final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset, isMulticast(cl)); - FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory); + FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory, shouldResetOnEveryMessage); try { consumer.start(); Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-04-06 14:11:18 UTC (rev 270) @@ -29,12 +29,14 @@ protected List connections = new ArrayList(); protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); protected final MessageBlockWriterFactory messageBlockWriterFactory; + protected final boolean shouldResetOnEveryMessage; public FastMessageProducer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, new MessageBlockWriterFactory()); + this(endpoint, templatesFile, new MessageBlockWriterFactory(), false); } - public FastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) { + public FastMessageProducer(Endpoint endpoint, File templatesFile, + MessageBlockWriterFactory messageBlockWriterFactory, boolean shouldResetOnEveryMessage) { Global.setErrorHandler(ErrorHandler.NULL); this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); @@ -46,7 +48,8 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.converter.setTemplateRegistry(this.templateRegistry); - this.messageBlockWriterFactory = messageBlockWriterFactory; + this.messageBlockWriterFactory = messageBlockWriterFactory; + this.shouldResetOnEveryMessage = shouldResetOnEveryMessage; } public void encode(File xmlDataFile) throws FastConnectionException, IOException { @@ -79,6 +82,9 @@ for (int j = 0; j < msgOutputStreams.size(); ++j) { MessageOutputStream out = (MessageOutputStream)msgOutputStreams.get(j); out.writeMessage(message); + if(shouldResetOnEveryMessage) { + out.reset(); + } } } } Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2012-04-06 14:11:18 UTC (rev 270) @@ -26,6 +26,7 @@ options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); options.addOption("k", WRITE_OFFSET, true, WRITE_OFFSET_DESCRIPTION); options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); + options.addOption("d", RESET, false, RESET_DESCRIPTION); } /** @@ -68,11 +69,12 @@ try { final int writeOffset = cl.hasOption(WRITE_OFFSET) ? getInteger(cl, WRITE_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; + final boolean shouldResetOnEveryMessage = (cl.hasOption(RESET) || (Variant.CME == variant)); final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset, isMulticast(cl)); FastMessageProducer producer = isMulticast(cl) - ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory) - : new FastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory); + ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory, shouldResetOnEveryMessage) + : new FastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory, shouldResetOnEveryMessage); producer.start(); producer.encode(xmlDataFile); Modified: trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-03-29 19:06:00 UTC (rev 269) +++ trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-04-06 14:11:18 UTC (rev 270) @@ -19,16 +19,17 @@ private MessageOutputStream out; public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile) throws IOException, FastConnectionException { - this(endpoint, templatesFile, new MessageBlockWriterFactory()); + this(endpoint, templatesFile, new MessageBlockWriterFactory(), false); } - public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) throws IOException, FastConnectionException { - super(endpoint, templatesFile, messageBlockWriterFactory); + public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory, + boolean shouldResetOnEveryMessage) throws IOException, FastConnectionException { + super(endpoint, templatesFile, messageBlockWriterFactory, shouldResetOnEveryMessage); Context context = new Context(); context.setErrorHandler(ErrorHandler.NULL); context.setTemplateRegistry(templateRegistry); out = new MessageOutputStream(endpoint.connect().getOutputStream(), context); - out.setBlockWriter(messageBlockWriterFactory.create()); + out.setBlockWriter(messageBlockWriterFactory.create()); } protected void publish(List messages, List msgOutputStreams) { @@ -38,7 +39,9 @@ for(int i = 0; i < messages.size(); ++i) { out.writeMessage((Message)messages.get(i), true); } - out.reset(); + if(shouldResetOnEveryMessage) { + out.reset(); + } } public void start() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-03-29 19:06:07
|
Revision: 269 http://openfast.svn.sourceforge.net/openfast/?rev=269&view=rev Author: gatny Date: 2012-03-29 19:06:00 +0000 (Thu, 29 Mar 2012) Log Message: ----------- Added message block reader and writer that can handle the variable-length "Length Indicator" header on messages from the CME TCP Replay feed. Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java trunk/src/main/java/org/openfast/examples/OpenFastExample.java trunk/src/main/java/org/openfast/examples/consumer/Main.java trunk/src/main/java/org/openfast/examples/producer/Main.java Added Paths: ----------- trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java trunk/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java Modified: trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java =================================================================== --- trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java 2012-02-21 16:07:21 UTC (rev 268) +++ trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java 2012-03-29 19:06:00 UTC (rev 269) @@ -10,27 +10,29 @@ public class MessageBlockReaderFactory { final Variant variant; final int offset; + final boolean isMulticast; public MessageBlockReaderFactory() { - this(Variant.DEFAULT, 0); + this(Variant.DEFAULT, 0, true); } - public MessageBlockReaderFactory(final Variant variant, final int offset) { + public MessageBlockReaderFactory(final Variant variant, final int offset, boolean isMulticast) { this.variant = variant; this.offset = offset; + this.isMulticast = isMulticast; } public MessageBlockReader create() { - switch(variant) { - case CME: - return new CmeMessageBlockReader(); + if(Variant.CME == variant) + { + if(this.isMulticast) + return new CmeMessageBlockReader(); + else + return new CmeTcpReplayMessageBlockReader(); + } + return createDefault(); + } - case DEFAULT: - default: - return createDefault(); - } - } - MessageBlockReader createDefault() { if(offset <= 0) return MessageBlockReader.NULL; Modified: trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java =================================================================== --- trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java 2012-02-21 16:07:21 UTC (rev 268) +++ trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java 2012-03-29 19:06:00 UTC (rev 269) @@ -10,25 +10,27 @@ public class MessageBlockWriterFactory { final Variant variant; final int offset; + final boolean isMulticast; public MessageBlockWriterFactory() { - this(Variant.DEFAULT, 0); + this(Variant.DEFAULT, 0, true); } - public MessageBlockWriterFactory(final Variant variant, final int offset) { + public MessageBlockWriterFactory(final Variant variant, final int offset, boolean isMulticast) { this.variant = variant; this.offset = offset; + this.isMulticast = isMulticast; } public MessageBlockWriter create() { - switch(variant) { - case CME: - return new CmeMessageBlockWriter(); - - case DEFAULT: - default: - return createDefault(); - } + if(Variant.CME == variant) + { + if(this.isMulticast) + return new CmeMessageBlockWriter(); + else + return new CmeTcpReplayMessageBlockWriter(); + } + return createDefault(); } MessageBlockWriter createDefault() { Modified: trunk/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2012-02-21 16:07:21 UTC (rev 268) +++ trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2012-03-29 19:06:00 UTC (rev 269) @@ -29,6 +29,15 @@ public enum Variant { DEFAULT, CME } + public static boolean isMulticast(CommandLine cl) { + if (cl.hasOption(PROTOCOL)) { + if ("udp".equals(cl.getOptionValue(PROTOCOL))) { + return true; + } + } + return false; + } + protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { BasicParser parser = new BasicParser(); Modified: trunk/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/Main.java 2012-02-21 16:07:21 UTC (rev 268) +++ trunk/src/main/java/org/openfast/examples/consumer/Main.java 2012-03-29 19:06:00 UTC (rev 269) @@ -45,10 +45,8 @@ String host = cl.hasOption(HOST) ? cl.getOptionValue(HOST) : "localhost"; String ifaddr = cl.hasOption(INTERFACE) ? cl.getOptionValue(INTERFACE) : null; - if (cl.hasOption(PROTOCOL)) { - if ("udp".equals(cl.getOptionValue(PROTOCOL))) { - endpoint = new MulticastClientEndpoint(port, host, ifaddr); - } + if(isMulticast(cl)) { + endpoint = new MulticastClientEndpoint(port, host, ifaddr); } if (endpoint == null) { endpoint = new TcpEndpoint(host, port); @@ -65,7 +63,7 @@ final int readOffset = cl.hasOption(READ_OFFSET) ? getInteger(cl, READ_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; - final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset); + final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset, isMulticast(cl)); FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory); try { Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2012-02-21 16:07:21 UTC (rev 268) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2012-03-29 19:06:00 UTC (rev 269) @@ -27,16 +27,7 @@ options.addOption("k", WRITE_OFFSET, true, WRITE_OFFSET_DESCRIPTION); options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); } - - public static boolean isMulticast(CommandLine cl) { - if (cl.hasOption(PROTOCOL)) { - if ("udp".equals(cl.getOptionValue(PROTOCOL))) { - return true; - } - } - return false; - } - + /** * @param args */ @@ -77,7 +68,7 @@ try { final int writeOffset = cl.hasOption(WRITE_OFFSET) ? getInteger(cl, WRITE_OFFSET) : 0; final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; - final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset); + final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset, isMulticast(cl)); FastMessageProducer producer = isMulticast(cl) ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory) Added: trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java (rev 0) +++ trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockReader.java 2012-03-29 19:06:00 UTC (rev 269) @@ -0,0 +1,38 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import org.openfast.Message; +import org.openfast.MessageBlockReader; +import org.openfast.template.type.codec.TypeCodec; + +public class CmeTcpReplayMessageBlockReader implements MessageBlockReader { + CmeMessageBlockReader preambleReader = new CmeMessageBlockReader(); + long lengthIndicator = 0; + + public void messageRead(InputStream in, Message message) { + } + + public boolean readBlock(InputStream in) { + lengthIndicator = TypeCodec.UINT.decode(in).toLong(); + return preambleReader.readBlock(in); + } + + public long getLastLengthIndicator() { + return lengthIndicator; + } + + public long getLastSeqNum() { + return preambleReader.getLastSeqNum(); + } + + public long getLastSubId() { + return preambleReader.getLastSubId(); + } + + @Override + public String toString() { + return "(" + getLastLengthIndicator() + "|" + getLastSeqNum() + "|" + getLastSubId() + ")"; + } +} + Added: trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java (rev 0) +++ trunk/src/main/java/org/openfast/impl/CmeTcpReplayMessageBlockWriter.java 2012-03-29 19:06:00 UTC (rev 269) @@ -0,0 +1,30 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.DataOutputStream; +import org.openfast.IntegerValue; +import org.openfast.Message; +import org.openfast.MessageBlockWriter; +import org.openfast.template.type.codec.TypeCodec; + +/** + * Write the CME "length indicator" and "preamble" headers. + * The sub-channel identifier (the fifth byte) is always (int)0. + */ +public class CmeTcpReplayMessageBlockWriter implements MessageBlockWriter { + CmeMessageBlockWriter preambleWriter = new CmeMessageBlockWriter(); + + public void writeBlockLength(OutputStream out, Message message, byte[] encodedMessage) throws IOException { + out.write(encodeTotalLen(encodedMessage.length, CmeConstants.PREAMBLE_LEN)); + preambleWriter.writeBlockLength(out, message, encodedMessage); + } + + final static byte[] encodeTotalLen(int encodedMessageLen, int preambleLen) { + byte [] result = TypeCodec.UINT.encodeValue(new IntegerValue(preambleLen + encodedMessageLen)); + final int endIndex = result.length - 1; + result[endIndex] = (byte)(result[endIndex] | (byte)0x80); // set stop bit + return result; + } +} Added: trunk/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java =================================================================== --- trunk/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java (rev 0) +++ trunk/src/test/java/org/openfast/impl/CmeTcpReplayMessageBlockReaderWriterTest.java 2012-03-29 19:06:00 UTC (rev 269) @@ -0,0 +1,89 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +package org.openfast.impl; + +import java.io.ByteArrayOutputStream; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; +import junit.framework.TestCase; +import org.openfast.Message; +import org.openfast.ScalarValue; +import org.openfast.template.Field; +import org.openfast.template.MessageTemplate; +import org.openfast.template.Scalar; +import org.openfast.template.operator.Operator; +import org.openfast.template.type.Type; + +public class CmeTcpReplayMessageBlockReaderWriterTest extends TestCase { + final static byte[] encodedMessageWithHeader = { + (byte)0x91, // "Length Indicator" (17) + (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, // "Preamble" (seqNo=1, subId=0) + (byte)0xc0, (byte)0x83, (byte)0x81, (byte)0x23, // FAST message... + (byte)0x5c, (byte)0x5e, (byte)0x0d, (byte)0x5f, // FAST message... + (byte)0x03, (byte)0x60, (byte)0xc4, (byte)0x82 // FAST message. + }; + + final byte[] encodedMessageSansHeader = { + (byte)0xc0, (byte)0x83, (byte)0x81, (byte)0x23, + (byte)0x5c, (byte)0x5e, (byte)0x0d, (byte)0x5f, + (byte)0x03, (byte)0x60, (byte)0xc4, (byte)0x82 + }; + + final static MessageTemplate msgTemplate = new MessageTemplate("", + new Field[] { + new Scalar("MsgSeqNum", Type.U32, Operator.COPY, ScalarValue.UNDEFINED, false) + } + ); + + public void testEncodeTotalLen() { + byte[] encoded = CmeTcpReplayMessageBlockWriter.encodeTotalLen(encodedMessageSansHeader.length, CmeConstants.PREAMBLE_LEN); + assertEquals(encodedMessageWithHeader[0], encoded[0]); + } + + public void testRead() { + CmeTcpReplayMessageBlockReader reader = new CmeTcpReplayMessageBlockReader(); + assertTrue(reader.readBlock(new ByteArrayInputStream(encodedMessageWithHeader))); + assertEquals(17, reader.getLastLengthIndicator()); + assertEquals(1, reader.getLastSeqNum()); + assertEquals(0, reader.getLastSubId()); + } + + public void testWriteThenRead() throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + Message msg = new Message(msgTemplate); + msg.setLong("MsgSeqNum", 1L); + + CmeTcpReplayMessageBlockWriter writer = new CmeTcpReplayMessageBlockWriter(); + writer.writeBlockLength(out, msg, encodedMessageSansHeader); + + CmeTcpReplayMessageBlockReader reader = new CmeTcpReplayMessageBlockReader(); + assertTrue(reader.readBlock(new ByteArrayInputStream(out.toByteArray()))); + assertEquals(encodedMessageSansHeader.length + CmeConstants.PREAMBLE_LEN , reader.getLastLengthIndicator()); + assertEquals(msg.getLong("MsgSeqNum"), reader.getLastSeqNum()); + assertEquals(0, reader.getLastSubId()); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-02-21 16:07:35
|
Revision: 268 http://openfast.svn.sourceforge.net/openfast/?rev=268&view=rev Author: joshseidel Date: 2012-02-21 16:07:21 +0000 (Tue, 21 Feb 2012) Log Message: ----------- Commit the updates to adding generics and some clean up and optimization to OpenFAST. All changes have been tested with unit tests. Modified Paths: -------------- branches/generics-cleanup/license.txt branches/generics-cleanup/pom.xml branches/generics-cleanup/src/main/java/org/openfast/ApplicationTypeDictionary.java branches/generics-cleanup/src/main/java/org/openfast/BitVector.java branches/generics-cleanup/src/main/java/org/openfast/BitVectorBuilder.java branches/generics-cleanup/src/main/java/org/openfast/ByteUtil.java branches/generics-cleanup/src/main/java/org/openfast/ByteVectorValue.java branches/generics-cleanup/src/main/java/org/openfast/Context.java branches/generics-cleanup/src/main/java/org/openfast/GlobalDictionary.java branches/generics-cleanup/src/main/java/org/openfast/GroupValue.java branches/generics-cleanup/src/main/java/org/openfast/Message.java branches/generics-cleanup/src/main/java/org/openfast/MessageInputStream.java branches/generics-cleanup/src/main/java/org/openfast/MessageOutputStream.java branches/generics-cleanup/src/main/java/org/openfast/Node.java branches/generics-cleanup/src/main/java/org/openfast/QName.java branches/generics-cleanup/src/main/java/org/openfast/SequenceValue.java branches/generics-cleanup/src/main/java/org/openfast/SimpleNode.java branches/generics-cleanup/src/main/java/org/openfast/TemplateDictionary.java branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java branches/generics-cleanup/src/main/java/org/openfast/codec/FastEncoder.java branches/generics-cleanup/src/main/java/org/openfast/debug/BasicEncodeTrace.java branches/generics-cleanup/src/main/java/org/openfast/error/ErrorCode.java branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/FastMessageDecoder.java branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/Main.java branches/generics-cleanup/src/main/java/org/openfast/examples/interpret/FastMessageInterpreter.java branches/generics-cleanup/src/main/java/org/openfast/examples/performance/HexadecimalInputStream.java branches/generics-cleanup/src/main/java/org/openfast/examples/performance/Main.java branches/generics-cleanup/src/main/java/org/openfast/examples/performance/PerformanceResult.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java branches/generics-cleanup/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java branches/generics-cleanup/src/main/java/org/openfast/examples/scp10/ScpMessageProducer.java branches/generics-cleanup/src/main/java/org/openfast/examples/tmplexch/TemplateExchangeDefinitionDecoder.java branches/generics-cleanup/src/main/java/org/openfast/examples/tmplexch/TemplateExchangeDefinitionEncoder.java branches/generics-cleanup/src/main/java/org/openfast/examples/util/FastMessageConsumer.java branches/generics-cleanup/src/main/java/org/openfast/examples/util/FastMessageReader.java branches/generics-cleanup/src/main/java/org/openfast/examples/xml/FastToXmlConverter.java branches/generics-cleanup/src/main/java/org/openfast/examples/xml/XmlToFastConverter.java branches/generics-cleanup/src/main/java/org/openfast/extensions/MapFieldParser.java branches/generics-cleanup/src/main/java/org/openfast/extensions/MapScalar.java branches/generics-cleanup/src/main/java/org/openfast/impl/CmeMessageBlockWriter.java branches/generics-cleanup/src/main/java/org/openfast/logging/FileFastMessageLogger.java branches/generics-cleanup/src/main/java/org/openfast/session/LocalEndpoint.java branches/generics-cleanup/src/main/java/org/openfast/session/Session.java branches/generics-cleanup/src/main/java/org/openfast/session/SessionControlProtocol_1_1.java branches/generics-cleanup/src/main/java/org/openfast/session/multicast/MulticastClientEndpoint.java branches/generics-cleanup/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java branches/generics-cleanup/src/main/java/org/openfast/session/multicast/MulticastServerEndpoint.java branches/generics-cleanup/src/main/java/org/openfast/session/template/exchange/AbstractFieldInstructionConverter.java branches/generics-cleanup/src/main/java/org/openfast/session/template/exchange/ConversionContext.java branches/generics-cleanup/src/main/java/org/openfast/session/template/exchange/GroupConverter.java branches/generics-cleanup/src/main/java/org/openfast/session/template/exchange/ScalarConverter.java branches/generics-cleanup/src/main/java/org/openfast/template/AbstractTemplateRegistry.java branches/generics-cleanup/src/main/java/org/openfast/template/BasicTemplateRegistry.java branches/generics-cleanup/src/main/java/org/openfast/template/ComposedScalar.java branches/generics-cleanup/src/main/java/org/openfast/template/DynamicTemplateReference.java branches/generics-cleanup/src/main/java/org/openfast/template/Field.java branches/generics-cleanup/src/main/java/org/openfast/template/Group.java branches/generics-cleanup/src/main/java/org/openfast/template/LongValue.java branches/generics-cleanup/src/main/java/org/openfast/template/MessageTemplate.java branches/generics-cleanup/src/main/java/org/openfast/template/NullTemplateRegistry.java branches/generics-cleanup/src/main/java/org/openfast/template/Scalar.java branches/generics-cleanup/src/main/java/org/openfast/template/Sequence.java branches/generics-cleanup/src/main/java/org/openfast/template/StaticTemplateReference.java branches/generics-cleanup/src/main/java/org/openfast/template/TemplateRegistry.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/AbstractFieldParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/ComposedDecimalParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/GroupParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/ParsingContext.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/ScalarParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/SequenceParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/TemplateParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/TemplateRefParser.java branches/generics-cleanup/src/main/java/org/openfast/template/loader/XMLMessageTemplateLoader.java branches/generics-cleanup/src/main/java/org/openfast/template/operator/CopyOperatorCodec.java branches/generics-cleanup/src/main/java/org/openfast/template/operator/DeltaDecimalOperatorCodec.java branches/generics-cleanup/src/main/java/org/openfast/template/operator/Operator.java branches/generics-cleanup/src/main/java/org/openfast/template/operator/OperatorCodec.java branches/generics-cleanup/src/main/java/org/openfast/template/operator/TailOperatorCodec.java branches/generics-cleanup/src/main/java/org/openfast/template/serializer/AbstractFieldSerializer.java branches/generics-cleanup/src/main/java/org/openfast/template/serializer/SerializerRegistry.java branches/generics-cleanup/src/main/java/org/openfast/template/serializer/TemplateSerializer.java branches/generics-cleanup/src/main/java/org/openfast/template/serializer/XMLMessageTemplateSerializer.java branches/generics-cleanup/src/main/java/org/openfast/template/type/Type.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/ByteVectorType.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/NullableByteVector.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/SignedInteger.java branches/generics-cleanup/src/main/java/org/openfast/template/type/codec/UnsignedInteger.java branches/generics-cleanup/src/main/java/org/openfast/util/ArrayIterator.java branches/generics-cleanup/src/main/java/org/openfast/util/IntegerMap.java branches/generics-cleanup/src/main/java/org/openfast/util/Key.java branches/generics-cleanup/src/main/java/org/openfast/util/SimpleIntegerMap.java branches/generics-cleanup/src/main/java/org/openfast/util/UnboundedCache.java branches/generics-cleanup/src/main/java/org/openfast/util/Util.java branches/generics-cleanup/src/main/java/org/openfast/util/XmlWriter.java branches/generics-cleanup/src/test/java/org/openfast/acceptance/EncodingDecodingAcceptanceTest.java branches/generics-cleanup/src/test/java/org/openfast/impl/CmeMessageBlockReaderWriterTest.java branches/generics-cleanup/src/test/java/org/openfast/session/SCP_1_1_Test.java branches/generics-cleanup/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java branches/generics-cleanup/src/test/java/org/openfast/session/template/exchange/VariableLengthInstructionConverterTest.java branches/generics-cleanup/src/test/java/org/openfast/submitted/TemplateDictionaryScopeTest.java branches/generics-cleanup/src/test/java/org/openfast/template/BasicTemplateRegistryTest.java branches/generics-cleanup/src/test/java/org/openfast/template/loader/Array.java branches/generics-cleanup/src/test/java/org/openfast/template/loader/TemplateRefParserTest.java branches/generics-cleanup/src/test/java/org/openfast/template/serializer/ScalarSerializerTest.java branches/generics-cleanup/src/test/java/org/openfast/test/TestUtil.java branches/generics-cleanup/src/test/java/org/openfast/util/ArrayIteratorTest.java branches/generics-cleanup/src/test/java/org/openfast/util/SimpleIntegerMapTest.java branches/generics-cleanup/src/test/java/org/openfast/util/UtilTest.java Modified: branches/generics-cleanup/license.txt =================================================================== --- branches/generics-cleanup/license.txt 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/license.txt 2012-02-21 16:07:21 UTC (rev 268) @@ -15,4 +15,5 @@ are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> \ No newline at end of file + Craig Otis <co...@la...> + Josh Seidel <jos...@ve...> \ No newline at end of file Modified: branches/generics-cleanup/pom.xml =================================================================== --- branches/generics-cleanup/pom.xml 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/pom.xml 2012-02-21 16:07:21 UTC (rev 268) @@ -40,6 +40,17 @@ </roles> <timezone>-5</timezone> </developer> + <developer> + <name>Josh Seidel</name> + <organization>Veritian</organization> + <organizationUrl> + http://www.veritian.net/ + </organizationUrl> + <roles> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> </developers> <contributors> Modified: branches/generics-cleanup/src/main/java/org/openfast/ApplicationTypeDictionary.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/ApplicationTypeDictionary.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/ApplicationTypeDictionary.java 2012-02-21 16:07:21 UTC (rev 268) @@ -28,39 +28,39 @@ public class ApplicationTypeDictionary implements Dictionary { - private Map dictionary = new HashMap(); + private Map<QName, Map<QName, ScalarValue>> dictionary = new HashMap<QName, Map<QName, ScalarValue>>(); public ScalarValue lookup(Group template, QName key, QName applicationType) { if (dictionary.containsKey(template.getTypeReference())) { - Map applicationTypeMap = (Map) dictionary.get(template.getTypeReference()); + Map<QName, ScalarValue> applicationTypeMap = dictionary.get(template.getTypeReference()); if (applicationTypeMap.containsKey(key)) - return (ScalarValue) applicationTypeMap.get(key); + return applicationTypeMap.get(key); } return ScalarValue.UNDEFINED; } public void reset() { - dictionary = new HashMap(); + dictionary = new HashMap<QName, Map<QName, ScalarValue>>(); } public void store(Group group, QName applicationType, QName key, ScalarValue value) { if (!dictionary.containsKey(group.getTypeReference())) { - dictionary.put(group.getTypeReference(), new HashMap()); + dictionary.put(group.getTypeReference(), new HashMap<QName, ScalarValue>()); } - Map applicationTypeDictionary = (Map) dictionary.get(group.getTypeReference()); + Map<QName, ScalarValue> applicationTypeDictionary = dictionary.get(group.getTypeReference()); applicationTypeDictionary.put(key, value); } public String toString() { StringBuilder builder = new StringBuilder(); - Iterator templateIterator = dictionary.keySet().iterator(); + Iterator<QName> templateIterator = dictionary.keySet().iterator(); while (templateIterator.hasNext()) { - Object type = templateIterator.next(); + QName type = templateIterator.next(); builder.append("Dictionary: Type=" + type.toString()); - Map templateMap = (Map)dictionary.get(type); - Iterator keyIterator = templateMap.keySet().iterator(); + Map<QName, ScalarValue> templateMap = dictionary.get(type); + Iterator<QName> keyIterator = templateMap.keySet().iterator(); while (keyIterator.hasNext()) { - Object key = keyIterator.next(); + QName key = keyIterator.next(); builder.append(key).append("=").append(templateMap.get(key)).append("\n"); } } Modified: branches/generics-cleanup/src/main/java/org/openfast/BitVector.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/BitVector.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/BitVector.java 2012-02-21 16:07:21 UTC (rev 268) @@ -78,7 +78,7 @@ if (other.size != this.size) { return false; } - for (int i = 0; i < this.bytes.length; i++) { + for (int i = 0; i < this.bytes.length; ++i) { if (this.bytes[i] != other.bytes[i]) { return false; } Modified: branches/generics-cleanup/src/main/java/org/openfast/BitVectorBuilder.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/BitVectorBuilder.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/BitVectorBuilder.java 2012-02-21 16:07:21 UTC (rev 268) @@ -29,10 +29,10 @@ } public void set() { vector.set(index); - index++; + ++index; } public void skip() { - index++; + ++index; } public BitVector getBitVector() { return vector; Modified: branches/generics-cleanup/src/main/java/org/openfast/ByteUtil.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/ByteUtil.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/ByteUtil.java 2012-02-21 16:07:21 UTC (rev 268) @@ -40,7 +40,7 @@ } String[] bitStrings = bitString.split(" "); byte[] bytes = new byte[bitStrings.length]; - for (int i = 0; i < bitStrings.length; i++) { + for (int i = 0; i < bitStrings.length; ++i) { bytes[i] = (byte) Integer.parseInt(bitStrings[i], 2); } return bytes; @@ -58,12 +58,13 @@ return bytes; } - public static String convertByteArrayToHexString(byte[] value) { - StringBuffer builder = new StringBuffer(value.length * 2); - for (int i = 0; i < value.length; i++) { - String hex = Integer.toHexString(value[i] & 0xff); - if (hex.length() == 1) - builder.append('0'); + public static String convertByteArrayToHexString(byte[] values) { + StringBuffer builder = new StringBuffer(values.length * 2); + for (byte value : values) { + String hex = Integer.toHexString(value & 0xff); + if(hex.length() == 1){ + builder.append('0'); + } builder.append(hex); } return builder.toString(); @@ -85,9 +86,9 @@ return ""; } StringBuilder builder = new StringBuilder(); - for (int i = 0; i < length; i++) { + for (int i = 0; i < length; ++i) { String bits = Integer.toString(bytes[i] & 0xFF, 2); - for (int j = 0; j < (8 - bits.length()); j++) + for (int j = 0; j < (8 - bits.length()); ++j) builder.append('0'); builder.append(bits).append(' '); } @@ -112,8 +113,8 @@ } public static boolean isEmpty(byte[] bytes) { - for (int i = 0; i < bytes.length; i++) - if ((bytes[i] & 0x7f) != 0) + for (byte b : bytes) + if ((b & 0x7f) != 0) return false; return true; } Modified: branches/generics-cleanup/src/main/java/org/openfast/ByteVectorValue.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/ByteVectorValue.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/ByteVectorValue.java 2012-02-21 16:07:21 UTC (rev 268) @@ -43,11 +43,9 @@ public String serialize() { StringBuffer builder = new StringBuffer(value.length * 2); - for (int i = 0; i < value.length; i++) { - String hex = Integer.toHexString(value[i] & 0xff); - if (hex.length() == 1) - builder.append('0'); - builder.append(hex); + for (byte v : value) { + String hex = Integer.toHexString(v & 0xff); + builder.append(hex.length() != 1 ? hex : '0'); } return builder.toString(); } @@ -67,10 +65,11 @@ if (this.length != other.length) { return false; } - for (int i = 0; i < length; i++) + for (int i = 0; i < length; ++i) { if (this.value[offset + i] != other.value[other.offset + i]) { return false; } + } return true; } Modified: branches/generics-cleanup/src/main/java/org/openfast/Context.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/Context.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/Context.java 2012-02-21 16:07:21 UTC (rev 268) @@ -47,14 +47,14 @@ public class Context implements OpenFastContext { private TemplateRegistry templateRegistry = new BasicTemplateRegistry(); private int lastTemplateId; - private final Map dictionaries = new HashMap(); + private final Map<String, Dictionary> dictionaries = new HashMap<String, Dictionary>(); private ErrorHandler errorHandler = ErrorHandler.DEFAULT; private QName currentApplicationType; - private final List listeners = Collections.EMPTY_LIST; + private final List<TemplateRegisteredListener> listeners = Collections.emptyList(); private boolean traceEnabled; private Trace encodeTrace; private Trace decodeTrace; - private final Map caches = new HashMap(); + private final Map<QName, Cache> caches = new HashMap<QName, Cache>(); private final OpenFastContext parentContext; private FastMessageLogger logger = null; @@ -84,9 +84,9 @@ } public void registerTemplate(int templateId, MessageTemplate template) { templateRegistry.register(templateId, template); - Iterator iter = listeners.iterator(); + Iterator<TemplateRegisteredListener> iter = listeners.iterator(); while (iter.hasNext()) { - ((TemplateRegisteredListener) iter.next()).templateRegistered(template, templateId); + iter.next().templateRegistered(template, templateId); } } public int getLastTemplateId() { @@ -103,7 +103,7 @@ private Dictionary getDictionary(String dictionary) { if (!dictionaries.containsKey(dictionary)) dictionaries.put(dictionary, new GlobalDictionary()); - return (Dictionary) dictionaries.get(dictionary); + return dictionaries.get(dictionary); } public void store(String dictionary, Group group, QName key, ScalarValue valueToEncode) { if (group.hasTypeReference()) @@ -111,8 +111,8 @@ getDictionary(dictionary).store(group, currentApplicationType, key, valueToEncode); } public void reset() { - for (Iterator iter = dictionaries.values().iterator(); iter.hasNext();) { - Dictionary dict = (Dictionary) iter.next(); + for (Iterator<Dictionary> iter = dictionaries.values().iterator(); iter.hasNext();) { + Dictionary dict = iter.next(); dict.reset(); } } @@ -120,7 +120,7 @@ this.errorHandler = errorHandler; } public void newMessage(MessageTemplate template) { - currentApplicationType = (template.hasTypeReference()) ? template.getTypeReference() : FastConstants.ANY_TYPE; + currentApplicationType = template.hasTypeReference() ? template.getTypeReference() : FastConstants.ANY_TYPE; } public void setCurrentApplicationType(QName name) { currentApplicationType = name; @@ -163,13 +163,13 @@ if (!caches.containsKey(key)) { caches.put(key, new UnboundedCache()); } - return (Cache) caches.get(key); + return caches.get(key); } public void store(QName key, int index, ScalarValue value) { if (!caches.containsKey(key)) { caches.put(key, new UnboundedCache()); } - ((Cache)caches.get(key)).store(index, value); + caches.get(key).store(index, value); } public FastMessageLogger getLogger() { if (logger == null) { Modified: branches/generics-cleanup/src/main/java/org/openfast/GlobalDictionary.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/GlobalDictionary.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/GlobalDictionary.java 2012-02-21 16:07:21 UTC (rev 268) @@ -28,14 +28,14 @@ public class GlobalDictionary implements Dictionary { - protected Map table = new HashMap(); + protected Map<QName, ScalarValue> table = new HashMap<QName, ScalarValue>(); public ScalarValue lookup(Group template, QName key, QName applicationType) { if (!table.containsKey(key)) { return ScalarValue.UNDEFINED; } - return (ScalarValue) table.get(key); + return table.get(key); } public void store(Group group, QName applicationType, QName key, ScalarValue value) { @@ -48,9 +48,9 @@ public String toString() { StringBuilder builder = new StringBuilder(); - Iterator keyIterator = table.keySet().iterator(); + Iterator<QName> keyIterator = table.keySet().iterator(); while (keyIterator.hasNext()) { - QName key = (QName) keyIterator.next(); + QName key = keyIterator.next(); builder.append("Dictionary: Global"); builder.append(key).append("=").append(table.get(key)).append("\n"); } Modified: branches/generics-cleanup/src/main/java/org/openfast/GroupValue.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/GroupValue.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/GroupValue.java 2012-02-21 16:07:21 UTC (rev 268) @@ -46,10 +46,10 @@ this.group = group; this.values = values; - for (int i=0; i<group.getFieldCount(); i++) { + for (int i = 0; i < group.getFieldCount(); ++i) { if (group.getField(i) instanceof Scalar) { - Scalar scalar = ((Scalar) group.getField(i)); - if (scalar.getOperator().equals(Operator.CONSTANT) && !scalar.isOptional()) { + Scalar scalar = (Scalar) group.getField(i); + if (Operator.CONSTANT.equals(scalar.getOperator()) && !scalar.isOptional()) { values[i] = scalar.getDefaultValue(); } } @@ -60,8 +60,8 @@ this(group, new FieldValue[group.getFieldCount()]); } - public Iterator iterator() { - return new ArrayIterator(values); + public Iterator<FieldValue> iterator() { + return new ArrayIterator<FieldValue>(values); } public int getInt(int fieldIndex) { @@ -120,7 +120,7 @@ public String getString(String fieldName) { FieldValue value = getValue(fieldName); - return (value == null) ? null : value.toString(); + return (value != null) ? value.toString() : null; } public double getDouble(int fieldIndex) { @@ -291,7 +291,7 @@ return false; } - for (int i = 0; i < values.length; i++) { + for (int i = 0; i < values.length; ++i) { if (values[i] == null) { if (other.values[i] != null) return false; @@ -310,11 +310,11 @@ @Override public String toString() { - StringBuilder builder = new StringBuilder(); + StringBuilder builder = new StringBuilder(6 + values.length * 16); builder.append(group).append(" -> {"); - for (int i = 0; i < values.length; i++) { - builder.append(values[i]).append(", "); + for (FieldValue value : values) { + builder.append(value).append(", "); } if (values.length > 0) { @@ -350,7 +350,7 @@ public FieldValue copy() { FieldValue[] copies = new FieldValue[values.length]; - for (int i = 0; i < copies.length; i++) { + for (int i = 0; i < copies.length; ++i) { copies[i] = values[i].copy(); } return new GroupValue(group, this.values); Modified: branches/generics-cleanup/src/main/java/org/openfast/Message.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/Message.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/Message.java 2012-02-21 16:07:21 UTC (rev 268) @@ -47,16 +47,18 @@ public boolean equals(Message message) { if (this.getFieldCount() != message.getFieldCount()) return false; - for (int i = 1; i < message.getFieldCount(); i++) - if (message.getValue(i) == null) { + for (int i = 1; i < message.getFieldCount(); ++i) { + FieldValue messageValue = message.getValue(i); + if (messageValue == null) { if (this.getValue(i) == null) { continue; } else { return false; } - } else if (!message.getValue(i).equals(this.getValue(i))) { + } else if (!messageValue.equals(this.getValue(i))) { return false; } + } return true; } @Override @@ -73,7 +75,7 @@ @Override public FieldValue copy() { FieldValue[] copies = new FieldValue[values.length]; - for (int i = 0; i < copies.length; i++) { + for (int i = 0; i < copies.length; ++i) { copies[i] = values[i].copy(); } return new Message(template, copies); Modified: branches/generics-cleanup/src/main/java/org/openfast/MessageInputStream.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/MessageInputStream.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/MessageInputStream.java 2012-02-21 16:07:21 UTC (rev 268) @@ -38,8 +38,8 @@ private InputStream in; private FastDecoder decoder; private Context context; - private Map templateHandlers = Collections.EMPTY_MAP; - private List handlers = Collections.EMPTY_LIST; + private Map<MessageTemplate, MessageHandler> templateHandlers = Collections.emptyMap(); + private List<MessageHandler> handlers = Collections.emptyList(); private MessageBlockReader blockReader = MessageBlockReader.NULL; public MessageInputStream(InputStream inputStream) { @@ -69,12 +69,12 @@ getContext().getLogger().log(message, ByteUtil.EMPTY, Direction.INBOUND); blockReader.messageRead(in, message); if (!handlers.isEmpty()) { - for (int i = 0; i < handlers.size(); i++) { - ((MessageHandler) handlers.get(i)).handleMessage(message, context, decoder); + for (MessageHandler handler : handlers) { + handler.handleMessage(message, context, decoder); } } if (templateHandlers.containsKey(message.getTemplate())) { - MessageHandler handler = (MessageHandler) templateHandlers.get(message.getTemplate()); + MessageHandler handler = templateHandlers.get(message.getTemplate()); handler.handleMessage(message, context, decoder); return readMessage(); } @@ -99,14 +99,14 @@ public void addMessageHandler(MessageTemplate template, MessageHandler handler) { if (templateHandlers == Collections.EMPTY_MAP) { - templateHandlers = new HashMap(); + templateHandlers = new HashMap<MessageTemplate, MessageHandler>(); } templateHandlers.put(template, handler); } public void addMessageHandler(MessageHandler handler) { if (handlers == Collections.EMPTY_LIST) { - handlers = new ArrayList(4); + handlers = new ArrayList<MessageHandler>(4); } handlers.add(handler); } Modified: branches/generics-cleanup/src/main/java/org/openfast/MessageOutputStream.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/MessageOutputStream.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/MessageOutputStream.java 2012-02-21 16:07:21 UTC (rev 268) @@ -37,8 +37,8 @@ private final OutputStream out; private final FastEncoder encoder; private final Context context; - private List handlers = Collections.EMPTY_LIST; - private Map templateHandlers = Collections.EMPTY_MAP; + private List<MessageHandler> handlers = Collections.emptyList(); + private Map<MessageTemplate, MessageHandler> templateHandlers = Collections.emptyMap(); private MessageBlockWriter blockWriter = MessageBlockWriter.NULL; public MessageOutputStream(OutputStream outputStream) { @@ -75,12 +75,12 @@ if (context.isTraceEnabled()) context.startTrace(); if (!handlers.isEmpty()) { - for (int i = 0; i < handlers.size(); i++) { - ((MessageHandler) handlers.get(i)).handleMessage(message, context, encoder); + for (MessageHandler handler : handlers) { + handler.handleMessage(message, context, encoder); } } if (templateHandlers.containsKey(message.getTemplate())) { - ((MessageHandler) templateHandlers.get(message.getTemplate())).handleMessage(message, context, encoder); + templateHandlers.get(message.getTemplate()).handleMessage(message, context, encoder); } return encoder.encode(message); } @@ -107,14 +107,14 @@ public void addMessageHandler(MessageTemplate template, MessageHandler handler) { if (templateHandlers == Collections.EMPTY_MAP) { - templateHandlers = new HashMap(); + templateHandlers = new HashMap<MessageTemplate, MessageHandler>(); } templateHandlers.put(template, handler); } public void addMessageHandler(MessageHandler handler) { if (handlers == Collections.EMPTY_LIST) { - handlers = new ArrayList(4); + handlers = new ArrayList<MessageHandler>(4); } handlers.add(handler); } Modified: branches/generics-cleanup/src/main/java/org/openfast/Node.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/Node.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/Node.java 2012-02-21 16:07:21 UTC (rev 268) @@ -4,12 +4,12 @@ import java.util.Map; public interface Node { - List getNodes(); - List getChildren(QName name); + List<Node> getNodes(); + List<Node> getChildren(QName name); String getAttribute(QName name); QName getNodeName(); - Map getAttributes(); + Map<QName, String> getAttributes(); boolean hasAttribute(QName name); boolean hasChild(QName name); Modified: branches/generics-cleanup/src/main/java/org/openfast/QName.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/QName.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/QName.java 2012-02-21 16:07:21 UTC (rev 268) @@ -38,8 +38,9 @@ public QName(String name, String namespace) { if (name == null) throw new NullPointerException(); + this.name = name; - this.namespace = namespace == null ? "" : namespace; + this.namespace = namespace != null ? namespace : ""; } public String getNamespace() { Modified: branches/generics-cleanup/src/main/java/org/openfast/SequenceValue.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/SequenceValue.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/SequenceValue.java 2012-02-21 16:07:21 UTC (rev 268) @@ -28,7 +28,7 @@ public class SequenceValue implements FieldValue { private static final long serialVersionUID = 1L; - private List elements = Collections.EMPTY_LIST; + private List<GroupValue> elements = Collections.emptyList(); private Sequence sequence; public SequenceValue(Sequence sequence) { @@ -42,20 +42,20 @@ return elements.size(); } - public Iterator iterator() { + public Iterator<GroupValue> iterator() { return elements.iterator(); } public void add(GroupValue value) { if (elements == Collections.EMPTY_LIST) { - elements = new ArrayList(); + elements = new ArrayList<GroupValue>(); } elements.add(value); } public void add(FieldValue[] values) { if (elements == Collections.EMPTY_LIST) { - elements = new ArrayList(); + elements = new ArrayList<GroupValue>(); } elements.add(new GroupValue(sequence.getGroup(), values)); } @@ -74,7 +74,7 @@ if (getLength() != other.getLength()) { return false; } - for (int i = 0; i < getLength(); i++) { + for (int i = 0; i < getLength(); ++i) { if (!elements.get(i).equals(other.elements.get(i))) { return false; } @@ -87,8 +87,8 @@ } public String toString() { - StringBuilder builder = new StringBuilder(); - Iterator iter = elements.iterator(); + StringBuilder builder = new StringBuilder(4 + elements.size() * 24); + Iterator<GroupValue> iter = elements.iterator(); builder.append("[ "); while (iter.hasNext()) { GroupValue value = (GroupValue) iter.next(); @@ -107,13 +107,13 @@ } public GroupValue[] getValues() { - return (GroupValue[]) this.elements.toArray(new GroupValue[elements.size()]); + return this.elements.toArray(new GroupValue[elements.size()]); } public FieldValue copy() { SequenceValue value = new SequenceValue(this.sequence); - for (int i = 0; i < elements.size(); i++) { - value.add((GroupValue) ((GroupValue) elements.get(i)).copy()); + for (GroupValue element : elements) { + value.add((GroupValue) element.copy()); } return value; } Modified: branches/generics-cleanup/src/main/java/org/openfast/SimpleNode.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/SimpleNode.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/SimpleNode.java 2012-02-21 16:07:21 UTC (rev 268) @@ -7,8 +7,8 @@ import java.util.Map; public class SimpleNode implements Node { - private List nodes = Collections.EMPTY_LIST; - protected Map attributes = Collections.EMPTY_MAP; + private List<Node> nodes = Collections.emptyList(); + protected Map<QName, String> attributes = Collections.emptyMap(); protected final QName name; public SimpleNode(QName nodeName) { @@ -17,29 +17,29 @@ public void addNode(Node node) { if (nodes.isEmpty()) - nodes = new ArrayList(3); + nodes = new ArrayList<Node>(3); nodes.add(node); } - public List getNodes() { + public List<Node> getNodes() { return nodes; } public String getAttribute(QName name) { - return (String) attributes.get(name); + return attributes.get(name); } - public Map getAttributes() { + public Map<QName, String> getAttributes() { return attributes; } - public List getChildren(QName name) { - List children = Collections.EMPTY_LIST; - for (int i=0; i<nodes.size() && name != null; i++) { + public List<Node> getChildren(QName name) { + List<Node> children = Collections.emptyList(); + for (int i = 0; i < nodes.size() && name != null; ++i) { Node child = (Node)nodes.get(i); if (name.equals(child.getNodeName())) { if (children.isEmpty()) { - children = new ArrayList(); + children = new ArrayList<Node>(); } children.add(nodes.get(i)); } @@ -53,7 +53,7 @@ public void setAttribute(QName name, String value) { if (attributes.isEmpty()) { - attributes = new HashMap(); + attributes = new HashMap<QName, String>(); } attributes.put(name, value); } @@ -63,7 +63,7 @@ } public boolean hasChild(QName name) { - for (int i=0; i<nodes.size() && name != null; i++) { + for (int i = 0; i < nodes.size() && name != null; ++i) { Node child = (Node)nodes.get(i); if (name.equals(child.getNodeName())) { return true; Modified: branches/generics-cleanup/src/main/java/org/openfast/TemplateDictionary.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/TemplateDictionary.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/TemplateDictionary.java 2012-02-21 16:07:21 UTC (rev 268) @@ -28,15 +28,15 @@ public class TemplateDictionary implements Dictionary { - protected Map table = new HashMap(); + protected Map<Group, Map<QName, ScalarValue>> table = new HashMap<Group, Map<QName, ScalarValue>>(); public ScalarValue lookup(Group template, QName key, QName applicationType) { if (!table.containsKey(template)) { return ScalarValue.UNDEFINED; } - if (((Map) table.get(template)).containsKey(key)) { - return (ScalarValue) ((Map) table.get(template)).get(key); + if(table.get(template).containsKey(key)) { + return table.get(template).get(key); } return ScalarValue.UNDEFINED; @@ -48,20 +48,20 @@ public void store(Group group, QName applicationType, QName key, ScalarValue valueToEncode) { if (!table.containsKey(group)) { - table.put(group, new HashMap()); + table.put(group, new HashMap<QName, ScalarValue>()); } - ((Map) table.get(group)).put(key, valueToEncode); + table.get(group).put(key, valueToEncode); } public String toString() { StringBuilder builder = new StringBuilder(); - Iterator templateIterator = table.keySet().iterator(); + Iterator<Group> templateIterator = table.keySet().iterator(); while (templateIterator.hasNext()) { Object template = templateIterator.next(); builder.append("Dictionary: Template=" + template.toString()); - Map templateMap = (Map)table.get(template); - Iterator keyIterator = templateMap.keySet().iterator(); + Map<QName, ScalarValue> templateMap = (Map<QName, ScalarValue>)table.get(template); + Iterator<QName> keyIterator = templateMap.keySet().iterator(); while (keyIterator.hasNext()) { Object key = keyIterator.next(); builder.append(key).append("=").append(templateMap.get(key)).append("\n"); Modified: branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/codec/FastDecoder.java 2012-02-21 16:07:21 UTC (rev 268) @@ -47,11 +47,11 @@ return null; // Must have reached end of stream; } - BitVector pmap = (bitVectorValue).value; + BitVector pmap = bitVectorValue.value; BitVectorReader presenceMapReader = new BitVectorReader(pmap); // if template id is not present, use previous, else decode template id - int templateId = (presenceMapReader.read()) ? TypeCodec.UINT.decode(in).toInt() : context.getLastTemplateId(); + int templateId = presenceMapReader.read() ? TypeCodec.UINT.decode(in).toInt() : context.getLastTemplateId(); MessageTemplate template = context.getTemplate(templateId); if (template == null) { Modified: branches/generics-cleanup/src/main/java/org/openfast/codec/FastEncoder.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/codec/FastEncoder.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/codec/FastEncoder.java 2012-02-21 16:07:21 UTC (rev 268) @@ -31,7 +31,7 @@ public class FastEncoder implements Coder { private Context context; - private List listeners = Collections.EMPTY_LIST; + private List<TemplateRegisteredListener> listeners = Collections.emptyList(); public FastEncoder(Context context) { this.context = context; @@ -55,7 +55,7 @@ } public void addTemplateRegisteredListener(TemplateRegisteredListener templateRegisteredListener) { if (listeners.isEmpty()) { - listeners = new ArrayList(); + listeners = new ArrayList<TemplateRegisteredListener>(); } listeners.add(templateRegisteredListener); } Modified: branches/generics-cleanup/src/main/java/org/openfast/debug/BasicEncodeTrace.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/debug/BasicEncodeTrace.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/debug/BasicEncodeTrace.java 2012-02-21 16:07:21 UTC (rev 268) @@ -32,18 +32,18 @@ public class BasicEncodeTrace implements Trace { - private Stack stack = new Stack(); + private Stack<TraceGroup> stack = new Stack<TraceGroup>(); private PrintWriter out = new PrintWriter(System.out); public void groupStart(Group group) { TraceGroup traceGroup = new TraceGroup(group); if (!stack.isEmpty()) - ((TraceGroup) stack.peek()).addGroup(traceGroup); + stack.peek().addGroup(traceGroup); stack.push(traceGroup); } public void field(Field field, FieldValue value, FieldValue encoded, byte[] encoding, int pmapIndex) { - ((TraceGroup) stack.peek()).addField(field, value, encoded, pmapIndex, encoding); + stack.peek().addField(field, value, encoded, pmapIndex, encoding); } public void groupEnd() { @@ -54,12 +54,12 @@ } public void pmap(byte[] pmap) { - ((TraceGroup) stack.peek()).setPmap(pmap); + stack.peek().setPmap(pmap); } private class TraceGroup implements TraceNode { - private List nodes; + private List<TraceNode> nodes; private byte[] pmap; @@ -67,7 +67,7 @@ public TraceGroup(Group group) { this.group = group; - this.nodes = new ArrayList(group.getFieldCount()); + this.nodes = new ArrayList<TraceNode>(group.getFieldCount()); } public void setPmap(byte[] pmap) { @@ -87,8 +87,8 @@ indent += 2; if (pmap != null) builder.append(indent(indent)).append("PMAP: ").append(ByteUtil.convertByteArrayToBitString(pmap)).append("\n"); - for (int i = 0; i < nodes.size(); i++) { - ((TraceNode) nodes.get(i)).serialize(builder, indent); + for (int i = 0; i < nodes.size(); ++i) { + nodes.get(i).serialize(builder, indent); } indent -= 2; return builder; @@ -135,10 +135,10 @@ } public String indent(int indent) { - String tab = ""; - for (int i = 0; i < indent; i++) - tab += " "; - return tab; + StringBuilder tab = new StringBuilder(indent); + for (int i = 0; i < indent; ++i) + tab.append(' '); + return tab.toString(); } public void setWriter(PrintWriter traceWriter) { Modified: branches/generics-cleanup/src/main/java/org/openfast/error/ErrorCode.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/error/ErrorCode.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/error/ErrorCode.java 2012-02-21 16:07:21 UTC (rev 268) @@ -25,7 +25,7 @@ import org.openfast.Message; public class ErrorCode { - private static final Map ALERT_CODES = new HashMap(); + private static final Map<Integer, ErrorCode> ALERT_CODES = new HashMap<Integer, ErrorCode>(); private final int code; private final String shortName; private final String description; @@ -62,7 +62,7 @@ } public static ErrorCode getAlertCode(Message alertMsg) { - return (ErrorCode) ALERT_CODES.get(new Integer(alertMsg.getInt(2))); + return ALERT_CODES.get(alertMsg.getInt(2)); } public ErrorType getType() { Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2012-02-21 16:07:21 UTC (rev 268) @@ -4,18 +4,18 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; + import org.openfast.Context; import org.openfast.Message; +import org.openfast.MessageBlockReader; import org.openfast.MessageInputStream; -import org.openfast.MessageBlockReader; import org.openfast.error.FastException; -import org.openfast.codec.FastDecoder; +import org.openfast.examples.MessageBlockReaderFactory; import org.openfast.session.Connection; import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; import org.openfast.template.TemplateRegistry; import org.openfast.template.loader.XMLMessageTemplateLoader; -import org.openfast.examples.MessageBlockReaderFactory; public class FastMessageConsumer { private final Endpoint endpoint; Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/consumer/Main.java 2012-02-21 16:07:21 UTC (rev 268) @@ -2,14 +2,14 @@ import java.io.File; import java.io.IOException; + import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.openfast.examples.Assert; +import org.openfast.examples.MessageBlockReaderFactory; import org.openfast.examples.OpenFastExample; -import org.openfast.examples.MessageBlockReaderFactory; import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; -import org.openfast.session.multicast.MulticastEndpoint; import org.openfast.session.multicast.MulticastClientEndpoint; import org.openfast.session.tcp.TcpEndpoint; Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/FastMessageDecoder.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/FastMessageDecoder.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/FastMessageDecoder.java 2012-02-21 16:07:21 UTC (rev 268) @@ -83,4 +83,8 @@ public void setBlockReader(MessageBlockReader messageBlockReader) { this.blockReader = messageBlockReader; } + + public int getReadOffset() { + return readOffset; + } } Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/Main.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/Main.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/decoder/Main.java 2012-02-21 16:07:21 UTC (rev 268) @@ -50,6 +50,7 @@ displayHelp("consumer", options); } + // TODO: readOffset is not used in the FastMessageDecoder final int readOffset = cl.hasOption(READ_OFFSET) ? getInteger(cl, READ_OFFSET) : 0; FastMessageDecoder consumer = new FastMessageDecoder(dataFile, templatesFile, cl.hasOption(NAMESPACE_AWARENESS), readOffset); if (cl.hasOption(BLOCK)) { Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/interpret/FastMessageInterpreter.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/interpret/FastMessageInterpreter.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/interpret/FastMessageInterpreter.java 2012-02-21 16:07:21 UTC (rev 268) @@ -115,8 +115,7 @@ indent = indent + tab; boolean needNewLine = false; - for (int i = 0; i < entries.length; i++) { - GroupValue entry = entries[i]; + for(GroupValue entry : entries) { line.append("\n").append(indent); // for each entry, iterate through the possible fields for (int nField = 0; nField < fieldCount; ++nField) { Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/performance/HexadecimalInputStream.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/performance/HexadecimalInputStream.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/performance/HexadecimalInputStream.java 2012-02-21 16:07:21 UTC (rev 268) @@ -23,7 +23,7 @@ int index = 0; while (index < numRead) { if (buffer[index] == '\r' || buffer[index] == '\n') { - index++; + ++index; continue; } if (index + 1 == numRead) { @@ -32,12 +32,12 @@ temp[1] = (byte) in.read(); String data = new String(temp); b[off + byteCount] = (byte) Integer.parseInt(data, 16); - byteCount++; + ++byteCount; break; } String data = new String(buffer, index, 2); b[off + byteCount] = (byte) Integer.parseInt(data, 16); - byteCount++; + ++byteCount; index+=2; } if (eof) Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/performance/Main.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/performance/Main.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/performance/Main.java 2012-02-21 16:07:21 UTC (rev 268) @@ -61,13 +61,13 @@ } private static void runRepeat(PerformanceRunner performanceRunner, int repeat) { - for (int i=0; i<repeat; i++) + for (int i = 0; i < repeat; ++i) run(performanceRunner); } private static void runContinuous(PerformanceRunner performanceRunner) { while (true) { - run (performanceRunner); + run(performanceRunner); } } Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/performance/PerformanceResult.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/performance/PerformanceResult.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/performance/PerformanceResult.java 2012-02-21 16:07:21 UTC (rev 268) @@ -15,7 +15,7 @@ } public void finishMessage() { - numMessages++; + ++numMessages; } public void stop() { Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2012-02-21 16:07:21 UTC (rev 268) @@ -1,32 +1,31 @@ package org.openfast.examples.producer; import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; + import org.openfast.Context; import org.openfast.Global; import org.openfast.Message; -import org.openfast.MessageBlockWriter; import org.openfast.MessageOutputStream; import org.openfast.error.ErrorHandler; +import org.openfast.examples.MessageBlockWriterFactory; import org.openfast.session.Connection; import org.openfast.session.ConnectionListener; import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; import org.openfast.template.TemplateRegistry; import org.openfast.template.loader.XMLMessageTemplateLoader; -import org.openfast.examples.MessageBlockWriterFactory; public class FastMessageProducer implements ConnectionListener { protected final Endpoint endpoint; protected final TemplateRegistry templateRegistry; protected Thread acceptThread; - protected List connections = new ArrayList(); + protected List<MessageOutputStream> connections = new ArrayList<MessageOutputStream>(); protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); protected final MessageBlockWriterFactory messageBlockWriterFactory; @@ -58,7 +57,7 @@ } public void encode(InputStream xmlData, boolean loopForever) throws FastConnectionException, IOException { - List messages = converter.parse(xmlData); + List<Message> messages = converter.parse(xmlData); if(messages == null) throw new IllegalArgumentException("The XML data stream contains no FAST messages!"); @@ -73,11 +72,9 @@ while(loopForever); } - protected void publish(List messages, List msgOutputStreams) { - for (int i = 0; i < messages.size(); ++i) { - Message message = (Message) messages.get(i); - for (int j = 0; j < msgOutputStreams.size(); ++j) { - MessageOutputStream out = (MessageOutputStream)msgOutputStreams.get(j); + protected void publish(List<Message> messages, List<MessageOutputStream> msgOutputStreams) { + for (Message message : messages) { + for(MessageOutputStream out : msgOutputStreams) { out.writeMessage(message); } } Modified: branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-02-21 16:01:05 UTC (rev 267) +++ branches/generics-cleanup/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2012-02-21 16:07:21 UTC (rev 268) @@ -3,17 +3,15 @@ import java.io.File; import java.io.IOException; import java.util.List; + import org.openfast.Context; import org.openfast.Message; -import org.openfast.MessageBlockWriter; import org.openfast.MessageOutputStream; import org.openfast.error.ErrorHandler; +import org.openfast.examples.MessageBlockWriterFactory; import org.openfast.session.Connection; import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; -import org.openfast.template.TemplateRegistry; -import org.openfast.template.loader.XMLMessageTemplateLoader; -import org.openfast.examples.MessageBlockWriterFactory; public class MulticastFastMessageProducer extends FastMessageProducer { private MessageOutputStream out; @@ -31,12 +29,12 @@ out.setBlockWriter(messageBlockWriterFactory.create()); } - protected void publish(List messages, List msgOutputStreams) { + protected void publish(List<Message> messages, List<MessageOutputStream> msgOutputStreams) { if(out == null) { return; } - for(int i = 0; i < messages.size(); ++i) { - out.writeMessage((Message)messages.get(i), true); + for(Message message : messages) { + out.writeMessage(message, true); } out.rese... [truncated message content] |
From: <ope...@li...> - 2012-02-21 16:01:16
|
Revision: 267 http://openfast.svn.sourceforge.net/openfast/?rev=267&view=rev Author: joshseidel Date: 2012-02-21 16:01:05 +0000 (Tue, 21 Feb 2012) Log Message: ----------- Update to create the initial branch for updating the code base for generics and some code clean up and optimization. Added Paths: ----------- branches/generics-cleanup/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-01-23 18:05:19
|
Revision: 266 http://openfast.svn.sourceforge.net/openfast/?rev=266&view=rev Author: jacob_northey Date: 2012-01-23 18:05:13 +0000 (Mon, 23 Jan 2012) Log Message: ----------- [FAST-41] Improved buffer creation performance [FAST-42] Notified when session closed unexpectedly Modified Paths: -------------- trunk/src/main/java/org/openfast/Global.java trunk/src/main/java/org/openfast/session/Session.java Modified: trunk/src/main/java/org/openfast/Global.java =================================================================== --- trunk/src/main/java/org/openfast/Global.java 2012-01-18 21:50:09 UTC (rev 265) +++ trunk/src/main/java/org/openfast/Global.java 2012-01-23 18:05:13 UTC (rev 266) @@ -21,15 +21,14 @@ package org.openfast; import java.io.ByteArrayOutputStream; -import java.util.ArrayList; -import java.util.List; + import org.openfast.error.ErrorCode; import org.openfast.error.ErrorHandler; public final class Global { private static ErrorHandler errorHandler = ErrorHandler.DEFAULT; private static int currentImplicitId = (int) (System.currentTimeMillis() % 10000); - private static List buffers = new ArrayList(); + private static final ThreadLocal<ByteArrayOutputStream> buffers = new ThreadLocal<ByteArrayOutputStream>(); public static void setErrorHandler(ErrorHandler handler) { if (handler == null) { @@ -53,22 +52,17 @@ private Global() {} public static ByteArrayOutputStream getBuffer() { - synchronized(buffers) { - if (buffers.isEmpty()) - return new PooledByteArrayOutputStream(); - ByteArrayOutputStream buffer = (ByteArrayOutputStream) buffers.remove(0); - buffer.reset(); + ByteArrayOutputStream buffer = buffers.get(); + if(buffer == null) { + buffer = new ByteArrayOutputStream(); + buffers.set(buffer); + // No reset after creation necessary return buffer; } + + buffer.reset(); + return buffer; } - private static class PooledByteArrayOutputStream extends ByteArrayOutputStream { - public synchronized byte[] toByteArray() { - byte[] byteArray = super.toByteArray(); - synchronized(buffers) { - buffers.add(this); - } - return byteArray; - } - } + } Modified: trunk/src/main/java/org/openfast/session/Session.java =================================================================== --- trunk/src/main/java/org/openfast/session/Session.java 2012-01-18 21:50:09 UTC (rev 265) +++ trunk/src/main/java/org/openfast/session/Session.java 2012-01-23 18:05:13 UTC (rev 266) @@ -145,10 +145,7 @@ Message message = in.readMessage(); if (message == null) { - listening = false; - if (sessionListener != null) { - sessionListener.onClose(); - } + notifySessionClosed(); break; } if (protocol.isProtocolMessage(message)) { @@ -162,7 +159,7 @@ } catch (Exception e) { Throwable cause = e.getCause(); if (cause != null && cause.getClass().equals(SocketException.class)) { - listening = false; + notifySessionClosed(); errorHandler.error(FastConstants.IO_ERROR, cause.getMessage(), cause); } else if (e instanceof FastException) { FastException fastException = ((FastException) e); @@ -173,6 +170,13 @@ } } } + + private void notifySessionClosed() { + listening = false; + if (sessionListener != null) { + sessionListener.onClose(); + } + } }; listeningThread = new Thread(messageReader, "FAST Session Message Reader"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-01-18 21:50:14
|
Revision: 265 http://openfast.svn.sourceforge.net/openfast/?rev=265&view=rev Author: jacob_northey Date: 2012-01-18 21:50:09 +0000 (Wed, 18 Jan 2012) Log Message: ----------- Fixed distributionManagement urls Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-01-18 21:49:36 UTC (rev 264) +++ trunk/pom.xml 2012-01-18 21:50:09 UTC (rev 265) @@ -230,21 +230,21 @@ <id>sourceforge.net</id> <name>Sourceforge.net Repository</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/release </url> </repository> <snapshotRepository> <id>sourceforge.net</id> <name>Sourceforge.net Snapshot Repository</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/snapshot </url> </snapshotRepository> <site> <id>sourceforge.net</id> <name>Sourceforge.net OpenFAST Web Site</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/ + scp://web.sourceforge.net/home/project-web/openfast/htdocs </url> </site> </distributionManagement> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-01-18 21:49:42
|
Revision: 264 http://openfast.svn.sourceforge.net/openfast/?rev=264&view=rev Author: jacob_northey Date: 2012-01-18 21:49:36 +0000 (Wed, 18 Jan 2012) Log Message: ----------- Fixed distributionManagement urls Modified Paths: -------------- tags/openfast-1.0.3/pom.xml Modified: tags/openfast-1.0.3/pom.xml =================================================================== --- tags/openfast-1.0.3/pom.xml 2012-01-18 21:16:06 UTC (rev 263) +++ tags/openfast-1.0.3/pom.xml 2012-01-18 21:49:36 UTC (rev 264) @@ -230,21 +230,21 @@ <id>sourceforge.net</id> <name>Sourceforge.net Repository</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/release </url> </repository> <snapshotRepository> <id>sourceforge.net</id> <name>Sourceforge.net Snapshot Repository</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + scp://web.sourceforge.net/home/project-web/openfast/htdocs/maven/snapshot </url> </snapshotRepository> <site> <id>sourceforge.net</id> <name>Sourceforge.net OpenFAST Web Site</name> <url> - scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/ + scp://web.sourceforge.net/home/project-web/openfast/htdocs </url> </site> </distributionManagement> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2012-01-18 21:16:13
|
Revision: 263 http://openfast.svn.sourceforge.net/openfast/?rev=263&view=rev Author: jacob_northey Date: 2012-01-18 21:16:06 +0000 (Wed, 18 Jan 2012) Log Message: ----------- Caught all Socket Exceptions regardless of the specific type in Session class Modified Paths: -------------- trunk/src/main/java/org/openfast/session/Session.java Modified: trunk/src/main/java/org/openfast/session/Session.java =================================================================== --- trunk/src/main/java/org/openfast/session/Session.java 2011-10-29 16:25:08 UTC (rev 262) +++ trunk/src/main/java/org/openfast/session/Session.java 2012-01-18 21:16:06 UTC (rev 263) @@ -161,10 +161,9 @@ } } catch (Exception e) { Throwable cause = e.getCause(); - - if (cause != null && cause.getClass().equals(SocketException.class) - && cause.getMessage().toLowerCase().contains("socket closed")) { + if (cause != null && cause.getClass().equals(SocketException.class)) { listening = false; + errorHandler.error(FastConstants.IO_ERROR, cause.getMessage(), cause); } else if (e instanceof FastException) { FastException fastException = ((FastException) e); errorHandler.error(fastException.getCode(), fastException.getMessage(), e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2011-10-29 16:25:14
|
Revision: 262 http://openfast.svn.sourceforge.net/openfast/?rev=262&view=rev Author: jacob_northey Date: 2011-10-29 16:25:08 +0000 (Sat, 29 Oct 2011) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-10-29 16:25:05 UTC (rev 261) +++ trunk/pom.xml 2011-10-29 16:25:08 UTC (rev 262) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.3</version> + <version>1.0.4-SNAPSHOT</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.3</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.3</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.3</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2011-10-29 16:25:11
|
Revision: 261 http://openfast.svn.sourceforge.net/openfast/?rev=261&view=rev Author: jacob_northey Date: 2011-10-29 16:25:05 +0000 (Sat, 29 Oct 2011) Log Message: ----------- [maven-release-plugin] copy for tag openfast-1.0.3 Added Paths: ----------- tags/openfast-1.0.3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2011-10-29 16:25:00
|
Revision: 260 http://openfast.svn.sourceforge.net/openfast/?rev=260&view=rev Author: jacob_northey Date: 2011-10-29 16:24:54 +0000 (Sat, 29 Oct 2011) Log Message: ----------- [maven-release-plugin] prepare release openfast-1.0.3 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-10-29 16:23:57 UTC (rev 259) +++ trunk/pom.xml 2011-10-29 16:24:54 UTC (rev 260) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.4-SNAPSHOT</version> + <version>1.0.3</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/trunk</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/trunk</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.3</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.3</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.3</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2011-10-29 16:24:03
|
Revision: 259 http://openfast.svn.sourceforge.net/openfast/?rev=259&view=rev Author: jacob_northey Date: 2011-10-29 16:23:57 +0000 (Sat, 29 Oct 2011) Log Message: ----------- Removed Paths: ------------- tags/openfast-1.0.3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |