File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818import org .agrona .CloseHelper ;
1919import org .agrona .concurrent .BackoffIdleStrategy ;
2020import org .agrona .concurrent .IdleStrategy ;
21+ import org .eclipse .microprofile .config .inject .ConfigProperty ;
2122
2223/**
2324 * Aeron Ingress Singleton Bean Launches an embedded MediaDriver and subscribes to market data
@@ -43,11 +44,20 @@ public class AeronSubscriberBean {
4344
4445 @ Inject @ VirtualThreadExecutor private ManagedExecutorService managedExecutorService ;
4546
47+ @ Inject
48+ @ ConfigProperty (name = "TRADER_INGESTION_MODE" , defaultValue = "AERON" )
49+ private String ingestionMode ;
50+
4651 void contextInitialized (@ Observes @ Initialized (ApplicationScoped .class ) Object event ) {
47- managedExecutorService .submit (() -> init () );
52+ managedExecutorService .submit (this :: init );
4853 }
4954
5055 public void init () {
56+ if ("DIRECT" .equalsIgnoreCase (ingestionMode )) {
57+ LOGGER .info ("Running in DIRECT mode - Skipping Aeron/MediaDriver initialization." );
58+ return ;
59+ }
60+
5161 LOGGER .info ("Initializing Aeron Subscriber Bean..." );
5262
5363 try {
Original file line number Diff line number Diff line change @@ -54,8 +54,7 @@ public class MarketDataPublisher {
5454 private final MarketDepthEncoder marketDepthEncoder = new MarketDepthEncoder ();
5555 private final HeartbeatEncoder heartbeatEncoder = new HeartbeatEncoder ();
5656
57- // Buffer for encoding messages
58- private final UnsafeBuffer buffer = new UnsafeBuffer (ByteBuffer .allocateDirect (BUFFER_SIZE ));
57+ private UnsafeBuffer buffer ;
5958
6059 private final AtomicLong sequenceNumber = new AtomicLong (0 );
6160 private final AtomicLong tradeIdGenerator = new AtomicLong (1000 );
@@ -139,6 +138,9 @@ public void init() {
139138 return ;
140139 }
141140
141+ // Initialize buffer only if in AERON mode
142+ this .buffer = new UnsafeBuffer (ByteBuffer .allocateDirect (BUFFER_SIZE ));
143+
142144 try {
143145 // Wait for AeronSubscriberBean to be ready (both observers fire at roughly same time)
144146 LOGGER .info ("Waiting for AeronSubscriberBean to be ready..." );
Original file line number Diff line number Diff line change @@ -76,12 +76,12 @@ public Response getComparison() {
7676 // Identify which JVM is running
7777 String jvmVendor = System .getProperty ("java.vm.vendor" );
7878 String jvmName = System .getProperty ("java.vm.name" );
79+ List <GarbageCollectorMXBean > gcBeans = ManagementFactory .getGarbageCollectorMXBeans ();
7980 String gcName =
80- ManagementFactory .getGarbageCollectorMXBeans ().stream ()
81- .map (GarbageCollectorMXBean ::getName )
82- .collect (Collectors .joining (", " ));
81+ gcBeans .stream ().map (GarbageCollectorMXBean ::getName ).collect (Collectors .joining (", " ));
8382
84- boolean isAzulC4 = jvmVendor != null && jvmVendor .contains ("Azul" );
83+ // More accurate check: C4 collector's MXBean is named "GPGC"
84+ boolean isAzulC4 = gcBeans .stream ().anyMatch (bean -> "GPGC" .equals (bean .getName ()));
8585
8686 comparison .put ("jvmVendor" , jvmVendor );
8787 comparison .put ("jvmName" , jvmName );
@@ -91,6 +91,9 @@ public Response getComparison() {
9191
9292 // Current stress level
9393 comparison .put ("allocationMode" , memoryPressureService .getCurrentMode ());
94+ comparison .put (
95+ "allocationRateMBps" ,
96+ memoryPressureService .getCurrentMode ().getBytesPerSecond () / (1024 * 1024 ));
9497 comparison .put ("messageRate" , publisher .getMessagesPublished ());
9598
9699 // GC Performance Metrics (keep old stats for backward compatibility)
Original file line number Diff line number Diff line change 22
33import com .hazelcast .core .HazelcastInstance ;
44import com .hazelcast .topic .ITopic ;
5- import com .hazelcast .topic .Message ;
6- import com .hazelcast .topic .MessageListener ;
75import jakarta .annotation .PostConstruct ;
86import jakarta .enterprise .context .ApplicationScoped ;
97import jakarta .inject .Inject ;
@@ -51,12 +49,9 @@ public void init() {
5149 if (hazelcastInstance != null ) {
5250 clusterTopic = hazelcastInstance .getTopic (TOPIC_NAME );
5351 clusterTopic .addMessageListener (
54- new MessageListener <String >() {
55- @ Override
56- public void onMessage (Message <String > message ) {
57- // Broadcast to local WebSocket sessions only
58- broadcastLocal (message .getMessageObject ());
59- }
52+ message -> {
53+ // Broadcast to local WebSocket sessions only
54+ broadcastLocal (message .getMessageObject ());
6055 });
6156 LOGGER .info ("Subscribed to Hazelcast topic: " + TOPIC_NAME + " (clustered mode)" );
6257 } else {
You can’t perform that action at this time.
0 commit comments