Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
package com.alignmentsystems.matching;

import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.util.Properties;

/******************************************************************************
*
* Author : John Greenan
Expand All @@ -14,7 +9,9 @@
* Artefact : ApplicationFIXEngine
* Description :
*****************************************************************************/

import java.io.FileNotFoundException;
import java.nio.ByteBuffer;
import java.util.Properties;
import java.util.UUID;

import org.apache.kafka.clients.consumer.ConsumerRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public class AlignmentFIXEngineKafkaConsumer extends InterfaceKafkaAbstractSimpl
private AlignmentLogEncapsulation log = null;
private AlignmentPersistenceToFileClient debugger = null;
private Properties props = null;
private final static int MILLISLEEP = 2000;


public AlignmentFIXEngineKafkaConsumer() throws Exception {
super();
}
Expand All @@ -65,7 +67,7 @@ public KafkaConsumer<String, byte[]> getKafkaConsumer() {
}

private synchronized void waiter() throws IllegalArgumentException, InterruptedException , IllegalMonitorStateException {
wait(2000);
wait(MILLISLEEP);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class AlignmentFIXEngineKafkaProducer implements InterfaceKafkaProducer,
private KafkaProducer<String, byte[]> kafkaProducerB = null;
private AlignmentLogEncapsulation log = null;
private AlignmentPersistenceToFileClient debugger = null;
private final static int MILLISLEEP = 2000;



Expand All @@ -54,7 +55,7 @@ protected void send(String topicName, String key, byte[] binaryMessage) {
}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
wait(2000);
wait(MILLISLEEP);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public void run() {
sender = null;
}
try {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
sleeper();

} catch (InterruptedException e) {

Expand All @@ -103,6 +102,11 @@ public void run() {
}
}

private synchronized void sleeper() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
}

/**
*
* @param topicName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class AlignmentOrderBook
private AtomicBoolean initialised = new AtomicBoolean(false);
private String symbol = null;
private AlignmentLogEncapsulation log = null;
private final int milliSleep = 200;
private final int MILLISLEEP = 200;

private OffsetDateTime orderBookCreationTime = null;
private OffsetDateTime orderBookLastUpdateTime = null;
Expand Down Expand Up @@ -407,9 +407,7 @@ public void run() {
running.set(true);

try {
Thread.currentThread();
Thread.sleep(milliSleep);

sleeper();
}catch(InterruptedException e){

running.set(false);
Expand All @@ -421,4 +419,12 @@ public void run() {
System.err.println(new StringBuilder() .append(CLASSNAME).append(Constants.SPACE) .append(e.getMessage()) .toString());
}
}

private synchronized void sleeper() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class AlignmentOrderBookKafkaConsumer extends InterfaceKafkaAbstractSimp
public final static String CLASSNAME = AlignmentOrderBookKafkaConsumer.class.getSimpleName();

private final int TIME_OUT_MS = 5000;
private final int MILLISLEEP = 2000;

private KafkaConsumer<String, byte[]> kafkaConsumer = null;
private final AtomicBoolean closed = new AtomicBoolean(false);
private AlignmentLogEncapsulation log = null;
Expand Down Expand Up @@ -137,7 +139,7 @@ public void runAlways(String topicName, InterfaceKafkaMessageHandler callback) t
}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
wait(2000);
wait(MILLISLEEP);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class AlignmentOrderBookKafkaProducer implements InterfaceKafkaProducer,
private AlignmentPersistenceToFileClient debugger = null;
private List<InterfaceMatchEvent> listenersMatchEvent = new ArrayList<InterfaceMatchEvent>();
private List<InterfaceAddedOrderToOrderBook> listenersAddedOrderToOrderBook = new ArrayList<InterfaceAddedOrderToOrderBook>();

private final int MILLISLEEP = 2000;

@Override
public void addAddedOrderToOrderBookListener(InterfaceAddedOrderToOrderBook toAdd) {
Expand Down Expand Up @@ -70,7 +70,7 @@ protected void send(String topicName, String key, byte[] binaryMessage) {
}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
wait(2000);
wait(MILLISLEEP);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class AlignmentQueueNonSequenced implements Runnable, InterfaceQueueNonSe
private AtomicBoolean running = new AtomicBoolean(false);
private AtomicBoolean initialised = new AtomicBoolean(false);

private synchronized void sleeper() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
}


@Override
public void run() {

Expand All @@ -46,8 +52,7 @@ public void run() {
while (running.get()) {

try {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
sleeper();

} catch (InterruptedException e) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class AlignmentQueueSequenced implements Runnable, InterfaceQueueSequence
protected final static String CLASSNAME = AlignmentQueueSequenced.class.getSimpleName().toString();
private ConcurrentLinkedQueue<InterfaceOrder> inQueue;
private ConcurrentLinkedQueue<InterfaceOrder> outQueue;
private final int milliSleep = 200;
private final int MILLISLEEP = 200;
private final int arrayListSize = 100;
private final int initialCapacityHashSet = 100;
private final float loadFactorHashSet = (float) 0.75;
Expand Down Expand Up @@ -70,8 +70,7 @@ public void run() {

}
try {
Thread.currentThread();
Thread.sleep(milliSleep);
sleeper();

} catch (InterruptedException e) {

Expand All @@ -87,6 +86,13 @@ public void run() {

}
}

private synchronized void sleeper() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
Thread.currentThread();
Thread.sleep(MILLISLEEP);
}



@Override
public ConcurrentLinkedQueue<InterfaceOrder> getOutputQueue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import com.alignmentsystems.library.constants.KafkaMessageTopology;
import com.alignmentsystems.library.enumerations.InstanceType;
import com.alignmentsystems.library.interfaces.InterfaceInstanceWrapper;
import com.alignmentsystems.matching.AlignmentInstanceWrapper;
/**
* @author <a href="mailto:sales@alignment-systems.com">John Greenan</a>
*
*/
public class MulticastInstanceWrapper implements InterfaceInstanceWrapper{
private final String CLASSNAME = this.getClass().getSimpleName();
private InstanceType instanceType ;

private final int MILLISLEEP = 2000;
private AlignmentLogEncapsulation log = new AlignmentLogEncapsulation(this.getClass());

@Override
Expand Down Expand Up @@ -93,11 +92,15 @@ public boolean initialise(InstanceType instanceType) {

while (returnValue) {
try {
this.wait(2000);
waiter();
} catch (InterruptedException e) {
log.error(e.getMessage() , e );
}
}
return returnValue;
}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
this.wait(MILLISLEEP);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.alignmentsystems.library.AlignmentFunctions;
import com.alignmentsystems.library.AlignmentLogEncapsulation;
import com.alignmentsystems.library.AlignmentPersistenceToFileClient;
import com.alignmentsystems.library.AlignmentUEH;
import com.alignmentsystems.library.enumerations.ConfigurationProperties;
import com.alignmentsystems.library.enumerations.Encodings;
import com.alignmentsystems.library.enumerations.InstanceType;
Expand All @@ -44,7 +45,8 @@
*/
public class MulticastServer implements InterfaceMulticastServer , Runnable , InterfaceKafkaMessageHandler{
public final static String CLASSNAME = MulticastServer.class.getSimpleName().toString();
final static Encodings encoding = Encodings.FIXSBELITTLEENDIAN;
private final static Encodings encoding = Encodings.FIXSBELITTLEENDIAN;
private final int MILLISLEEP = 2000;

private DatagramSocket socket;
private InetAddress group;
Expand Down Expand Up @@ -84,6 +86,12 @@ public void multicastThis(byte[] multicastBytes) throws IOException {
private boolean innerInitialise() {
boolean returnValue = Boolean.TRUE;

AlignmentUEH ueh = new AlignmentUEH();

Thread.setDefaultUncaughtExceptionHandler(ueh);



try {
socket = getSocket();
} catch (SocketException e) {
Expand Down Expand Up @@ -119,6 +127,9 @@ public boolean initialise(
, AlignmentPersistenceToFileClient debugger) throws Exception{
this.log = log;
this.debugger = debugger;



try {
this.host = AlignmentFunctions.getProperty(MulticastServer.class.getClassLoader() , InstanceType.MULTICASTSERVER.getProperties(), ConfigurationProperties.MULTICASTHOST);
this.port = AlignmentFunctions.getPropertyAsInt(MulticastServer.class.getClassLoader() , InstanceType.MULTICASTSERVER.getProperties(), ConfigurationProperties.MULTICASTPORT);
Expand All @@ -139,14 +150,20 @@ public void run() {
running.set(true);
while (running.get()) {
try {
wait(2000);
waiter();
} catch (InterruptedException e) {
log.error(e.getMessage() , e );
}
}

}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
this.wait(MILLISLEEP);
}



@Override
public void processMessage(String topicName, ConsumerRecord<String, byte[]> message) throws Exception {
//So,we listen to the Kafka queue to see what's going on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public class MulticastServerKafkaListener extends InterfaceKafkaAbstractSimple i
private AlignmentLogEncapsulation log = null;
private Properties props = null;
private AlignmentPersistenceToFileClient debugger = null;
private final int MILLISLEEP = 2000;

public MulticastServerKafkaListener() throws Exception {
super();
// TODO Auto-generated constructor stub
}
/**
*
Expand All @@ -63,12 +63,17 @@ public KafkaConsumer<String, byte[]> getKafkaConsumer() {
return kafkaConsumer;
}

private synchronized void waiter() throws IllegalArgumentException , InterruptedException , IllegalMonitorStateException {
this.wait(MILLISLEEP);
}


@Override
public void run() {
AtomicBoolean run = new AtomicBoolean(true);
while (run.get()) {
try {
wait(2000);
waiter();
} catch (InterruptedException e) {
log.error(e.getMessage() , e );
}
Expand Down