public void Init() { LBMContext lbmContext = new LBMContext(); LBMEventQueue lbmEventQueue = new LBMEventQueue(); var topicString = "bxu"; LBMreqCB lbMreqCallBack = new LBMreqCB(0); for (int i = 0; i < 10; i++) { var requestMsg = Encoding.UTF8.GetBytes(string.Format("request {0}", i)); LBMRequest lbmRequest = new LBMRequest(requestMsg, requestMsg.Length); lbmRequest.addResponseCallback(lbMreqCallBack.onResponse); Console.Out.WriteLine("Sending RequestImmediateAndEvent {0}", i); lbmContext.send(topicString, lbmRequest, lbmEventQueue, 0); var qTimer = new EQTimer(lbmContext, 5000, lbmEventQueue); lbmEventQueue.run(LBM.EVENT_QUEUE_BLOCK); Console.Out.WriteLine("Done waiting for responses, {0} response{1} ({2} total bytes) received. Deleting request.\n", lbMreqCallBack.response_count, (lbMreqCallBack.response_count == 1 ? "" : "s"), lbMreqCallBack.response_byte_count); lbMreqCallBack.response_count = 0; lbMreqCallBack.response_byte_count = 0; lbmRequest.close(); } Console.ReadLine(); }
//LBMRespTimer timer; public LBMRespReceiver(LBMContext ctx, LBMTopic topic, LBMEventQueue evq, int verbose, bool end_on_eos) { _verbose = verbose; _evq = evq; _end_on_eos = end_on_eos; _rcv = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null, evq); }
static void Main(string[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMSource src = null; /* Source object: for sending messages. */ LBMEventQueue evq = null; /* Event Queue object: process source events on app thread */ SrcCB cb = null; /*** Create a source using an event queue ***/ try { LBMTopic topic = null; LBMSourceAttributes srcAttr = null; ctx = new LBMContext(); srcAttr = new LBMSourceAttributes(); /* create callback to process events */ cb = new SrcCB(); /* define Event Queue. This allows us to process events on an */ /* application thread, as opposed to the default behavior, */ /* which is to process events on the (internal) context thread.*/ evq = new LBMEventQueue(); topic = ctx.allocTopic("test.topic", srcAttr); src = new LBMSource(ctx, topic, evq); } catch (LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } /* run the event queue for 60 seconds */ /* all the source events will be processed */ /* in this thread * evq.run(60000); * * try * { * src.close(); * ctx.close(); * evq.close(); * } * catch (LBMException ex) * { * System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message); * System.Environment.Exit(1); * } * * } /* main */ } /* class eventQ */
static void Main(string[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMSource src = null; /* Source object: for sending messages. */ LBMEventQueue evq = null; /* Event Queue object: process source events on app thread */ SrcCB cb = null; /*** Create a source using an event queue ***/ try { LBMTopic topic = null; LBMSourceAttributes srcAttr = null; ctx = new LBMContext(); srcAttr = new LBMSourceAttributes(); /* create callback to process events */ cb = new SrcCB(); /* define Event Queue. This allows us to process events on an */ /* application thread, as opposed to the default behavior, */ /* which is to process events on the (internal) context thread.*/ evq = new LBMEventQueue(); topic = ctx.allocTopic("test.topic", srcAttr); src = new LBMSource(ctx, topic, evq); } catch (LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } /* run the event queue for 60 seconds */ /* all the source events will be processed */ /* in this thread evq.run(60000); try { src.close(); ctx.close(); evq.close(); } catch (LBMException ex) { System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message); System.Environment.Exit(1); } } /* main */ } /* class eventQ */
public SrcStatsTimer(LBMContext ctx, LBMSource src, long tmo, LBMEventQueue evq, LBMObjectRecyclerBase recycler) : base(ctx, tmo, evq) { _recycler = recycler; _src = src; _tmo = tmo; if (tmo == 0) { print_stats(); } else { this.addTimerCallback(new LBMTimerCallback(onExpiration)); } }
public SrcStatsTimer(LBMContext lbmctx, LBMSource src, long milliseconds, LBMEventQueue lbmevq, LBMObjectRecyclerBase recycler) : base(lbmctx, milliseconds, lbmevq) { _recycler = recycler; _src = src; _milliseconds = milliseconds; if (milliseconds == 0) { print_stats(); } else { this.addTimerCallback(new LBMTimerCallback(onExpiration)); } }
public void Init() { using (LBMContext lbmContext = new LBMContext()) { LBMTopic lbmTopic = new LBMTopic(lbmContext, "Greeting"); var cbArg = new object(); var lbmEventQueue = new LBMEventQueue(); using (LBMReceiver lbmReceiver = new LBMReceiver(lbmContext, lbmTopic, LBMReceiverCallback, cbArg, lbmEventQueue)) { lbmEventQueue.run(-1); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); } } }
public PongLBMReceiver(LBMContext ctx, LBMTopic topic, LBMEventQueue evq, LBMSource src, bool ping, int msecpause, int msgs, bool verbose, bool end_on_eos, bool rtt_collect, int ignore, bool mim) { _ctx = ctx; _rcv = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null, evq); _msgs = msgs; _verbose = verbose; _msecpause = msecpause; _ping = ping; _evq = evq; _end_on_eos = end_on_eos; _src = src; if (rtt_collect) { rtt_data = new double[msgs]; } rtt_ignore = ignore; use_mim = mim; use_smx = src.getAttributeValue("transport").ToLower().Contains("smx"); }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMReceiver rcv = null; /* Source object: for sending messages. */ LBMEventQueue evq = null; /* Event Queue object: process receiver events on app thread */ LBMReceiverCallback cb = new LBMReceiverCallback(onReceive); /* Wrapping the onReceive functor in a callback */ ctx = new LBMContext(); evq = new LBMEventQueue(); { LBMTopic topic = null; topic = ctx.lookupTopic("test.topic"); /* The event queue object is passed into the receiver constructor */ /* This causes events to be queued in an unbounded Q. In order */ /* to process these messages the evq.Run() method must be called */ rcv = new LBMReceiver(ctx, topic, onReceive, null, evq); } /* run the event queue for 60 seconds */ /* all the receiver events will be processed */ /* in this thread. This includes message */ /* processing. */ evq.run(60000); try { /* Shutdown order is important. Event Queues should */ /* be .close()d after the context and receiver. */ rcv.close(); ctx.close(); evq.close(); } catch (LBMException ex) { System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message); System.Environment.Exit(1); } }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMReceiver rcv = null; /* Source object: for sending messages. */ LBMEventQueue evq = null; /* Event Queue object: process receiver events on app thread */ LBMReceiverCallback cb = new LBMReceiverCallback(onReceive); /* Wrapping the onReceive functor in a callback */ ctx = new LBMContext(); evq = new LBMEventQueue(); { LBMTopic topic = null; topic = ctx.lookupTopic("test.topic"); /* The event queue object is passed into the receiver constructor */ /* This causes events to be queued in an unbounded Q. In order */ /* to process these messages the evq.Run() method must be called */ rcv = new LBMReceiver(ctx, topic, onReceive, null, evq); } /* run the event queue for 60 seconds */ /* all the receiver events will be processed */ /* in this thread. This includes message */ /* processing. */ evq.run(60000); try { /* Shutdown order is important. Event Queues should */ /* be .close()d after the context and receiver. */ rcv.close(); ctx.close(); evq.close(); } catch(LBMException ex) { System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message); System.Environment.Exit(1); } }
public void Init() { LBMContext lbmContext = new LBMContext(); LBMEventQueue lbmEventQueue = new LBMEventQueue(); var topicString = "bxu"; var lbmTopic = lbmContext.allocTopic(topicString, null); var lbmSource = lbmContext.createSource(lbmTopic, onSourceEvent, null, null); for (int i = 0; i < 10; i++) { var requestMsg = Encoding.UTF8.GetBytes(string.Format("request {0}", i)); LBMRequest lbmRequest = new LBMRequest(requestMsg, requestMsg.Length); lbmRequest.addResponseCallback(onResponse); Console.Out.WriteLine("Sending RequestNOImmediateAndEvent {0}", i); lbmSource.send(lbmRequest, lbmEventQueue, 0); var qTimer = new EQTimer(lbmContext, 5000, lbmEventQueue); lbmEventQueue.run(LBM.EVENT_QUEUE_BLOCK); } }
public EQTimer(LBMContext lbmctx, long milliseconds, LBMEventQueue lbmevq) : base(lbmctx, milliseconds, lbmevq) { _evq = lbmevq; addTimerCallback(onExpiration); }
public EQTimer(LBMContext ctx, long tmo, LBMEventQueue evq) : base(ctx, tmo, evq) { _evq = evq; this.addTimerCallback(new LBMTimerCallback(onExpiration)); }
public LBMMRcvReceiver(LBMContext ctx, LBMTopic topic, LBMEventQueue evq, bool verbose) { rcv = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null, evq); _verbose = verbose; _evq = evq; }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMEventQueue evq = new LBMEventQueue(); /* Initialization: create necessary UM objects. */ try { LBMContextAttributes ctxAttr = new LBMContextAttributes(); ctx = new LBMContext(ctxAttr); } catch (LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } /* Initialize and create receiver and receiver callback */ LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive); LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes(); LBMTopic rtopic = new LBMTopic(ctx, "test.topic", rcv_attr); LBMReceiver rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, evq); /* Initialize and create source */ LBMTopic stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes()); LBMSource src = new LBMSource(ctx, stopic); EQThread evqThread = new EQThread(evq); evqThread.start(); try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } src.send(Encoding.ASCII.GetBytes("hello"), 5, LBM.MSG_FLUSH); while (cleanup == 0) { try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } } evq.stop(); evqThread.join(); src.close(); rcv.close(); ctx.close(); evq.close(); } /* main */
public EQThread(LBMEventQueue evq) { _evq = evq; }
static void Main(String[] args) { LBMContext ctx = null; /* Context object: container for UM "instance". */ LBMEventQueue evq = new LBMEventQueue(); /* Initialization: create necessary UM objects. */ try { LBMContextAttributes ctxAttr = new LBMContextAttributes(); ctx = new LBMContext(ctxAttr); } catch(LBMException ex) { System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message); System.Environment.Exit(1); } /* Initialize and create receiver and receiver callback */ LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive); LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes(); LBMTopic rtopic = new LBMTopic(ctx, "test.topic", rcv_attr); LBMReceiver rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, evq); /* Initialize and create source */ LBMTopic stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes()); LBMSource src = new LBMSource(ctx, stopic); EQThread evqThread = new EQThread(evq); evqThread.start(); try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } src.send(Encoding.ASCII.GetBytes("hello"), 5, LBM.MSG_FLUSH); while (cleanup == 0) { try { System.Threading.Thread.Sleep(1000); } catch (Exception eex) { System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception: " + eex.Message); System.Environment.Exit(1); } } evq.stop(); evqThread.join(); src.close(); rcv.close(); ctx.close(); evq.close(); }
private static void print_stats(LBMReceiverStatistics stats, LBMEventQueue evq) { if (evq != null) { if (Convert.ToInt32(evq.getAttributeValue("queue_size_warning")) > 0) { System.Console.Out.WriteLine("Event queue size: " + evq.size()); } } for (int i = 0; i < stats.size(); i++) { switch (stats.type(i)) { case LBM.TRANSPORT_STAT_TCP: System.Console.Out.WriteLine("TCP, source " + stats.source(i) + ", received " + stats.messagesReceived(i) + "/" + stats.bytesReceived(i) + ", no topics " + stats.noTopicMessagesReceived(i) + ", requests " + stats.lbmRequestsReceived(i)); break; case LBM.TRANSPORT_STAT_LBTRU: case LBM.TRANSPORT_STAT_LBTRM: if (stats.type() == LBM.TRANSPORT_STAT_LBTRU) { System.Console.Out.Write("LBT-RU"); } else { System.Console.Out.Write("LBT-RM"); } System.Console.Out.WriteLine(", source " + stats.source(i) + ", received " + stats.messagesReceived(i) + "/" + stats.bytesReceived(i) + ", naks " + stats.nakPacketsSent(i) + "/" + stats.naksSent(i) + ", lost " + stats.lost(i) + ", ncfs " + stats.ncfsIgnored(i) + "/" + stats.ncfsShed(i) + "/" + stats.ncfsRetransmissionDelay(i) + "/" + stats.ncfsUnknown(i) + ", recovery " + stats.minimumRecoveryTime(i) + "/" + stats.meanRecoveryTime(i) + "/" + stats.maximumRecoveryTime(i) + ", nak tx " + stats.minimumNakTransmissions(i) + "/" + stats.minimumNakTransmissions(i) + "/" + stats.maximumNakTransmissions(i) + ", dup " + stats.duplicateMessages(i) + ", unrecovered " + stats.unrecoveredMessagesWindowAdvance(i) + "/" + stats.unrecoveredMessagesNakGenerationTimeout(i) + ", LBM msgs " + stats.lbmMessagesReceived(i) + ", no topics " + stats.noTopicMessagesReceived(i) + ", requests " + stats.lbmRequestsReceived(i)); break; case LBM.TRANSPORT_STAT_LBTIPC: System.Console.Out.WriteLine("LBT-IPC, source " + stats.source(i) + ", received " + stats.messagesReceived(i) + "/" + stats.bytesReceived(i) + ", LBM msgs " + stats.lbmMessagesReceived(i) + ", no topics " + stats.noTopicMessagesReceived(i) + ", requests " + stats.lbmRequestsReceived(i)); break; case LBM.TRANSPORT_STAT_LBTRDMA: System.Console.Out.WriteLine("LBT-RDMA, source " + stats.source(i) + ", received " + stats.messagesReceived(i) + "/" + stats.bytesReceived(i) + ", LBM msgs " + stats.lbmMessagesReceived(i) + ", no topics " + stats.noTopicMessagesReceived(i) + ", requests " + stats.lbmRequestsReceived(i)); break; } } System.Console.Out.Flush(); }
public EQThread(LBMEventQueue evq) { _evq = evq; }