コード例 #1
0
    static void Main(String[] args)
    {
        LBMContext            ctx    = null;     /* Context object: container for UM "instance". */
        LBMReceiver           rcv    = null;     /* Receiver object: for receiving messages. */
        LBMTopic              rtopic = null;     /* Topic object */
        LBMReceiverAttributes rcv_attr;          /* Receiver attribute object */

        /* Initialize and create receiver and receiver callback */
        LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

        /*** Initialization: create necessary UM objects. ***/
        ctx = new LBMContext();

        rcv_attr = new LBMReceiverAttributes();
        rcv_attr.setValue("resolution_no_source_notification_threshold", noSourceQueries);

        rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
        rcv    = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

        while (noSource == 0)
        {
            try
            {
                System.Threading.Thread.Sleep(1000);
            }
            catch (Exception eex)
            {
                System.Console.Error.WriteLine("Error Thread.sleep interrupted: " + eex.Message);
                System.Environment.Exit(1);
            }
        }

        rcv.close();
        ctx.close();
    }     /* main */
コード例 #2
0
ファイル: NoSourceNotify.cs プロジェクト: debhack/UMExamples
    static void Main(String[] args)
    {
        LBMContext ctx = null;           /* Context object: container for UM "instance". */
                LBMReceiver rcv = null;          /* Receiver object: for receiving messages. */
                LBMTopic rtopic = null;          /* Topic object */
                LBMReceiverAttributes rcv_attr;  /* Receiver attribute object */

                /* Initialize and create receiver and receiver callback */
                LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

                /*** Initialization: create necessary UM objects. ***/
                ctx = new LBMContext();

                rcv_attr = new LBMReceiverAttributes();
                rcv_attr.setValue("resolution_no_source_notification_threshold", noSourceQueries);

                rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
                rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

                while(noSource == 0) {
                    try
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    catch (Exception eex)
                    {
                        System.Console.Error.WriteLine("Error Thread.sleep interrupted: " + eex.Message);
                        System.Environment.Exit(1);
                    }
                }

                rcv.close();
                ctx.close();
    }
コード例 #3
0
ファイル: lbmresp.cs プロジェクト: UltraMessaging/betadoc
        //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);
        }
コード例 #4
0
    static void Main(String[] args)
    {
        LBMContext            ctx    = null;     /* Context object: container for UM "instance". */
        LBMReceiver           rcv    = null;     /* Receiver object: for receiving messages. */
        LBMTopic              rtopic = null;     /* Topic object */
        LBMReceiverAttributes rcv_attr;          /* Receiver attribute object */

        /* Initialize and create receiver and receiver callback */
        LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

        /*** Initialization: create necessary UM objects. ***/
        ctx      = new LBMContext();
        rcv_attr = new LBMReceiverAttributes();

        UMERcvRecInfo umerecinfocb = new UMERcvRecInfo();

        rcv_attr.setRecoverySequenceNumberCallback(umerecinfocb.setRecoverySequenceNumberInfo, null);

        rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
        rcv    = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

        while (true)
        {
        }
    }     /* main */
コード例 #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();
    }  /* main */
コード例 #6
0
    static void Main(String[] args)
    {
        LBMContext ctx = null;           /* Context object: container for UM "instance". */
                LBMReceiver rcv = null;          /* Receiver object: for receiving messages. */
                LBMTopic rtopic = null;          /* Topic object */
                LBMReceiverAttributes rcv_attr;  /* Receiver attribute object */

                /* Initialize and create receiver and receiver callback */
                LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

                /*** Initialization: create necessary UM objects. ***/
                ctx = new LBMContext();
                rcv_attr = new LBMReceiverAttributes();

                UMERcvRecInfo umerecinfocb = new UMERcvRecInfo();
                rcv_attr.setRecoverySequenceNumberCallback(umerecinfocb.setRecoverySequenceNumberInfo, null);

                rtopic = new LBMTopic(ctx, "test.topic", rcv_attr);
                rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

                while(true)
                {

                }
    }
コード例 #7
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();
    }
コード例 #8
0
ファイル: lbmlatping.cs プロジェクト: UltraMessaging/betadoc
            public lbmlatpingreceiver(LBMContext lbmctx, LBMTopic lbmtopic, lbmlatping mylatping)
            {
                latping   = mylatping;
                source    = latping.ping_src;
                buffer    = latping.msgbuf;
                bufferptr = latping.msgbufPtr;

                if (source.buffAcquire(out bufferAcquired, (uint)buffer.Length, 0) == 0)
                {
                    bufferAcquiredSize = buffer.Length;
                }
                receiver = new LBMReceiver(lbmctx, lbmtopic, new LBMReceiverCallback(onReceive), null, null);
            }
コード例 #9
0
ファイル: late_join.cs プロジェクト: mallickhruday/MyDemos
    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);
        }
    }
コード例 #10
0
ファイル: late_join.cs プロジェクト: debhack/UMExamples
    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);
        }
    }
コード例 #11
0
        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();
                }
            }
        }
コード例 #12
0
    static void Main(String[] args)
    {
        LBMContext  ctx    = null;               /* Context object: container for UM "instance". */
        LBMReceiver rcv    = null;               /* Receiver object: for receiving messages. */
        LBMTopic    rtopic = null;               /* Topic object */

        /* Initialize and create receiver and receiver callback */
        LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

        /*** Initialization: create necessary UM objects. ***/
        ctx = new LBMContext();

        rtopic = new LBMTopic(ctx, "test.topic");
        rcv    = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

        while (true)
        {
        }
    }     /* main */
コード例 #13
0
    static void Main(String[] args)
    {
        LBMContext ctx = null;           /* Context object: container for UM "instance". */
                LBMReceiver rcv = null;          /* Receiver object: for receiving messages. */
                LBMTopic rtopic = null;          /* Topic object */

                /* Initialize and create receiver and receiver callback */
                LBMReceiverCallback myReceiverCallback = new LBMReceiverCallback(onReceive);

                /*** Initialization: create necessary UM objects. ***/
                ctx = new LBMContext();

                rtopic = new LBMTopic(ctx, "test.topic");
                rcv = new LBMReceiver(ctx, rtopic, myReceiverCallback, null);

                while(true)
                {

                }
    }
コード例 #14
0
ファイル: lbmpong.cs プロジェクト: UltraMessaging/betadoc
 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");
 }
コード例 #15
0
    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);
        }
    }
コード例 #16
0
ファイル: event_q_rcv.cs プロジェクト: debhack/UMExamples
    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);
        }
    }
コード例 #17
0
ファイル: lbmrcvxsp.cs プロジェクト: UltraMessaging/currdoc
        static void Main(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));

            LBMObjectRecycler objRec = new LBMObjectRecycler();

            string num_srcs = null;
            int    i;
            int    n = args.Length;

            bool   monitor_context       = false;
            int    monitor_context_ivl   = 0;
            bool   monitor_receiver      = false;
            int    monitor_receiver_ivl  = 0;
            string application_id        = null;
            int    mon_format            = LBMMonitor.FORMAT_CSV;
            int    mon_transport         = LBMMonitor.TRANSPORT_LBM;
            string mon_format_options    = null;
            string mon_transport_options = null;
            bool   error = false;
            bool   done  = false;
            LBMRoundRobinXSPMappingHandler rrHelper = null;

            const string OPTION_MONITOR_CTX            = "--monitor-ctx";
            const string OPTION_MONITOR_RCV            = "--monitor-rcv";
            const string OPTION_MONITOR_TRANSPORT      = "--monitor-transport";
            const string OPTION_MONITOR_TRANSPORT_OPTS = "--monitor-transport-opts";
            const string OPTION_MONITOR_FORMAT         = "--monitor-format";
            const string OPTION_MONITOR_FORMAT_OPTS    = "--monitor-format-opts";
            const string OPTION_MONITOR_APPID          = "--monitor-appid";

            for (i = 0; i < n; i++)
            {
                try
                {
                    switch (args[i])
                    {
                    case OPTION_MONITOR_APPID:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        application_id = args[i];
                        break;

                    case OPTION_MONITOR_CTX:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_context     = true;
                        monitor_context_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_RCV:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_receiver     = true;
                        monitor_receiver_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_FORMAT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("csv") == 0)
                        {
                            mon_format = LBMMonitor.FORMAT_CSV;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("lbm") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBM;
                        }
                        else if (args[i].ToLower().CompareTo("udp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_UDP;
                        }
                        else if (args[i].ToLower().CompareTo("lbmsnmp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBMSNMP;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_transport_options += args[i];
                        break;

                    case OPTION_MONITOR_FORMAT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_format_options += args[i];
                        break;

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

                    case "-d":
                        defer_xsp_deletion = true;
                        break;

                    case "-D":
                        use_default_xsp = true;
                        break;

                    case "-E":
                        end_on_eos = true;
                        break;

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

                    case "-P":
                        rr_preallocate = true;
                        break;

                    case "-Q":
                        sequential_xsps = true;
                        break;

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

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

                    case "-S":
                        end_on_eos = true;
                        summary    = true;
                        break;

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

                    case "-v":

                        verbose = true;
                        break;

                    case "-V":
                        verifiable = true;
                        break;

                    default:
                        if (args[i].StartsWith("-"))
                        {
                            error = true;
                        }
                        else
                        {
                            done = true;
                        }
                        break;
                    }
                    if (error || done)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    /* type conversion exception */
                    System.Console.Error.WriteLine("lbmrcvxsp: 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);
            }
            LBMRcvReceiver       rcv      = new LBMRcvReceiver(verbose, end_on_eos, summary, objRec);
            LBMContextAttributes ctx_attr = new LBMContextAttributes();

            ctx_attr.setImmediateMessageCallback(new LBMImmediateMessageCallback(rcv.onReceive));
            ctx_attr.setObjectRecycler(objRec, null);

            if (use_default_xsp)
            {
                ctx_attr.setTransportMappingCallback(new LBMTransportMappingCallback(onTransportMapping), null);
            }
            else
            {
                if (round_robin <= 0)
                {
                    System.Console.Out.WriteLine("!! round_robin must be >= 1  -  setting to 1");
                    round_robin = 1;
                }

                System.Console.Out.WriteLine("\nUsing a round-robin strategy with " + round_robin + " XSPs.  Preallocation is " +
                                             (rr_preallocate ? "ON" : "OFF") + "\n");

                rrHelper = new LBMRoundRobinXSPMappingHandler();
                ctx_attr.setTransportMappingCallback(new LBMTransportMappingCallback(rrHelper.onTransportMapping), null);
            }

            LBMContext ctx = new LBMContext(ctx_attr);

            if (ctx.getAttributeValue("request_tcp_bind_request_port") != "0")
            {
                string request_tcp_iface = ctx.getAttributeValue("request_tcp_interface");
                // Check if a different interface was specified for request_tcp_interface
                if (!request_tcp_iface.Equals("0.0.0.0"))
                {
                    System.Console.Out.WriteLine("Immediate messaging target: TCP:"
                                                 + request_tcp_iface + ":"
                                                 + ctx.getAttributeValue("request_tcp_port"));
                }
                else
                {
                    System.Console.Out.WriteLine("Immediate messaging target: TCP:"
                                                 + ctx.getAttributeValue("resolver_multicast_interface") + ":"
                                                 + ctx.getAttributeValue("request_tcp_port"));
                }
            }
            else
            {
                System.Console.Out.WriteLine("Request port binding disabled, no immediate messaging target");
            }
            if ((rrHelper != null) && (rr_preallocate))
            {
                rrHelper.preallocateXSPs(ctx);
            }

            LBMReceiverAttributes rattr = new LBMReceiverAttributes();

            if (num_srcs != null)
            {
                rattr.setValue("resolution_number_of_sources_query_threshold", num_srcs);
            }
            rattr.setObjectRecycler(objRec, null);
            LBMTopic    topic = ctx.lookupTopic(args[i], rattr);
            LBMReceiver lbmrcv;

            lbmrcv = new LBMReceiver(ctx, topic, rcv.onReceive, null);

            System.Console.Out.Flush();

            LBMMonitorSource lbmmonsrc = null;

            if (monitor_context || monitor_receiver)
            {
                lbmmonsrc = new LBMMonitorSource(mon_format, mon_format_options, mon_transport, mon_transport_options);
                if (monitor_context)
                {
                    lbmmonsrc.start(ctx, application_id, monitor_context_ivl);
                }
                else
                {
                    lbmmonsrc.start(lbmrcv, application_id, monitor_receiver_ivl);
                }
            }
            long start_time;
            long end_time;
            long last_lost = 0, lost_tmp = 0, lost = 0;
            bool have_stats             = false;
            LBMReceiverStatistics stats = null;
            long stat_time              = System.DateTime.Now.AddSeconds(stat_secs).Ticks;

            for (; ;)
            {
                start_time = System.DateTime.Now.Ticks;
                System.Threading.Thread.Sleep(1000);

                have_stats = false;
                while (!have_stats)
                {
                    try
                    {
                        stats      = lbmrcv.getStatistics(nstats);
                        have_stats = true;
                    }
                    catch (LBMException ex)
                    {
                        /* Double the number of stats passed to the API to be retrieved */
                        /* Do so until we retrieve stats successfully or hit the max limit */
                        nstats *= 2;
                        if (nstats > DEFAULT_MAX_NUM_SRCS)
                        {
                            System.Console.Error.WriteLine("Error getting receiver statistics: " + ex.Message);
                            System.Environment.Exit(1);
                        }
                        /* have_stats is still false */
                    }
                }

                /* If we get here, we have the stats */
                lost = 0;
                for (i = 0; i < stats.size(); i++)
                {
                    lost += stats.lost(i);
                }
                /* Account for loss in previous iteration */
                lost_tmp = lost;
                if (last_lost <= lost)
                {
                    lost -= last_lost;
                }
                else
                {
                    lost = 0;
                }
                last_lost = lost_tmp;

                end_time = System.DateTime.Now.Ticks;
                print_bw((end_time - start_time) / 10000,
                         rcv.msg_count,
                         rcv.byte_count,
                         rcv.unrec_count,
                         lost,
                         rcv.burst_loss,
                         rcv.rx_msgs,
                         rcv.otr_msgs);

                if (stat_secs > 0 && stat_time <= end_time)
                {
                    stat_time = System.DateTime.Now.AddSeconds(stat_secs).Ticks;
                    print_stats(stats);
                }
                // recycle stats object when finished so it can be reused by LBM
                objRec.doneWithReceiverStatistics(stats);

                rcv.msg_count   = 0;
                rcv.byte_count  = 0;
                rcv.unrec_count = 0;
                rcv.burst_loss  = 0;
                rcv.rx_msgs     = 0;
                rcv.otr_msgs    = 0;

                if (reap_msgs != 0 && rcv.total_msg_count >= reap_msgs)
                {
                    break;
                }
            }
            System.Console.Error.WriteLine("Quitting.... received "
                                           + rcv.total_msg_count
                                           + " messages");

            objRec.close();
            lbmrcv.close();
            ctx.close();
        }
コード例 #18
0
ファイル: lbmlatpong.cs プロジェクト: UltraMessaging/currdoc
 public lbmlatpongreceiver(LBMContext lbmctx, LBMTopic lbmtopic, lbmlatpong mylatpong, LBMSource src)
 {
     latpong  = mylatpong;
     source   = src;
     receiver = new LBMReceiver(lbmctx, lbmtopic, new LBMReceiverCallback(onReceive), null, null);
 }
コード例 #19
0
        private static void MiniTest(string[] args)
        {
            var delay = 0;

            if (args.Length > 0)
            {
                delay = int.Parse(args[0]);
            }

            /*
             * 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.  That
             * is the constructor we will call here; note that "Greeting" is
             * the topic string.
             */
            LBMTopic myTopic = new LBMTopic(myContext, "Greeting");

            MinRcvReceiverCallback myReceiverCallback = new MinRcvReceiverCallback(delay);
            LBMReceiver            myReceiver         = new LBMReceiver(myContext, myTopic, myReceiverCallback.onReceive, null, null);


            Console.WriteLine("Press any key to exit...");
            Console.ReadLine();

            /*
             * We've received and processed some messages.  Now let's close
             * things down.
             */

            /*
             * Close the receiver, which means we quit listening for messages
             * on our receiver's topic.
             */
            myReceiver.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();
        }
コード例 #20
0
ファイル: lbmresp.cs プロジェクト: UltraMessaging/betadoc
 public LBMRespReceiver(LBMContext ctx, LBMTopic topic, int verbose, bool end_on_eos)
 {
     _verbose    = verbose;
     _end_on_eos = end_on_eos;
     _rcv        = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null);
 }
コード例 #21
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 */
コード例 #22
0
ファイル: MinRcv.cs プロジェクト: UltraMessaging/betadoc
        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.  That
             * is the constructor we will call here; note that "Greeting" is
             * the topic string.
             */
            LBMTopic myTopic = new LBMTopic(myContext, "Greeting");

            MinRcvReceiverCallback myReceiverCallback = new MinRcvReceiverCallback();

            /*
             * Create the receiver object and bind it to a topic.  Receivers
             * must be associated with a context.
             */
            LBMReceiver myReceiver = new LBMReceiver(myContext, myTopic, myReceiverCallback.onReceive, null, null);


            /*
             * Wait until we've received some messages. While the main thread
             * of the example program sleeps, LBM will receive messages and
             * call the "onReceive" method of our MinRcvReceiverCallback class.
             */
            while (messagesReceived == 0)
            {
                System.Threading.Thread.Sleep(1000);
            }

            /*
             * We've received and processed some messages.  Now let's close
             * things down.
             */

            /*
             * Close the receiver, which means we quit listening for messages
             * on our receiver's topic.
             */
            myReceiver.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 */
コード例 #23
0
ファイル: lbmmrcv.cs プロジェクト: UltraMessaging/betadoc
 public LBMMRcvReceiver(LBMContext ctx, LBMTopic topic, bool verbose)
 {
     rcv      = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null);
     _verbose = verbose;
 }
コード例 #24
0
ファイル: lbmmrcv.cs プロジェクト: UltraMessaging/betadoc
 public LBMMRcvReceiver(LBMContext ctx, LBMTopic topic, LBMEventQueue evq, bool verbose)
 {
     rcv      = new LBMReceiver(ctx, topic, new LBMReceiverCallback(onReceive), null, evq);
     _verbose = verbose;
     _evq     = evq;
 }
コード例 #25
0
ファイル: lbmrcv.cs プロジェクト: UltraMessaging/currdoc
        static void Main(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));

            LBMObjectRecycler objRec = new LBMObjectRecycler();

            string qdelay   = null;
            string qsize    = null;
            string num_srcs = null;
            int    i;
            int    n = args.Length;

            bool   monitor_context       = false;
            int    monitor_context_ivl   = 0;
            bool   monitor_receiver      = false;
            int    monitor_receiver_ivl  = 0;
            string application_id        = null;
            int    mon_format            = LBMMonitor.FORMAT_CSV;
            int    mon_transport         = LBMMonitor.TRANSPORT_LBM;
            string mon_format_options    = null;
            string mon_transport_options = null;
            bool   error  = false;
            bool   done   = false;
            bool   use_hf = false;

            List <uint>  channels                      = new List <uint>();
            const string OPTION_MONITOR_CTX            = "--monitor-ctx";
            const string OPTION_MONITOR_RCV            = "--monitor-rcv";
            const string OPTION_MONITOR_TRANSPORT      = "--monitor-transport";
            const string OPTION_MONITOR_TRANSPORT_OPTS = "--monitor-transport-opts";
            const string OPTION_MONITOR_FORMAT         = "--monitor-format";
            const string OPTION_MONITOR_FORMAT_OPTS    = "--monitor-format-opts";
            const string OPTION_MONITOR_APPID          = "--monitor-appid";

            for (i = 0; i < n; i++)
            {
                try
                {
                    switch (args[i])
                    {
                    case OPTION_MONITOR_APPID:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        application_id = args[i];
                        break;

                    case OPTION_MONITOR_CTX:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_context     = true;
                        monitor_context_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_RCV:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_receiver     = true;
                        monitor_receiver_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_FORMAT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("csv") == 0)
                        {
                            mon_format = LBMMonitor.FORMAT_CSV;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("lbm") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBM;
                        }
                        else if (args[i].ToLower().CompareTo("udp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_UDP;
                        }
                        else if (args[i].ToLower().CompareTo("lbmsnmp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBMSNMP;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_transport_options += args[i];
                        break;

                    case OPTION_MONITOR_FORMAT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_format_options += args[i];
                        break;

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

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

                    case "-D":
                        if (verifiable)
                        {
                            System.Console.Error.WriteLine("Unable to use SDM because verifiable messages are on. Turn off verifiable messages (-V).");
                            System.Environment.Exit(1);
                        }
                        sdm = true;
                        break;

                    case "-f":
                        use_hf = true;
                        break;

                    case "-E":
                        end_on_eos = true;
                        break;

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

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

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

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

                    case "-N":
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        try
                        {
                            channels.Add(Convert.ToUInt32(args[i]));
                        }
                        catch (Exception e)
                        {
                            Console.Error.WriteLine(e.Message);
                            error = true;
                        }
                        break;

                    case "-S":
                        end_on_eos = true;
                        summary    = true;
                        break;

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

                    case "-v":

                        verbose = true;
                        break;

                    case "-V":
                        if (sdm)
                        {
                            System.Console.Error.WriteLine("Unable to use verifiable messages because sdm is on. Turn off sdm (-D).");
                            System.Environment.Exit(1);
                        }
                        verifiable = true;
                        break;

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

                    default:
                        if (args[i].StartsWith("-"))
                        {
                            error = true;
                        }
                        else
                        {
                            done = true;
                        }
                        break;
                    }
                    if (error || done)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    /* type conversion exception */
                    System.Console.Error.WriteLine("lbmrcv: 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);
            }
            LBMRcvReceiver       rcv      = new LBMRcvReceiver(verbose, end_on_eos, summary, objRec);
            LBMContextAttributes ctx_attr = new LBMContextAttributes();
            LBMRcvEventQueue     evq      = null;

            if (eventq)
            {
                System.Console.Error.WriteLine("Event queue in use");
                LBMEventQueueAttributes evqattr = null;
                if (qsize != null || qdelay != null)
                {
                    evqattr = new LBMEventQueueAttributes();
                    if (qdelay != null)
                    {
                        evqattr.setValue("queue_delay_warning", qdelay);
                    }
                    if (qsize != null)
                    {
                        evqattr.setValue("queue_size_warning", qsize);
                    }
                }
                evq = new LBMRcvEventQueue(evqattr);
                ctx_attr.setImmediateMessageCallback(new LBMImmediateMessageCallback(rcv.onReceive), evq);
            }
            else
            {
                ctx_attr.setImmediateMessageCallback(new LBMImmediateMessageCallback(rcv.onReceive));
            }
            ctx_attr.setObjectRecycler(objRec, null);

            LBMContext ctx = new LBMContext(ctx_attr);

            if (ctx.getAttributeValue("request_tcp_bind_request_port") != "0")
            {
                string request_tcp_iface = ctx.getAttributeValue("request_tcp_interface");
                // Check if a different interface was specified for request_tcp_interface
                if (!request_tcp_iface.Equals("0.0.0.0"))
                {
                    System.Console.Out.WriteLine("Immediate messaging target: TCP:"
                                                 + request_tcp_iface + ":"
                                                 + ctx.getAttributeValue("request_tcp_port"));
                }
                else
                {
                    System.Console.Out.WriteLine("Immediate messaging target: TCP:"
                                                 + ctx.getAttributeValue("resolver_multicast_interface") + ":"
                                                 + ctx.getAttributeValue("request_tcp_port"));
                }
            }
            else
            {
                System.Console.Out.WriteLine("Request port binding disabled, no immediate messaging target");
            }

            LBMReceiverAttributes rattr = new LBMReceiverAttributes();

            if (num_srcs != null)
            {
                rattr.setValue("resolution_number_of_sources_query_threshold", num_srcs);
            }
            rattr.setObjectRecycler(objRec, null);
            LBMTopic    topic = ctx.lookupTopic(args[i], rattr);
            LBMReceiver lbmrcv;

            if (use_hf)
            {
                System.Console.Error.Write("Hot-Failover, ");
            }
            if (eventq)
            {
                if (use_hf)
                {
                    lbmrcv = new LBMHotFailoverReceiver(ctx, topic, rcv.onReceive, null, evq);
                }
                else
                {
                    lbmrcv = new LBMReceiver(ctx, topic, rcv.onReceive, null, evq);
                }
            }
            else
            {
                System.Console.Error.WriteLine("No event queue");
                if (use_hf)
                {
                    lbmrcv = new LBMHotFailoverReceiver(ctx, topic, rcv.onReceive, null);
                }
                else
                {
                    lbmrcv = new LBMReceiver(ctx, topic, rcv.onReceive, null);
                }
            }
            System.Console.Out.Flush();

            if (channels.Count > 0)
            {
                System.Console.Error.Write("Subscribing to channels: ");
                foreach (uint channel in channels)
                {
                    try
                    {
                        lbmrcv.subscribeChannel(channel, rcv.onReceive, null);
                        System.Console.Error.Write("{0} ", channel);
                    }
                    catch (Exception e)
                    {
                        System.Console.Error.WriteLine();
                        System.Console.Error.WriteLine(e.Message);
                    }
                }
                System.Console.Error.WriteLine();
            }

            LBMMonitorSource lbmmonsrc = null;

            if (monitor_context || monitor_receiver)
            {
                lbmmonsrc = new LBMMonitorSource(mon_format, mon_format_options, mon_transport, mon_transport_options);
                if (monitor_context)
                {
                    lbmmonsrc.start(ctx, application_id, monitor_context_ivl);
                }
                else
                {
                    lbmmonsrc.start(lbmrcv, application_id, monitor_receiver_ivl);
                }
            }
            long start_time;
            long end_time;
            long last_lost = 0, lost_tmp = 0, lost = 0;
            bool have_stats             = false;
            LBMReceiverStatistics stats = null;
            long stat_time              = System.DateTime.Now.AddSeconds(stat_secs).Ticks;

            for (; ;)
            {
                start_time = System.DateTime.Now.Ticks;
                if (eventq)
                {
                    evq.run(1000);
                }
                else
                {
                    System.Threading.Thread.Sleep(1000);
                }

                have_stats = false;
                while (!have_stats)
                {
                    try
                    {
                        stats      = lbmrcv.getStatistics(nstats);
                        have_stats = true;
                    }
                    catch (LBMException ex)
                    {
                        /* Double the number of stats passed to the API to be retrieved */
                        /* Do so until we retrieve stats successfully or hit the max limit */
                        nstats *= 2;
                        if (nstats > DEFAULT_MAX_NUM_SRCS)
                        {
                            System.Console.Error.WriteLine("Error getting receiver statistics: " + ex.Message);
                            System.Environment.Exit(1);
                        }
                        /* have_stats is still false */
                    }
                }

                /* If we get here, we have the stats */
                lost = 0;
                for (i = 0; i < stats.size(); i++)
                {
                    lost += stats.lost(i);
                }
                /* Account for loss in previous iteration */
                lost_tmp = lost;
                if (last_lost <= lost)
                {
                    lost -= last_lost;
                }
                else
                {
                    lost = 0;
                }
                last_lost = lost_tmp;

                end_time = System.DateTime.Now.Ticks;
                print_bw((end_time - start_time) / 10000,
                         rcv.msg_count,
                         rcv.byte_count,
                         rcv.unrec_count,
                         lost,
                         rcv.burst_loss,
                         rcv.rx_msgs,
                         rcv.otr_msgs);

                if (stat_secs > 0 && stat_time <= end_time)
                {
                    stat_time = System.DateTime.Now.AddSeconds(stat_secs).Ticks;
                    print_stats(stats, evq);
                }
                // recycle stats object when finished so it can be reused by LBM
                objRec.doneWithReceiverStatistics(stats);

                rcv.msg_count   = 0;
                rcv.byte_count  = 0;
                rcv.unrec_count = 0;
                rcv.burst_loss  = 0;
                rcv.rx_msgs     = 0;
                rcv.otr_msgs    = 0;

                if (reap_msgs != 0 && rcv.total_msg_count >= reap_msgs)
                {
                    break;
                }
            }
            System.Console.Error.WriteLine("Quitting.... received "
                                           + rcv.total_msg_count
                                           + " messages");

            if (channels.Count > 0)
            {
                /* Unsubscribe from channels */
                foreach (uint channel in channels)
                {
                    lbmrcv.unsubscribeChannel(channel);
                }
            }

            objRec.close();
            lbmrcv.close();
            ctx.close();
            if (eventq)
            {
                evq.close();
            }
        }
コード例 #26
0
ファイル: umercv.cs プロジェクト: UltraMessaging/currdoc
        static void Main(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));

            LBMObjectRecycler objRec = new LBMObjectRecycler();

            string qdelay   = null;
            string qsize    = null;
            string num_srcs = null;
            int    i;
            int    n = args.Length;

            bool monitor_context     = false;
            int  monitor_context_ivl = 0;

            bool         monitor_receiver      = false;
            int          monitor_receiver_ivl  = 0;
            string       application_id        = null;
            int          mon_format            = LBMMonitor.FORMAT_CSV;
            int          mon_transport         = LBMMonitor.TRANSPORT_LBM;
            string       mon_format_options    = null;
            string       mon_transport_options = null;
            bool         error                         = false;
            bool         done                          = false;
            string       regid_offset                  = "1000";
            int          seqnum_offset                 = 0;
            bool         sqn_info                      = false;
            const string OPTION_MONITOR_CTX            = "--monitor-ctx";
            const string OPTION_MONITOR_RCV            = "--monitor-rcv";
            const string OPTION_MONITOR_TRANSPORT      = "--monitor-transport";
            const string OPTION_MONITOR_TRANSPORT_OPTS = "--monitor-transport-opts";
            const string OPTION_MONITOR_FORMAT         = "--monitor-format";
            const string OPTION_MONITOR_FORMAT_OPTS    = "--monitor-format-opts";
            const string OPTION_MONITOR_APPID          = "--monitor-appid";

            for (i = 0; i < n; i++)
            {
                try
                {
                    switch (args[i])
                    {
                    case OPTION_MONITOR_APPID:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        application_id = args[i];
                        break;

                    case OPTION_MONITOR_CTX:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_context     = true;
                        monitor_context_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_RCV:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        monitor_receiver     = true;
                        monitor_receiver_ivl = Convert.ToInt32(args[i]);
                        break;

                    case OPTION_MONITOR_FORMAT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("csv") == 0)
                        {
                            mon_format = LBMMonitor.FORMAT_CSV;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        if (args[i].ToLower().CompareTo("lbm") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBM;
                        }
                        else if (args[i].ToLower().CompareTo("udp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_UDP;
                        }
                        else if (args[i].ToLower().CompareTo("lbmsnmp") == 0)
                        {
                            mon_transport = LBMMonitor.TRANSPORT_LBMSNMP;
                        }
                        else
                        {
                            error = true;
                            break;
                        }
                        break;

                    case OPTION_MONITOR_TRANSPORT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_transport_options += args[i];
                        break;

                    case OPTION_MONITOR_FORMAT_OPTS:
                        if (++i >= n)
                        {
                            error = true;
                            break;
                        }
                        mon_format_options += args[i];
                        break;

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

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

                    case "-E":
                        end_on_eos = true;
                        break;

                    case "-D":
                        dereg = 1;
                        break;

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

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

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

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

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

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

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

                    case "-S":
                        end_on_eos = true;
                        summary    = true;
                        break;

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

                    case "-v":
                        verbose = true;
                        break;

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

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

            cattr.setObjectRecycler(objRec, null);
            LBMContext            ctx   = new LBMContext(cattr);
            LBMReceiverAttributes rattr = null;
            UMERegistrationId     umeregid;

            rattr = new LBMReceiverAttributes();
            rattr.setObjectRecycler(objRec, null);
            if (num_srcs != null)
            {
                rattr.setValue("resolution_number_of_sources_query_threshold", num_srcs);
            }
            if (regid_offset != null)
            {
                umeregid = new UMERegistrationId(regid_offset);
                rattr.setRegistrationIdCallback(new UMERegistrationIdExCallback(umeregid.setRegistrationId), null);
                System.Console.Out.WriteLine("Will use RegID offset " + regid_offset + ".");
            }
            else
            {
                System.Console.Out.WriteLine("Will not use specific RegID.");
            }

            if (sqn_info)
            {
                UMERcvRecInfo umerecinfocb = new UMERcvRecInfo(seqnum_offset);
                rattr.setRecoverySequenceNumberCallback(umerecinfocb.setRecoverySequenceNumberInfo, null);
                System.Console.Out.WriteLine("Will use seqnum info with low offset " + seqnum_offset + ".");
            }

            if (exack > 0)
            {
                try
                {
                    rattr.setValue("ume_explicit_ack_only", "1");
                }
                catch (LBMException e)
                {
                    System.Console.Error.WriteLine("Error setting ume_explicit_ack_only=" + exack + e.Message);
                    System.Environment.Exit(1);
                }
            }

            LBMTopic         topic = ctx.lookupTopic(args[i], rattr);
            UMERcvReceiver   rcv   = new UMERcvReceiver(verbose, end_on_eos, summary, exack, dereg);
            LBMReceiver      lbmrcv;
            UMERcvEventQueue evq = null;

            if (eventq)
            {
                System.Console.Error.WriteLine("Event queue in use");
                LBMEventQueueAttributes evqattr = null;
                if (qsize != null || qdelay != null)
                {
                    evqattr = new LBMEventQueueAttributes();
                    if (qdelay != null)
                    {
                        evqattr.setValue("queue_delay_warning", qdelay);
                    }
                    if (qsize != null)
                    {
                        evqattr.setValue("queue_size_warning", qsize);
                    }
                }
                evq    = new UMERcvEventQueue(evqattr);
                lbmrcv = new LBMReceiver(ctx, topic, rcv.onReceive, null, evq);
                ctx.enableImmediateMessageReceiver(evq);
            }
            else
            {
                System.Console.Error.WriteLine("No event queue");
                lbmrcv = new LBMReceiver(ctx, topic, rcv.onReceive, null);
                ctx.enableImmediateMessageReceiver();
            }

            rcv.setRcvr(lbmrcv);

            // This immediate-mode receiver is *only* used for topicless
            // immediate-mode sends.  Immediate sends that use a topic
            // are received with normal receiver objects.
            ctx.addImmediateMessageReceiver(new LBMImmediateMessageCallback(rcv.onReceive));

            LBMMonitorSource lbmmonsrc = null;

            if (monitor_context || monitor_receiver)
            {
                lbmmonsrc = new LBMMonitorSource(mon_format, mon_format_options, mon_transport, mon_transport_options);
                if (monitor_context)
                {
                    lbmmonsrc.start(ctx, application_id, monitor_context_ivl);
                }
                else
                {
                    lbmmonsrc.start(lbmrcv, application_id, monitor_receiver_ivl);
                }
            }
            System.Console.Out.Flush();
            long start_time;
            long end_time;
            long last_lost = 0, lost_tmp = 0, lost = 0;
            bool have_stats;
            LBMReceiverStatistics stats = null;
            long stat_time = System.DateTime.Now.AddSeconds(stat_secs).Ticks;

            for (; ;)
            {
                start_time = System.DateTime.Now.Ticks;
                if (eventq)
                {
                    evq.run(1000);
                }
                else
                {
                    System.Threading.Thread.Sleep(1000);
                }

                have_stats = false;
                while (!have_stats)
                {
                    try
                    {
                        stats      = lbmrcv.getStatistics(nstats);
                        have_stats = true;
                    }
                    catch (LBMException ex)
                    {
                        /* Double the number of stats passed to the API to be retrieved */
                        /* Do so until we retrieve stats successfully or hit the max limit */
                        nstats *= 2;
                        if (nstats > DEFAULT_MAX_NUM_SRCS)
                        {
                            System.Console.Error.WriteLine("Error getting receiver statistics: " + ex.Message);
                            System.Environment.Exit(1);
                        }
                        /* have_stats is still false */
                    }
                }

                /* If we get here, we have the stats */
                lost = 0;
                for (i = 0; i < stats.size(); i++)
                {
                    lost += stats.lost(i);
                }

                /* Account for loss in previous iteration */
                lost_tmp = lost;
                if (last_lost <= lost)
                {
                    lost -= last_lost;
                }
                else
                {
                    lost = 0;
                }
                last_lost = lost_tmp;

                end_time = System.DateTime.Now.Ticks;

                print_bw((end_time - start_time) / 10000,
                         rcv.msg_count,
                         rcv.byte_count,
                         rcv.unrec_count,
                         lost,
                         rcv.burst_loss,
                         rcv.rx_msgs,
                         rcv.otr_msgs);

                if (stat_secs > 0 && stat_time <= end_time)
                {
                    stat_time = System.DateTime.Now.AddSeconds(stat_secs).Ticks;
                    print_stats(stats, evq);
                }

                objRec.doneWithReceiverStatistics(stats);

                rcv.msg_count   = 0;
                rcv.byte_count  = 0;
                rcv.unrec_count = 0;
                rcv.burst_loss  = 0;
                rcv.rx_msgs     = 0;
                rcv.otr_msgs    = 0;

                if (reap_msgs != 0 && rcv.total_msg_count >= reap_msgs)
                {
                    break;
                }
            }

            System.Console.Error.WriteLine("Quitting.... received "
                                           + rcv.total_msg_count
                                           + " messages");
            objRec.close();
            lbmrcv.close();
            ctx.close();
            if (eventq)
            {
                evq.close();
            }
            GC.KeepAlive(lbm);
        }
コード例 #27
0
ファイル: CleanShutdown.cs プロジェクト: debhack/UMExamples
    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();
    }
コード例 #28
0
ファイル: umercv.cs プロジェクト: UltraMessaging/currdoc
 public void setRcvr(LBMReceiver rcvr)
 {
     _lbmrcvr = rcvr;
 }
コード例 #29
0
ファイル: TmonExample.cs プロジェクト: UltraMessaging/tmon
        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