/// <summary> /// Initializes a new instance of the <see cref="ClientBusListener" /> class. /// </summary> /// <param name="busAtt">object responsible for connecting to and optionally managing a message /// bus.</param> /// <param name="op">Stress Operation using this class as listener object</param> /// <param name="foundNameEvent">Event to set when the first service is discovered</param> public ClientBusListener(BusAttachment busAtt, StressOperation op, AutoResetEvent foundNameEvent) { this.stressOp = op; this.mutex = new Mutex(); this.foundAvertisedName = false; this.foundName = foundNameEvent; // Create Bus Listener and register signal handlers this.busListener = new BusListener(busAtt); this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected); this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping); this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName); this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered); this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered); this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName); this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged); // Create Session Listener and register signal handlers this.sessionListener = new SessionListener(busAtt); this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost); this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded); this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved); busAtt.RegisterBusListener(this.busListener); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusListener" /> class. /// </summary> /// <param name="busAtt">object responsible for connecting to and optionally managing a message /// bus.</param> /// <param name="op">Stress Operation using this class as listener object</param> public ServiceBusListener(BusAttachment busAtt, StressOperation op) { this.stressOp = op; // Create Bus Listener and register signal handlers this.busListener = new BusListener(busAtt); this.busListener.BusDisconnected += new BusListenerBusDisconnectedHandler(this.BusListenerBusDisconnected); this.busListener.BusStopping += new BusListenerBusStoppingHandler(this.BusListenerBusStopping); this.busListener.FoundAdvertisedName += new BusListenerFoundAdvertisedNameHandler(this.BusListenerFoundAdvertisedName); this.busListener.ListenerRegistered += new BusListenerListenerRegisteredHandler(this.BusListenerListenerRegistered); this.busListener.ListenerUnregistered += new BusListenerListenerUnregisteredHandler(this.BusListenerListenerUnregistered); this.busListener.LostAdvertisedName += new BusListenerLostAdvertisedNameHandler(this.BusListenerLostAdvertisedName); this.busListener.NameOwnerChanged += new BusListenerNameOwnerChangedHandler(this.BusListenerNameOwnerChanged); // Create Session Listener and register signal handlers this.sessionListener = new SessionListener(busAtt); this.sessionListener.SessionLost += new SessionListenerSessionLostHandler(this.SessionListenerSessionLost); this.sessionListener.SessionMemberAdded += new SessionListenerSessionMemberAddedHandler(this.SessionListenerSessionMemberAdded); this.sessionListener.SessionMemberRemoved += new SessionListenerSessionMemberRemovedHandler(this.SessionListenerSessionMemberRemoved); // Create Session Port Listener and register signal handlers this.sessionPortListener = new SessionPortListener(busAtt); this.sessionPortListener.AcceptSessionJoiner += new SessionPortListenerAcceptSessionJoinerHandler(this.SessionPortListenerAcceptSessionJoiner); this.sessionPortListener.SessionJoined += new SessionPortListenerSessionJoinedHandler(this.SessionPortListenerSessionJoined); busAtt.RegisterBusListener(this.busListener); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceBusObject"/> class. /// </summary> /// <param name="busAtt">Message bus for the stress operation using this</param> /// <param name="op">Stress operation using this bus object</param> public ServiceBusObject(BusAttachment busAtt, StressOperation op) { this.stressOp = op; this.busObject = new BusObject(busAtt, ServicePath, false); // Implement the 'cat' interface InterfaceDescription[] intfDescription = new InterfaceDescription[1]; busAtt.CreateInterface(InterfaceName, intfDescription, false); intfDescription[0].AddMethod("cat", "ss", "s", "inStr1,inStr2,outStr", (byte)0, string.Empty); intfDescription[0].Activate(); this.busObject.AddInterface(intfDescription[0]); // Register 'cat' method handler InterfaceMember catMethod = intfDescription[0].GetMethod("cat"); MessageReceiver catReceiver = new MessageReceiver(busAtt); catReceiver.MethodHandler += new MessageReceiverMethodHandler(this.Cat); this.busObject.AddMethodHandler(catMethod, catReceiver); busAtt.RegisterBusObject(this.busObject); }
/// <summary> /// Create the specified number of threads which will execute the specified stress /// type for a specified number of iterations /// </summary> /// <param name="args">Arguments obtained from the user which configure the execution /// of the app</param> public void RunStressOperations(ArgumentObject args) { this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); this.DebugPrint("//// Starting the stress operation"); this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); for (uint iters = 0; iters < args.NumOfIterations; iters++) { this.tasks = new Task[args.NumOfTasks]; for (uint taskNum = 0; taskNum < args.NumOfTasks; taskNum++) { Task t = new Task( () => { StressOperation stressOp = new StressOperation(TaskCount); stressOp.Start(args.StressOperation, this, args.IsMultipoint); }); t.Start(); this.tasks[taskNum] = t; } // Wait for all threads to finish execution if (args.StopThreadBeforeJoin) { // TODO: Kill the tasks before join (Haven't found a way to accomplish this) } // Wait on all threads to finish execution Task.WaitAll(this.tasks, 15000); this.tasks = null; } this.CurrentlyRunning = false; this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); this.DebugPrint("//// The stress operation has finished"); this.DebugPrint("//////////////////////////////////////////////////////////////////////////"); }