locked
Problem with Incremental discovery in SCOM 2012 SDK RRS feed

  • Question

  • Our application is using SDK based incremental discovery. It's a C# based code and is working fine for SCOM 2007 R2. When we try to port the  code into SCOM 2012, we are getting the below exception. We are using the new SDK binaries that comes with SCOM 2012 RTM SDK and we have already changed our code to use new SDK classes.

    Microsoft.EnterpriseManagement.Common.DiscoveryDataInsertionCollisionException: A discovery data item was rejected because the item has already been inserted by another user or process.
       at Microsoft.EnterpriseManagement.Common.Internal.ServiceProxy.HandleFault(String methodName, Message message)
       at Microsoft.EnterpriseManagement.Common.Internal.ConnectorFrameworkConfigurationServiceProxy.ProcessDiscoveryData(Guid discoverySourceId, IList`1 entityInstances, IDictionary`2 streams, ObjectChangelist`1 extensions)
       at Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData.CommitInternal(EnterpriseManagementGroup managementGroup, Guid discoverySourceId, Boolean useOptimisticConcurrency)
       at Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData.Commit(EnterpriseManagementGroup managementGroup, Guid discoverySourceId, Boolean useOptimisticConcurrency)
       at Microsoft.EnterpriseManagement.ConnectorFramework.IncrementalDiscoveryData.Commit(EnterpriseManagementConnector monitoringConnector)
       at xx.Integration.SCOM.Discovery.DiscoveryIntegrationService.AddComponent(Component component, String

    Could you help me to understand what has changed in SCOM 2012 SDK related to incremental discovery? I can't find any sample code for incremental discovery in SDK documentation. Moreover, the exception message does not clearly indicate the source of the problem.

    This is how we are using incremental discovery for SCOM 2012:  


                ConnectorInfo info = new ConnectorInfo();
                info.Name = connectorName;
                info.DisplayName = connectorDisplayName;
                info.DiscoveryDataIsManaged = true;
                info.DiscoveryDataIsShared = true; //this has no effect
                IConnectorFrameworkManagement mcfAdmin = managementGroup.ConnectorFramework;
                MonitoringConnector monitoringConnector = mcfAdmin.Setup(info);
                monitoringConnector.Initialize();
                ManagementPackClass componentClass = sdkService.GetMonitoringClass("xx.Monitoring.Components." + componentType);
                CreatableEnterpriseManagementObject componentObject = new CreatableEnterpriseManagementObject(managementGroup, componentClass);
                ....
                // code that set values for key property and other properties of ComponentClass
                ....
                ....
                IncrementalDiscoveryData incrementalAdd = new IncrementalDiscoveryData();
                incrementalAdd.Add(componentObject);
                incrementalAdd.Commit(monitoringConnector);

    Please help to resolve this issue.

    -- Mano

    • Edited by Manoharan S Thursday, April 26, 2012 3:58 AM
    Thursday, April 26, 2012 3:56 AM

All replies

  • I am getting the exact same error/issue with a custom connector we created.  Using very similar methodology in the code I have been unable to determine why this exception is getting thrown.  If you capture the exception you can extract the ClassGUID and the ObjectGUID that are causing it.  Something like this is what I use:

            public static void CommitDiscoveryData()
            {
                try
                {
                    //discoveryData.Commit(monitoringConnector);
                    discoveryData.Commit(managementGroup);
                }
                catch (Microsoft.EnterpriseManagement.Common.DiscoveryDataInsertionCollisionException ex)
                {
                    Guid guid = ex.ClassId;
                    System.Collections.ICollection data = ex.Data;
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(String.Format("InnerEx:{0}", ex.InnerException));
                    sb.AppendLine(String.Format("MessageEx:{0}", ex.Message));
                    sb.AppendLine(String.Format("ClassID:{0}", ex.ClassId));
                    sb.AppendLine(String.Format("ObjectID:{0}", ex.ObjectId));
                    Utilities.LogConnectorResults(sb, "CommitDiscDataException");
                    Logging log = new Logging("SCOM_FNTG_CONNECTOR", "Application");
                    log.LogNewEvent(log.EventSourceName, String.Format("Discovery Data Insertion Collision:{0}{1}",
                        Environment.NewLine, sb.ToString()),
                        Logging.c_Error, 10113);
                }
            }

    The Logging class is as follows:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    
    namespace FNTG_SCOM2k12_Connector
    {
        public class Logging
        {
            #region Constructor
            public Logging()
            { }
    
            public Logging(string Source, string Log)
            {
                if (!EventSourceExists(Source))
                    CreateEventSource(Source, Log);
                EventSourceName = Source;
                EventLogName = Log;
            }
            #endregion
    
            #region Constants
            public const EventLogEntryType c_Information = EventLogEntryType.Information;
            public const EventLogEntryType c_Warning = EventLogEntryType.Warning;
            public const EventLogEntryType c_Error = EventLogEntryType.Error;
            #endregion
    
            #region Variables
            public EventLogEntryType EventType { get; set; }
            public int EventID { get; set; }
            public string EventSourceName { get; set; }
            public string EventLogName { get; set; }
            public string EventDesc { get; set; }
            #endregion
    
            #region Methods
            public bool EventSourceExists(string Source)
            {
                if (!EventLog.SourceExists(Source))                
                    return false;
                else
                    return true;
            }
    
            public void CreateEventSource(string Source, string LogName)
            {
                EventLog.CreateEventSource(Source, LogName);
            }
    
            public void LogNewEvent(string source, string desc, EventLogEntryType type, int id)
            {
                EventLog.WriteEntry(source, desc, type, id);
            }
            #endregion
        }
    }

    Doing this I found that the Class that it is saying  is already is inserted is Windows.Computer and the Object is the first server on my list that I am trying to extend the properties on.

    In short, I have a existing MP I have imported that contains a custom class called "START.Computer" and I am using my connector to query a DB and populate in SCOM the properties of each START.Computer using results from the DB query.  It works perfect in 2007, but in 2012 it is throwing this exception and I can't get past it so far.


    Always seek the innovative solution.

    Tuesday, July 31, 2012 5:55 PM
  • When I used Overwrite method instead of Commit, the code worked. Overwrite and Commit seem to do the same thing but I haven't been to clearly understand the difference.

    incrementalAdd.Overwrite(monitoringConnector);

    Wednesday, August 1, 2012 10:47 AM
  • Interesting that in 2007 my connector works just fine with .Commit but in 2012 it will only work with .Overwrite being used instead.  Thanks for pointing that out.

    I did find this post discussing the difference between the two, but it doesn't really explain why 2007 it works with .Commit, and .2012 it doesn't.  I think that may require a further dive into the code on their part.

    http://social.technet.microsoft.com/Forums/en-US/operationsmanagerextensibility/thread/454def6a-2c16-4252-9662-a8b855ed748c/


    Always seek the innovative solution.

    Wednesday, August 1, 2012 4:43 PM