Esempio n. 1
0
    public static void Main(String[] args)
    {
        /* Initialization: create necessary UM objects. */
        LBMContext ctx = new LBMContext();

        /* Create LBMReceiverCallback using the method onReceive defined in this class */
        LBMReceiverCallback rcvCallback = new LBMReceiverCallback(onReceive);

        /* Create receiver objects */
        LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes();
        LBMTopic    rtopic             = new LBMTopic(ctx, "test.topic", rcv_attr);
        LBMReceiver rcv = new LBMReceiver(ctx, rtopic, rcvCallback, null, null);

        /* Initialize and create source */
        LBMTopic  stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes());
        LBMSource src    = new LBMSource(ctx, stopic);

        String msgData = "request";

        byte[] bytes = new byte[msgData.Length * sizeof(char)];
        System.Buffer.BlockCopy(msgData.ToCharArray(), 0, bytes, 0, bytes.Length);

        LBMRequest          req = new LBMRequest(bytes, bytes.Length);
        LBMResponseCallback myResponseCallback = new LBMResponseCallback(onResponse);

        req.addResponseCallback(myResponseCallback);

        /* Sleep for 1 second to allow TR to complete */
        try
        {
            System.Threading.Thread.Sleep(1000);
        }
        catch (Exception ex)
        {
            System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
            System.Environment.Exit(1);
        }

        /* Send a message. */
        src.send(req, LBM.MSG_FLUSH | LBM.SRC_BLOCK);

        while (run == 1)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }
        }

        /* Cleanup: delete UM objects. */
        req.close();
        src.close();
        rcv.close();
        ctx.close();
    }  /* main */
Esempio n. 2
0
        static void Main(string[] args)
        {
            LBMContext ctx = null;  /* Context object: container for UM "instance". */
            LBMSource  src = null;  /* Source object: for sending messages. */


            /*** Initialization: create necessary UM objects. ***/

            ctx = new LBMContext();

            {
                LBMTopic topic = null;
                topic = new LBMTopic(ctx, "Greeting");
                src   = new LBMSource(ctx, topic);
            }

            System.Threading.Thread.Sleep(3000);


            /*** Send a message. ***/

            src.send(Encoding.ASCII.GetBytes("Hello!"), 7, LBM.MSG_FLUSH | LBM.SRC_BLOCK);


            /*** Cleanup: delete UM objects. ***/

            System.Threading.Thread.Sleep(2000);

            src.close();
            ctx.close();
        } /* Main */
Esempio n. 3
0
        static void Main(string[] args)
        {
            LBMContext ctx = nil;  /* Context object: container for UM "instance". */
              LBMSource src = nil;   /* Source object: for sending messages. */

              /*** Initialization: create necessary UM objects. ***/

              ctx = new LBMContext();

              {
            LBMTopic topic = nil;
            topic = new LBMTopic(ctx, "Greeting");
            src = new LBMSource(ctx, topic);
              }

              System.Threading.Thread.Sleep(3000);

              /*** Send a message. ***/

              src.send(Encoding.ASCII.GetBytes("Hello!"), 7, LBM.MSG_FLUSH | LBM.SRC_BLOCK);

              /*** Cleanup: delete UM objects. ***/

              System.Threading.Thread.Sleep(2000);

              src.close();
              ctx.close();
        }
Esempio n. 4
0
    static void Main(String[] args)
    {
        LBMContext ctx = null; /* Context object: container for UM "instance". */
        LBMSource  src = null; /* Source object: for sending messages. */
        LBM        lbm = new LBM();

        /*** Initialization: create necessary UM objects. ***/
        try
        {
            LBMTopic            topic   = null;
            LBMSourceAttributes srcAttr = null;

            lbm.setLogger(new LBMLogging(logger));

            ctx     = new LBMContext();
            srcAttr = new LBMSourceAttributes();
            srcAttr.setValue("late_join", "1");
            topic = ctx.allocTopic("test.topic", srcAttr);
            src   = ctx.createSource(topic, null, null, null);
        }
        catch (LBMException ex)
        {
            System.Console.Error.Write("Error initializing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }

        /* Cleanup */
        src.close();
        ctx.close();
    } /* main */
Esempio n. 5
0
    public static void main(String[] args)
    {
        /* Initialization: create necessary UM objects. */
        LBMContext ctx = new LBMContext();

        /* Create LBMReceiverCallback using the method onReceive defined in this class */
        LBMReceiverCallback rcvCallback = new LBMReceiverCallback(onReceive);

        /* Create receiver objects */
        LBMReceiverAttributes rcv_attr = new LBMReceiverAttributes();
        LBMTopic rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
        LBMReceiver rcv = new LBMReceiver(ctx, rtopic, rcvCallback, null, null);

        /* Initialize and create source */
        LBMTopic stopic = new LBMTopic(ctx, "test.topic", new LBMSourceAttributes());
        LBMSource src = new LBMSource(ctx, stopic);

        String msgData = "request";
        byte[] bytes = new byte[msgData.Length * sizeof(char)];
        System.Buffer.BlockCopy(msgData.ToCharArray(), 0, bytes, 0, bytes.Length);

        LBMRequest req = new LBMRequest(bytes, bytes.Length);
        LBMResponseCallback myResponseCallback = new LBMResponseCallback(onResponse);
        req.addResponseCallback(myResponseCallback);

        /* Sleep for 1 second to allow TR to complete */
        try
        {
            System.Threading.Thread.Sleep(1000);
        }
        catch (Exception ex)
        {
            System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
            System.Environment.Exit(1);
        }

        /* Send a message. */
        src.send(req, LBM.MSG_FLUSH | LBM.SRC_BLOCK);

        while (run == 1)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }
        }

        /* Cleanup: delete UM objects. */
        req.close();
        src.close();
        rcv.close();
        ctx.close();
    }
Esempio n. 6
0
    static void Main(String[] args)
    {
        LBMContext          ctx       = null;                               /* Context object: container for UM "instance". */
        LBMReceiver         lateRcv   = null;                               /* Receiver object: for sending messages. */
        LBMReceiverCallback cb        = new LBMReceiverCallback(onReceive); /* Wrapping the onReceive functor in a callback */
        LBMSource           early_src = null;                               /* Source object: for sending messages. */

        ctx = new LBMContext();


        try
        {
            LBMTopic            srcTopic = null;
            LBMSourceAttributes srcAttr  = null;

            srcAttr = new LBMSourceAttributes();

            srcAttr.setValue("late_join", "1");
            srcAttr.setValue("retransmit_retention_size_threshold", "1");

            srcTopic  = ctx.allocTopic("test.topic", srcAttr);
            early_src = new LBMSource(ctx, srcTopic);

            early_src.send(Encoding.ASCII.GetBytes("test"), 4, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK);
        }
        catch (LBMException ex)
        {
            System.Console.Error.WriteLine("Error initializing LBM objects:  " + ex.Message);
            System.Environment.Exit(1);
        }

        {
            LBMTopic topic = null;
            topic = ctx.lookupTopic("test.topic");

            lateRcv = new LBMReceiver(ctx, topic, onReceive, null, null);
        }

        Thread.Sleep(100);

        try {
            early_src.close();
            lateRcv.close();
            ctx.close();
        }
        catch (LBMException ex)
        {
            System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }
    }
Esempio n. 7
0
    static void Main(String[] args)
    {
        LBMContext ctx = null;      /* Context object: container for UM "instance". */
        LBMReceiver lateRcv = null; /* Receiver object: for sending messages. */
        LBMReceiverCallback cb = new LBMReceiverCallback(onReceive);    /* Wrapping the onReceive functor in a callback */
        LBMSource early_src = null;   /* Source object: for sending messages. */

        ctx = new LBMContext();

        try
        {
            LBMTopic srcTopic = null;
            LBMSourceAttributes srcAttr = null;

            srcAttr = new LBMSourceAttributes();

            srcAttr.setValue("late_join", "1");
            srcAttr.setValue("retransmit_retention_size_threshold", "1");

            srcTopic = ctx.allocTopic("test.topic", srcAttr);
            early_src = new LBMSource(ctx, srcTopic);

            early_src.send(Encoding.ASCII.GetBytes("test"), 4, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK);
        }
        catch (LBMException ex)
        {
            System.Console.Error.WriteLine("Error initializing LBM objects:  " + ex.Message);
            System.Environment.Exit(1);
        }

        {
            LBMTopic topic = null;
            topic = ctx.lookupTopic("test.topic");

            lateRcv = new LBMReceiver(ctx, topic, onReceive, null, null);
        }

        Thread.Sleep(100);

        try {
            early_src.close();
            lateRcv.close();
            ctx.close();
        }
        catch(LBMException ex)
        {
            System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
            System.Environment.Exit(1);
        }
    }
Esempio n. 8
0
        } // Dispose

        private void Dispose(bool disposing)
        {
            if (_tmonUmSource != null)
            {
                _tmonUmSource.flush();
                _tmonUmSource.close();
                _tmonUmSource = null;
            }
            if (_tmonUmContext != null)
            {
                _tmonUmContext.close();
                _tmonUmContext = null;
            }
        } // Dispose
Esempio n. 9
0
    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();
    }
Esempio n. 10
0
        static void Main(string[] args)
        {
            LBMContext          ctx     = null; /* Container for UM instance */
            LBMTopic            topic1  = null; /* Object used to create topic */
            LBMTopic            topic2  = null; /* Object used to create topic */
            LBMSource           src1    = null; /* Used for sending messages on a single topic */
            LBMSource           src2    = null; /* Used for sending messages on a single topic */
            LBMSourceAttributes srcAttr = null; /* Object used to configure sources */
            int resPort;
            int desPort;

            /* We are using certain lbm objects that require an application level   */
            /* memory manager called the LBMObjectRecycler to cleanup               */
            LBMObjectRecycler objRec = new LBMObjectRecycler();

            try
            {
                /* create ctxAttr to set config values before creating context */
                LBMContextAttributes ctxAttr = new LBMContextAttributes();
                ctxAttr.setObjectRecycler(objRec, null);

                /* Modify resolver address by setting attributes */
                ctxAttr.setValue("resolver_multicast_address", "224.10.11.12");

                /* Create a context with default attributes */
                ctx = new LBMContext(ctxAttr);
                /* Create source attributes object, used to configure sources */
                srcAttr = new LBMSourceAttributes();
                srcAttr.setObjectRecycler(objRec, null);

                /* Set configuration value using strings */
                srcAttr.setValue("transport", "lbtrm");

                /* The Java API only accepts string values. ints, for example */
                /* must be converted to strings */
                desPort = 14001;
                srcAttr.setValue("transport_lbtrm_destination_port", desPort.ToString());

                /* Create topic for the first source with configured attributes */
                topic1 = new LBMTopic(ctx, "test.topic1", srcAttr);
                src1   = new LBMSource(ctx, topic1);
                /* Modify Configuration for second topic to use a new port */
                desPort = 14002;
                srcAttr.setValue("transport_lbtrm_destination_port", desPort.ToString());

                /* Create second topic and source using modified configuration values */
                topic2 = new LBMTopic(ctx, "test.topic2", srcAttr);
                src2   = new LBMSource(ctx, topic2);
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
            System.Console.Out.WriteLine("Context Attributes: ");
            List <LBMConfigOption> cfgOptList = ctx.dumpAttributeList();

            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            System.Console.Out.WriteLine("Source #1 Attributes: ");
            cfgOptList = src1.dumpAttributeList();
            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            System.Console.Out.WriteLine("Source #2 Attributes: ");
            cfgOptList = src2.dumpAttributeList();
            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            /* Cleanup all LBM objects */
            try
            {
                objRec.close();
                src2.close();
                src1.close();
                ctx.close();
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
        }
Esempio n. 11
0
    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 */
Esempio n. 12
0
        static void Main(string[] args)
        {
            LBMContext ctx = null;  /* Context object: container for UM "instance". */
            LBMSource  src = null;  /* Source object: for sending messages. */

            try
            {
                LBMTopic            topic   = null;
                LBMSourceAttributes srcAttr = null;

                ctx     = new LBMContext();
                srcAttr = new LBMSourceAttributes();
                srcAttr.setValue("ume_store", "127.0.0.1:29999");
                srcAttr.setValue("ume_flight_size", maxFlightSize.ToString());
                topic = ctx.allocTopic("test.topic", srcAttr);
                src   = new LBMSource(ctx, topic);
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error initializing LBM objects:  " + ex.Message);
                System.Environment.Exit(1);
            }

            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }

            while (true)
            {
                /*** Send a message. ***/
                try
                {
                    src.send(Encoding.ASCII.GetBytes("test"), 4, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK);
                }
                catch (LBMEWouldBlockException ex)
                {
                    try
                    {
                        int currentFlightSize = src.getInflight(LBM.FLIGHT_SIZE_TYPE_UME);

                        if (currentFlightSize == maxFlightSize)
                        {
                            System.Console.Error.WriteLine("Source is blocked on flight. Exiting");
                            break;
                        }
                    }
                    catch (LBMException exInflight)
                    {
                        System.Console.Error.WriteLine("Error getting flightsize: " + exInflight.Message);
                    }
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error sending: " + ex.Message);
                }
            }

            /*** Cleanup: delete UM objects. ***/
            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }

            try
            {
                src.close();
                ctx.close();
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
        } /* Main */
Esempio n. 13
0
        private lbmpong(string[] args)
        {
            if (System.Environment.GetEnvironmentVariable("LBM_LICENSE_FILENAME") == null &&
                System.Environment.GetEnvironmentVariable("LBM_LICENSE_INFO") == null)
            {
                SetEnvironmentVariable("LBM_LICENSE_FILENAME", "lbm_license.txt");
            }
            LBM lbm = new LBM();

            lbm.setLogger(new LBMLogging(logger));

            process_cmdline(args);

            if (use_mim && !eventq)
            {
                System.Console.Out.WriteLine("Using mim requires event queue to send from receive callback - forcing use");
                eventq = true;
            }
            if (msecpause > 0 && !eventq)
            {
                System.Console.Out.WriteLine("Setting pause value requires event queue - forcing use");
                eventq = true;
            }
            LBMSourceAttributes  sattr = new LBMSourceAttributes();
            LBMContextAttributes cattr = new LBMContextAttributes();

            /* Check if protocol needs to be set to lbtrm | lbtru */
            if (protocol == 'M')
            {
                try
                {
                    sattr.setValue("transport", "LBTRM");
                    cattr.setValue("transport_lbtrm_data_rate_limit", send_rate.ToString());
                    cattr.setValue("transport_lbtrm_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error setting LBTRM rate: " + ex.Message);
                    System.Environment.Exit(1);
                }
            }
            if (protocol == 'U')
            {
                try
                {
                    sattr.setValue("transport", "LBTRU");
                    cattr.setValue("transport_lbtru_data_rate_limit", send_rate.ToString());
                    cattr.setValue("transport_lbtru_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error setting LBTRU rate: " + ex.Message);
                    System.Environment.Exit(1);
                }
            }

            LBMContext        ctx = new LBMContext(cattr);
            PongLBMEventQueue evq = null;

            if (eventq)
            {
                System.Console.Error.WriteLine("Event queue in use");
                evq = new PongLBMEventQueue();
            }
            else
            {
                System.Console.Error.WriteLine("No event queue");
            }
            System.Console.Out.Flush();
            LBMSource       src = null;
            PongLBMReceiver rcv;
            LBMTopic        src_topic = null;
            LBMTopic        rcv_topic;

            if (ping)
            {
                System.Console.Error.WriteLine(
                    "Sending " + msgs + " " + msglen +
                    " byte messages to topic lbmpong/ping pausing "
                    + msecpause + " msec between");
                if (!use_mim)
                {
                    src_topic = ctx.allocTopic("lbmpong/ping", sattr);
                }
                rcv_topic = ctx.lookupTopic("lbmpong/pong");
            }
            else
            {
                rcv_topic = ctx.lookupTopic("lbmpong/ping");
                if (!use_mim)
                {
                    src_topic = ctx.allocTopic("lbmpong/pong", sattr);
                }
            }
            PongSrcCB srccb = new PongSrcCB();

            if (!use_mim)
            {
                src     = ctx.createSource(src_topic, new LBMSourceEventCallback(srccb.onSourceEvent), null);
                use_smx = src.getAttributeValue("transport").ToLower().Contains("smx");

                if (use_smx)
                {
                    /* Perform configuration validation */
                    const int smx_header_size  = 16;
                    int       max_payload_size =
                        Convert.ToInt32(src.getAttributeValue("transport_lbtsmx_datagram_max_size")) + smx_header_size;
                    if (msglen > max_payload_size)
                    {
                        /* The SMX transport doesn't fragment, so payload must be within maximum size limits */
                        System.Console.WriteLine("Error: Message size requested is larger than configured SMX datagram size.");
                        System.Environment.Exit(1);
                    }
                }
            }
            rcv = new PongLBMReceiver(ctx, rcv_topic, evq, src, ping, msecpause, msgs, verbose,
                                      end_on_eos, rtt_collect, rtt_ignore, use_mim);
            System.Threading.Thread.Sleep(5000);
            if (ping)
            {
                byte [] message = new byte[msglen];
                rcv.start();

                format(message, 0, System.Diagnostics.Stopwatch.GetTimestamp() * lbmpong.pspertick / 1000);
                if (use_mim)
                {
                    ctx.send("lbmpong/ping", message, msglen, LBM.MSG_FLUSH);
                }
                else if (use_smx)
                {
                    try
                    {
                        IntPtr writeBuff;
                        if (src.buffAcquire(out writeBuff, (uint)msglen, 0) == 0)
                        {
                            Marshal.Copy(message, 0, writeBuff, msglen);
                            src.buffsComplete();
                        }
                    }
                    catch (LBMException ex)
                    {
                        System.Console.Error.WriteLine("Error (while doing SMX acquire/complete): " + ex.Message);
                        System.Environment.Exit(1);
                    }
                }
                else
                {
                    src.send(message, msglen, LBM.MSG_FLUSH);
                }
            }
            if (eventq)
            {
                evq.run(run_secs * 1000);
            }
            else
            {
                System.Threading.Thread.Sleep(run_secs * 1000);
            }

            System.Console.Error.WriteLine("Quitting....");
            if (!use_mim)
            {
                src.close();
            }
            rcv.close();
            ctx.close();
            if (eventq)
            {
                evq.close();
            }
        }
        static void Main(string[] args)
        {
            LBMContext ctx = null;  /* Context object: container for UM "instance". */
            LBMSource src = null;   /* Source object: for sending messages. */

            try
            {
                LBMTopic topic = null;
                LBMSourceAttributes srcAttr = null;

                ctx = new LBMContext();
                srcAttr = new LBMSourceAttributes();
                srcAttr.setValue("ume_store", "127.0.0.1:29999");
                srcAttr.setValue("ume_flight_size", maxFlightSize.ToString());
                topic = ctx.allocTopic("test.topic", srcAttr);
                src = new LBMSource(ctx, topic);
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error initializing LBM objects:  " + ex.Message);
                System.Environment.Exit(1);
            }

            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }

            while (true)
            {
                /*** Send a message. ***/
                try
                {
                    src.send(Encoding.ASCII.GetBytes("test"), 4, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK);
                }
                catch (LBMEWouldBlockException ex)
                {
                    try
                    {
                        int currentFlightSize = src.getInflight(LBM.FLIGHT_SIZE_TYPE_UME);

                        if (currentFlightSize == maxFlightSize)
                        {
                            System.Console.Error.WriteLine("Source is blocked on flight. Exiting");
                            break;
                        }
                    }
                    catch (LBMException exInflight)
                    {
                        System.Console.Error.WriteLine("Error getting flightsize: " + exInflight.Message);
                    }
                }
                catch (LBMException ex)
                {
                    System.Console.Error.WriteLine("Error sending: " + ex.Message);
                }
            }

            /*** Cleanup: delete UM objects. ***/
            try
            {
                System.Threading.Thread.Sleep(3000);
            }
            catch (Exception ex)
            {
                System.Console.Error.WriteLine("Error System.Threading.Thread.Sleep() exception:  " + ex.Message);
                System.Environment.Exit(1);
            }

            try
            {
                src.close();
                ctx.close();
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
        }
Esempio n. 15
0
        static void Main(string[] args)
        {
            LBMContext ctx = null;      /* Container for UM instance */
            LBMTopic topic1 = null;		/* Object used to create topic */
            LBMTopic topic2 = null;	    /* Object used to create topic */
            LBMSource src1 = null;      /* Used for sending messages on a single topic */
            LBMSource src2 = null;      /* Used for sending messages on a single topic */
            LBMSourceAttributes srcAttr = null; 	/* Object used to configure sources */
            int resPort;
            int desPort;

            /* We are using certain lbm objects that require an application level 	*/
            /* memory manager called the LBMObjectRecycler to cleanup 				*/
            LBMObjectRecycler objRec = new LBMObjectRecycler();

            try
            {
                /* create ctxAttr to set config values before creating context */
                LBMContextAttributes ctxAttr = new LBMContextAttributes();
                ctxAttr.setObjectRecycler(objRec, null);

                /* Modify resolver address by setting attributes */
                ctxAttr.setValue("resolver_multicast_address", "224.10.11.12");

                /* Create a context with default attributes */
                ctx = new LBMContext(ctxAttr);
                /* Create source attributes object, used to configure sources */
                srcAttr = new LBMSourceAttributes();
                srcAttr.setObjectRecycler(objRec, null);

                /* Set configuration value using strings */
                srcAttr.setValue("transport", "lbtrm");

                /* The Java API only accepts string values. ints, for example */
                /* must be converted to strings */
                desPort = 14001;
                srcAttr.setValue("transport_lbtrm_destination_port", desPort.ToString());

                /* Create topic for the first source with configured attributes */
                topic1 = new LBMTopic(ctx, "test.topic1", srcAttr);
                src1 = new LBMSource(ctx, topic1);
                /* Modify Configuration for second topic to use a new port */
                desPort = 14002;
                srcAttr.setValue("transport_lbtrm_destination_port", desPort.ToString());

                /* Create second topic and source using modified configuration values */
                topic2 = new LBMTopic(ctx, "test.topic2", srcAttr);
                src2 = new LBMSource(ctx, topic2);
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error initializing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
            System.Console.Out.WriteLine("Context Attributes: ");
            List<LBMConfigOption> cfgOptList = ctx.dumpAttributeList();
            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            System.Console.Out.WriteLine("Source #1 Attributes: ");
            cfgOptList = src1.dumpAttributeList();
            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            System.Console.Out.WriteLine("Source #2 Attributes: ");
            cfgOptList = src2.dumpAttributeList();
            for (int i = 0; i < cfgOptList.Count; i++)
            {
                System.Console.Out.WriteLine(cfgOptList[i].Type + " " + cfgOptList[i].OptionName + " " + cfgOptList[i].Value);
            }
            /* Cleanup all LBM objects */
            try
            {
                objRec.close();
                src2.close();
                src1.close();
                ctx.close();
            }
            catch (LBMException ex)
            {
                System.Console.Error.WriteLine("Error closing LBM objects: " + ex.Message);
                System.Environment.Exit(1);
            }
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            /*
             * Create a context object.  A context is an environment in which
             * LBM functions.  Each context can have its own attributes and
             * configuration settings, which can be specified in an
             * LBMContextAttributes object.  In this example program, we'll
             * just use the default attributes.
             */
            LBMContext myContext = new LBMContext();

            /*
             * Create a topic object.  A topic object is little more than a
             * string (the topic name).  During operation, LBM keeps some state
             * information in the topic object as well.  The topic is bound to
             * the containing context, and will also be bound to a receiver
             * object.  Topics can also have a set of attributes; these are
             * specified using either an LBMReceiverAttributes object or an
             * LBMSourceAttributes object.  The simplest LBMTopic constructor
             * makes a Receiver topic with the default set of attributes.
             * However, there is a difference between "receiver" topics and
             * "source" topics.  To make a "source topic", we need to use a
             * constructor that lets us pass in an LBMSourceAttributes object.
             * Here, we pass in default attributes by creating a dummy
             * LBMSourceAttributes object.  Note that "Greeting" is the topic
             * string.
             */
            LBMTopic myTopic = new LBMTopic(myContext, "Greeting", new LBMSourceAttributes());

            /*
             * Create the source object and bind it to a topic.  Sources must be
             * associated with a context.
             */
            LBMSource mySource = new LBMSource(myContext, myTopic);

            /*
             * Need to wait for receivers to find us before first send.  There are
             * other ways to accomplish this, but sleep is easy.  See https://communities.informatica.com/infakb/faq/5/Pages/80061.aspx
             * for details.
             */
            System.Threading.Thread.Sleep(3000);

            /*
             * Send a message to the "Greeting" topic.  The flags make sure the
             * call to lbm_src_send doesn't return until the message is sent.
             * LBM expects messages to be byte arrays.  Since C# strings are
             * encoded with Unicode by default, and we'd rather have ASCII
             * for this simple test program, we'll explicitly encode the string
             * using ASCII.
             */
            byte[] myMessage = Encoding.ASCII.GetBytes("Hello!");
            mySource.send(myMessage, myMessage.Length, LBM.MSG_FLUSH | LBM.SRC_BLOCK);

            /*
             * We've sent our one message.  Let's close things down.
             */

            /*
             * For some transport types (mostly UDP-based), a short delay before
             * deleting the source is advisable.  Even though the message is sent,
             * there may have been packet loss, and some transports need a bit of
             * time to request re-transmission.  Also, if the above lbm_src_send call
             * didn't include the flush, some time might also be needed to empty the
             * batching buffer.
             */
            System.Threading.Thread.Sleep(2000);

            /*
             * First, we close the source.
             */
            mySource.close();

            /*
             * Notice that we don't "close" the topic.  LBM keeps track of
             * topics for you.
             */

            /*
             * Now, we close the context itself.  Always close a context that
             * is no longer in use and won't be used again.
             */
            myContext.close();
        } /* Main */
Esempio n. 17
0
        static void Main(string[] args)
        {
            if (Environment.GetEnvironmentVariable("LBM_LICENSE_FILENAME") == null &&
                Environment.GetEnvironmentVariable("LBM_LICENSE_INFO") == null)
            {
                SetEnvironmentVariable("LBM_LICENSE_FILENAME", "lbm_license.txt");
            }

            LBM lbm = new LBM();

            lbm.setLogger(logger);

            string target             = null;
            int    send_rate          = 0;              //	Used for lbmtrm | lbtru transports
            int    retrans_rate       = 0;              //
            char   protocol           = '\0';           //
            int    linger             = 5;
            int    msglen             = MIN_ALLOC_MSGLEN;
            int    pause_milliseconds = 5;
            int    delay = 1;
            int    i;
            int    n     = args.Length;
            bool   error = false;
            bool   done  = false;

            for (i = 0; i < n; i++)
            {
                try
                {
                    switch (args[i])
                    {
                    case "-c":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        try
                        {
                            LBM.setConfiguration(args[i]);
                        }
                        catch (LBMException Ex)
                        {
                            Console.Error.WriteLine("lbmreq error: " + Ex.Message);
                            error = true;
                        }
                        break;

                    case "-d":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        delay = Convert.ToInt32(args[i]);
                        break;

                    case "-h":
                        print_help_exit(0);
                        break;

                    case "-i":
                        send_immediate = true;
                        break;

                    case "-q":
                        eventq = true;
                        break;

                    case "-l":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        msglen = Convert.ToInt32(args[i]);
                        break;

                    case "-L":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        linger = Convert.ToInt32(args[i]);
                        break;

                    case "-P":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        pause_milliseconds = Convert.ToInt32(args[i]);
                        break;

                    case "-R":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        requests = Convert.ToInt32(args[i]);
                        break;

                    case "-r":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        ParseRateVars parseRateVars = lbmExampleUtil.parseRate(args[i]);
                        if (parseRateVars.error)
                        {
                            print_help_exit(1);
                        }
                        send_rate    = parseRateVars.rate;
                        retrans_rate = parseRateVars.retrans;
                        protocol     = parseRateVars.protocol;
                        break;

                    case "-s":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        stats_sec = Convert.ToInt32(args[i]);
                        break;

                    case "-T":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        target = args[i];
                        break;

                    case "-v":
                        verbose++;
                        break;

                    default:
                        if (args[i].StartsWith("-"))
                        {
                            error = true;
                        }
                        else
                        {
                            done = true;
                        }
                        break;
                    }
                    if (error || done)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    /* type conversion exception */
                    Console.Error.WriteLine("lbmreq: error\n" + e.Message + "\n");
                    print_help_exit(1);
                }
            }
            if (error || i >= n)
            {
                /* An error occurred processing the command line - print help and exit */
                print_help_exit(1);
            }
            string topic_str = null;

            if (i >= n)
            {
                if (!send_immediate)
                {
                    print_help_exit(1);
                }
            }
            else
            {
                topic_str = args[i];
            }

            byte[] message = null;

            /* if message buffer is too small, then the enc.GetBytes will cause issues.
             *          Therefore, allocate with a MIN_ALLOC_MSGLEN */
            if (msglen < MIN_ALLOC_MSGLEN)
            {
                message = new byte[MIN_ALLOC_MSGLEN];
            }
            else
            {
                message = new byte[msglen];
            }

            LBMSourceAttributes  lbmSourceAttributes  = new LBMSourceAttributes();
            LBMContextAttributes lbmContextAttributes = new LBMContextAttributes();

            /* Check if protocol needs to be set to lbtrm | lbtru */
            if (protocol == 'M')
            {
                try
                {
                    lbmSourceAttributes.setValue("transport", "LBTRM");

                    lbmContextAttributes.setValue("transport_lbtrm_data_rate_limit", send_rate.ToString());
                    lbmContextAttributes.setValue("transport_lbtrm_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    Console.Error.WriteLine("Error setting LBTRM rate: " + ex.Message);
                    Environment.Exit(1);
                }
            }
            if (protocol == 'U')
            {
                try
                {
                    lbmSourceAttributes.setValue("transport", "LBTRU");

                    lbmContextAttributes.setValue("transport_lbtru_data_rate_limit", send_rate.ToString());
                    lbmContextAttributes.setValue("transport_lbtru_retransmit_rate_limit", retrans_rate.ToString());
                }
                catch (LBMException ex)
                {
                    Console.Error.WriteLine("Error setting LBTRU rate: " + ex.Message);
                    Environment.Exit(1);
                }
            }

            LBMContext       ctx = new LBMContext(lbmContextAttributes);
            LBMreqEventQueue lbmReqEventQueue = null;

            if (eventq)
            {
                lbmReqEventQueue = new LBMreqEventQueue();
                Console.Error.WriteLine("Event queue in use.");
            }
            else
            {
                Console.Error.WriteLine("No event queue\n");
            }

            LBMTopic  topic;
            LBMSource src            = null;
            LBMreqCB  lbMreqCallBack = new LBMreqCB(verbose);

            if (!send_immediate)
            {
                topic = ctx.allocTopic(topic_str, lbmSourceAttributes);
                src   = ctx.createSource(topic, lbMreqCallBack.onSourceEvent, null, lbmReqEventQueue);
                if (delay > 0)
                {
                    Console.Out.WriteLine("Delaying requests for {0} second{1}...\n",
                                          delay, ((delay > 1) ? "s" : ""));
                    Thread.Sleep(delay * 1000);
                }
            }
            ASCIIEncoding enc = new ASCIIEncoding();

            if (requests > 0)
            {
                Console.Out.WriteLine("Will send {0} request{1}\n", requests, (requests == 1 ? "" : "s"));
            }

            Console.Out.Flush();

            for (int count = 0; count < requests; count++)
            {
                LBMTimer      qTimer;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Request data {0}", count);
                enc.GetBytes(sb.ToString(), 0, sb.ToString().Length, message, 0);

                LBMRequest req = new LBMRequest(message, msglen);
                req.addResponseCallback(lbMreqCallBack.onResponse);

                Console.Out.WriteLine("Sending request " + count);

                if (send_immediate)
                {
                    if (target == null)
                    {
                        if (eventq)
                        {
                            ctx.send(topic_str, req, lbmReqEventQueue, 0);
                        }
                        else
                        {
                            ctx.send(topic_str, req, 0);
                        }
                    }
                    else
                    {
                        if (eventq)
                        {
                            ctx.send(target, topic_str, req, lbmReqEventQueue, 0);
                        }
                        else
                        {
                            ctx.send(target, topic_str, req, 0);
                        }
                    }
                }
                else
                {
                    if (eventq)
                    {
                        src.send(req, lbmReqEventQueue, 0);
                    }
                    else
                    {
                        src.send(req, 0);
                    }
                }

                if (verbose > 0)
                {
                    Console.Out.Write("Sent request " + count + ". ");
                }

                if (!eventq)
                {
                    if (verbose > 0)
                    {
                        Console.Out.WriteLine("Pausing " + pause_milliseconds + " seconds.");
                    }

                    Thread.Sleep(pause_milliseconds);
                }
                else
                {
                    if (verbose > 0)
                    {
                        Console.Out.WriteLine("Creating timer for " + pause_milliseconds + " seconds and initiating event pump.");
                    }

                    qTimer = new EQTimer(ctx, pause_milliseconds, lbmReqEventQueue);
                    lbmReqEventQueue.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;

                req.close();

                Console.Out.Flush();
            }//end of for

            if (linger > 0)
            {
                Console.Out.WriteLine("\nLingering for {0} second{1}...\n", linger, ((linger > 1) ? "s" : ""));
                Thread.Sleep(linger * 1000);
            }

            Console.Out.WriteLine("Quitting...");
            if (src != null)
            {
                src.close();
            }
            ctx.close();
        }
Esempio n. 18
0
        void Run(string[] args)
        {
            string cfgFile = "application.cfg";
            string test    = "1";

            if (args.Length == 2)
            {
                cfgFile = args[0];
                test    = args[1];
            }
            else if (args.Length == 1)
            {
                cfgFile = args[0];
            }
            else if (args.Length != 0)
            {
                throw new TmonException("TmonExample: bad arg count (" + args.Length + ")");
            }

            LBM lbm = new LBM();

            lbm.setLogger(this.Logger);

            _timeOfDay = new TmonGetTimeOfDay();

            LBM.setConfiguration(cfgFile);

            MyLog("Creating context.");
            // Context name must be alpha, numeric, underscore, hyphen.
            LBMContextAttributes ctxAttr = new LBMContextAttributes("tmon_example_ctx");
            LBMContext           ctx     = new LBMContext(ctxAttr);

            MyLog("Creating topic monitor.");
            TmonContext tmonContext = new TmonContext(ctx);

            tmonContext.InitSender(); // I.e. this tmon context is for sending reports.

            MyLog("Creating wildcard rcv for '^.*2$' (will resolv, no msg)");
            TmonReceiver          tmonWRcv = tmonContext.ReceiverCreate(ReceiverType.Wildcard, "^.*2$");
            LBMReceiverAttributes rcvAttr  = new LBMReceiverAttributes("29west_tmon_context", "wc2");

            rcvAttr.setSourceNotificationCallbacks(this.OnDeliveryControllerCreate,
                                                   this.OnDeliveryControllerDelete, tmonWRcv);
            LBMWildcardReceiver wrcv = new LBMWildcardReceiver(ctx, "^.*2$", rcvAttr,
                                                               null, this.OnReceive, null);

            MyLog("Creating rcv for 'src\\1' (will resolv, rcv msg)");
            TmonReceiver tmonRcv1 = tmonContext.ReceiverCreate(ReceiverType.Regular, "src\\1");

            rcvAttr = new LBMReceiverAttributes("29west_tmon_context", "src\\1");
            rcvAttr.setSourceNotificationCallbacks(this.OnDeliveryControllerCreate,
                                                   this.OnDeliveryControllerDelete, tmonRcv1);
            LBMReceiver rcv1 = new LBMReceiver(ctx, ctx.lookupTopic("src\\1", rcvAttr),
                                               this.OnReceive, null, null);

            MyLog("Creating rcv for 'src3' (will resolve, no msg)");
            TmonReceiver tmonRcv3 = tmonContext.ReceiverCreate(ReceiverType.Regular, "src3");

            rcvAttr = new LBMReceiverAttributes("29west_tmon_context", "src3");
            rcvAttr.setSourceNotificationCallbacks(this.OnDeliveryControllerCreate,
                                                   this.OnDeliveryControllerDelete, tmonRcv3);
            LBMReceiver rcv3 = new LBMReceiver(ctx, ctx.lookupTopic("src3", rcvAttr),
                                               this.OnReceive, null, null);

            MyLog("Creating rcv for 'srcx' (will not resolve)");
            TmonReceiver tmonRcvx = tmonContext.ReceiverCreate(ReceiverType.Regular, "srcx");

            rcvAttr = new LBMReceiverAttributes("29west_tmon_context", "srcx");
            rcvAttr.setSourceNotificationCallbacks(this.OnDeliveryControllerCreate,
                                                   this.OnDeliveryControllerDelete, tmonRcvx);
            LBMReceiver rcvx = new LBMReceiver(ctx, ctx.lookupTopic("srcx", rcvAttr),
                                               this.OnReceive, null, null);

            MyLog("Creating src for 'src\\1' (will resolve, send msg)");
            TmonSource          tmonSrc1 = tmonContext.SourceCreate("src\\1");
            LBMSourceAttributes srcAttr  = new LBMSourceAttributes("29west_tmon_context", "src\\1");
            LBMSource           src1     = ctx.createSource(ctx.allocTopic("src\\1", srcAttr));

            Thread.Sleep(100); // Let receiver discover.

            MyLog("Creating src for 'src,2' (wildcard resolve, no msg)");
            TmonSource tmonSrc2 = tmonContext.SourceCreate("src,2");

            srcAttr = new LBMSourceAttributes("29west_tmon_context", "src,2");
            LBMSource src2 = ctx.createSource(ctx.allocTopic("src,2", srcAttr));

            Thread.Sleep(100); // Let receiver discover.

            MyLog("Creating src for 'src3' (will resolve, no msg)");
            TmonSource tmonSrc3 = tmonContext.SourceCreate("src3");

            srcAttr = new LBMSourceAttributes("29west_tmon_context", "src3");
            LBMSource src3 = ctx.createSource(ctx.allocTopic("src3", srcAttr));

            Thread.Sleep(100); // Let receiver discover.

            MyLog("Delete receiver for 'src,2' to get DC delete without BOS or EOS");
            wrcv.close();
            tmonWRcv.Close();

            MyLog("Sleeping 6 for BOS triggered by TSNI for 'src\\1', 'src3'");
            Thread.Sleep(6000);

            MyLog("Deleting rcv for 'src3' while src still up - should get DC delete without EOS");
            rcv3.close();
            tmonRcv3.Close();

            string msg = "Hello!";

            if (test.Equals("1"))
            {
                MyLog("Sending to 'src\\1'");
                src1.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0);

                MyLog("Wait for msg receive or EOS");
                while (_messagesReceived == 0)
                {
                    Thread.Sleep(1000);
                }
            }
            else if (test.Equals("2"))
            {
                MyLog("Sending 120 msgs to 'src\\1'");
                for (int i = 0; i < 120; i++)
                {
                    src1.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0);
                } // for
                MyLog("lingering 10 sec");
                Thread.Sleep(10000);
            }
            else
            {
                throw new TmonException("TmonExample: bad test number (" + test + ")");
            }

            MyLog("Delete sources");
            src1.close();
            tmonSrc1.Close();
            src2.close();
            tmonSrc2.Close();
            src3.close();
            tmonSrc3.Close();

            MyLog("Sleeping 6 sec for EOS and DC delete for 'src\\1'.");
            Thread.Sleep(6000);

            MyLog("Deleting rcvs for 'src\\1'");
            rcv1.close();
            tmonRcv1.Close();

            MyLog("Generate rolling EOS on srcx");
            LBM.setLbtrmSrcLossRate(100);
            TmonSource tmonSrcx = tmonContext.SourceCreate("srcx");

            srcAttr = new LBMSourceAttributes("29west_tmon_context", "srcx");
            LBMSource srcx = ctx.createSource(ctx.allocTopic("srcx", srcAttr));

            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Start SMs going.
            Thread.Sleep(13750);                                    // Wait 2.5 * RM activity timeouts.

            MyLog("Generate BOS on srcx and msg");
            LBM.setLbtrmSrcLossRate(0);
            msg = "1";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Trigger BOS.
            Thread.Sleep(100);

            MyLog("Generate unrecoverable loss on srcx");
            LBM.setLbtrmSrcLossRate(100);
            msg = "2";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            Thread.Sleep(100);
            LBM.setLbtrmSrcLossRate(0);
            msg = "3";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // gap.
            Thread.Sleep(200);                                      // 2*nak gen ivl.
            msg = "4";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // push out loss event.
            Thread.Sleep(100);

            MyLog("Generate suppressed unrecoverable loss");
            LBM.setLbtrmSrcLossRate(0);
            msg = "1";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Trigger BOS.
            Thread.Sleep(100);
            LBM.setLbtrmSrcLossRate(100);
            msg = "2";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            Thread.Sleep(100);
            LBM.setLbtrmSrcLossRate(0);
            msg = "3";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // gap.
            Thread.Sleep(200);                                      // 2*nak gen ivl.
            msg = "4";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // push out loss event.
            Thread.Sleep(100);

            Thread.Sleep(10100); // Expire tmon's 10-second loss suppression.

            MyLog("Generate unrecoverable burst loss");
            LBM.setLbtrmSrcLossRate(100);
            msg = "5";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            msg = "6";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            msg = "7";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            msg = "8";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // Lost pkt.
            Thread.Sleep(100);
            LBM.setLbtrmSrcLossRate(0);
            msg = "9";
            srcx.send(Encoding.ASCII.GetBytes(msg), msg.Length, 0); // gap.
            Thread.Sleep(200);                                      // Wait for BURST.

            MyLog("Delete rcvx, srcx.");
            rcvx.close();
            tmonRcvx.Close();
            srcx.close();
            tmonSrcx.Close();

            MyLog("Deleting tmon_ctx.");
            tmonContext.Close();

            MyLog("Deleting context.");
            ctx.close();
        } // Run