Beispiel #1
0
        public static void  Main(string[] args)
        {
            LBM lbm = new LBM();

            lbm.setLogger(new LBMLogging(logger));
            LBMObjectRecyclerBase objRec = new LBMObjectRecycler();

            int          transport                     = LBMMonitor.TRANSPORT_LBM;
            int          format                        = LBMMonitor.FORMAT_CSV;
            string       transport_options             = "";
            string       format_options                = "";
            const string OPTION_MONITOR_TRANSPORT      = "--transport";
            const string OPTION_MONITOR_TRANSPORT_OPTS = "--transport-opts";
            const string OPTION_MONITOR_FORMAT         = "--format";
            const string OPTION_MONITOR_FORMAT_OPTS    = "--format-opts";
            int          n = args.Length;
            int          i;
            bool         error = false;

            for (i = 0; i < n; i++)
            {
                switch (args[i])
                {
                case "-h":
                    print_help_exit(0);
                    break;

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

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

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

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

                default:
                    error = true;
                    break;
                }
                if (error)
                {
                    break;
                }
            }

            if (error)
            {
                /* An error occurred processing the command line - print help and exit */
                print_help_exit(1);
            }

            LBMMonitorReceiver lbmmonrcv = new LBMMonitorReceiver(format, format_options, transport, transport_options, objRec, null);
            //If not using object recycling
            //LBMMonitorReceiver lbmmonrcv = new LBMMonitorReceiver(format, format_options, transport, transport_options);
            LBMMonCallbacks lbmmoncbs = new LBMMonCallbacks(lbmmonrcv, objRec);
            LBMMonitorSourceStatisticsCallback scb;

            scb = new LBMMonitorSourceStatisticsCallback(lbmmoncbs.onReceive);
            LBMMonitorReceiverStatisticsCallback rcb;

            rcb = new LBMMonitorReceiverStatisticsCallback(lbmmoncbs.onReceive);
            LBMMonitorEventQueueStatisticsCallback evqcb;

            evqcb = new LBMMonitorEventQueueStatisticsCallback(lbmmoncbs.onReceive);
            LBMMonitorContextStatisticsCallback ctxcb;

            ctxcb = new LBMMonitorContextStatisticsCallback(lbmmoncbs.onReceive);
            LBMMonitorImmediateMessageReceiverStatisticsCallback imrcvcb;

            imrcvcb = new LBMMonitorImmediateMessageReceiverStatisticsCallback(lbmmoncbs.onReceive);
            LBMMonitorImmediateMessageSourceStatisticsCallback imsrccb;

            imsrccb = new LBMMonitorImmediateMessageSourceStatisticsCallback(lbmmoncbs.onReceive);

            lbmmonrcv.addStatisticsCallback(scb, rcb, evqcb, ctxcb);
            lbmmonrcv.addStatisticsCallback(imsrccb);
            lbmmonrcv.addStatisticsCallback(imrcvcb);
            for (; ;)
            {
                System.Threading.Thread.Sleep(2000);
            }
        }
Beispiel #2
0
 internal LBMMonCallbacks(LBMMonitorReceiver lbmmonrcv, LBMObjectRecyclerBase recycler)
 {
     _lbmmonrcv = lbmmonrcv;
     _recycler  = recycler;
 }