public void InvalidLogLevel() { // Invalid log level MamaLogLevel logLevel = (MamaLogLevel)19; Mama.logToFile(Path.GetTempPath(), logLevel); }
public void InvalidArguments() { // Create an invalid log level MamaLogLevel logLevel = (MamaLogLevel)19; // Attempt to enable logging Mama.setLogLevel(logLevel); }
public void InvalidLogLevel() { // Create an invalid log level MamaLogLevel logLevel = (MamaLogLevel)19; // Log with an invalid level Mama.log(logLevel, "This is a test"); }
/// <summary> /// Enable logging. /// </summary> /// <param name="level"> /// The logging level allowed. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// The file name contains invalid characters. /// </exception> public static void enableLogging(MamaLogLevel level) { // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } MamaWrapper.CheckResultCode(NativeMethods.mama_enableLogging(IntPtr.Zero, (int)level)); }
public void onLog(MamaLogLevel level, string message) { /* Format the log as a string, do this separately so we can * see the string in the debugger. */ m_buffer = message; /* Write it out. */ Console.WriteLine(m_buffer); }
/// <summary> /// Constructor initialises all member variables including setting the defaults for the various /// options that can be provided on the command line. /// </summary> private MamaListen() { // Initialise member variables m_dictionarySourceName = "WOMBAT"; m_downloadDictionary = true; m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_WARN; m_middlewareName = "wmw"; m_recapThrottleRate = -1; m_sourceName = "Wombat"; m_subscriptions = new ArrayList(); m_symbols = new ArrayList(); m_throttleRate = -1; }
public void onLog(MamaLogLevel level, string message) { /* Format the log as a string, do this separately so we can * see the string in the debugger. */ m_buffer = message; /* Write it out. */ Console.WriteLine(m_buffer); // Call the default function if the message isn't blank if (!string.IsNullOrEmpty(message)) { Mama.defaultLogFunction(level, message); } }
/// <summary> /// This function will invoke the default log function. /// </summary> /// <param name="level"> /// The level to log at. /// </param> /// <param name="text"> /// The log message. /// </param> /// <exception cref="ArgumentNullException"> /// The logging text has not been supplied. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The logging level is invalid. /// </exception> public static void defaultLogFunction(MamaLogLevel level, string text) { // Check the arguments if ((text == null) || (text == string.Empty)) { throw new ArgumentNullException("text"); } // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } // Call the native method NativeMethods.mama_logDefault2((int)level, text); }
/// <summary> /// Add string to mama log at specified mama level. /// </summary> /// <param name="level"> /// The level to log at. /// </param> /// <param name="text"> /// The log message. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// The logging level is invalid. /// </exception> public static void log(MamaLogLevel level, string text) { // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } // If null has been passed for the text then use a blank string if (text == null) { NativeMethods.mama_log2((int)level, string.Empty); } else { NativeMethods.mama_log2((int)level, text); } }
/* ****************************************************** */ #region Private Operations /// <summary> /// This function will enumerate all the available log levels and write an entry /// at that level. /// If the supplied target log level is lower or equal to the level at which the /// log has been written then a message should be sent to the log callback function. /// This function will verify that messages are sent at the correct times. /// </summary> /// <param name="targetLevel"> /// The target log level. /// </param> /// <exception cref="InvalidOperationException"> /// Thrown if a log is written or not written at the wrong time. /// </exception> private void CheckLogStatement(MamaLogLevel targetLevel) { // The test log statement string testLog = "This is a test"; // Enumerate all the log levels foreach (MamaLogLevel level in Enum.GetValues(typeof(MamaLogLevel))) { // Ignore Off if (level == MamaLogLevel.MAMA_LOG_LEVEL_OFF) { continue; } // Clear the log buffer m_callback.Buffer = null; // Write a log at this level Mama.log(level, testLog); // Verify that the log has been written if (level <= targetLevel) { // If the log statement isn't correct then throw an exception if (string.Compare(testLog, m_callback.Buffer, false) != 0) { throw new InvalidOperationException("Log entry text has become corrupt."); } } /* If the target level is lower than the level that the log has been written * then the log should be null. */ else { if (m_callback.Buffer != null) { throw new InvalidOperationException("A log should not be written at this level."); } } } }
/// <summary> /// Enable logging, accepts a string representing the file location. /// </summary> /// <param name="fileName"> /// The full path to the log file. /// </param> /// <param name="level"> /// The logging level allowed. /// </param> /// <exception cref="ArgumentNullException"> /// The file name is null or blank. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// The file name contains invalid characters. /// </exception> public static void logToFile(string fileName, MamaLogLevel level) { // Check the arguments if ((fileName == null) || (fileName == string.Empty)) { throw new ArgumentNullException("fileName"); } // Check for invalid characters in the file name if (fileName.IndexOfAny(Path.GetInvalidPathChars()) != -1) { throw new ArgumentOutOfRangeException(fileName, "The file or path contains invalid characters"); } // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } // Call the native function MamaWrapper.CheckResultCode(NativeMethods.mama_logToFile(fileName, (int)level)); }
//////////////////////////////////////////////////////////////////////////////////////////////// private bool parseCommandLine(string[] args) { if ((args == null) || (args.Length == 0)) { Console.WriteLine("Running with default: -S NASDAQ -s MSFT -m wmw -tport rv1"); mamaSymbols[mamaNumSymbols] = "MSFT"; mamaNumSymbols++; return true; } for (int i = 0; i < args.Length; i++) { if (args[i].CompareTo("-S") == 0) { if ((i + 1) < args.Length) { mamaSourceName = args[++i]; continue; } } if (args[i].CompareTo("-d") == 0) { if ((i + 1) < args.Length) { mamaDictionarySourceName = args[++i]; continue; } } if (args[i].CompareTo("-s") == 0) { if ((i + 1) < args.Length) { mamaSymbols[mamaNumSymbols] = args[++i]; mamaNumSymbols++; if (mamaNumSymbols == 4999) { Console.WriteLine("Using max of 5000 symbols"); break; } continue; } } if (args[i].CompareTo("-m") == 0) { if ((i + 1) < args.Length) { mamaMiddlewareName = args[++i]; continue; } } if (args[i].CompareTo("-tport") == 0) { if ((i + 1) < args.Length) { mamaTransportName = args[++i]; continue; } } if ((args[i].CompareTo("-t") == 0) || (args[i].CompareTo("-timeout") == 0)) { if ((i + 1) < args.Length) { m_churnTimeout = double.Parse(args[++i]); continue; } } if ((args[i].CompareTo("-k") == 0) || (args[i].CompareTo("-kill") == 0)) { if ((i + 1) < args.Length) { m_killTimeout = double.Parse(args[++i]); continue; } } if (args[i].CompareTo("--help") == 0) { foreach (string usageLine in m_usage) { Console.WriteLine(usageLine); } return false; } if (args[i].CompareTo("-?") == 0) { foreach (string usageLine in m_usage) { Console.WriteLine(usageLine); } return false; } if (args[i].CompareTo("-f") == 0) { if ((i + 1) < args.Length) { string fileName = args[++i]; TextReader tr = new StreamReader(fileName); string symbol = null; while ((symbol = tr.ReadLine()) != null) { symbol = symbol.Trim(); if (symbol.Length != 0) { mamaSymbols[mamaNumSymbols] = symbol; mamaNumSymbols++; } } continue; } } if (args[i].CompareTo("-r") == 0) { if ((i + 1) < args.Length) { mamaThrottle = Convert.ToInt64(args[++i]); continue; } } if (args[i].CompareTo("-rr") == 0) { if ((i + 1) < args.Length) { mamaRecapThrottle = Convert.ToInt64(args[++i]); continue; } } if (args[i].CompareTo("-mp") == 0) { if ((i + 1) < args.Length) { mamaMapFilename = args[++i]; continue; } } if (args[i].CompareTo("-threads") == 0) { if ((i + 1) < args.Length) { mamaThreads = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-hw") == 0) { if ((i + 1) < args.Length) { mamaHighWaterMark = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-lw") == 0) { if ((i + 1) < args.Length) { mamaLowWaterMark = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-c") == 0) { if ((i + 1) < args.Length) { quota = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging(mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging(mamaLogLevel); } continue; } if (args[i].CompareTo("-q") == 0) { mamaQuietness++; continue; } if (args[i].CompareTo("-log_file") == 0) { if ((i + 1) < args.Length) { Mama.logToFile(args[++i], MamaLogLevel.MAMA_LOG_LEVEL_FINEST); continue; } } } if (mamaNumSymbols == 0) { mamaSymbols[mamaNumSymbols] = "MSFT"; mamaNumSymbols++; } return true; }
private bool parseCommandLine(string[] args) { for (int i = 0; i < args.Length; i++) { if (args[i].CompareTo("-s") == 0) { if ((i + 1) < args.Length) { topicName = args[++i]; continue; } } if (args[i].CompareTo("-m") == 0) { if ((i + 1) < args.Length) { middlewareNames.Add(args[++i]); continue; } } if (args[i].CompareTo("-tport") == 0) { if ((i + 1) < args.Length) { transportName = args[++i]; continue; } } if (args[i].CompareTo("--help") == 0) { Console.WriteLine(usage); return(false); } if (args[i].CompareTo("-?") == 0) { Console.WriteLine(usage); return(false); } if (args[i].CompareTo("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging(mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging(mamaLogLevel); } continue; } Console.WriteLine("Error: unrecognized parameter: " + args[i]); return(false); } return(true); }
public static void Main(string[] args) { MamaTransport baseTransport = null; MamaTransport optionTransport = null; MamaTransport dictTransport = null; string dictTransportName = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); if (options.hasLogLevel()) { logLevel_ = options.getLogLevel(); Mama.enableLogging(logLevel_); } try { // Initialize MAMA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); // Initialize transports. We're assuming that options and // underlyings might be on different transports. Note: // some companies might use multiple transports for // underlyings (e.g., CTA and NASDAQ), which case it would // be necessary to create three transports here and be // sure to pass the correct transport later. baseTransport = new MamaTransport(); baseTransport.create(options.getTransport(), myBridge); optionTransport = baseTransport; defaultQueue = Mama.getDefaultEventQueue(myBridge); // Fetch and initialize the data dictionary MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictTransportName = options.getDictTransport(); if (null != dictTransportName) { dictTransport = new MamaTransport(); dictTransport.create(dictTransportName, myBridge); } else { dictTransport = baseTransport; } dictionarySource.transport = dictTransport; dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); MamdaFundamentalFields.setDictionary(dictionary, null); MamdaOptionFields.setDictionary(dictionary, null); // Create listeners for each chain. Two subscriptions are // necessary. foreach (string symbol in options.getSymbolList()) { // Create chain and listener objects. MamdaTradeListener aBaseTradeListener = new MamdaTradeListener(); MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener(); MamdaOptionChain anOptionChain = new MamdaOptionChain(symbol); anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener); anOptionChain.setUnderlyingTradeListener(aBaseTradeListener); MamdaOptionChainListener anOptionListener = new MamdaOptionChainListener(anOptionChain); // Create our handlers (the UnderlyingTicker and // OptionChainDisplay could be a single class). UnderlyingTicker aBaseTicker = new UnderlyingTicker(anOptionChain, true); OptionChainDisplay aDisplay = new OptionChainDisplay(anOptionChain); // Create subscriptions for underlying and option chain: MamdaSubscription aBaseSubscription = new MamdaSubscription(); MamdaSubscription anOptionSubscription = new MamdaSubscription(); // Register for underlying quote and trade events. aBaseTradeListener.addHandler(aBaseTicker); aBaseQuoteListener.addHandler(aBaseTicker); aBaseSubscription.addMsgListener(aBaseTradeListener); aBaseSubscription.addMsgListener(aBaseQuoteListener); aBaseSubscription.create( baseTransport, defaultQueue, options.getSource(), symbol, null); mamdaSubscriptions.Add(aBaseSubscription); // Register for underlying option events. anOptionListener.addHandler(aDisplay); // We set the timeout to 1 for this example because we // currently use the timeout feature to determine when // to say that we have received all of the initials. // There will be a separate time interval for this in // the future. anOptionSubscription.setTimeout(1); anOptionSubscription.addMsgListener(anOptionListener); anOptionSubscription.addStaleListener(aDisplay); anOptionSubscription.addErrorListener(aDisplay); anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP); anOptionSubscription.create( optionTransport, defaultQueue, options.getSource(), symbol, null); optionSubscriptions.Add(anOptionSubscription); } //Start dispatching on the default event queue Mama.start(myBridge); GC.KeepAlive(dictionary); Console.WriteLine("Press ENTER or Ctrl-C to quit..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
private bool parseCommandLine(string[] args) { for (int i = 0; i < args.Length;i++) { if (args[i].CompareTo("-s") == 0) { if ((i +1) < args.Length) { topicName = args[++i]; continue; } } if (args[i].CompareTo("-m") == 0) { if ((i +1) < args.Length) { middlewareNames.Add (args[++i]); continue; } } if (args[i].CompareTo("-tport") == 0) { if ((i +1) < args.Length) { transportName = args[++i]; continue; } } if (args[i].CompareTo("--help") == 0) { Console.WriteLine(usage); return false; } if (args[i].CompareTo("-?") == 0) { Console.WriteLine(usage); return false; } if (args[i].CompareTo ("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging (mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging (mamaLogLevel); } continue; } Console.WriteLine("Error: unrecognized parameter: " + args[i]); return false; } return true; }
static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor (args); myQuietModeLevel = options.getQuietModeLevel (); if (options.hasLogLevel ()) { myLogLevel = options.getLogLevel (); Mama.enableLogging (myLogLevel); } try { //Initialize MAMA API myBridge = new MamaBridge (options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); myMamaSource = new MamaSource (); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource (); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary (dictionary, null); MamdaTradeFields.setDictionary (dictionary, null); MamdaCommonFields.setDictionary (dictionary, null); MamdaOrderBookFields.setDictionary (dictionary, null); myQueueGroup = new MamaQueueGroup (myBridge, options.getNumThreads()); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription (); MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener(); AtomicBookTicker aTicker = new AtomicBookTicker (); aBookListener.addBookHandler (aTicker); aBookListener.addLevelHandler (aTicker); if (options.getPrintEntries()) { // Entries aBookListener.addLevelEntryHandler (aTicker); } aSubscription.addMsgListener (aBookListener); aSubscription.addStaleListener (aTicker); aSubscription.addErrorListener (aTicker); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK); aSubscription.create (transport, myQueueGroup.getNextQueue(), options.getSource (), symbol, null); mamdaSubscriptions.Add(aSubscription); } //Start dispatching on the default MAMA event queue Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start (myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { try { options = new CommandLineProcessor(args); //Getting the log File name myLogFileName = options.getLogFileName(); if (myLogFileName != null) { myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate); myOut = new StreamWriter(myOutFile); myOut.WriteLine("Date/Time"+ "," + "ChurnStats" +"," + "UpdateStats" + "," + "PeakMsgCount" + "," + "RecapStats" + "," + "BookGapStats" + "," +"freeMemory" +"," +"Memory Used"); } else { myOut = Console.Out; } // Initialize MAMA bridge = new MamaBridge(options.getMiddleware()); Mama.open(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } transport = new MamaTransport(); transport.create(options.getTransport(), bridge); defaultQueue = Mama.getDefaultEventQueue(bridge); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { subscribeToBooks(symbol); } myChurnRate = options.getChurnRate(); Thread.Sleep(10000); //Getting the TimerInterval from the cmd prompt myChurnInterval = options.getTimerInterval(); //Churn Timer if (myChurnRate > 0) { myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval); } //Stats Timer myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0); Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(bridge); GC.KeepAlive(dictionary); Console.ReadLine(); if (myOutFile != null) { myOut.Close(); } } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }
//////////////////////////////////////////////////////////////////////////////////////////////// private bool parseCommandLine(string[] args) { if ((args == null) || (args.Length == 0)) { Console.WriteLine("Running with default: -S NASDAQ -s MSFT -m wmw -tport rv1"); mamaSymbols[mamaNumSymbols] = "MSFT"; mamaNumSymbols++; return(true); } for (int i = 0; i < args.Length; i++) { if (args[i].CompareTo("-S") == 0) { if ((i + 1) < args.Length) { mamaSourceName = args[++i]; continue; } } if (args[i].CompareTo("-d") == 0) { if ((i + 1) < args.Length) { mamaDictionarySourceName = args[++i]; continue; } } if (args[i].CompareTo("-s") == 0) { if ((i + 1) < args.Length) { mamaSymbols[mamaNumSymbols] = args[++i]; mamaNumSymbols++; if (mamaNumSymbols == 4999) { Console.WriteLine("Using max of 5000 symbols"); break; } continue; } } if (args[i].CompareTo("-m") == 0) { if ((i + 1) < args.Length) { mamaMiddlewareName = args[++i]; continue; } } if (args[i].CompareTo("-tport") == 0) { if ((i + 1) < args.Length) { mamaTransportName = args[++i]; continue; } } if ((args[i].CompareTo("-t") == 0) || (args[i].CompareTo("-timeout") == 0)) { if ((i + 1) < args.Length) { m_churnTimeout = double.Parse(args[++i]); continue; } } if ((args[i].CompareTo("-k") == 0) || (args[i].CompareTo("-kill") == 0)) { if ((i + 1) < args.Length) { m_killTimeout = double.Parse(args[++i]); continue; } } if (args[i].CompareTo("--help") == 0) { foreach (string usageLine in m_usage) { Console.WriteLine(usageLine); } return(false); } if (args[i].CompareTo("-?") == 0) { foreach (string usageLine in m_usage) { Console.WriteLine(usageLine); } return(false); } if (args[i].CompareTo("-f") == 0) { if ((i + 1) < args.Length) { string fileName = args[++i]; TextReader tr = new StreamReader(fileName); string symbol = null; while ((symbol = tr.ReadLine()) != null) { symbol = symbol.Trim(); if (symbol.Length != 0) { mamaSymbols[mamaNumSymbols] = symbol; mamaNumSymbols++; } } continue; } } if (args[i].CompareTo("-r") == 0) { if ((i + 1) < args.Length) { mamaThrottle = Convert.ToInt64(args[++i]); continue; } } if (args[i].CompareTo("-rr") == 0) { if ((i + 1) < args.Length) { mamaRecapThrottle = Convert.ToInt64(args[++i]); continue; } } if (args[i].CompareTo("-mp") == 0) { if ((i + 1) < args.Length) { mamaMapFilename = args[++i]; continue; } } if (args[i].CompareTo("-threads") == 0) { if ((i + 1) < args.Length) { mamaThreads = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-hw") == 0) { if ((i + 1) < args.Length) { mamaHighWaterMark = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-lw") == 0) { if ((i + 1) < args.Length) { mamaLowWaterMark = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-c") == 0) { if ((i + 1) < args.Length) { quota = Convert.ToInt32(args[++i]); continue; } } if (args[i].CompareTo("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging(mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging(mamaLogLevel); } continue; } if (args[i].CompareTo("-q") == 0) { mamaQuietness++; continue; } if (args[i].CompareTo("-log_file") == 0) { if ((i + 1) < args.Length) { Mama.logToFile(args[++i], MamaLogLevel.MAMA_LOG_LEVEL_FINEST); continue; } } } if (mamaNumSymbols == 0) { mamaSymbols[mamaNumSymbols] = "MSFT"; mamaNumSymbols++; } return(true); }
/// <summary> /// This function will parse the command line and initialise the various member variables with /// the information passed in. /// </summary> /// <param name="args"> /// The array of command line arguments. /// </param> /// <returns> /// True to continue with the application or false to quit out. /// </returns> private bool parseCommandLine(string[] args) { bool ret = true; if ((args == null) || (args.Length == 0)) { throw new ApplicationException("No command line arguments supplied."); } // Iterate through all the arguments and check for possible values for (int index = 0; index < args.Length; index++) { // Create snapshot subscriptions if (args[index].CompareTo("-1") == 0) { m_snapshot = true; continue; } // Don't obtain the dictionary if (args[index].CompareTo("-B") == 0) { m_downloadDictionary = false; continue; } // The dictionary source name if (args[index].CompareTo("-d") == 0) { if ((index + 1) < args.Length) { m_dictionarySourceName = args[++index]; continue; } } // The dictionary transport if (args[index].CompareTo("-dict_tport") == 0) { if ((index + 1) < args.Length) { m_dictionaryTransportName = args[++index]; continue; } } // Symbol file path if (args[index].CompareTo("-f") == 0) { if ((index + 1) < args.Length) { string fileName = args[++index]; readSymbolsFromFile(fileName); continue; } } // Display the usage string if ((args[index].CompareTo("--help") == 0) || (args[index].CompareTo("-?") == 0)) { Console.WriteLine(usage); ret = false; break; } // The high watermark level for queue monitoring if (args[index].CompareTo("-hw") == 0) { if ((index + 1) < args.Length) { m_highWaterMark = Convert.ToInt32(args[++index]); continue; } } // Write out to a log file if (args[index].CompareTo("-log_file") == 0) { if ((index + 1) < args.Length) { m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.logToFile(args[++index], MamaLogLevel.MAMA_LOG_LEVEL_FINEST); continue; } } // The low watermark level for queue monitoring if (args[index].CompareTo("-lw") == 0) { if ((index + 1) < args.Length) { m_lowWaterMark = Convert.ToInt32(args[++index]); continue; } } // The middleware name if (args[index].CompareTo("-m") == 0) { if ((index + 1) < args.Length) { m_middlewareName = args[++index]; continue; } } // Use new iterator functionality if (args[index].CompareTo("-ni") == 0) { m_iterator = true; continue; } // The quietness level if (args[index].CompareTo("-q") == 0) { m_quietness++; continue; } // The throttle rate if (args[index].CompareTo("-r") == 0) { if ((index + 1) < args.Length) { m_throttleRate = Convert.ToInt64(args[++index]); continue; } } // Recap throttle rate if (args[index].CompareTo("-rr") == 0) { if ((index + 1) < args.Length) { m_recapThrottleRate = Convert.ToInt64(args[++index]); continue; } } // The source name if (args[index].CompareTo("-S") == 0) { if ((index + 1) < args.Length) { m_sourceName = args[++index]; continue; } } // The symbol name if (args[index].CompareTo("-s") == 0) { if ((index + 1) < args.Length) { m_symbols.Add(args[++index]); continue; } } // Length of time to run for if (args[index].CompareTo("-shutdown") == 0) { m_shutdownTime = double.Parse(args[++index]); continue; } // Number of threads to run if (args[index].CompareTo("-threads") == 0) { if ((index + 1) < args.Length) { m_numberThreads = Convert.ToInt32(args[++index]); continue; } } // The main transport if (args[index].CompareTo("-tport") == 0) { if ((index + 1) < args.Length) { m_transportName = args[++index]; continue; } } // The verbosity level if (args[index].CompareTo("-v") == 0) { switch (m_logLevel) { case MamaLogLevel.MAMA_LOG_LEVEL_WARN: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; break; case MamaLogLevel.MAMA_LOG_LEVEL_NORMAL: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINE: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINER: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; break; } continue; } } if (m_symbols.Count == 0) { throw new ApplicationException("No symbols were supplied"); } return ret; }
public CommandLineProcessor(string[] args) { for (int i = 0; i < args.Length; ) { string arg = args[i]; if ( arg == "-S") { mSource = args[i + 1]; i += 2; } else if (args[i].CompareTo("-dict_tport") == 0) { mDictTransport = args[i + 1]; i += 2; } else if ((args[i].CompareTo("-dict_source") == 0) || (args[i].CompareTo("-d") == 0)) { mDictSource = args[i + 1]; i += 2; } else if (arg == "-T" || arg == "-tport") { mTransport = args[i + 1]; i += 2; } else if (arg == "-m" || arg == "-middleware") { mMiddleware = args[i + 1]; i += 2; } else if (arg == "-precision") { mPrecision = Int32.Parse(args[i + 1]); i += 2; } else if (arg == "-s") { mSymbolList.Add(args[i + 1]); i += 2; } else if (arg == "-f") { mFileName = args[i + 1]; i += 2; } else if (arg == "-r" || arg == "-rate") { mThrottleRate = Double.Parse(args[i + 1]); i += 2; } else if (arg == "-v") { mLogLevel = mLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN ? MamaLogLevel.MAMA_LOG_LEVEL_NORMAL : mLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL ? MamaLogLevel.MAMA_LOG_LEVEL_FINE : mLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE ? MamaLogLevel.MAMA_LOG_LEVEL_FINER : MamaLogLevel.MAMA_LOG_LEVEL_FINEST; i++; mHasLogLevel = true; } else if (arg == "-q") { mQuietModeLevel++; i++; } else if (arg == "-b") { mCacheFullBooks = false; i++; } else if (arg == "-e") { mPrintEntries = true; i++; } else if (arg == "-W") { mUseWorldView = true; ++i; } else if (arg == "-L") { mLogReqResp= true; ++i; } else if (arg == "-Y") { mSymbology = args[i+1]; i += 2; } else if (arg == "-churn") { mChurnRate = Int32.Parse(args[i+1]); i += 2; } else if (arg == "-logfile") { mLogFileName = args[i+1]; i += 2; } else if (arg == "-timerInterval") { mTimerInterval = Double.Parse(args[i + 1]); i += 2; } else if (arg == "-1") { mSnapshot = true; ++i; } else if (arg == "-threads") { mNumThreads = Int32.Parse(args[i+1]); i += 2; } else { i++; } } if (mSymbolList.Count == 0) { readSymbolList(); } }
private static void parseCommandLine(string[] args) { for (int i = 0; i < args.Length;) { if (args[i] == "-source" || args[i] == "-S") { mySymbolNamespace = args[i + 1]; i += 2; } else if (args[i] == "-d" || args[i] == "-dict_source") { dictSource = args[i + 1]; i += 2; } else if (args[i] == "-dict_tport") { myDictTportName = args[i + 1]; i += 2; } else if (args[i] == "-tport") { transportName = args[i + 1]; i += 2; } else if (args[i] == "-threads") { numThreads = Convert.ToInt32(args[i + 1]); i += 2; } else if (args[i] == "-q") { quietness++; i++; } else if (args[i] == ("-v")) { switch (mamaLogLevel) { case MamaLogLevel.MAMA_LOG_LEVEL_WARN: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; break; case MamaLogLevel.MAMA_LOG_LEVEL_NORMAL: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINE: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINER: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; break; } i++; } else if (args[i] == ("-m")) { myMiddleware = args[i + 1]; i += 2; } } }
private void parseCommandLine(string[] args) { string tport = null; uint ft_type = (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST; bool displayVersion = false; for (int i = 0; i < args.Length;) { if ((args[i].CompareTo("-h")) == 0 || (args[i].CompareTo("-?")) == 0) { usage(0); } if ((args[i].CompareTo("-g") == 0) || (args[i].CompareTo("-group") == 0)) { myGroup = args[i + 1]; i += 2; continue; } if ((args[i].CompareTo("-w") == 0) || (args[i].CompareTo("-weight") == 0)) { myWeight = Convert.ToUInt32(args[i + 1]); i += 2; continue; } if (args[i].CompareTo("-m") == 0) { myMiddleware = args[i + 1]; i += 2; continue; } if ((args[i].CompareTo("-t") == 0) || (args[i].CompareTo("-tport") == 0)) { tport = args[i + 1]; i += 2; continue; } if (args[i].CompareTo("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging(mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging(mamaLogLevel); } i++; continue; } if (args[i].CompareTo("-version") == 0) { displayVersion = true; break; } if (args[i].CompareTo("-b") == 0) { ft_type = (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE; i++; continue; } i++; } myBridge = Mama.loadBridge(myMiddleware); Mama.open(); if (displayVersion) { Console.WriteLine(Mama.getVersion(myBridge)); Exit(0); } myTimer = new MamaTimer(); myTransport = new MamaTransport(); myTransport.create(tport, myBridge); if (myGroup == null) { Console.WriteLine("No FT group name specified"); usage(1); } switch (ft_type) { case (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST: myFtMember = new MamaMulticastFtMember(); break; case (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE: myFtMember = new MamaBridgeFtMember(); break; default: Console.WriteLine("No FT type specified"); usage(1); break; } }
static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor (args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } myCacheFullBooks = options.cacheFullBooks(); myPrintEntries = options.getPrintEntries(); mySnapshot = options.getSnapshot(); myPrecision = options.getPrecision(); try { //Initialize MAMA API myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); myMamaSource = new MamaSource (); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary (dictionary, null); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); MamdaOrderBookListener aBookListener; if (myCacheFullBooks) { aBookListener = new MamdaOrderBookListener(); } else { aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook()); } BookTicker aTicker = new BookTicker(); aBookListener.addHandler(aTicker); aSubscription.addMsgListener(aBookListener); aSubscription.addStaleListener(aTicker); aSubscription.addErrorListener(aTicker); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK); if (mySnapshot) { aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0); } aSubscription.create( transport, defaultQueue, options.getSource(), symbol, null); mamdaSubscriptions.Add(aSubscription); } //Start dispatching on the default MAMA event queue Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } try { // Initialize MAMDA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); /*Get the data dictionary*/ MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); MamdaSecurityStatusFields.setDictionary(dictionary, null); mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count]; int i=0; foreach (string symbol in options.getSymbolList()) { mamdaSubscriptions[i] = new MamdaSubscription(); MamdaTradeListener aTradeListener = new MamdaTradeListener(); MamdaQuoteListener aQuoteListener = new MamdaQuoteListener(); MamdaSecurityStatusListener aSecurityStatusListener = new MamdaSecurityStatusListener(); ComboTicker aTicker = new ComboTicker(); aTradeListener.addHandler(aTicker); aQuoteListener.addHandler(aTicker); aSecurityStatusListener.addHandler(aTicker); mamdaSubscriptions[i].addMsgListener(aTradeListener); mamdaSubscriptions[i].addMsgListener(aQuoteListener); mamdaSubscriptions[i].addStaleListener(aTicker); mamdaSubscriptions[i].addErrorListener(aTicker); mamdaSubscriptions[i].create(transport, defaultQueue, options.getSource(), symbol, null/*Closure*/); i++; } Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }
/// <summary> /// This function will parse the command line and initialise the various member variables with /// the information passed in. /// </summary> /// <param name="args"> /// The array of command line arguments. /// </param> /// <returns> /// True to continue with the application or false to quit out. /// </returns> private bool parseCommandLine(string[] args) { bool ret = true; if ((args == null) || (args.Length == 0)) { throw new ApplicationException("No command line arguments supplied."); } // Iterate through all the arguments and check for possible values for (int index = 0; index < args.Length; index++) { // Create snapshot subscriptions if (args[index].CompareTo("-1") == 0) { m_snapshot = true; continue; } // Don't obtain the dictionary if (args[index].CompareTo("-B") == 0) { m_downloadDictionary = false; continue; } // The dictionary source name if (args[index].CompareTo("-d") == 0) { if ((index + 1) < args.Length) { m_dictionarySourceName = args[++index]; continue; } } // The dictionary transport if (args[index].CompareTo("-dict_tport") == 0) { if ((index + 1) < args.Length) { m_dictionaryTransportName = args[++index]; continue; } } // Symbol file path if (args[index].CompareTo("-f") == 0) { if ((index + 1) < args.Length) { string fileName = args[++index]; readSymbolsFromFile(fileName); continue; } } // Display the usage string if ((args[index].CompareTo("--help") == 0) || (args[index].CompareTo("-?") == 0)) { Console.WriteLine(usage); ret = false; break; } // The high watermark level for queue monitoring if (args[index].CompareTo("-hw") == 0) { if ((index + 1) < args.Length) { m_highWaterMark = Convert.ToInt32(args[++index]); continue; } } // Write out to a log file if (args[index].CompareTo("-log_file") == 0) { if ((index + 1) < args.Length) { m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.logToFile(args[++index], MamaLogLevel.MAMA_LOG_LEVEL_FINEST); continue; } } // The low watermark level for queue monitoring if (args[index].CompareTo("-lw") == 0) { if ((index + 1) < args.Length) { m_lowWaterMark = Convert.ToInt32(args[++index]); continue; } } // The middleware name if (args[index].CompareTo("-m") == 0) { if ((index + 1) < args.Length) { m_middlewareName = args[++index]; continue; } } // Use new iterator functionality if (args[index].CompareTo("-ni") == 0) { m_iterator = true; continue; } // The quietness level if (args[index].CompareTo("-q") == 0) { m_quietness++; continue; } // The throttle rate if (args[index].CompareTo("-r") == 0) { if ((index + 1) < args.Length) { m_throttleRate = Convert.ToInt64(args[++index]); continue; } } // Recap throttle rate if (args[index].CompareTo("-rr") == 0) { if ((index + 1) < args.Length) { m_recapThrottleRate = Convert.ToInt64(args[++index]); continue; } } // The source name if (args[index].CompareTo("-S") == 0) { if ((index + 1) < args.Length) { m_sourceName = args[++index]; continue; } } // The symbol name if (args[index].CompareTo("-s") == 0) { if ((index + 1) < args.Length) { m_symbols.Add(args[++index]); continue; } } // Length of time to run for if (args[index].CompareTo("-shutdown") == 0) { m_shutdownTime = double.Parse(args[++index]); continue; } // Number of threads to run if (args[index].CompareTo("-threads") == 0) { if ((index + 1) < args.Length) { m_numberThreads = Convert.ToInt32(args[++index]); continue; } } // The main transport if (args[index].CompareTo("-tport") == 0) { if ((index + 1) < args.Length) { m_transportName = args[++index]; continue; } } // The verbosity level if (args[index].CompareTo("-v") == 0) { switch (m_logLevel) { case MamaLogLevel.MAMA_LOG_LEVEL_WARN: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; break; case MamaLogLevel.MAMA_LOG_LEVEL_NORMAL: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINE: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINER: m_logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; break; } continue; } } if (m_symbols.Count == 0) { throw new ApplicationException("No symbols were supplied"); } return(ret); }
/// <summary> /// Set the log level. /// </summary> /// <param name="level"> /// The logging level allowed. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// The file name contains invalid characters. /// </exception> public static void setLogLevel(MamaLogLevel level) { // Check for a valid enumeration value if (!Enum.IsDefined(typeof(MamaLogLevel), (int)level)) { throw new ArgumentOutOfRangeException("level"); } MamaWrapper.CheckResultCode(NativeMethods.mama_setLogLevel((int)level)); }
private void ParseArgs() { for (int i = 0; i < args.Length; ) { string arg = args[i]; if (arg[0] != '-') { Console.WriteLine("Ignoring invalid argument {0}", arg); ++i; continue; } string opt = arg.Substring(1); switch (opt) { case "s": if ((i + 1) == args.Length) { Console.WriteLine("Expecting outbound topic name after {0}", arg); ++i; continue; } outboundTopic = args[++i]; break; case "l": if ((i + 1) == args.Length) { Console.WriteLine("Expecting inbound topic name after {0}", arg); ++i; continue; } inboundTopic = args[++i]; break; case "nosub": nosub = true; break; case "c": if ((i + 1) == args.Length) { Console.WriteLine("Expecting message count after {0}", arg); ++i; continue; } try { messageCount = int.Parse(args[++i], NumberStyles.Integer, CultureInfo.InvariantCulture); } catch // ignore parse error { } break; case "i": if ((i + 1) == args.Length) { Console.WriteLine("Expecting interval after {0}", arg); ++i; continue; } double.TryParse(args[++i], NumberStyles.Float, CultureInfo.InvariantCulture, out interval); break; case "h": case "?": helpNeeded = true; return; case "m": if ((i + 1) == args.Length) { Console.WriteLine("Expected middleware name after {0}", arg); ++i; continue; } middlewareName = args[++i]; break; case "tport": if ((i + 1) == args.Length) { Console.WriteLine("Expecting transport name after {0}", arg); ++i; continue; } transportName = args[++i]; break; case "q": quiet = true; break; case "pubCb": pubCb = true; break; case "v": if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging (logLevel); } else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging (logLevel); } else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging (logLevel); } else { logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging (logLevel); } break; default: Console.WriteLine("Ignoring invalid option {0}", arg); break; } ++i; } Console.WriteLine("Starting Publisher with:\n" + " topic: {0}\n" + " inbound topic: {1}\n" + " interval {2}\n" + " middleware {3}\n" + " transport: {4}\n", outboundTopic, inboundTopic, interval, middlewareName, transportName); }
static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } try { //Initialize MAMA API myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); myMamaSource = new MamaSource(); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); MamdaCommonFields.setDictionary(dictionary, null); MamdaOrderBookFields.setDictionary(dictionary, null); myQueueGroup = new MamaQueueGroup(myBridge, options.getNumThreads()); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener(); AtomicBookTicker aTicker = new AtomicBookTicker(); aBookListener.addBookHandler(aTicker); aBookListener.addLevelHandler(aTicker); if (options.getPrintEntries()) { // Entries aBookListener.addLevelEntryHandler(aTicker); } aSubscription.addMsgListener(aBookListener); aSubscription.addStaleListener(aTicker); aSubscription.addErrorListener(aTicker); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK); aSubscription.create(transport, myQueueGroup.getNextQueue(), options.getSource(), symbol, null); mamdaSubscriptions.Add(aSubscription); } //Start dispatching on the default MAMA event queue Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
private static void parseCommandLine (string[] args) { for(int i = 0; i < args.Length;) { if (args[i] == "-source" || args[i] == "-S") { mySymbolNamespace = args[i +1]; i += 2; } else if (args[i] == "-d" || args[i] == "-dict_source") { dictSource = args[i + 1]; i += 2; } else if (args[i] == "-dict_tport") { myDictTportName = args[i + 1]; i += 2; } else if (args[i] == "-tport") { transportName = args[i + 1]; i += 2; } else if (args[i] == "-threads") { numThreads = Convert.ToInt32 (args[i+1]); i += 2; } else if (args[i] == "-q") { quietness++; i++; } else if (args[i] == ("-v")) { switch (mamaLogLevel) { case MamaLogLevel.MAMA_LOG_LEVEL_WARN: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; break; case MamaLogLevel.MAMA_LOG_LEVEL_NORMAL: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINE: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; break; case MamaLogLevel.MAMA_LOG_LEVEL_FINER: mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; break; } i++; } else if (args[i] == ("-m")) { myMiddleware = args[i + 1]; i += 2; } } }
public static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); double throttleRate = options.getThrottleRate(); if (options.hasLogLevel()) { logLevel_ = options.getLogLevel(); Mama.enableLogging(logLevel_); } if ((throttleRate > 100.0) || (throttleRate <= 0.0)) { throttleRate = 100.0; } try { // Initialize MAMDA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); //Initialise the dictionary and fields MamdaCommonFields.setDictionary(dictionary, null); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP); aSubscription.create( transport, defaultQueue, options.getSource(), symbol, null); /* For each subscription a MamdaMultiParticipantManager is * added as the message listener. The callbacks on the * MamdaMultiPartHandler will be invokes as new group members * become available.*/ MamdaMultiParticipantManager multiPartManager = new MamdaMultiParticipantManager(symbol); multiPartManager.addHandler(new MultiPartHandler()); aSubscription.addMsgListener(multiPartManager); aSubscription.activate(); mamdaSubscriptions.Add(aSubscription); } Mama.start(myBridge); GC.KeepAlive(dictionary); Console.WriteLine("Press ENTER or Ctrl-C to quit..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
private void parseCommandLine(string[] args) { string tport = null; uint ft_type = (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST; bool displayVersion = false; for (int i = 0; i < args.Length; ) { if ((args[i].CompareTo ("-h")) == 0 || (args[i].CompareTo ("-?")) == 0) { usage (0); } if ((args[i].CompareTo ("-g") == 0) || (args[i].CompareTo ("-group") == 0)) { myGroup = args[i+1]; i += 2; continue; } if ((args[i].CompareTo ("-w") == 0) || (args[i].CompareTo ("-weight") == 0)) { myWeight = Convert.ToUInt32 (args[i+1]); i += 2; continue; } if (args[i].CompareTo ("-m") == 0) { myMiddleware = args[i+1]; i += 2; continue; } if ((args[i].CompareTo ("-t") == 0) || (args[i].CompareTo ("-tport") == 0)) { tport = args[i+1]; i += 2; continue; } if (args[i].CompareTo ("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging (mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging (mamaLogLevel); } i++; continue; } if (args[i].CompareTo ("-version") == 0) { displayVersion = true; break; } if (args[i].CompareTo ("-b") == 0) { ft_type = (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE; i++; continue; } i++; } myBridge = Mama.loadBridge(myMiddleware); Mama.open(); if (displayVersion) { Console.WriteLine (Mama.getVersion (myBridge)); Exit (0); } myTimer = new MamaTimer(); myTransport = new MamaTransport(); myTransport.create(tport, myBridge); if (myGroup == null) { Console.WriteLine ("No FT group name specified"); usage(1); } switch (ft_type) { case (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST: myFtMember = new MamaMulticastFtMember (); break; case (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE: myFtMember = new MamaBridgeFtMember (); break; default: Console.WriteLine ("No FT type specified"); usage(1); break; } }
public static void Main(string[] args) { CommandLineProcessor options = new CommandLineProcessor(args); MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; double intervalSecs = options.getTimerInterval(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } try { myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); mySource = new MamaSource(); defaultQueue = Mama.getDefaultEventQueue(myBridge); // We might as well also enforce strict checking of order book updates MamdaOrderBook.setStrictChecking(true); /*Get the Data Dictionary*/ MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary(dictionary, null); if (intervalSecs == 0) { intervalSecs = 5; } foreach (string symbol in options.getSymbolList()) { BookSelfTest aSelfTest = new BookSelfTest (); MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker( transport, defaultQueue, aSelfTest, options.getSource(), symbol, intervalSecs); obookCheckers.Add(aBookChecker); } Mama.start(myBridge); GC.KeepAlive(dictionary); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Environment.Exit(1); } }