static internal void OnShutdown() { ForceDisposeListenerGroups(); FDefaultGroup = null; FActiveGroup = null; }
static public Boolean Remove(ListenerGroup group) { lock (FListenerGroups) { ListenerGroup gNode = (ListenerGroup)FListenerGroups[group.Name]; if (gNode == null) { return(false); } if (!Object.ReferenceEquals(gNode, group)) { return(false); } if (Object.ReferenceEquals(gNode, group)) { FListenerGroups.Remove(group.Name); group.InternalDispose(false); AddDefaultListenerGroupIfNecessary(); } if (group.IsActive) { PrepareActiveGroup(); } return(true); } }
internal DestinationBindingGroup(String name, ListenerGroup parent) { Id = GetId(name); Name = name; Parent = parent; Destinations = new HashSet <DestinationInfo>(); ReconstructFastDestinationArray(); }
static public ListenerGroup Add(String name, Boolean bEnabled, Boolean bMaskIdentities) { ListenerGroup group = new ListenerGroup(name, bEnabled, bMaskIdentities); AddGroup(group, false); return(group); }
public virtual void Dispatch(ReflectInsightPackage userPackage, ListenerGroup lgroup) { if (!Enabled || !lgroup.Enabled) { return; } MessageQueue.SendMessage(new BoundReflectInsightPackage() { BindingGroupId = DestinationBindingGroupId, Package = userPackage }); }
static public ListenerGroup Get(String name) { lock (FListenerGroups) { ListenerGroup group = (ListenerGroup)FListenerGroups[name]; if (group == null) { return(null); } return(group); } }
static public Boolean Remove(String name) { lock (FListenerGroups) { ListenerGroup group = (ListenerGroup)FListenerGroups[name]; if (group != null) { return(Remove(group)); } return(false); } }
static private void SetActiveListenerGroup(ListenerGroup group) { lock (FListenerGroups) { MessageQueue.WaitUntilNoMessages(100); if (group == null) { return; } FActiveGroup = group; } }
static private void AddDefaultListenerGroupIfNecessary() { lock (FListenerGroups) { String defaultName = FDefaultGroup != null ? FDefaultGroup.Name : "_default"; ListenerGroup group = (ListenerGroup)FListenerGroups[defaultName]; if (group == null) { // default group doesn't exist, add it FDefaultGroup = new ListenerGroup("_default", true, false); FDefaultGroup.AddDestination("_default", "Console"); AddGroup(FDefaultGroup, true); } } }
static private void PrepareActiveGroup() { lock (FListenerGroups) { String activeGroupName = ReflectInsightConfig.Settings.GetListenerGroupsAttribute("active", "_default"); ListenerGroup group = (ListenerGroup)FListenerGroups[activeGroupName]; if (group == null) { activeGroupName = ReflectInsightConfig.Settings.GetListenerGroupsAttribute("active", "_default"); group = (ListenerGroup)FListenerGroups[activeGroupName]; if (group == null) { group = FDefaultGroup; } } SetActiveListenerGroup(group); } }
static private void AddGroup(ListenerGroup group, Boolean bFromConfig) { if (group == null) { return; } lock (FListenerGroups) { ListenerGroup gNode = (ListenerGroup)FListenerGroups[group.Name]; if (gNode != null && !Object.ReferenceEquals(gNode, group)) { // from this point the groups names are similar but are not the same object // we cannot replace a non-config'd group with a config'd group if (!gNode.FromConfig && bFromConfig) { group.InternalDispose(false); return; } // make sure the one we are replacing was not active. // if active, then the group that is replacing will be active if (gNode.IsActive) { SetActiveListenerGroup(group); } // set to default if the one being replaced was default if (gNode.IsDefault) { FDefaultGroup = group; } group.InternalDispose(false); } group.FromConfig = bFromConfig; FListenerGroups[group.Name] = group; } }
static internal void ProcessMessages() { lock (FDebugLockObject) { ListenerGroup activeGroup = RIListenerGroupManager.ActiveGroup; BoundReflectInsightPackage[] boundPackages = MessageQueue.GetBoundMessages(); if (activeGroup == null || boundPackages.Length == 0) { return; } DestinationInfo[] destinations = activeGroup.Destinations; if (destinations.Length == 0) { return; } // chunk the sending to reduce memory pressure Int32 at = 0; Int32 remaining = boundPackages.Length; Int32 chunk = remaining < FMaxChunking ? remaining : FMaxChunking; while (remaining > 0) { for (Int32 i = at; i < (at + chunk); i++) { RIUtils.HandleUnknownMessage(boundPackages[i].Package); AddToDestinationInterimMessageQueue(destinations, boundPackages[i]); } SendPackages(destinations); Thread.Sleep(0); at += chunk; remaining -= chunk; chunk = remaining < FMaxChunking ? remaining : FMaxChunking; } } }
static private void SetDefaultListenerGroup(ListenerGroup group) { lock (FListenerGroups) { if (group == null) { return; } ListenerGroup gNode = (ListenerGroup)FListenerGroups[group.Name]; if (gNode == null || group.IsDefault) { return; } if (Object.ReferenceEquals(FDefaultGroup, FActiveGroup)) { SetActiveListenerGroup(group); } FDefaultGroup = group; } }
internal List <ListenerGroup> LoadListenerGroups() { var groups = new List <ListenerGroup>(); if (XmlSection == null) { return(groups); } var objNode = XmlSection.SelectSingleNode("./listenerGroups"); if (objNode == null) { return(groups); } foreach (XmlNode gNode in objNode.ChildNodes) { if (gNode.Name != "group") { continue; } if (gNode.Attributes["name"] == null) { continue; } var name = gNode.Attributes["name"].Value; var bEnabled = (gNode.Attributes["enabled"] != null ? gNode.Attributes["enabled"].Value : "true") == "true"; var bMask = (gNode.Attributes["maskIdentities"] != null ? gNode.Attributes["maskIdentities"].Value : "false") == "true"; var group = new ListenerGroup(name, bEnabled, bMask); groups.Add(group); // let's add the destinations XmlNode destNodes = gNode.SelectSingleNode("./destinations"); if (destNodes != null) { foreach (XmlNode dNode in destNodes.ChildNodes) { if (dNode.Name != "destination") { continue; } if (dNode.Attributes["name"] == null || dNode.Attributes["details"] == null) { continue; } bEnabled = (dNode.Attributes["enabled"] != null ? dNode.Attributes["enabled"].Value : "true") == "true"; var filter = dNode.Attributes["filter"] != null ? dNode.Attributes["filter"].Value : string.Empty; group.AddDestination(dNode.Attributes["name"].Value, dNode.Attributes["details"].Value, bEnabled, filter); } } // let's add the destination binding groups XmlNode destinationBindingGroupNodes = gNode.SelectSingleNode("./destinationBindingGroups"); if (destinationBindingGroupNodes != null) { foreach (XmlNode bNode in destinationBindingGroupNodes.ChildNodes) { if (bNode.Name != "destinationBindingGroup") { continue; } var bindingGroupName = bNode.Attributes["name"] != null ? bNode.Attributes["name"].Value : null; var bindingGroup = group.GetDestinationBindingGroup(bindingGroupName); if (bindingGroup == null) { bindingGroup = group.AddDestinationBindingGroup(bindingGroupName); } else { bindingGroup.ClearDestinationBindings(); } foreach (XmlNode dbNode in bNode.ChildNodes) { if (dbNode.Name != "destination") { continue; } if (dbNode.Attributes["name"] == null) { continue; } bindingGroup.AddDestinationBinding(dbNode.Attributes["name"].Value); } } } } return(groups); }