<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coral Blocks &#187; StraightToThePoint</title>
	<atom:link href="https://www.coralblocks.com/index.php/category/straighttothepoint/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.coralblocks.com/index.php</link>
	<description>Building amazing software, one piece at a time.</description>
	<lastBuildDate>Tue, 21 Apr 2026 23:44:16 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>CoralFIX (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralfix-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralfix-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralfix-straight-to-the-point/#comments</comments>
		<pubDate>Mon, 27 Apr 2015 17:37:31 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[coralfix]]></category>
		<category><![CDATA[coralreactor]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[heartbeat]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1454</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below an example of a FIX client and server that you can use as reference to start coding your own clients and servers. You can run their <code>main</code> methods and the client will connect to the server and start heartbeating.</p>
<p>The client:</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralfix.sample;

import static com.coralblocks.coralfix.FixTags.*;

import com.coralblocks.coralfix.FixConstants.FixVersions;
import com.coralblocks.coralfix.FixConstants.MsgTypes;
import com.coralblocks.coralfix.FixGroup;
import com.coralblocks.coralfix.FixMessage;
import com.coralblocks.coralfix.FixTag;
import com.coralblocks.coralfix.FixTags;
import com.coralblocks.coralfix.client.FixApplicationClient;
import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class SimpleFixApplicationClient extends FixApplicationClient {
	
	// Add any extra / non-standard fix tag from your spec, so you can work with the name instead of the id
	private static FixTag MySpecialTag = FixTags.addTag(&quot;MySpecialTag&quot;, 3434);
	
	public SimpleFixApplicationClient(NioReactor nio, String localhost, int port, Configuration config) {
	    super(nio, localhost, port, config);
    }
	
	@Override
	protected void handleOpened() {
		// client was opened and will now try to connect to its destination
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleClosed() {
		// client was closed, its connection was terminated and it will now sit idle
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionEstablished() {
		// socket connection was established but no login handshake was done yet
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionOpened() {
		// the FIX session handshake through LOGON messages was performed...
		// the client is now ready to start sending/receiving messages
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionReady() {
		// any sequence reset or re-send request have been processed at the session level...
		// the client is now ready to start sending/receiving any business application messages
		
		// do anything you want to do here...
		
		sendNewOrderSingle();
	}
	
	private void sendNewOrderSingle() {
		
		FixMessage outFixMsg = getOutFixMessage(MsgTypes.NewOrderSingle);
		
		// Add the tags you want to outFixMsg
		// NOTE: there is no need to add any session-level tags like MsgSeqNum, SenderCompID, etc.
		outFixMsg.add(Price, 50.34);
		outFixMsg.addTimestamp(TransactTime, System.currentTimeMillis());
		outFixMsg.add(ClOrdID, &quot;A123&quot;);
		outFixMsg.add(MySpecialTag, 'Y');
		
		// Add a repeating group
		FixGroup partyIds = outFixMsg.createGroup(NoPartyIDs);
		partyIds.nextElement().add(PartyID, &quot;BLAH&quot;).add(PartyIDSource, 'D').add(PartyRole, 54);
		partyIds.nextElement().add(PartyID, &quot;TRD&quot;).add(PartyIDSource, 'D').add(PartyRole, 36);
		partyIds.nextElement().add(PartyID, &quot;FOO&quot;).add(PartyIDSource, 'D').add(PartyRole, 7);
		
		// Send out the message to the client
		send(outFixMsg);
	}
	
	@Override
	protected void handleConnectionTerminated() {
		// the socket connection was broken/terminated
		
		// do anything you want to do here...
	}
	
	@Override
	protected void prepareLogon(FixMessage outFixMsg) {
		super.prepareLogon(outFixMsg);
		
		// add/remove any tag here... probably not necessary because the base
		// class is already adding all the required tags
	}
	
	@Override
	protected void handleFixApplicationMessage(FixMessage fixMsg, boolean possDupe) {
		
		// do what you have to do with this FIX application message
	}		
	
	public static void main(String[] args) {
		
		String senderComp = args.length &gt; 0 ? args[0] : &quot;testClient&quot;;
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		
		// REQUIRED
		config.add(&quot;fixVersion&quot;, FixVersions.VERSION_44);
		
		// the senderComp of the fix client
		// REQUIRED
		config.add(&quot;senderComp&quot;, senderComp);
		
		// NOT required:
		// config.add(&quot;targetComp&quot;, &quot;testAcct&quot;); // the TargetCompID tag
		// config.add(&quot;senderSub&quot;, &quot;xxx&quot;); // the SenderSubID tag
		// config.add(&quot;targetSub&quot;, &quot;yyy&quot;); // the TargetSubID tag
		// config.add(&quot;senderLoc&quot;, &quot;aaa&quot;); // the SenderLocationID tag
		// config.add(&quot;heartbeat&quot;, &quot;20&quot;); // the HeartBtInt tag (defaults to 10 seconds)
		// config.add(&quot;encryption&quot;, &quot;1&quot;); // the EncryptMethod tag (defaults to 0)
		// config.add(&quot;username&quot;, &quot;myusername&quot;); // sends the Username tag with the Logon message
		// config.add(&quot;password&quot;, &quot;mypass&quot;); // the RawData tag (the RawDataLength tag will also be included)
		
		// print all messages received and sent to STDOUT for debugging purposes
		// (default is false)
		config.add(&quot;debugMessages&quot;, true);
		// config.add(&quot;debugHeartbeats&quot;, true); // show heartbeats as well (default is true)
		
		// send a ResetSeqNumFlag=Y on Logon to force a sequence reset on both sides (inbound and outbound)
		// (default is false)
		config.add(&quot;forceSeqReset&quot;, true);
		
		// turn on asynchronous audit logging
		// (default is false)
		config.add(&quot;auditLog&quot;, false);
		// config.add(&quot;auditLogDir&quot;, &quot;/mylogdir/&quot;); // set the folder where to save the audit log file (default is &quot;auditLog&quot;)
		
		// turn on asynchronous fix logging (human readable fix messages)
		// (default is false)
		config.add(&quot;fixLog&quot;, false);
		// config.add(&quot;fixLogDir&quot;, &quot;/mylogdir&quot;); // set the folder where to save the fix log file (default is &quot;fixLog&quot;)
		// config.add(&quot;fixLogHeartbeats&quot;, true); // log heartbeats to the fix log (default is false)
		
		// persist sequences asynchronously to a file, so you don't lose them across restarts
		// (default is false)
		config.add(&quot;persistSequences&quot;, false);
		// config.add(&quot;persistDir&quot;, &quot;mySeqFolder&quot;); // the folder where to store the sequence files (default is current dir)
		// config.add(&quot;persistFilename, &quot;mySeqFilename&quot;); // the filename of the sequence file (default is the client name)
		
		// persists outbound fix messages asynchronously for message resends / gap fills
		// (default is false)
		config.add(&quot;supportPersistence&quot;, false);
		
		// open the admin server to accept telnet connections to monitor and control this fix client
		// (default is false)
		config.add(&quot;adminServer&quot;, false);
		
		// change the port for the admin server
		// (default is 45441)
		config.add(&quot;adminServerPort&quot;, 45441);
		
		// change to put the outbound FIX store in another thread
		// (default is true)
		config.add(&quot;fixStoreAsync&quot;, false);
		
		// set heartbeat interval in seconds
		// (default is 10)
		config.add(&quot;heartbeat&quot;, 5);
		
		/*
		// More optional config parameters
		// IMPORTANT: The default values should be what you want most of the time!
		
		config.add(&quot;includeLastMsgSeqNumProcessedTag&quot;, false); // include this header tag on every fix message? (default is true)
		
		config.add(&quot;maxLogonAttempts&quot;, 10); // if Logon fail for whatever reason, retry (default is 5)
		
		config.add(&quot;secondsToReopenAfterClose&quot;, 60 * 10); // if can't logon, then client will be closed and re-open after N seconds (default is 300)
		
		config.add(&quot;sendLogoutOnClose&quot;, false); // on a client close, a logout message will be sent (default is false)
		
		config.add(&quot;sendLogonOnConnected&quot;, true); // when socket is estabilished send logon automatically (default is true)
		
		config.add(&quot;persistSequencesImmediately&quot;, false); // force the mmap file to commit the the sequences to disk immediately (default is false)
		
		config.add(&quot;sequence&quot;, 1); // the initial inbound sequence (default is 1 or whatever is persisted if persistence is on)
		
		config.add(&quot;outboundSeq&quot;, 1); // the initial outbound sequence (default is 1 or wahtever is persisted if persitence is on)
		
		config.add(&quot;acceptInboundSeqFromServer&quot;, false); // accept whatever sequence you get from server as your inbound sequence (default is false)
		
		config.add(&quot;disconnectOnGap&quot;, false); // disconnect on gap instead of sending a sequence reset / message retransmission (default is false)
		
		config.add(&quot;reconnectOnStartTimerEvent&quot;, true); // when using a start timer, reconnect if connected (default is true)
		
		config.add(&quot;resetSequencesOnStartTimerEvent&quot;, true); // when using a start timer, reset the sequences (default is true)
		 */
		
		/*
		// More optional config parameters related to the max size of FIX messages:
		
		config.add(&quot;fixMaxTags&quot;, 64); // max number of tags, not including tags from repeating groups (defaults to 64)
		config.add(&quot;fixMaxGroups&quot;, 8); // max number of different repeating groups a message can have (defaults to 8)
		config.add(&quot;fixMaxValueLength&quot;, 256); // max length of a tag value in characters (defaults to 256)
		config.add(&quot;fixMaxGroupElements&quot;, 64); // max number of repeating group elements (defaults to 64)
		config.add(&quot;fixMaxValuesPerGroupElement&quot;, 64); // max number of repeating group tags/values per group element (defaults to 64)
		 */
		
		Client client = new SimpleFixApplicationClient(nio, &quot;localhost&quot;, 45451, config);
		client.open();
		
		nio.start();
	}
}
</pre>
<p>The server:</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralfix.sample;

import static com.coralblocks.coralfix.FixTags.*;

import java.util.Iterator;

import com.coralblocks.coralfix.FixConstants.FixVersions;
import com.coralblocks.coralfix.FixConstants.MsgTypes;
import com.coralblocks.coralfix.FixGroup;
import com.coralblocks.coralfix.FixGroupElement;
import com.coralblocks.coralfix.FixMessage;
import com.coralblocks.coralfix.FixTag;
import com.coralblocks.coralfix.FixTags;
import com.coralblocks.coralfix.server.FixApplicationServer;
import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class SimpleFixApplicationServer extends FixApplicationServer {
	
	// Add any extra / non-standard fix tag from your spec, so you can work with the name instead of the id
	private static FixTag MySpecialTag = FixTags.addTag(&quot;MySpecialTag&quot;, 3434);

	public SimpleFixApplicationServer(NioReactor nio, int port, Configuration config) {
		super(nio, port, config);
		
	    // Specify the repeating group you expect to parse, for each message type:
	    addGroupTemplate(MsgTypes.NewOrderSingle, NoPartyIDs, PartyID, PartyIDSource, PartyRole);
	    
	   /* Explanation about addGroupTemplate above:
        *
        * MsgTypes.NewOrderSingle is the message type containing the repeating group
        *    
        * NoPartyIDs is the main repeating group tag, meaning the repeating groups will
        * start after that tag. This tag contains the number (i.e. an integer) of repeating groups that follow.
        *
        * PartyID is the very first tag that every repeating group will have. That's important
        * to correctly denote the starting of a new repeating group and is enforced by the
        * FIX spec (i.e. you can't start a new repeating group with another tag)
        *
        * PartyIDSource, PartyRole, etc. are all the other tags (not included the very first
        * one above) that this repeating group can contain. They can be specified in any order
        * and can appear in the repeating group in any order. They are also all optional, in other words,
        * they do not need to appear in the FIX message BUT THEY DO HAVE TO BE SPECIFIED HERE, ALL OF THEM.
        */
    }
	
	@Override
	protected void handleOpened() {
		// sever was opened and will now accept connections from clients...
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleClosed() {
		// server was closed, all clients were disconnected and it will not accept any connection...
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionEstablished(Client client) {
		// socket connection was established for a client but no login handshake was done yet
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionOpened(Client client) {
		// the FIX session handshake through LOGON messages was performed for this client...
		// the client is now ready to start sending/receiving messages
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionReady(Client client) {
		// any sequence reset or re-send request have been processed at the session level...
		// the client is now ready to start sending/receiving any business application messages
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleConnectionTerminated(Client client) {
		// the socket connection was broken/terminated for this client
		
		// do anything you want to do here...
	}
	
	@Override
	protected void handleFixApplicationMessage(Client client, FixMessage fixMsg, boolean possDupe) {
		
		// do whatever you want to do with the application message received from this client...
		
		if (fixMsg.checkType(MsgTypes.NewOrderSingle)) {
			
			double price = fixMsg.getDouble(Price);
			System.out.println(&quot;Read price: &quot; + price);
			
			CharSequence clOrdID = fixMsg.getCharSequence(ClOrdID);
			System.out.println(&quot;Read ClOrdID: &quot; + clOrdID);
			
			char mySpecialTag = fixMsg.getChar(MySpecialTag);
			System.out.println(&quot;Read MySpecialTag: &quot; + mySpecialTag);
			
			FixGroup fixGroup = fixMsg.getGroup(NoPartyIDs);
			System.out.println(fixGroup.getNumberOfElements());
		 
			// you can also print the whole fix group for debugging purposes:
			System.out.println(fixGroup);
		         
	        Iterator&lt;FixGroupElement&gt; iter = fixGroup.iterator();
		         
	        while(iter.hasNext()) {
	             
	            FixGroupElement elem = iter.next();
	            
	            CharSequence partyID = elem.getCharSequence(PartyID);
	            System.out.println(partyID);
	            
	            char partyIDSource = elem.getChar(PartyIDSource);
	            System.out.println(partyIDSource);
	            
	            int partyRole = elem.getInt(PartyRole);
	            System.out.println(partyRole);
	             
	            // you can also print the whole element for debugging purposes:
	            System.out.println(elem);
	        }
		}
	}
	
	public static void main(String[] args) {

		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		
		// REQUIRED
		config.add(&quot;fixVersion&quot;, FixVersions.VERSION_44);
		
		// print all messages received and sent to STDOUT for debugging purposes
		// (default is false)
		config.add(&quot;debugMessages&quot;, true);
		
		// accept as the client inbound sequence whatever sequence I receive in the first message coming from the client
		// (default is false)
		config.add(&quot;acceptInboundSeqFromClient&quot;, false);
		
		// turn on asynchronous audit logging
		// (default is false)
		config.add(&quot;auditLog&quot;, false);
		
		// turn on asynchronous fix logging (human readable fix messages)
		// (default is false)
		config.add(&quot;fixLog&quot;, false);
		
		// persist all sequences from all clients (senderCompIDs) to disk
		// (default is false)
		config.add(&quot;persistSequences&quot;, false);
		
		// support persistence of outbound fix messages for message resends / gap fills
		// (default is false)
		config.add(&quot;supportPersistence&quot;, false);
		
		// enable the telnet admin server
		// (default is false)
		config.add(&quot;adminServer&quot;, false);
		
		// change the port for the admin server
		// (default is 45442)
		config.add(&quot;adminServerPort&quot;, 45442);
		
		// change to put the outbound FIX store in another thread
		// (default is true)
		config.add(&quot;fixStoreAsync&quot;, false);
		
		FixApplicationServer server = new SimpleFixApplicationServer(nio, 45451, config);
		server.open();

		nio.start();
	}
}
</pre>
<p>Server log output:</p>
<pre>
$ ./bin/run.sh com.coralblocks.coralfix.sample.SimpleFixApplicationServer
java -DshutdownHooksDebug=true -server -Dapple.awt.UIElement=true -XX:+UseCompressedOops -XX:+OptimizeStringConcat -Xms2g -Xmx8g -XX:NewSize=512m -XX:MaxNewSize=1024m -cp target/coralfix-all.jar:lib/jna-3.5.1.jar -DlogColors=true -DlogLevel=Info -DnioReactorPerformanceBoost=OFF com.coralblocks.coralfix.sample.SimpleFixApplicationServer
20:43:49.352039-INFO SimpleFixApplicationServer-45451 Server opened! bindAddress=/0.0.0.0:45451 actualBindAddress=/0:0:0:0:0:0:0:0:45451 host=0.0.0.0 port=45451 readServerSocketBufferSize=6710884 serverSocketReuseBindPort=false
20:43:49.352559-INFO NioReactor Reactor started! type=OptimumNioReactor datagramChannelImpl=DatagramChannelImpl selectorImpl=KQueueSelectorImpl supportConcurrentCallbacks=true
20:44:04.047525-INFO SimpleFixApplicationServer-45451 Client connection established! client=SimpleFixApplicationServerClient-127.0.0.1:59061 writeBufferSize=16384 readBufferSize=16384 writeSocketBufferSize=6710884 readSocketBufferSize=6710884
20:44:04.054598-SYSOUT SimpleFixApplicationServer-45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=72 MsgType(35)=Logon("A") MsgSeqNum(34)=1 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=0 SendingTime(52)=20250620-23:44:04.053 EncryptMethod(98)=0 HeartBtInt(108)=5 ResetSeqNumFlag(141)=Y CheckSum(10)=126
20:44:04.054836-INFO SimpleFixApplicationServer-45451 Received Logon message from client! client=SimpleFixApplicationServerClient-127.0.0.1:59061 senderComp=testClient seq=1 logonReceived="8=FIX.4.4|9=72|35=A|34=1|49=testClient|369=0|52=20250620-23:44:04.053|98=0|108=5|141=Y|10=126|"
20:44:04.055120-EVENT SimpleFixApplicationServer-45451 Client is forcing a sequence reset with tag ResetSeqNumFlag! client=SimpleFixApplicationServerClient-127.0.0.1:59061 nextExpectedSeq=2 nextOutboundSeq=1 senderComp=testClient
20:44:04.055196-INFO SimpleFixApplicationServer-45451 Client connection opened! client=SimpleFixApplicationServerClient-127.0.0.1:59061
20:44:04.055880-SYSOUT SimpleFixApplicationServer-45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=72 MsgType(35)=Logon("A") MsgSeqNum(34)=1 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=1 SendingTime(52)=20250620-23:44:04.056 HeartBtInt(108)=5 EncryptMethod(98)=0 ResetSeqNumFlag(141)=Y CheckSum(10)=128
20:44:04.056089-INFO SimpleFixApplicationServer-45451 Client logged to fix session! client=SimpleFixApplicationServerClient-127.0.0.1:59061 senderComp=testClient heartbeat=5 isResetSeqNumFlag=false logonSent="8=FIX.4.4|9=72|35=A|34=1|56=testClient|369=1|52=20250620-23:44:04.056|108=5|98=0|141=Y|10=XXX|"
20:44:06.556871-INFO SimpleFixApplicationServer-45451 Connection is now ready! client=SimpleFixApplicationServerClient-127.0.0.1:59061 connectionReadyInterval=2500
20:44:06.568439-SYSOUT SimpleFixApplicationServer-45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=173 MsgType(35)=NewOrderSingle("D") MsgSeqNum(34)=2 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=1 SendingTime(52)=20250620-23:44:06.564 Price(44)=50.34 TransactTime(60)=20250620-23:44:06.561 ClOrdID(11)=A123 MySpecialTag(3434)=Y [NoPartyIDs(453)=3 | PartyID(448)=BLAH PartyIDSource(447)=D PartyRole(452)=54 | PartyID(448)=TRD PartyIDSource(447)=D PartyRole(452)=36 | PartyID(448)=FOO PartyIDSource(447)=D PartyRole(452)=7] CheckSum(10)=120
Read price: 50.34
Read ClOrdID: A123
Read MySpecialTag: Y
3
PartyID(448)=BLAH PartyIDSource(447)=D PartyRole(452)=54 | PartyID(448)=TRD PartyIDSource(447)=D PartyRole(452)=36 | PartyID(448)=FOO PartyIDSource(447)=D PartyRole(452)=7
BLAH
D
54
PartyID(448)=BLAH PartyIDSource(447)=D PartyRole(452)=54
TRD
D
36
PartyID(448)=TRD PartyIDSource(447)=D PartyRole(452)=36
FOO
D
7
PartyID(448)=FOO PartyIDSource(447)=D PartyRole(452)=7
20:44:09.057270-SYSOUT SimpleFixApplicationServer-45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=2 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=2 SendingTime(52)=20250620-23:44:09.057 CheckSum(10)=096
20:44:11.559755-SYSOUT SimpleFixApplicationServer-45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=3 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=2 SendingTime(52)=20250620-23:44:11.558 CheckSum(10)=098
20:44:14.059070-SYSOUT SimpleFixApplicationServer-45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=3 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=3 SendingTime(52)=20250620-23:44:14.059 CheckSum(10)=096
20:44:16.561967-SYSOUT SimpleFixApplicationServer-45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=4 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=3 SendingTime(52)=20250620-23:44:16.560 CheckSum(10)=098
</pre>
<p>Client log output:</p>
<pre>
$ ./bin/run.sh com.coralblocks.coralfix.sample.SimpleFixApplicationClient
java -DshutdownHooksDebug=true -server -Dapple.awt.UIElement=true -XX:+UseCompressedOops -XX:+OptimizeStringConcat -Xms2g -Xmx8g -XX:NewSize=512m -XX:MaxNewSize=1024m -cp target/coralfix-all.jar:lib/jna-3.5.1.jar -DlogColors=true -DlogLevel=Info -DnioReactorPerformanceBoost=OFF com.coralblocks.coralfix.sample.SimpleFixApplicationClient
20:44:04.043041-INFO SimpleFixApplicationClient-testClient-localhost:45451 Client opened! sequence=1 session=null shouldResetSeqOnOpen=false
20:44:04.045146-INFO SimpleFixApplicationClient-testClient-localhost:45451 Bound socket channel! bindAddress=null boundTo=0.0.0.0:59061 bindPortProvider=null writeBufferSize=16384 readBufferSize=16384 writeSocketBufferSize=6710884 readSocketBufferSize=6710884
20:44:04.046328-INFO NioReactor Reactor started! type=OptimumNioReactor datagramChannelImpl=DatagramChannelImpl selectorImpl=KQueueSelectorImpl supportConcurrentCallbacks=true
20:44:04.051103-INFO SimpleFixApplicationClient-testClient-localhost:45451 Connection established!
20:44:04.051186-EVENT SimpleFixApplicationClient-testClient-localhost:45451 Resetting outbound sequence to 1! oldOutboundSeq=1
20:44:04.051224-INFO SimpleFixApplicationClient-testClient-localhost:45451 Connected to server! Sending Logon message... senderCompID=testClient isResettingSequences=true outboundSeq=1 logonAttempts=1
20:44:04.053586-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=72 MsgType(35)=Logon("A") MsgSeqNum(34)=1 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=0 SendingTime(52)=20250620-23:44:04.053 EncryptMethod(98)=0 HeartBtInt(108)=5 ResetSeqNumFlag(141)=Y CheckSum(10)=126
20:44:04.053907-INFO SimpleFixApplicationClient-testClient-localhost:45451 Sent Logon message to server! logonSent="8=FIX.4.4|9=72|35=A|34=1|49=testClient|369=0|52=20250620-23:44:04.053|98=0|108=5|141=Y|10=XXX|"
20:44:04.056825-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=72 MsgType(35)=Logon("A") MsgSeqNum(34)=1 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=1 SendingTime(52)=20250620-23:44:04.056 HeartBtInt(108)=5 EncryptMethod(98)=0 ResetSeqNumFlag(141)=Y CheckSum(10)=128
20:44:04.056950-INFO SimpleFixApplicationClient-testClient-localhost:45451 Received Logon response from server! sequence=1 hearbeat=5 logonReceived="8=FIX.4.4|9=72|35=A|34=1|56=testClient|369=1|52=20250620-23:44:04.056|108=5|98=0|141=Y|10=128|"
20:44:04.057000-EVENT SimpleFixApplicationClient-testClient-localhost:45451 Server is forcing a sequence reset with tag ResetSeqNumFlag! newInboundSequence=2 newOutboundSeq=2
20:44:04.057036-INFO SimpleFixApplicationClient-testClient-localhost:45451 Connection opened!
20:44:06.557617-INFO SimpleFixApplicationClient-testClient-localhost:45451 Connection is now ready! connectionReadyInterval=2500
20:44:06.564415-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=173 MsgType(35)=NewOrderSingle("D") MsgSeqNum(34)=2 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=1 SendingTime(52)=20250620-23:44:06.564 Price(44)=50.34 TransactTime(60)=20250620-23:44:06.561 ClOrdID(11)=A123 MySpecialTag(3434)=Y [NoPartyIDs(453)=3 | PartyID(448)=BLAH PartyIDSource(447)=D PartyRole(452)=54 | PartyID(448)=TRD PartyIDSource(447)=D PartyRole(452)=36 | PartyID(448)=FOO PartyIDSource(447)=D PartyRole(452)=7] CheckSum(10)=120
20:44:09.058828-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=2 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=2 SendingTime(52)=20250620-23:44:09.057 CheckSum(10)=096
20:44:11.558729-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=3 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=2 SendingTime(52)=20250620-23:44:11.558 CheckSum(10)=098
20:44:14.060615-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 IN <= BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=3 TargetCompID(56)=testClient LastMsgSeqNumProcessed(369)=3 SendingTime(52)=20250620-23:44:14.059 CheckSum(10)=096
20:44:16.560829-SYSOUT SimpleFixApplicationClient-testClient-localhost:45451 OUT => BeginString(8)=FIX.4.4 BodyLength(9)=55 MsgType(35)=Heartbeat("0") MsgSeqNum(34)=4 SenderCompID(49)=testClient LastMsgSeqNumProcessed(369)=3 SendingTime(52)=20250620-23:44:16.560 CheckSum(10)=098
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralfix-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralReactor (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralreactor-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralreactor-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralreactor-straight-to-the-point/#comments</comments>
		<pubDate>Sun, 26 Apr 2015 07:00:29 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[netty]]></category>
		<category><![CDATA[network i/o]]></category>
		<category><![CDATA[nio]]></category>
		<category><![CDATA[non-blocking]]></category>
		<category><![CDATA[reactor]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1425</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below the basics of CoralReactor: <span id="more-1425"></span></p>
<p>You can implement your own UDP and TCP clients and servers through the classes <code>AbstractUdpClient</code>, <code>AbstractTcpClient</code> and <code>AbstractTcpServer</code>. See further below this article for an example of an UDP client implementation.</p>
<p>It also comes with some clients and servers you can use out of the box. They are: LineTcpClient/LineTcpServer (messages delimited by the newline character), BytePayloadTcpClient/BytePayloadTcpServer (payload protocol with a byte size) and ShortPayloadTcpClient/ShortPayloadTcpServer (payload protocol with a short size). Below an example of a client that extends <code>LineTcpClient</code> to receive messages delimited by the newline character and print them to the console.</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralreactor.client.print;

import java.nio.ByteBuffer;

import com.coralblocks.coralbits.util.ByteBufferUtils;
import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.client.line.LineTcpClient;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class PrintLineClient extends LineTcpClient {

	public PrintLineClient(NioReactor nio, String host, int port, Configuration config) {
	    super(nio, host, port, config);
    }
	
	@Override
	protected void handleOpened() {
		// the client was open and will now start trying to connect to its destination...
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleClosed() {
		// the client was closed and will now do nothing (won't connect to anywhere and just sit idle)
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleConnectionEstablished() {
		// a network connection was established
		// for TCP this is a socket connection
		// for UDP that means a packet was received so a &quot;connection&quot; can be assumed
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleConnectionOpened() {
		// any special protocol login, handshake, authentication, etc. was successfully done
		// client is now ready to start exchanging messages
		// by default a connection is opened as soon as it is established but some special clients require
		// some initial login, handshake, authentication, etc. before they can start sending/receiving messages
		
		// do whatever you want here...
		
		send(&quot;Hello there!&quot;);
	}
	
	@Override
	protected void handleConnectionTerminated() {
		// the connection was broken or terminated for any reason...
		// for TCP this is a socket termination or the disconnect() method was explicitly called on the client
		// for UDP this is a read timeout (lack of heartbeat and data for some time) or the disconnect() method was explicitly called
		// after the connection is terminated the client will automatically try to reconnect unless the close() method is called
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleMessage(ByteBuffer msg) {
		
		// here is an application message received by this client...
		// it does NOT include the newline character
		
		ByteBufferUtils.println(msg);
	}
	
	public static void main(String[] args) {
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		
		Client client = new PrintLineClient(nio, &quot;localhost&quot;, 45151, config);
		client.open();
		
		nio.start();
	}
}
</pre>
<p>You can easily simulate a server with <i>netcat</i>:<br />
<a href="http://www.coralblocks.com/wp-content/uploads/2015/04/Screen-Shot-2015-04-25-at-9.20.58-PM.png"><img src="http://www.coralblocks.com/wp-content/uploads/2015/04/Screen-Shot-2015-04-25-at-9.20.58-PM.png" alt="Screen Shot 2015-04-25 at 9.20.58 PM" width="763" height="437" class="alignnone size-full wp-image-1426" /></a></p>
<p>The log output from the client is:</p>
<pre class="brush: java; title: ; notranslate">
21:20:39.023705-INFO PrintClient-localhost:45151 Client opened! sequence=1 session=null
21:20:39.083586-INFO NioReactor Reactor started! type=OptimumNioReactor impl=KQueueSelectorImpl
21:20:39.085061-INFO PrintClient-localhost:45151 Connection established!
21:20:39.085096-INFO PrintClient-localhost:45151 Connection opened!
[hi]
[this is a test]
[how are you?]
</pre>
<p>The code for a server is very similar, the difference being that all methods have a client argument since the server can handle many clients simultaneously. To make it more interesting we add a timer on each client to send a message every N seconds.</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralreactor.server.print;

import java.nio.ByteBuffer;

import com.coralblocks.coralbits.util.ByteBufferUtils;
import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.server.Server;
import com.coralblocks.coralreactor.server.line.LineTcpServer;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class PrintLineServer extends LineTcpServer {
	
	private final int interval;

	public PrintLineServer(NioReactor nio, int port, Configuration config) {
	    super(nio, port, config);
	    this.interval = config.getInt(&quot;interval&quot;, 1000); // 1 second by default
    }
	
	@Override
	protected void handleOpened() {
		// the server was open and will now start accepting connections (i.e. clients)
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleClosed() {
		// the server was closed, all clients was closed and the server will not accept any more connections
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleConnectionEstablished(Client client) {
		// a network connection was established with the given client
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleConnectionOpened(Client client) {
		// any special protocol login, handshake, authentication, etc. was successfully done
		// client is now ready to start exchanging messages
		// by default a connection is opened as soon as it is established but special clients require
		// some initial login, handshake, authentication, etc. before they can start sending/receiving messages
		
		// do whatever you want here...
		
		client.setEventTimeout(interval);
	}
	
	@Override
	public void handleEventTimeout(Client client, long now, int timeout) {
		client.send(&quot;Hello&quot;);
		client.setEventTimeout(timeout); // timers trigger just once so re-register for another trigger
	}
	
	@Override
	protected void handleConnectionTerminated(Client client) {
		// the connection with the given client was closed
		
		// do whatever you want here...
	}
	
	@Override
	protected void handleMessage(Client client, ByteBuffer msg) {
		
		// here is an application message received by the given client...
		// it does NOT include the newline character
		
		if (ByteBufferUtils.equals(msg, &quot;bye&quot;)) {
			client.close();
			return;
		}
		
		System.out.print(&quot;Message from &quot;);
		System.out.print(client);
		System.out.print(&quot; &quot;);
		
		ByteBufferUtils.println(msg);
	}
	
	public static void main(String[] args) {
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		config.add(&quot;interval&quot;, 2000); // 2 seconds
		
		Server server = new PrintLineServer(nio, 45151, config);
		server.open();
		
		nio.start();
	}
}
</pre>
<p>To connect to the server we can use the PrintLineClient we just wrote. For simplicity we just use <i>netcat</i>:</p>
<p><a href="http://www.coralblocks.com/wp-content/uploads/2015/04/Screen-Shot-2015-04-25-at-9.55.05-PM.png"><img src="http://www.coralblocks.com/wp-content/uploads/2015/04/Screen-Shot-2015-04-25-at-9.55.05-PM.png" alt="Screen Shot 2015-04-25 at 9.55.05 PM" width="763" height="437" class="alignnone size-full wp-image-1428" /></a></p>
<p>The log output from the server is:</p>
<pre class="brush: java; title: ; notranslate">
21:50:51.014509-INFO PrintLineServer-45151 Server opened! host=0.0.0.0 port=45151
21:50:51.017752-INFO NioReactor Reactor started! type=OptimumNioReactor impl=KQueueSelectorImpl
21:51:13.404784-INFO TcpServerClient-127.0.0.1:54391 Client connection established!
21:51:13.404828-INFO TcpServerClient-127.0.0.1:54391 Client connection opened!
Message from TcpServerClient-127.0.0.1:54391 [Hi]
21:51:30.109062-INFO PrintLineServer-45151 Client disconnected: TcpServerClient-127.0.0.1:54391
</pre>
<p><br/></p>
<p>You can also code your own clients and servers through the <code>AbstractUdpClient</code>, <code>AbstractTcpClient</code> and <code>AbstractTcpServer</code>. Below an example of an UDP client that receives and prints packets.</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralreactor.client.print;

import static com.coralblocks.corallog.Log.*;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;

import com.coralblocks.coralreactor.client.AbstractUdpClient;
import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class PrintPacketClient extends AbstractUdpClient {

	public PrintPacketClient(NioReactor nio, String host, int port, Configuration config) {
	    super(nio, host, port, config);
    }
	
	@Override
	protected void handleOpened() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleClosed() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleConnectionEstablished() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleConnectionOpened() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleConnectionTerminated() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleMessage(InetSocketAddress from, ByteBuffer msg) {
		Info.log(name, &quot;Got packet:&quot;, msg);
	}
	
	public static void main(String[] args) {
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		
		Client client = new PrintPacketClient(nio, &quot;0.0.0.0&quot;, 45151, config);
		client.open();
		
		nio.start();
	}	
}
</pre>
<p>To code an UDP client that only sends packets, we can extend <code>SenderUdpClient</code> as below:</p>
<pre class="brush: java; title: ; notranslate">
package com.coralblocks.coralreactor.client.sender;

import static com.coralblocks.corallog.Log.*;

import com.coralblocks.coralreactor.client.Client;
import com.coralblocks.coralreactor.nio.NioReactor;
import com.coralblocks.coralreactor.util.Configuration;
import com.coralblocks.coralreactor.util.MapConfiguration;

public class SenderPacketClient extends SenderUdpClient {
	
	private final int interval;

	public SenderPacketClient(NioReactor nio, String host, int port, Configuration config) {
	    super(nio, host, port, config);
	    this.interval = config.getInt(&quot;interval&quot;, 1000); // 1 second by default
    }
	
	@Override
	protected void handleOpened() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleClosed() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleConnectionEstablished() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleConnectionOpened() {
		setEventTimeout(interval);
	}
	
	@Override
	protected void handleConnectionTerminated() {
		// optional (here for clarity)
	}
	
	@Override
	protected void handleEventTimeout(long now, int timeout) {
		Info.log(name, &quot;Sending packet...&quot;);
		send(&quot;Hello there!&quot;);
		if (isConnectionOpen()) { // just in case there was an error sending the UDP packet and the client was closed
			setEventTimeout(timeout); // re-register so it happens again (timers trigger only once)
		}
	}
	
	public static void main(String[] args) {
		
		NioReactor nio = NioReactor.create();
		
		MapConfiguration config = new MapConfiguration();
		
		config.add(&quot;sendAddress&quot;, &quot;localhost&quot;);
		config.add(&quot;sendPort&quot;, 45151);
		
		String bindAddress = &quot;0.0.0.0&quot;;
		int bindPort = 0; // choose any free port to bind (ephemeral port)
		
		Client client = new SenderPacketClient(nio, bindAddress, bindPort, config);
		client.open();
		
		nio.start();
	}
}
</pre>
<p>Now if we run both clients, we get the following log output:</p>
<pre class="brush: java; title: ; notranslate">
02:53:41.328129-INFO SenderPacketClient-localhost:45151 Bound datagram channel to /0.0.0.0:55365
02:53:41.329297-INFO SenderPacketClient-localhost:45151 Client opened! sequence=1 session=null
02:53:41.331682-INFO SenderPacketClient-localhost:45151 Connection established!
02:53:41.333870-INFO SenderPacketClient-localhost:45151 Connection opened!
02:53:41.334212-INFO NioReactor Reactor started! type=OptimumNioReactor impl=KQueueSelectorImpl
02:53:41.800535-INFO SenderPacketClient-localhost:45151 Sending packet...
02:53:42.801833-INFO SenderPacketClient-localhost:45151 Sending packet...
02:53:43.802194-INFO SenderPacketClient-localhost:45151 Sending packet...
</pre>
<pre class="brush: java; title: ; notranslate">
03:00:08.926596-INFO PrintPacketClient-0.0.0.0:45151 Bound datagram channel to /0.0.0.0:45151
03:00:08.927742-INFO PrintPacketClient-0.0.0.0:45151 Client opened! sequence=1 session=null
03:00:08.937026-INFO NioReactor Reactor started! type=OptimumNioReactor impl=KQueueSelectorImpl
03:00:08.943330-INFO PrintPacketClient-0.0.0.0:45151 Connection established!
03:00:08.943557-INFO PrintPacketClient-0.0.0.0:45151 Connection opened!
03:00:08.943622-INFO PrintPacketClient-0.0.0.0:45151 Got packet: Hello there!
03:00:09.838106-INFO PrintPacketClient-0.0.0.0:45151 Got packet: Hello there!
03:00:10.838293-INFO PrintPacketClient-0.0.0.0:45151 Got packet: Hello there!
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralreactor-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralStore (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralstore-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralstore-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralstore-straight-to-the-point/#comments</comments>
		<pubDate>Sat, 25 Apr 2015 17:34:47 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[async store]]></category>
		<category><![CDATA[asynchronous logging]]></category>
		<category><![CDATA[CoralStore]]></category>
		<category><![CDATA[store]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1410</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below the basics of CoralStore: <span id="more-1410"></span></p>
<pre class="brush: java; highlight: [11,17,25,31,49]; title: ; notranslate">
		ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
		
		String storeDir = &quot;.&quot;;
		String theSession = &quot;theSession&quot;;
		
		// Store implementations:
		// - FileStore: in-disk
		// - MapStore: in-memory (for testing / debugging)
		// - CircularStore: in-memory (backed up by a circular array)
		// - CircularTailFileStore (hybrid of FileStore and CircularStore)
		Store store = new FileStore(storeDir, theSession);
		
		byteBuffer.clear();
		byteBuffer.put(&quot;A message&quot;.getBytes());
		byteBuffer.flip();
		
		store.addMessage(byteBuffer);
		
		byteBuffer.clear();
		byteBuffer.put(&quot;Another message&quot;.getBytes());
		byteBuffer.flip();
		
		store.addMessage(byteBuffer);
		
		store.flush();
		
		System.out.println(&quot;Store size: &quot; + store.size()); // =&gt; 2
		System.out.println(&quot;Store next seq: &quot; + store.getNextExpectedSequence()); // =&gt; 3
		
		byteBuffer.clear();
		int msgSize = store.getMessage(2, byteBuffer);
		System.out.println(&quot;Size read: &quot; + msgSize); // =&gt; 15
		byteBuffer.flip();
		ByteBufferUtils.println(byteBuffer); // =&gt; [Another message]
		
		byteBuffer.clear();
		byteBuffer.put(&quot;Yet another message&quot;.getBytes());
		byteBuffer.flip();
		
		store.addMessage(byteBuffer);
		store.flush();

		System.out.println(&quot;Has sequence 2: &quot; + store.checkSequence(2)); // =&gt; true
		System.out.println(&quot;Has sequence 4: &quot; + store.checkSequence(4)); // =&gt; false
		
		System.out.println(&quot;Has range 2-3: &quot; + store.checkRange(2, 2)); // =&gt; true
		System.out.println(&quot;Has range 2-4: &quot; + store.checkRange(2, 3)); // =&gt; false
		
		store.close();
</pre>
<p><br/></p>
<h3 class="coral">AsyncStore</h3>
<p>To create an asynchronous store all you have to do is pass a store in the constructor of <code>AsyncStore</code>.</p>
<pre class="brush: java; title: ; notranslate">
		Store store = new FileStore(storeDir, theSession);
		AsyncStore asyncStore = new AsyncStore(store);
		
		// now use it as you would use any store

		// one extra method:
		asyncStore.drainAndWait(); // block and drain

		asyncStore.close(); // returns immediately but don't worry: async store will be drained
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralstore-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralLog (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/corallog-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=corallog-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/corallog-straight-to-the-point/#comments</comments>
		<pubDate>Fri, 24 Apr 2015 20:12:43 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[asynchronous logging]]></category>
		<category><![CDATA[event sourcing]]></category>
		<category><![CDATA[latency]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[logback]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1383</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below the basics of CoralLog:. <span id="more-1383"></span><br />
<br/></p>
<h3 class="coral">Level Logging</h3>
<pre class="brush: java; title: ; notranslate">
// this static import is all you need to start using CoralLog:
import static com.coralblocks.corallog.Log.*;

// if you want to log to a file, instead of to the console (stdout)
Log.setFile(true); // or -DlogFile=true (you can also use a configuration file)
 
// then, anywhere in your code you can write:

Warn.log(&quot;This is a log message!&quot;, &quot;string=&quot;, myString, &quot;byteBuffer=&quot;, myByteBuffer, &quot;price=&quot;, price);

Error.log(appName, &quot;An exception happened:&quot;, exception);

Info.log(myStringBuilder);
Info.log(myByteBuffer);
Info.log(myByteArray);

// you can also use placeholders:

Debug.log(&quot;This is a log message! user={} age={}&quot;, &quot;foo&quot;, 21);
</pre>
<p><br/></p>
<h3 class="coral">Event Sourcing</h3>
<pre class="brush: java; title: ; notranslate">
// pass a filename to be created in the current directory
Logger myLogger = Log.createLogger(&quot;myLogFile.log&quot;);
 
// or you can pass the directory
Logger myLogger = Log.createLogger(&quot;/var/mydir/&quot;, &quot;myLogFile.log&quot;);

// turn off timestamps before each log line
Logger myLogger = Log.createLogger(&quot;myLogFile.log&quot;, false); // no timestamps
 
// turn off timestamps before each log line
Logger myLogger = Log.createLogger(&quot;/var/mydir/&quot;, &quot;myLogFile.log&quot;, false); // no timestamps

// then log as usual:

myLogger.log(&quot;This is a log message!&quot;, &quot;string=&quot;, myString, &quot;byteBuffer=&quot;, myByteBuffer, &quot;price=&quot;, price);

myLogger.log(appName, &quot;An exception happened:&quot;, exception);

myLogger.log(myStringBuilder);
myLogger.log(myByteBuffer);
myLogger.log(myByteArray);

// you can also use placeholders:

myLogger.log(&quot;This is a log message! user={} age={}&quot;, &quot;foo&quot;, 21);
</pre>
<p><br/></p>
<h3 class="coral">Using LogConfig</h3>
<pre class="brush: java; highlight: [6]; title: ; notranslate">
LogConfig logConfig = new LogConfig(filename); // current directory
// or LogConfig logConfig = new LogConfig(dir, filename);
logConfig.includeLogEntrySeparator = false; // default is true
logConfig.includeTopHeader = true; // default is false

Logger myLogger = Log.createLogger(logConfig);
</pre>
<p>Below all the <code>LogConfig</code> options with their defaults:</p>
<pre class="brush: java; title: ; notranslate">
	public String dir = Log.getDir();
	public boolean isSynchronized = false;
	public boolean isMemoryMapped = false;
	public int memoryMappedBufferSize = 64 * 1024 * 1024; // 64m
	public List&lt;Encoder&gt; encoders = Log.getEncoders();
	public boolean isAsynchronous = true;
	public boolean includeTopHeader = false;
	public boolean includeLogEntrySeparator = true;
	public int outputBufferSize = 64 * 1024; // 64k (optimum)
	public boolean flushImmediately = false;
	public boolean includeTimestamp = true;
	public int secondsToFlush = -1;
	public boolean isNoSpaceBetweenObjects = false;
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/corallog-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralQueue (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralqueue-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralqueue-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralqueue-straight-to-the-point/#comments</comments>
		<pubDate>Fri, 24 Apr 2015 05:18:43 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[concurrentlinkedlist]]></category>
		<category><![CDATA[demultiplexer]]></category>
		<category><![CDATA[demux]]></category>
		<category><![CDATA[multicast]]></category>
		<category><![CDATA[multiplexer]]></category>
		<category><![CDATA[queue]]></category>
		<category><![CDATA[splitter]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1368</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below the basics of CoralQueue: <span id="more-1368"></span></p>
<p><br/></p>
<h3 class="coral">Queue</h3>
<p>One producer sending messages to one consumer. One thread sending to another thread.</p>
<pre class="brush: java; highlight: [11,22,24,31,42,44]; title: ; notranslate">
package com.coralblocks.coralqueue.sample.queue;

import com.coralblocks.coralqueue.AtomicQueue;
import com.coralblocks.coralqueue.Queue;
import com.coralblocks.coralqueue.util.MutableLong;

public class Sample {
	
	public static void main(String[] args) throws InterruptedException {
		
		final Queue&lt;MutableLong&gt; queue = new AtomicQueue&lt;MutableLong&gt;(1024, MutableLong.class);
		
		Thread consumer = new Thread() {
			
			@Override
			public void run() {
				
				boolean running = true;
				
				while(running) {
					long avail;
					while((avail = queue.availableToPoll()) == 0); // busy spin
					for(int i = 0; i &lt; avail; i++) {
						MutableLong ml = queue.poll();
						if (ml.get() == -1) { // message to flag exit...
							running = false;
							break;
						}
						System.out.println(ml.get());
					}
					queue.donePolling();
				}
			}
			
		};
		
		consumer.start();
		
		MutableLong ml;
		
		for(int i = 0; i &lt; 10; i++) {
			while((ml = queue.nextToDispatch()) == null); // busy spin
			ml.set(System.nanoTime());
			queue.flush();
		}
		
		// send a message to stop consumer...
		while((ml = queue.nextToDispatch()) == null); // busy spin
		ml.set(-1);
		queue.flush();
		
		consumer.join(); // wait for the consumer thread to die...
	}
}
</pre>
<p><br/></p>
<h3 class="coral">Demultiplexer</h3>
<p>One producer distributing messages to multiple consumers. Each message is processed only once by a random consumer. One thread sending to many threads. Great for parallel processing. Note that you can also <i>route</i> a message to a specific consumer (line 60).</p>
<pre class="brush: java; highlight: [13,21,30,32,40,51,54,60]; title: ; notranslate">
package com.coralblocks.coralqueue.sample.demux;

import com.coralblocks.coralqueue.demux.AtomicDemux;
import com.coralblocks.coralqueue.demux.Consumer;
import com.coralblocks.coralqueue.demux.Demux;

public class SampleWithConsumer {

	private static final int NUMBER_OF_CONSUMERS = 4;
	
	public static void main(String[] args) throws InterruptedException {
		
		final Demux&lt;StringBuilder&gt; demux = new AtomicDemux&lt;StringBuilder&gt;(1024, StringBuilder.class, NUMBER_OF_CONSUMERS);
		
		Thread[] consumers = new Thread[NUMBER_OF_CONSUMERS];
		
		for(int i = 0; i &lt; consumers.length; i++) {
			
    		consumers[i] = new Thread(&quot;Consumer-&quot; + i) {
    			
    			private final Consumer&lt;StringBuilder&gt; consumer = demux.nextConsumer();
    			
    			@Override
    			public void run() {
    				
    				boolean running = true;
    				
    				while(running) {
    					long avail;
    					while((avail = consumer.availableToPoll()) == 0); // busy spin
    					for(int i = 0; i &lt; avail; i++) {
    						StringBuilder sb = consumer.poll();
    						if (sb == null) break; // mandatory for demuxes!
    						if (sb.length() == 0) {
    							running = false;
    							break; // exit immediately...
    						}
    						System.out.println(sb.toString());
    					}
    					consumer.donePolling();
    				}
    			}
    		};
    		
    		consumers[i].start();
		}
		
		StringBuilder sb;
		
		for(int i = 0; i &lt; 3; i++) {
			while((sb = demux.nextToDispatch()) == null); // busy spin
			sb.setLength(0);
			sb.append(&quot;message &quot;).append(i);
			demux.flush();
		}
		
		// send a message to stop consumers...
		for(int i = 0; i &lt; NUMBER_OF_CONSUMERS; i++) {
			// routing is being used here...
			while((sb = demux.nextToDispatch(i)) == null); // busy spin
			sb.setLength(0);
		}
		
		demux.flush(); // sent batch
		
		for(int i = 0; i &lt; consumers.length; i++) consumers[i].join();
	}
}
</pre>
<p><br/></p>
<h3 class="coral">Multiplexer</h3>
<p>Multiple producers pipelining (i.e. sending) messages to a single consumer. Many threads sending to one thread. Great for gathering results from parallel processing.</p>
<pre class="brush: java; highlight: [21,29,37,40,62,64,75]; title: ; notranslate">
package com.coralblocks.coralqueue.sample.mux;

import com.coralblocks.coralbits.util.Builder;
import com.coralblocks.coralqueue.mux.AtomicMux;
import com.coralblocks.coralqueue.mux.Mux;
import com.coralblocks.coralqueue.mux.Producer;

public class SampleWithProducer {
	
	private static final int NUMBER_OF_PRODUCERS = 4;
	
	public static void main(String[] args) throws InterruptedException {
		
		Builder&lt;StringBuilder&gt; builder = new Builder&lt;StringBuilder&gt;() {
			@Override
            public StringBuilder newInstance() {
	            return new StringBuilder(1024);
            }
		};
		
		final Mux&lt;StringBuilder&gt; mux = new AtomicMux&lt;StringBuilder&gt;(1024, builder, NUMBER_OF_PRODUCERS);
		
		Thread[] producers = new Thread[NUMBER_OF_PRODUCERS];
		
		for(int i = 0; i &lt; producers.length; i++) {
			
			producers[i] = new Thread(new Runnable() {
				
				private final Producer&lt;StringBuilder&gt; producer = mux.nextProducer();

				@Override
                public void run() {
					
					StringBuilder sb;
					
					for(int j = 0; j &lt; 4; j++) {
						while((sb = producer.nextToDispatch()) == null); // busy spin
						sb.setLength(0);
						sb.append(&quot;message &quot;).append(j).append(&quot; from producer &quot;).append(producer.getIndex());
						producer.flush();
					}
					
					// send final message
					while((sb = producer.nextToDispatch()) == null); // busy spin
					sb.setLength(0); // empty string to signal we are done
					producer.flush();
                }
			}, &quot;Producer&quot; + i);
		}
		
		Thread consumer = new Thread(new Runnable() {

			@Override
            public void run() {
				
				boolean running = true;
				int finalMessages = 0;
				
				while(running) {
					
					long avail;
					while((avail = mux.availableToPoll()) == 0); // busy spin
					for(int i = 0; i &lt; avail; i++) {
						StringBuilder sb = mux.poll();
						if (sb.length() == 0) {
							if (++finalMessages == NUMBER_OF_PRODUCERS) {
								// and we are done!
								running = false;
								break;
							}
						} else {
							System.out.println(sb.toString());
						}
					}
					mux.donePolling();
				}
            }
		}, &quot;Consumer&quot;);
		
		consumer.start();
		for(int i = 0; i &lt; producers.length; i++) producers[i].start();
		
		consumer.join();
		for(int i = 0; i &lt; producers.length; i++) producers[i].join();
	}
}
</pre>
<p><br/></p>
<h3 class="coral">Splitter / Broadcaster</h3>
<p>One producer sending messages to multiple consumers. Each message is processed by each and every consumer. One thread sending to many threads. Great for broadcasting messages to multiple threads.</p>
<pre class="brush: java; highlight: [13,21,30,32,40,51,54]; title: ; notranslate">
package com.coralblocks.coralqueue.sample.splitter;

import com.coralblocks.coralqueue.splitter.AtomicSplitter;
import com.coralblocks.coralqueue.splitter.Consumer;
import com.coralblocks.coralqueue.splitter.Splitter;

public class SampleWithConsumer {

	private static final int NUMBER_OF_CONSUMERS = 4;
	
	public static void main(String[] args) throws InterruptedException {
		
		final Splitter&lt;StringBuilder&gt; splitter = new AtomicSplitter&lt;StringBuilder&gt;(1024, StringBuilder.class, NUMBER_OF_CONSUMERS);
		
		Thread[] consumers = new Thread[NUMBER_OF_CONSUMERS];
		
		for(int i = 0; i &lt; consumers.length; i++) {
			
    		consumers[i] = new Thread(&quot;Consumer-&quot; + i) {
    			
    			private final Consumer&lt;StringBuilder&gt; consumer = splitter.nextConsumer();
    			
    			@Override
    			public void run() {
    				
    				boolean running = true;
    				
    				while(running) {
    					long avail;
    					while((avail = consumer.availableToPoll()) == 0); // busy spin
    					for(int i = 0; i &lt; avail; i++) {
    						StringBuilder sb = consumer.poll();
    						if (sb == null) break; // mandatory for splitters!
    						if (sb.length() == 0) {
    							running = false;
    							break; // exit immediately...
    						}
    						System.out.println(&quot;got &quot; + sb.toString() + &quot; at consumer &quot; + consumer.getIndex());
    					}
    					consumer.donePolling();
    				}
    			}
    		};
    		
    		consumers[i].start();
		}
		
		StringBuilder sb;
		
		for(int i = 0; i &lt; 3; i++) {
			while((sb = splitter.nextToDispatch()) == null); // busy spin
			sb.setLength(0);
			sb.append(&quot;message &quot;).append(i);
			splitter.flush();
		}
		
		// send a message to stop consumers...
		while((sb = splitter.nextToDispatch()) == null); // busy spin
		sb.setLength(0);
		splitter.flush();
		
		for(int i = 0; i &lt; consumers.length; i++) consumers[i].join();
	}
}
</pre>
<p><br/></p>
<h3 class="coral">MpmcQueue</h3>
<p>Multiple-producers sending messages to multiple-consumers. You can choose any number of producers and consumers. You can also route a message to a specific consumer (line 90).</p>
<pre class="brush: java; highlight: [16,24,33,35,43,59,67,72,90]; title: ; notranslate">
package com.coralblocks.coralqueue.sample.mpmc;

import java.util.concurrent.atomic.AtomicLong;

import com.coralblocks.coralqueue.mpmc.Consumer;
import com.coralblocks.coralqueue.mpmc.MpmcQueue;
import com.coralblocks.coralqueue.mpmc.Producer;

public class Sample {

	private static final int NUMBER_OF_PRODUCERS = 4;
	private static final int NUMBER_OF_CONSUMERS = 2;
	
	public static void main(String[] args) throws InterruptedException {
		
		final MpmcQueue&lt;StringBuilder&gt; mpmc = new MpmcQueue&lt;StringBuilder&gt;(1024, StringBuilder.class, NUMBER_OF_PRODUCERS, NUMBER_OF_CONSUMERS);
		
		Thread[] consumers = new Thread[NUMBER_OF_CONSUMERS];
		
		for(int i = 0; i &lt; consumers.length; i++) {
			
    		consumers[i] = new Thread(&quot;Consumer-&quot; + i) {
    			
    			private final Consumer&lt;StringBuilder&gt; consumer = mpmc.nextConsumer();
    			
    			@Override
    			public void run() {
    				
    				boolean running = true;
    				
    				while(running) {
    					long avail;
    					while((avail = consumer.availableToPoll()) == 0); // busy spin
    					for(int i = 0; i &lt; avail; i++) {
    						StringBuilder sb = consumer.poll();
    						if (sb == null) break; // mandatory for mpmc!
    						if (sb.length() == 0) {
								running = false;
								break; // exit immediately...
    						}
    						System.out.println(sb.toString() + &quot; got by consumer &quot; + consumer.getIndex());
    					}
    					consumer.donePolling();
    				}
    			}
    		};
    		
    		consumers[i].start();
		}
		
		Thread[] producers = new Thread[NUMBER_OF_PRODUCERS];
		
		final AtomicLong counter = new AtomicLong(0);
		
		for(int i = 0; i &lt; producers.length; i++) {
			
    		producers[i] = new Thread(&quot;Producer-&quot; + i) {
    			
    			private final Producer&lt;StringBuilder&gt; producer = mpmc.nextProducer();
    			
    			@Override
    			public void run() {

    				StringBuilder sb;
    				
    				for(int i = 0; i &lt; 3; i++) {
    					while((sb = producer.nextToDispatch()) == null); // busy spin
    					long msgNumber = counter.getAndIncrement();
    					sb.setLength(0);
    					sb.append(&quot;message &quot;).append(msgNumber);
    					System.out.println(&quot;sending message &quot; + msgNumber + &quot; from producer &quot; + producer.getIndex());
    					producer.flush();
    				}
    			}
    		};
    		
    		producers[i].start();
		}
		
		for(int i = 0; i &lt; producers.length; i++) producers[i].join();
		
		Thread.sleep(4000);
		
		Producer&lt;StringBuilder&gt; p = mpmc.getProducer(0);
	
		for(int i = 0; i &lt; consumers.length; i++) {
			StringBuilder sb;
			// send a message to stop consumers...
			// routing is being used here...
			while((sb = p.nextToDispatch(i)) == null); // busy spin
			sb.setLength(0);
		}
		
		p.flush();
		
		for(int i = 0; i &lt; consumers.length; i++) consumers[i].join();
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralqueue-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralThreads (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralthreads-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralthreads-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralthreads-straight-to-the-point/#comments</comments>
		<pubDate>Fri, 24 Apr 2015 04:50:22 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[cpuset]]></category>
		<category><![CDATA[hyper-threading]]></category>
		<category><![CDATA[isolcpus]]></category>
		<category><![CDATA[jni]]></category>
		<category><![CDATA[multithreading]]></category>
		<category><![CDATA[pin]]></category>
		<category><![CDATA[taskdef]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1365</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Below the basics of CoralThreads: <span id="more-1365"></span></p>
<pre class="brush: java; highlight: [13,25,35]; title: ; notranslate">
import com.coralblocks.coralthreads.Affinity;
 
public class Basics {
     
    public static void main(String[] args) throws Exception {
         
        Thread thread = new Thread(new Runnable() {
 
            @Override
            public void run() {
 
                // must be the first thing inside the run method
                Affinity.bind();
                 
                try {
                     
                    while(true) {
                         
                        // do whatever you want here...
                    }
                     
                } finally {
                     
                    // must be the last thing inside the run method
                    Affinity.unbind();
                }
            }
        }, &quot;MyPinnedThread&quot;);
         
        System.out.println();
        Affinity.printSituation(); // nothing done yet...
         
        // assign thread to processor:
        int procToBind = Integer.parseInt(args[0]);
        Affinity.assignToProcessor(procToBind, thread);
         
        Affinity.printSituation(); // now you see it there...
         
        // start the thread!
        thread.start();
         
        Affinity.printSituation(); // now it is running with a pid...
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralthreads-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CoralBits (Straight to the Point)</title>
		<link>https://www.coralblocks.com/index.php/coralbits-straight-to-the-point/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coralbits-straight-to-the-point</link>
		<comments>https://www.coralblocks.com/index.php/coralbits-straight-to-the-point/#comments</comments>
		<pubDate>Thu, 23 Apr 2015 07:21:49 +0000</pubDate>
		<dc:creator><![CDATA[cb]]></dc:creator>
				<category><![CDATA[StraightToThePoint]]></category>
		<category><![CDATA[data structures]]></category>
		<category><![CDATA[garbage collector]]></category>
		<category><![CDATA[garbage leaks]]></category>
		<category><![CDATA[gc]]></category>
		<category><![CDATA[latency]]></category>

		<guid isPermaLink="false">http://www.coralblocks.com/index.php/?p=1278</guid>
		<description><![CDATA[ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
CoralBits offers high-performance, powerful and easy-to-use libraries to build ultra-low-latency systems that produce zero garbage. <span id="more-1278"></span>
</p>
<h3 class="coral">Data Structures</h3>
<p><i>All data structures have garbage-free iterators</i></p>
<p><h5><u>Maps:</u></h5>
<table>
<tr>
<td width="20%"><code>ByteArrayMap</code></td>
<td>Map that uses a byte[] for its keys</td>
</tr>
<tr>
<td width="20%"><code>CharSequenceMap</code></td>
<td>Map that uses a CharSequence for its keys</td>
</tr>
<tr>
<td width="20%"><code>ByteMap</code></td>
<td>Map that uses a byte for its keys</td>
</tr>
<tr>
<td width="20%"><code>CharMap</code></td>
<td>Map that uses a char for its keys</td>
</tr>
<tr>
<td width="20%"><code>IntMap</code></td>
<td>Map that uses an int for its keys</td>
</tr>
<tr>
<td width="20%"><code>LongMap</code></td>
<td>Map that uses a long for its keys</td>
</tr>
<tr>
<td width="20%"><code>IdentityMap</code></td>
<td>Map that uses object identity when comparing keys</td>
</tr>
<tr>
<td width="20%"><code>PooledHashMap</code></td>
<td>java.util.HashMap fixed not to produce any garbage</td>
</tr>
<tr>
<td width="20%"><code>FastIntMap</code></td>
<td>A very fast IntMap for when max key is known in advance and it is not so big</td>
</tr>
</table>
<p><br/></p>
<p><h5><u>Sets:</u></h5>
<table>
<tr>
<td width="20%"><code>ByteArraySet</code></td>
<td>Set of byte[]s</td>
</tr>
<tr>
<td width="20%"><code>LongSet</code></td>
<td>Set of longs</td>
</tr>
<tr>
<td width="20%"><code>IntSet</code></td>
<td>Set of ints</td>
</tr>
<tr>
<td width="20%"><code>PooledHashSet</code></td>
<td>java.util.HashSet fixed not to produce any garbage</td>
</tr>
<tr>
<td width="20%"><code>IntChecker</code></td>
<td>A fast and clean bounded set for integers</td>
</tr>
<tr>
<td width="20%"><code>IdentitySet</code></td>
<td>A set that uses object identity when comparing keys</td>
</tr>
</table>
<p><br/></p>
<p><h5><u>Lists:</u></h5>
<table>
<tr>
<td width="20%"><code>ObjectLinkedList</code></td>
<td>Double linked-list of Objects</td>
</tr>
<tr>
<td width="20%"><code>CharSequenceList</code></td>
<td>List of CharSequences</td>
</tr>
<tr>
<td width="20%"><code>CircularLongList</code></td>
<td>List of longs backed up by a circular array</td>
</tr>
<tr>
<td width="20%"><code>CircularQueue</code></td>
<td>A fast and clean circular array implementation</td>
</tr>
<tr>
<td width="20%"><code>IntList</code></td>
<td>List of ints</td>
</tr>
<tr>
<td width="20%"><code>LongList</code></td>
<td>List of longs</td>
</tr>
<tr>
<td width="20%"><code>ObjectList</code></td>
<td>List of objects</td>
</tr>
<tr>
<td width="20%"><code>ObjectLinkedList</code></td>
<td>A fast and clean double-linked list that exposes its entries</td>
</tr>
<tr>
<td width="20%"><code>PooledLinkedList</code></td>
<td>java.util.LinkedList fixed not to produce any garbage</td>
</tr>
<tr>
<td width="20%"><code>SortedLongList</code></td>
<td>Sorted list of longs</td>
</tr>
</table>
<p><br/></p>
<p><h5><u>Pools:</u></h5>
<table>
<tr>
<td width="20%"><code>CircularObjectPool</code></td>
<td>Object pool backed up by a circular array (fixed size)</td>
</tr>
<tr>
<td width="20%"><code>LinkedObjectPool</code></td>
<td>Object pool backed up by a linked list (dynamic size)</td>
</tr>
<tr>
<td width="20%"><code>ResettableObjectPool</code></td>
<td>Object pool that can reclaim all objects very fast</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Garbage Collector Utilities</h3>
<table>
<tr>
<td width="20%"><code>MemorySampler</code></td>
<td>Check memory allocated by the VM around any block of code</td>
</tr>
<tr>
<td width="20%"><code>GarbageCollector</code></td>
<td>Synchronous and predictable GC</td>
</tr>
<tr>
<td width="20%"><code>GCSampler</code></td>
<td>Check memory collected by the GC around any block of code</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Memory Allocation</h3>
<table>
<tr>
<td width="20%"><code>HeapMemory</code></td>
<td>Allocates chunks of memory in the Java heap</td>
</tr>
<tr>
<td width="20%"><code>DirectMemory</code></td>
<td>Allocates chunks of native memory (off-heap)</td>
</tr>
<tr>
<td width="20%"><code>MMapMemory</code></td>
<td>Allocates chunks of memory through a memory-mapped file off-heap</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Timestampers</h3>
<table>
<tr>
<td width="25%"><code>SystemMillisecondTimestamper</code></td>
<td>Uses System.currentTimeMillis() (millisecond precision &#8211; realtime)</td>
</tr>
<tr>
<td width="25%"><code>SystemNanosecondTimestamper</code></td>
<td>Uses System.nanoTime() (nanosecond precision &#8211; monotonic)</td>
</tr>
<tr>
<td width="25%"><code>RdtscTimestamper</code></td>
<td>Uses native rdtsc() syscall (nanosecond precision &#8211; monotonic)</td>
</tr>
<tr>
<td width="25%"><code>SysTimeTimestamper</code></td>
<td>Uses native clock_gettime() syscall (nanosecond precision &#8211; monotonic and realtime)</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Benchmarks</h3>
<table>
<tr>
<td width="20%"><code>Benchmarker</code></td>
<td>Benchmark with average, minimum and maximum time</td>
</tr>
<tr>
<td width="20%"><code>DetailedBenchmarker</code></td>
<td>Detailed benchmark with avg, min, max, percentiles, standard deviation and more</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Utilities</h3>
<table>
<tr>
<td width="20%"><code>AccessorUtils</code></td>
<td>Reflection utilities</td>
</tr>
<tr>
<td width="20%"><code>ByteArrayUtils</code></td>
<td>Parser plus various utilities for working with byte[]s</td>
</tr>
<tr>
<td width="20%"><code>ByteBufferUtils</code></td>
<td>Parser plus various utilities for working with ByteBuffers</td>
</tr>
<tr>
<td width="20%"><code>ByteUtils</code></td>
<td>Various utilities for working with bytes</td>
</tr>
<tr>
<td width="20%"><code>CharUtils</code></td>
<td>Various utilities for working with chars</td>
</tr>
<tr>
<td width="20%"><code>DateTimeUtils</code></td>
<td>Various utilities for working with date and time</td>
</tr>
<tr>
<td width="20%"><code>DoubleUtils</code></td>
<td>Various utilities for working with doubles</td>
</tr>
<tr>
<td width="20%"><code>ExceptionUtils</code></td>
<td>Various utilities for working with exceptions</td>
</tr>
<tr>
<td width="20%"><code>IOUtils</code></td>
<td>Various utilities for working with I/O</td>
</tr>
<tr>
<td width="20%"><code>MathUtils</code></td>
<td>Various utilities for working with math</td>
</tr>
<tr>
<td width="20%"><code>NumberUtils</code></td>
<td>Various utilities for working with numbers</td>
</tr>
<tr>
<td width="20%"><code>OSUtils</code></td>
<td>Operating System utilities</td>
</tr>
<tr>
<td width="20%"><code>RegexUtils</code></td>
<td>Various utilities for working with regular expressions</td>
</tr>
<tr>
<td width="20%"><code>ShutdownHook</code></td>
<td>Various utilities for working with shutdown hooks</td>
</tr>
<tr>
<td width="20%"><code>StringUtils</code></td>
<td>Various utilities for working with strings</td>
</tr>
<tr>
<td width="20%"><code>SystemUtils</code></td>
<td>Various utilities for working with system properties</td>
</tr>
</table>
<p><br/></p>
<p><h3 class="coral">Others</h3>
<table>
<tr>
<td width="20%"><code>CheapDataTimeFormatter</code></td>
<td>Formats a timestamp (epoch) into a Date/Time char sequence without producing garbage</td>
</tr>
<tr>
<td width="20%"><code>CheapDataTimestamperParser</code></td>
<td>Parses a Date/Time from a ByteBuffer into an epoch timestamp without producing garbage</td>
</tr>
</table>
<p><br/><br />
<i>And much more&#8230;</i></p>
]]></content:encoded>
			<wfw:commentRss>https://www.coralblocks.com/index.php/coralbits-straight-to-the-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
